These are chat archives for FreeCodeCamp/HelpJavaScript

27th
Mar 2017
Dmytro Holysh
@dmk1111
Mar 27 2017 00:01 UTC
@www-leafie-io user actually can change example.com/#!/user/main to example.com/#!/admin/main in address line. So I want to block #!/admin/ for user with 'user' role
Leafie Tutoring
@www-leafie-io
Mar 27 2017 00:01 UTC
@dmk1111 you would have to check if they are authenticated in the session
nsonhouse
@nsonhouse
Mar 27 2017 00:05 UTC
Hello all
need a little help
Joseph
@revisualize
Mar 27 2017 00:05 UTC
With?
Stephen James
@sjames1958gm
Mar 27 2017 00:05 UTC
@nsonhouse Ask away
nsonhouse
@nsonhouse
Mar 27 2017 00:06 UTC
I need to put a countdown timer on a quiz
Stephen James
@sjames1958gm
Mar 27 2017 00:06 UTC
@nsonhouse And . . .
nsonhouse
@nsonhouse
Mar 27 2017 00:06 UTC
I have the quiz working fine, but have not figured out how to use the setTimeout correctly
Stephen James
@sjames1958gm
Mar 27 2017 00:07 UTC
@nsonhouse What have you tried?
nsonhouse
@nsonhouse
Mar 27 2017 00:08 UTC
I have created function and I pass the seconds and the element where I want to the clock to appear
The quiz needs to end when the timer hits 0, but it does not.
The user is till able to answer the remaing questions
Stephen James
@sjames1958gm
Mar 27 2017 00:10 UTC
@nsonhouse How are you expecting to stop the user? the setTimer timeout will be asynchronous
Dmytro Holysh
@dmk1111
Mar 27 2017 00:11 UTC
@www-leafie-io should this work out?
function loginController($http, $state) {
    let self = this;
    self.loginErrorMessage = false;
    self.username = '';
    self.password = '';
    self.user = '';

    self.logIn = function () {
        var data = {
        username: self.username,
        password: self.password
    };
        $http.post('/api/login', data,
            {headers: {
                'x-requested-with': 'XMLHttpRequest'
                }
            }
        ).then(function (res) {
            self.user = res.data;
               if (self.user.role === 'student') {
            $state.go('student');
              } else if (self.user.role === 'admin') {
            $state.go('admin') }
        }, function (err) {
            self.loginErrorMessage = true;
        });
    }
}

loginController.$inject = ['$http', '$state'];

module.exports = loginController;
Chris
@bestintown23
Mar 27 2017 00:11 UTC
How do I use the mouse over function in javascript to stop my slideshow
nsonhouse
@nsonhouse
Mar 27 2017 00:12 UTC
@sjames1958gm Please elaborate.
Stephen James
@sjames1958gm
Mar 27 2017 00:13 UTC
@nsonhouse How are you expecting the stop the user from answering more questions. Do you go to a completion page or something else?
@nsonhouse It is going to be difficult without a link to the code, or at least some of the code.
nsonhouse
@nsonhouse
Mar 27 2017 00:15 UTC

function countDown(secs, elem)
{

            var element = document.getElementById(elem);
            element.innerHTML = "You have " + secs + " seconds left";
            if(secs < 1) 
            {

                clearTimeout(timer);
                element.innerHTML = '<h2>Test is Complete!</h2>';

            }

            secs--;
            var timer = setTimeout('countDown('+secs+',"'+elem+'")',1000);

    }        

    countDown(15,"clock");



    function returnID(x){

            return document.getElementById(x);
    }



    function showQuestion()
    {

        test = returnID("test");
        if(position >= questions.length)
        {
            test.innerHTML = "<h2> You have "+correct+" of "+questions.length+" questions correct</h2>";
            returnID("testStatus").innerHTML = "Test Complete";
            position = 0;
            correct = 0;
            return false;
        }


        returnID("testStatus").innerHTML = "Question " + (position+1)+ " of " + questions.length;
        question = questions[position][0];
        choiceA  = questions[position][1];
        choiceB  = questions[position][2];
        choiceC  = questions[position][3];
        choiceD  = questions[position][4];

        test.innerHTML = "<h3>" + question + "</h3>"; 
        test.innerHTML += "<input type='radio' name='choices' value='A'> " +choiceA+"<br>";
        test.innerHTML += "<input type='radio' name='choices' value='B'> " +choiceB+"<br>";
        test.innerHTML += "<input type='radio' name='choices' value='C'> " +choiceC+"<br>";
        test.innerHTML += "<input type='radio' name='choices' value='D'> " +choiceD+"<br><br>";
        test.innerHTML += "<button onclick = 'checkAnswer()'>Submit Answer</button>";


    }



    function checkAnswer()
    {
            choices = document.getElementsByName("choices");
            for(var i=0; i<choices.length; i++)
            {
                if(choices[i].checked)
                {
                    choice = choices[i].value;
                }
            }

                if(choice == questions[position][5])
                {
                    correct++;
                }
                else{

                }

            position++;
            showQuestion();
    }

window.addEventListener("load", showQuestion, false);

Stephen James
@sjames1958gm
Mar 27 2017 00:16 UTC
@nsonhouse When the timer expires you could set a flag that tells submit answer to not process anymore clicks?
Leafie Tutoring
@www-leafie-io
Mar 27 2017 00:17 UTC
@dmk1111 i dunno you would have to test it
nsonhouse
@nsonhouse
Mar 27 2017 00:18 UTC
@sjames1958gm So when the clock hits 0, disable the button?
Dmytro Holysh
@dmk1111
Mar 27 2017 00:18 UTC
@www-leafie-io kk, will try
Lee
@eightlimbs
Mar 27 2017 00:29 UTC

how can i declare a local variable "myVar" inside "myLocalScope"?

function myLocalScope() {
'use strict';

console.log(myVar);
}
myLocalScope();

nsonhouse
@nsonhouse
Mar 27 2017 00:31 UTC
@sjames1958gm What about calling the countdown function with the onload function?
David Hart
@hart143
Mar 27 2017 00:32 UTC
i've been stuck on this one for a while, any suggestions?
David Rowan III
@rowanD72
Mar 27 2017 00:33 UTC
hello everyone
David Hart
@hart143
Mar 27 2017 00:33 UTC
function largestOfFour(arr) {
  // You can do this!
  var myArr = [];
  var subArr = [];
  for (var i = 0; i < arr.length; i++) { 
    var large = 0;
    subArr = arr.slice(i,i + 1);
    large = Math.max(subArr);
    myArr.push(large);
  }
  return myArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
David Rowan III
@rowanD72
Mar 27 2017 00:34 UTC
I need a little help understanding some simple parts of javascript.
David Hart
@hart143
Mar 27 2017 00:35 UTC
@rowanD72 whats your question
David Rowan III
@rowanD72
Mar 27 2017 00:36 UTC
nested functions are very confusing to me @hart143
well should I say functions are kind of confusing to me. I really don't fully understand them.
I understand that a function is used to make the code perform some action
I know how to write a function but when it comes to seeing the flow of the function I get confused
David Hart
@hart143
Mar 27 2017 00:38 UTC
functions do something, they are called. information can be passed to them or they can just do something, they can return a value
well what's going on in the function?
David Rowan III
@rowanD72
Mar 27 2017 00:39 UTC
it's no particular function in question, it's how do I learn the flow of the function. Kind of hard to explain.
silver537
@silver537
Mar 27 2017 00:40 UTC
should handle words without vowels?
wtf
David Rowan III
@rowanD72
Mar 27 2017 00:40 UTC
maybe I am making understanding functions harder than needs to be
David Hart
@hart143
Mar 27 2017 00:40 UTC
the flow... a function starts at the top and flows to the bottom
anyone got any ideas why i am getting "null, null, null, null?
function largestOfFour(arr) {
  // You can do this!
  var myArr = [];
  var subArr = [];
  for (var i = 0; i < arr.length; i++) { 
    var large = 0;
    subArr = arr.slice(i,i + 1);
    large = Math.max(subArr);
    myArr.push(large);
  }
  return myArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Seth
@sethdcd
Mar 27 2017 00:44 UTC
how would i target a: 1 in the first object of this array? [{ "a": 1, "b": 3 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }]
Manish Giri
@Manish-Giri
Mar 27 2017 00:45 UTC
@sethdcd you know the array index, and you know the property name..
try it out
Jason Luboff
@JLuboff
Mar 27 2017 00:45 UTC
@hart143 large = Math.max(subArr); This line doesn't work, subArr is a multi-demension array
@hart143 You have [[4,5,1,3]] for instances. You can get it to work though..
David Rowan III
@rowanD72
Mar 27 2017 00:46 UTC
ok @hart143
Lee
@eightlimbs
Mar 27 2017 00:47 UTC
I am looking for some help with the "Stand in Line" challenge

function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Jason Luboff
@JLuboff
Mar 27 2017 00:47 UTC
@eightlimbs You need to use two array methods you recently learned about (pop,push, unshift, shift). Review those challenges and determine which two to use
Stephen James
@sjames1958gm
Mar 27 2017 00:48 UTC
@nsonhouse Don't you need somehow to stop the user input once the timer expires
nsonhouse
@nsonhouse
Mar 27 2017 00:49 UTC
@sjames1958gm yes sir
Lee
@eightlimbs
Mar 27 2017 00:49 UTC
i'll try pop and shift @JLuboff
Stephen James
@sjames1958gm
Mar 27 2017 00:50 UTC
@nsonhouse So once the timer expires, you should stop accepting input and going to the next question.
David Rowan III
@rowanD72
Mar 27 2017 00:50 UTC
so are global var good or bad?
Stephen James
@sjames1958gm
Mar 27 2017 00:50 UTC
@rowanD72 Generally they are to be avoided.
Jason Luboff
@JLuboff
Mar 27 2017 00:50 UTC
@eightlimbs shift is correct, but pop is not
David Rowan III
@rowanD72
Mar 27 2017 00:50 UTC
ok
David Hart
@hart143
Mar 27 2017 00:51 UTC
@JLuboff i was able to get the slice to return 4,5,1,3 (for example) and was able to use max to return 5 (for example) on w3schools, so why doesn't it work now?
Lee
@eightlimbs
Mar 27 2017 00:51 UTC
push
nsonhouse
@nsonhouse
Mar 27 2017 00:51 UTC
@sjames1958gm I am unaware of how to do this. I either want to disable the button or make it disappear. I am not sure how to set the Boolean value to a button that is being written dynamically.
David Rowan III
@rowanD72
Mar 27 2017 00:51 UTC
I just a lot of examples that have global variables. Maybe they're used for teaching purposes only
Stephen James
@sjames1958gm
Mar 27 2017 00:51 UTC
@hart143 to get max to work on an array you need Math.max.apply(null, arr[i]);
Jason Luboff
@JLuboff
Mar 27 2017 00:51 UTC
@hart143 slice is not returning 4,5,1,3 Its returning [[4,5,1,3]]
David Rowan III
@rowanD72
Mar 27 2017 00:51 UTC
*I just see a lot...
Jason Luboff
@JLuboff
Mar 27 2017 00:51 UTC
@eightlimbs Correct
Stephen James
@sjames1958gm
Mar 27 2017 00:52 UTC
@nsonhouse Give the button an id or class and then set the display to none
Lee
@eightlimbs
Mar 27 2017 00:53 UTC
@JLuboff, so what would return item; be changed to ?
Stephen James
@sjames1958gm
Mar 27 2017 00:53 UTC
@hart143 you can use arr[i] to get the element
Seth
@sethdcd
Mar 27 2017 00:53 UTC
@Manish-Giri ah! i asked that wrongly haha.. what i'm trying to achieve is looping through this array and pulling out each of the values. so yes it'd be nice and easy if i just needed one of the values, but would it be the same thing? Objects.keys gives me 0,1,2 so i'm not sure how to narrow it down
David Hart
@hart143
Mar 27 2017 00:54 UTC
@sjames1958gm man that worked but why doesn't the slice work :-(
@sjames1958gm thanks!
CamperBot
@camperbot
Mar 27 2017 00:54 UTC
hart143 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6368 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 27 2017 00:54 UTC
@hart143 Because of what @JLuboff says slice gives [[4, 5, 1, 3]] where arr[i] is only [4, 5, 1, 3]
Jason Luboff
@JLuboff
Mar 27 2017 00:54 UTC
@eightlimbs Well keep in mind the when you use shift on an array, it returns the element that it removes from the array
Seth
@sethdcd
Mar 27 2017 00:55 UTC
@Manish-Giri collections is the parameter/argument collection[0][Object.keys(collection[0])] i was thinking something like this
Manish Giri
@Manish-Giri
Mar 27 2017 00:55 UTC
@sethdcd you could first loop through the array, then each element in the array will be an object, since you already know the object properties, you could get their values easily with something like arr[i].a
David Hart
@hart143
Mar 27 2017 00:55 UTC
@JLuboff thanks!
CamperBot
@camperbot
Mar 27 2017 00:55 UTC
hart143 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1287 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Mar 27 2017 00:55 UTC
@hart143 slice could work...but you would need to have Math.max.apply(null, subArr[0]); Which really is just an extra unneeded step
Stephen James
@sjames1958gm
Mar 27 2017 00:56 UTC
@JLuboff Not just extra, and not just unneeded but extra uneeded :)
Jason Luboff
@JLuboff
Mar 27 2017 00:56 UTC
:joy:
David Hart
@hart143
Mar 27 2017 00:56 UTC
thanks guys
Jason Luboff
@JLuboff
Mar 27 2017 00:57 UTC
@sjames1958gm I was making sure I got my point across :D
Lee
@eightlimbs
Mar 27 2017 00:58 UTC
item.push();
i don't know what to type in between the ()
Jason Luboff
@JLuboff
Mar 27 2017 01:01 UTC
item is what you want to be pushing. You need to tell it the array to push the item into though
Lee
@eightlimbs
Mar 27 2017 01:04 UTC
testArr.push(item);
Jason Luboff
@JLuboff
Mar 27 2017 01:05 UTC
arr since thats the parameter from the function
Fabusuyi David Oluwasegun
@dav4thevid
Mar 27 2017 01:06 UTC
currently stuck with #Using Objects for Lookups

// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup;
  lookup(val="Adams");{result = "alpha";}
  (val = "Boston"); {result = "bravo";}
  (val = "Chicago"); {result = "charlie";}
  (val = "Denver");{result = "delta";}
  (val = "Easy"); {result = "Echo";}
  (val = "Frank"); {result = "foxtrot";}



  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
pls help anyone
Manish Giri
@Manish-Giri
Mar 27 2017 01:08 UTC
um
you should probably redo the objects lesson
@dav4thevid
Fabusuyi David Oluwasegun
@dav4thevid
Mar 27 2017 01:09 UTC
i think so........ma brains aint working well more....its 2:08am here
guess i need a break
Aaron Fox
@aaronfox
Mar 27 2017 01:09 UTC
@dav4thevid an object is in the form
var lookup = {
    "a": "hello",
    "b": "world",
  };
and, for example, to return the value "hello", you would return lookup["a"]
herunan
@herunan
Mar 27 2017 01:13 UTC

Hi all, I’m on this challenge: https://www.freecodecamp.com/challenges/caesars-cipher

function rot13(str) {
  var arr = str.toUpperCase().split('');
  var unicodeArr = [];
  for (var i=0; i < arr.length; i++) {
    if (arr[i].charCodeAt() > 64 && arr[i].charCodeAt() < 91); {
      unicodeArr.push(arr[i].charCodeAt()+13)
    }
  }
  console.log(unicodeArr);
}

rot13("SERR PBQR PNZC”);

Unfortunately this still adds 13 to non-alphabetic characters (e.g. spaces).

Hernan Mendez
@hernanmendez
Mar 27 2017 01:14 UTC
why this cuts up the first 2 characters instead of the first one
function translatePigLatin(str) {
switch (str[0]){
case "a":
case "e":
case "i":
case "o":
case "u":
return str+"way";
}
var substr="";
for (var u=0; u<str.length;u++){
if(str[u] == "a" || str[u] == "e" || str[u] == "i" || str[u] == "o" || str[u] == "u")
{
break;
}
substr+=str[u];
str = str.substr(1);}
return str;
}
@herunan try console.log on the array first to see if everything is ok
herunan
@herunan
Mar 27 2017 01:24 UTC
@hernanmendez Indeed, everything seems fine
Hernan Mendez
@hernanmendez
Mar 27 2017 01:26 UTC
@herunan i think i know why, it's because the str length changes
how do i declare a constant?
Eric Long
@ejlong90
Mar 27 2017 01:28 UTC

Hey, I am on the "Selecting from many options with Switch Statements" section of javascript and I am pretty confused.

It is asking me to Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

But I am confused on what statements we are supposed to use when the result of expression matches. This is what i have so far, not much


function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
 switch (1) {
   case "alpha":

 }


  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
Hernan Mendez
@hernanmendez
Mar 27 2017 01:31 UTC
now i have no idea
even with a constant
i think is a bug?
DJToners
@DJToners
Mar 27 2017 01:34 UTC
yo
how do i share whats on my screen so you can see what i need help with
herunan
@herunan
Mar 27 2017 01:35 UTC
@hernanmendez I see what you mean! I just need to add 13 to all alphabetic characters and pass non-alphabetic characters.
@Do you think .map() method would work better?
Gulsvi
@gulsvi
Mar 27 2017 01:37 UTC
@DJToners Put your code between backticks https://forum.freecodecamp.com/t/markdown-code-formatting/18391
Hernan Mendez
@hernanmendez
Mar 27 2017 01:37 UTC
@herunan i just added another variable and decided to not mess around with str
JamesVitaly
@JamesVitaly
Mar 27 2017 01:38 UTC
come this is not returning a whole number
Math.floor(Math.random() * 9);
how*
Sean McDaniel
@SeanMcDaniel1
Mar 27 2017 01:39 UTC
Why doesnt this convert the value ?
JamesVitaly
@JamesVitaly
Mar 27 2017 01:39 UTC
well I just need to return a whole number it it keeps produing a decimal but i was sure math.floor converted to a whole number
in fact that is the challenge
Gulsvi
@gulsvi
Mar 27 2017 01:39 UTC
@JamesVitaly That should give a whole number, is there more code to show?
JamesVitaly
@JamesVitaly
Mar 27 2017 01:40 UTC

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

Math.floor(Math.random() * 10);

return Math.random();
}

Moisés Man
@moigithub
Mar 27 2017 01:40 UTC
ur function returning something else
not math.floor result
Gulsvi
@gulsvi
Mar 27 2017 01:40 UTC
@JamesVitaly You are returning Math.random() not Math.floor(Math.random() * 10);
Ken Haduch
@khaduch
Mar 27 2017 01:40 UTC
@JamesVitaly - you should save your value from the Math.floor() or directly return it, do not do the additional Math.random()
JamesVitaly
@JamesVitaly
Mar 27 2017 01:40 UTC
ok i see! thanks, kind of weird because that was already there as part of the challenge marked not to edit haha ill change it and see
thanks @khaduch and @SkyCoder01
CamperBot
@camperbot
Mar 27 2017 01:41 UTC
jamesvitaly sends brownie points to @khaduch and @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 703 | @skycoder01 |http://www.freecodecamp.com/skycoder01
:star2: 2684 | @khaduch |http://www.freecodecamp.com/khaduch
Hernan Mendez
@hernanmendez
Mar 27 2017 01:42 UTC
@ejlong90 what goes betew
@ejlong90 what goes between the switch parameters "()" is val and the cases should be the possibles values of val
@ejlong90 remenber to always use break; at the end of each case
Eric Long
@ejlong90
Mar 27 2017 01:44 UTC
So are they asking me to use a random statement for each case? @hernanmendez
Hernan Mendez
@hernanmendez
Mar 27 2017 01:44 UTC
@ejlong90 switch (val){
case 1 :
Victoria Zambrano
@vzambrano98
Mar 27 2017 01:44 UTC
has anyone been having issues with codepen and bootstrap?
Hernan Mendez
@hernanmendez
Mar 27 2017 01:45 UTC
@ejlong90 keep calm and just search for switch on javascript in google if you have any doubts
Gulsvi
@gulsvi
Mar 27 2017 01:46 UTC
@vzambrano98 It works fine - it's just that the Bootstrap that gets added with the Quick Add menu is Bootstrap 4. Bootstrap 3 classes don't all work with Bootstrap 4.
Go to Settings -> CSS and replace the link to bootstrap with this one if you want to use bootstrap 3: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css
Hernan Mendez
@hernanmendez
Mar 27 2017 01:47 UTC
@SkyCoder01 so that's why the well class doesn't work?
Gulsvi
@gulsvi
Mar 27 2017 01:47 UTC
@hernanmendez Yes, the well class isn't in Bootstrap 4 :(
Victoria Zambrano
@vzambrano98
Mar 27 2017 01:48 UTC
@SkyCoder01 you're a savior! haha thanks so much!
CamperBot
@camperbot
Mar 27 2017 01:48 UTC
vzambrano98 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 704 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
Mar 27 2017 01:48 UTC
No problem, everyone has been hitting that lately :)
Hernan Mendez
@hernanmendez
Mar 27 2017 01:48 UTC
@SkyCoder01 WOW i was dying about why that wasn't working
Joseph
@revisualize
Mar 27 2017 01:48 UTC
hey hey.
Gulsvi
@gulsvi
Mar 27 2017 01:49 UTC
Hello hello
Hernan Mendez
@hernanmendez
Mar 27 2017 01:49 UTC
@SkyCoder01 i think that my brain was turned off while i was writting my last message
Gulsvi
@gulsvi
Mar 27 2017 01:50 UTC
@hernanmendez wells are now cards in Bootstrap 4: https://v4-alpha.getbootstrap.com/components/card/#background-variants
That's okay lol
Luis
@electrone901
Mar 27 2017 01:52 UTC
palindrome("0_0 (: /-\ :) 0-0") should return true.
can't pass the test
suhaschauhan
@suhaschauhan
Mar 27 2017 01:54 UTC

function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift();
return arr; // Change this line
}
nextInLine([2],1);
// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

can some1 tell me what to return ? Since the function should return the element that was removed
Manish Giri
@Manish-Giri
Mar 27 2017 01:58 UTC
@suhaschauhan arr.shift();
Gulsvi
@gulsvi
Mar 27 2017 01:58 UTC
@suhaschauhan The push() method adds one or more elements to the end of an array and returns the new length of the array. The shift() method removes the first element from an array and returns that element.
Manish Giri
@Manish-Giri
Mar 27 2017 01:58 UTC
you need to return the value of that
@suhaschauhan
David Amanze
@GodKingShogun
Mar 27 2017 02:01 UTC
@Manish-Giri :wave:
suhaschauhan
@suhaschauhan
Mar 27 2017 02:02 UTC
ahhh gotcha !! great thanks @Manish-Giri
CamperBot
@camperbot
Mar 27 2017 02:02 UTC
suhaschauhan sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4935 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 27 2017 02:02 UTC
@GodKingShogun :wave:
Danny Welstad
@GoonTwo
Mar 27 2017 02:07 UTC

someone wanna give me a hint on how to set up the answer to the "Profile Lookup" question in JS basics?

I get how to iterate through the array and select certain properties, just can't figure out how to get it all to work together

Danny Welstad
@GoonTwo
Mar 27 2017 02:09 UTC
@revisualize thanks! ill take a look at it and see what I come up with
CamperBot
@camperbot
Mar 27 2017 02:09 UTC
dwelstad sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3599 | @revisualize |http://www.freecodecamp.com/revisualize
Uros Tadic
@urketadic
Mar 27 2017 02:13 UTC
why is twitch api not working? the link on fcc
Din
@DinShpati
Mar 27 2017 02:13 UTC
hey guys i need help with this challenge its called "Make Object Properties Private"
here is what i did

var Bike = function() {

// Only change code below this line.
var gear = 0;

this.setGear = function() {
gear += 4;
};

this.getGear = function() {
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();

can someone help pls
Stephen James
@sjames1958gm
Mar 27 2017 02:14 UTC
@DinShpati setGear needs a parameter to set the gear value to
Edward John
@eddmecha
Mar 27 2017 02:15 UTC
morning guys
Din
@DinShpati
Mar 27 2017 02:15 UTC
Like this.setGear = function(value){};
Edward John
@eddmecha
Mar 27 2017 02:15 UTC
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (answer) {
    case 1:
      console.log("alpha");
      break;
    case 2:
      console.log("beta");
      break;
    case 3:
      console.log("gamma");
      break;
    case 4:
      console.log("delta");
      break;

    default:
  }


  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
the above code written
what did i do wrongly?
Din
@DinShpati
Mar 27 2017 02:15 UTC
Like this.setGear = function(value){ gear };
Like this.setGear = function(value){ gear += set };
????????????
@sjames1958gm ??????
Joseph
@revisualize
Mar 27 2017 02:18 UTC
@eddmecha You shouldn't be console.log Your function needs to return answer and so you need to change the value of answer.
Stephen James
@sjames1958gm
Mar 27 2017 02:19 UTC
@DinShpati gear = value
Din
@DinShpati
Mar 27 2017 02:19 UTC
ok thanks
ill try it
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:19 UTC
function chunkArrayInGroups(arr, size) {
var split = arr.slice(0, size);
  var newArray = [];
  if (arr > size){
    newArray.push(split);
  }
  return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
dont get how to push my split array into a new array
Din
@DinShpati
Mar 27 2017 02:19 UTC
@sjames1958gm Thanks it worked
CamperBot
@camperbot
Mar 27 2017 02:19 UTC
dinshpati sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6369 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:20 UTC
function chunkArrayInGroups(arr, size) {
var split = arr.slice(0, size);
  var newArray = [];
  if (arr.length > size){
    newArray.push(split);
  }
  return newArray;
}

chunkArrayInGroups(["a", "b",
Stephen James
@sjames1958gm
Mar 27 2017 02:20 UTC
@DinShpati :+1:
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:22 UTC
that pushes just the first set of the array in i need to get both so that i have a two-dimensional array
any advise
Danny Welstad
@GoonTwo
Mar 27 2017 02:22 UTC
@revisualize Hey, I got it to work after looking at your notes. Just curious if how I did it is the easiest/expected way.
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (firstName === contacts[i].firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else {
      return "No such property";
    }
}
}
  return "No such contact";
// Only change code above this line
}
Edward John
@eddmecha
Mar 27 2017 02:24 UTC
@revisualize ohh i see so it means i have to use
JamesVitaly
@JamesVitaly
Mar 27 2017 02:25 UTC
i am tring to return a random function, i have this code but it is telling me it cannot read property of length

function randomWholeNum(quotes) {

var newQuotes = quotes[Math.floor(Math.random()*quotes.length)];
}

Manish Giri
@Manish-Giri
Mar 27 2017 02:25 UTC
@dwelstad yup
JamesVitaly
@JamesVitaly
Mar 27 2017 02:25 UTC
return a random string**
\
Edward John
@eddmecha
Mar 27 2017 02:25 UTC
answer = "beta"
JamesVitaly
@JamesVitaly
Mar 27 2017 02:25 UTC
sorry
Danny Welstad
@GoonTwo
Mar 27 2017 02:26 UTC
@Manish-Giri thanks!
CamperBot
@camperbot
Mar 27 2017 02:26 UTC
dwelstad sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4937 | @manish-giri |http://www.freecodecamp.com/manish-giri
KatieCz
@KteCz77
Mar 27 2017 02:27 UTC
working on the converting celcisus to fahrenheit step. i get the formulas right one at a time but don't understand how to get them all checked off to move on. can anyone explain?
Joseph
@revisualize
Mar 27 2017 02:27 UTC
@eddmecha yes
Edward John
@eddmecha
Mar 27 2017 02:27 UTC
@revisualize ok i try it now
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:28 UTC
@JamesVitaly your math.floor is in an array for starters try deleting the [ ]
JamesVitaly
@JamesVitaly
Mar 27 2017 02:29 UTC
tried
still not working :(
Emilio Cantón
@Cabemo
Mar 27 2017 02:30 UTC

Hey guys, one question: Is it possible to use comparison and logical operators in "switch"?
ex:

case x < 5:

or

case <5:
Luis
@electrone901
Mar 27 2017 02:31 UTC
Hi guys, quick question. have anyone tried to check if a string is a palindrome?
Joseph
@revisualize
Mar 27 2017 02:31 UTC
@Cabemo Neither.
JamesVitaly
@JamesVitaly
Mar 27 2017 02:31 UTC
@ronnieg1988 Yeh i tried changing it out but still no luck, any ideas ?
Emilio Cantón
@Cabemo
Mar 27 2017 02:32 UTC
All right, and in general in "switch" I`m guessing it can´t be used @revisualize
Joseph
@revisualize
Mar 27 2017 02:32 UTC
@Cabemo If you want to make a comparison or use a logical operator.. You should use an if
Jor
@joreyesl
Mar 27 2017 02:33 UTC
@Cabemo you can do it, but its not very intuitive. You could just use if statements.
Emilio Cantón
@Cabemo
Mar 27 2017 02:35 UTC
Thanks @joreyesl @revisualize then it was easier with "IF" I guess, some dude told me yesterday it would be better with "switch"
CamperBot
@camperbot
Mar 27 2017 02:35 UTC
cabemo sends brownie points to @joreyesl and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 681 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 3600 | @revisualize |http://www.freecodecamp.com/revisualize
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:36 UTC
function ourRandomRange(quote {

  return Math.floor(Math.random() * (quote.length+ 1)) ;
}
@JamesVitaly maybe try something like this
opps forgot )
JamesVitaly
@JamesVitaly
Mar 27 2017 02:36 UTC
@ronnieg1988 will try now
@ronnieg1988 no luck :(
Manish Giri
@Manish-Giri
Mar 27 2017 02:38 UTC
@JamesVitaly what seems to be the problem?
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:38 UTC
post the whole code
Jor
@joreyesl
Mar 27 2017 02:38 UTC
@JamesVitaly is quotes defined and is it an array?
JamesVitaly
@JamesVitaly
Mar 27 2017 02:38 UTC

function randomWholeNum(quotes) {

return Math.floor(Math.random() * (quotes.length+ 1));
}
var quotes = ["I had nothing to offer anybody except my own confusion.", "We are here to laugh at the odds and live our lives so well that Death will tremble to take us.","Your mind will answer most questions if you learn to relax and wait for the answer.","We are what we pretend to be, so we must be careful about what we pretend to be."];

yeh
Jor
@joreyesl
Mar 27 2017 02:39 UTC
@electrone901 you can just post your code here rather than the link
Luis
@electrone901
Mar 27 2017 02:39 UTC
thanks @joreyesl
CamperBot
@camperbot
Mar 27 2017 02:39 UTC
electrone901 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 682 | @joreyesl |http://www.freecodecamp.com/joreyesl
JamesVitaly
@JamesVitaly
Mar 27 2017 02:39 UTC
@Manish-Giri i want to return a random string from an array, I though i came up with a solution but it tells me that length is undefine cannot read it as a property
Luis
@electrone901
Mar 27 2017 02:40 UTC
function palindrome(str) {
str = str.toLowerCase();
str = str.replace(/["_", " ", ",", ".", "-", "(", ":", "/", "\", ":", ")" ]/g, '');
newStr = str.split('').reverse().join('');
if(str == newStr) return true;
else return false;
}
palindrome("0_0 (: /-\ :) 0-0");
Manish Giri
@Manish-Giri
Mar 27 2017 02:40 UTC
@JamesVitaly can you share your pen link?
Luis
@electrone901
Mar 27 2017 02:41 UTC
should return true
JamesVitaly
@JamesVitaly
Mar 27 2017 02:41 UTC
Jor
@joreyesl
Mar 27 2017 02:41 UTC
@JamesVitaly you have a parameter quotes and also a global array quotes, make sure you are actually passing in an argument to the function otherwise quotes inside the function will be undefined.
Ngo Quoc Hiep
@quochiep87
Mar 27 2017 02:41 UTC
how to do?
Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
JamesVitaly
@JamesVitaly
Mar 27 2017 02:42 UTC
@joreyesl will tak a closer look at that thanks
CamperBot
@camperbot
Mar 27 2017 02:42 UTC
jamesvitaly sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 683 | @joreyesl |http://www.freecodecamp.com/joreyesl
Manish Giri
@Manish-Giri
Mar 27 2017 02:43 UTC
@JamesVitaly works for me
 function newQuote(quotes) {
 var quote = quotes[Math.floor(Math.random() * quotes.length)];
   console.log(quote);
}
var quotes = ["I had nothing to offer anybody except my own confusion.", "We are here to laugh at the odds and live our lives so well that Death will tremble to take us.","Your mind will answer most questions if you learn to relax and wait for the answer.","We are what we pretend to be, so we must be careful about what we pretend to be."]
newQuote(quotes);
JamesVitaly
@JamesVitaly
Mar 27 2017 02:44 UTC
@Manish-Giri how did you test it, I have been trying to test in an random free code camp challenge... thanks for checking haha!
CamperBot
@camperbot
Mar 27 2017 02:44 UTC
jamesvitaly sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4939 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Mar 27 2017 02:44 UTC
remember to pass the quotes array to the newQuote function, as @joreyesl said
@JamesVitaly
@JamesVitaly I tested by putting a console.log statement - console.log(quote);
JamesVitaly
@JamesVitaly
Mar 27 2017 02:45 UTC
@Manish-Giri thanks again and @ronnieg1988 thanks for your help earlier too
CamperBot
@camperbot
Mar 27 2017 02:45 UTC
jamesvitaly sends brownie points to @manish-giri and @ronnieg1988 :sparkles: :thumbsup: :sparkles:
:warning: jamesvitaly already gave manish-giri points
:cookie: 249 | @ronnieg1988 |http://www.freecodecamp.com/ronnieg1988
Shikazuka
@Arthareza
Mar 27 2017 02:46 UTC
sorry guys can anyone help me with task "create decimal number with javascript"
Roxroy
@roxroy
Mar 27 2017 02:46 UTC
@JamesVitaly , now that it is working you can move on to hookup the button click - use jQuery to handle the on click event.
Joseph
@revisualize
Mar 27 2017 02:47 UTC
@quochiep87 How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Jor
@joreyesl
Mar 27 2017 02:47 UTC
@electrone901 that looks good but you could use a better regex for the replace method. Try looking at using the character class \W along with a character set [ ]. And you dont need quotes " inside the regex. They will be treated as literals, ex: if i want to match _ and ., I could do /[_.]/g dont need to do /["_","."]/g as you are doing.
Roxroy
@roxroy
Mar 27 2017 02:47 UTC
@Arthareza , what part are u stuck with?
JamesVitaly
@JamesVitaly
Mar 27 2017 02:48 UTC
@roxroy yeh thats the next step
Roxroy
@roxroy
Mar 27 2017 02:48 UTC
@JamesVitaly , show me what u have done so far
JamesVitaly
@JamesVitaly
Mar 27 2017 02:49 UTC
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:49 UTC
function chunkArrayInGroups(arr, size) {
var split = arr.slice(0, size);
  var newArray = [];
  if (arr.length > size){
    newArray.push(split);
  }
  return newArray;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
cant figure out how to add the second array to the newarray
JamesVitaly
@JamesVitaly
Mar 27 2017 02:49 UTC
@roxroy just trying to make sure i have passed on my array to the function
Shikazuka
@Arthareza
Mar 27 2017 02:50 UTC

@roxroy i don't know how to make the variable mydecimal

mydecimal=5.7;

is this true ?

Roxroy
@roxroy
Mar 27 2017 02:51 UTC
@Arthareza , you are missing the var part before mydecimal =....
Luis
@electrone901
Mar 27 2017 02:51 UTC
@joreyesl let me try
Jor
@joreyesl
Mar 27 2017 02:51 UTC
@ronnieg1988 you will need to use a loop. and slice the array by size chunks. .splice might be better if you want to use the same arguments, otherwise if you want to use .slice you will need to update the range you want to slice
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:51 UTC
@joreyesl i did i can return the a and b together but cant return the c and d
Shikazuka
@Arthareza
Mar 27 2017 02:52 UTC
@roxroy still not working
Roxroy
@roxroy
Mar 27 2017 02:52 UTC
@Arthareza , paste the line here..
Carson Michael
@Carson2003
Mar 27 2017 02:53 UTC
can someone please tell me why this isn't working here is my code

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
var checkN = "No such contact";
var checkP = "No such property";

for( i = 0; i < contacts.length; i++){
if (contacts[i].firstName == firstName){
checkN = contacts[i.firstName];
if(contacts[i].hasOwnProperty(prop)){
checkP = contacts[i].prop;

 }

}
}
if (checkN == "No such contact"){
return checkN;
}else{
return checkP;
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

Shikazuka
@Arthareza
Mar 27 2017 02:53 UTC
var mydecimal = 5.7;
Jor
@joreyesl
Mar 27 2017 02:53 UTC
@ronnieg1988 yes because you are only slice once, you also need to slice the 2nd half, and if the array they pass in is bigger, then you need to slice some more, and so on. That is why you want to do it in a loop.
Roxroy
@roxroy
Mar 27 2017 02:53 UTC
@Arthareza , variable names are case sensitive you need to use myDecimal
Shikazuka
@Arthareza
Mar 27 2017 02:54 UTC
@roxroy it's work Thanks
CamperBot
@camperbot
Mar 27 2017 02:54 UTC
arthareza sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @roxroy |http://www.freecodecamp.com/roxroy
Ronald Johnson
@ronnieg1988
Mar 27 2017 02:54 UTC
so i need another if loop or a different one?
Roxroy
@roxroy
Mar 27 2017 02:55 UTC
@Arthareza , NP. There you go. Remember that the mydecimal is not the same as myDecimal or MyDecimal
David Amanze
@GodKingShogun
Mar 27 2017 02:56 UTC
can someone tell me why this is return unefined or null reference
return str.match(/[^\d\s()-]/g).length;
Carson Michael
@Carson2003
Mar 27 2017 02:57 UTC
need help please
David Amanze
@GodKingShogun
Mar 27 2017 02:58 UTC
@Carson2003 with what
Roxroy
@roxroy
Mar 27 2017 02:58 UTC
@JamesVitaly , you can use this example
Carson Michael
@Carson2003
Mar 27 2017 02:58 UTC
with this

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
var checkN = "No such contact";
var checkP = "No such property";

for( i = 0; i < contacts.length; i++){
if (contacts[i].firstName == firstName){
checkN = contacts[i.firstName];
if(contacts[i].hasOwnProperty(prop)){
checkP = contacts[i].prop;

 }

}
}
if (checkN == "No such contact"){
return checkN;
}else{
return checkP;
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

it is the profile lookup challenge
JamesVitaly
@JamesVitaly
Mar 27 2017 02:58 UTC
@roxroy which example?
David Amanze
@GodKingShogun
Mar 27 2017 02:59 UTC
@Carson2003 what specifically do you need help with
Ángel Araya
@angelaraya
Mar 27 2017 02:59 UTC
@GodKingShogun null is returned when no match is found. What is the value of str?
Cryptonomy
@Cryptonomy
Mar 27 2017 02:59 UTC
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Roxroy
@roxroy
Mar 27 2017 02:59 UTC
@JamesVitaly , you can use this example, ]see here
$( "#target" ).click(function() {
  alert( "Handler for .click() called." );
});
Cryptonomy
@Cryptonomy
Mar 27 2017 02:59 UTC
I'm confused on this one..
David Amanze
@GodKingShogun
Mar 27 2017 03:00 UTC
@angelaraya @angelaraya
telephoneCheck("555-555-5555");
Carson Michael
@Carson2003
Mar 27 2017 03:00 UTC
its not returning any properties
Jor
@joreyesl
Mar 27 2017 03:00 UTC
@Carson2003 you need to fix this line contacts[i.firstName]; and also this one contacts[i].prop;.
remember contacts[i] is the object you are looking at, and prop is a variable so you can't use dot notation, you have to use bracket notation.
Cryptonomy
@Cryptonomy
Mar 27 2017 03:00 UTC
Tried different combinations of shift and push but not availing here. Any hints/ tips for "Stand in line"
David Amanze
@GodKingShogun
Mar 27 2017 03:00 UTC
@Cryptonomy you will have to revisit the section that talks about push and pop an array
Ángel Araya
@angelaraya
Mar 27 2017 03:01 UTC
@GodKingShogun well, I think your regex is not looking for numbers, so none is going to be matched
Carson Michael
@Carson2003
Mar 27 2017 03:01 UTC
@joreyesl it didn't help
Ángel Araya
@angelaraya
Mar 27 2017 03:01 UTC
A rule of thumb for regex is to start simple and then grow from there
Jor
@joreyesl
Mar 27 2017 03:02 UTC
@Carson2003 what is the new code? only post the changes, not the whole thing.
Ronald Johnson
@ronnieg1988
Mar 27 2017 03:03 UTC
function chunkArrayInGroups(arr, size) {
var split = arr.slice(0, size);
  var splitAgain= arr.slice(2,arr.length);
  var newArray = [];
  if (arr.length > size){
    newArray.push(split);
  }
  if (arr.length > size){
    newArray.push(splitAgain);
  }
  return newArray;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
@joreyesl i got it to return both arrays into the new one but it only works for 1 of the objectives
Carson Michael
@Carson2003
Mar 27 2017 03:03 UTC
if (contacts[i.firstName] == firstName){
checkN = contacts[i.firstName];
if(contacts[i].hasOwnProperty(prop)){
checkP = contacts[i.prop];
David Amanze
@GodKingShogun
Mar 27 2017 03:03 UTC
@angelaraya idu. i know none is going to be matched with that example so the length is going to be 0
but it return undefined or null
which is bad for me
Jor
@joreyesl
Mar 27 2017 03:04 UTC
@Carson2003 you want to keep it like contacts[i]. That is the object. then if want the firstName then you want to do contacts[i].firstName. Now for props it will be different because prop is a variable so you have to use bracket notation, like contacts[i][prop]
Ángel Araya
@angelaraya
Mar 27 2017 03:04 UTC
@GodKingShogun because String.match() return null when there is no match. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match
David Amanze
@GodKingShogun
Mar 27 2017 03:05 UTC
@angelaraya okay. let me build my code around that info
@angelaraya thanks
CamperBot
@camperbot
Mar 27 2017 03:05 UTC
godkingshogun sends brownie points to @angelaraya :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @angelaraya |http://www.freecodecamp.com/angelaraya
Chuck Taylor
@cbtaylor2
Mar 27 2017 03:06 UTC
Totally lost on the "Word Blanks" challenge. Pls assist.
Carson Michael
@Carson2003
Mar 27 2017 03:06 UTC
thanks @joreyesl it worked
CamperBot
@camperbot
Mar 27 2017 03:06 UTC
carson2003 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 684 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Mar 27 2017 03:06 UTC
@Carson2003 :thumbsup:
ivorygrant
@ivorygrant
Mar 27 2017 03:06 UTC
hi everyone, working on the profile lookup challenge, i think i'm very close. I'm getting an error on my first if statement if someone can point me the right direction
function lookUpProfile(firstName, prop){
// Only change code below this line

  for (i=0; i<contacts.length; i++) {

    if (contacts[i].firstName==firstName && contacts[i].hasOwnProperty==prop) {
      return firstName, contacts[i].prop; 

    }

    else if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty!=prop) {
      return "No such property";
    }
    else if(contacts[i].firstName!=firstName){
      return "No such contact";
    }
  }
Ángel Araya
@angelaraya
Mar 27 2017 03:07 UTC
@cbtaylor2 Hi! What have you tried so far?
Jor
@joreyesl
Mar 27 2017 03:08 UTC
@ronnieg1988 yea thats is why i suggested a loop, and as you've noticed the start and end index for slice will change, but they are easy to calculate in terms of i and size.
JamesVitaly
@JamesVitaly
Mar 27 2017 03:08 UTC
@roxroy thanks for your help I have to dash off, now ill get to the bottom of thr problem later )
CamperBot
@camperbot
Mar 27 2017 03:08 UTC
jamesvitaly sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 476 | @roxroy |http://www.freecodecamp.com/roxroy
Roxroy
@roxroy
Mar 27 2017 03:09 UTC
@JamesVitaly , catch you later
Cryptonomy
@Cryptonomy
Mar 27 2017 03:10 UTC
@GodKingShogun I went and looked back at everything and it's still not clicking with me how to go about this.
Joseph
@revisualize
Mar 27 2017 03:10 UTC
@ivorygrant Your for loop isn't looping.
Roxroy
@roxroy
Mar 27 2017 03:10 UTC
@ivorygrant , the issue is with contacts[i].hasOwnProperty==prop The hasOwnProperty() method returns a boolean indicating whether the object has the specified property.
eg o.hasOwnProperty('prop'); // returns true
kailasa8055
@kailasa8055
Mar 27 2017 03:10 UTC
Screenshot (7).png
Chuck Taylor
@cbtaylor2
Mar 27 2017 03:10 UTC

i keep getting an error message on "Word Blanks" challenge. Please Help.function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

kailasa8055
@kailasa8055
Mar 27 2017 03:10 UTC
how do iterate through the array when it has one dimension and some other times multi dimension?
Joseph
@revisualize
Mar 27 2017 03:10 UTC
@kailasa8055 You're doing too much multiplication.
@kailasa8055 Your second loop isn't correct.

@cbtaylor2 Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

@roxroy @ivorygrant That isn't correct.. Quotes define strings.
Cryptonomy
@Cryptonomy
Mar 27 2017 03:13 UTC

function nextInLine(arr, item) {
// Your code here
arr.push();
arr.shift();

return item; // Change this line
}

Joseph
@revisualize
Mar 27 2017 03:13 UTC
@Cryptonomy You're not adding anything to the array.
ivorygrant
@ivorygrant
Mar 27 2017 03:13 UTC
hmmm let me think about this...are my other conditions correct?
Joseph
@revisualize
Mar 27 2017 03:14 UTC
@ivorygrant Was that question for me?
ivorygrant
@ivorygrant
Mar 27 2017 03:15 UTC
@revisualize yes
Cryptonomy
@Cryptonomy
Mar 27 2017 03:15 UTC
@Joseph Not sure how I'm supposed to go about this
Joseph
@revisualize
Mar 27 2017 03:15 UTC
@ivorygrant You have to change your logic. Your loop isn't looping.
@Cryptonomy How do you add an element to the end of an array?
Ronald Johnson
@ronnieg1988
Mar 27 2017 03:16 UTC
function chunkArrayInGroups(arr, size) {
var split = arr.slice(0, size);
  var splitAgain= arr.slice(2,arr.length);
  var newArray = [];
  if (arr.length > size){
    newArray.push(split);
  }
  if (arr.length > size){
    newArray.push(splitAgain);
  }
  return newArray;

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
@joreyesl this should return 3 arrays [0,1][2,3][4,5] its only returning 2 [0,1,2][2,3,4,5]
ivorygrant
@ivorygrant
Mar 27 2017 03:16 UTC
@revisualize so my for statement is incorrect? hmmm
Cryptonomy
@Cryptonomy
Mar 27 2017 03:16 UTC
@joseph unshift?
Roxroy
@roxroy
Mar 27 2017 03:16 UTC
@revisualize , @ivorygrant is doing the Profile question not the Quote question. The issue is regarding the use of the hasOwnProperty function.
Joseph
@revisualize
Mar 27 2017 03:16 UTC
@Cryptonomy Incorrect.
@roxroy I know what @ivorygrant is doing. I've solved that challenge 5 different ways.
Cryptonomy
@Cryptonomy
Mar 27 2017 03:17 UTC
@joseph wait, push is supposed to add the beginning to last.
Joseph
@revisualize
Mar 27 2017 03:17 UTC
@roxroy I made a comment for @cbtaylor2 then I made a comment for @roxroy and tagged @ivorygrant
@Cryptonomy There is no method that adds the beginning of an array to the end of an array.
Cryptonomy
@Cryptonomy
Mar 27 2017 03:18 UTC
Yes, it is. But I'm just not sure how to utilize it properly apparently lol.
ivorygrant
@ivorygrant
Mar 27 2017 03:18 UTC
@revisualize hmmm the only think i can think of is to do <= to include all members
Joseph
@revisualize
Mar 27 2017 03:19 UTC
@Cryptonomy You should look up the methods that you're trying to use.
Cryptonomy
@Cryptonomy
Mar 27 2017 03:19 UTC
".push() takes one or more parameters and "pushes" them onto the end of the array."
Joseph
@revisualize
Mar 27 2017 03:19 UTC
@Cryptonomy Okay. What does that method return?
Cryptonomy
@Cryptonomy
Mar 27 2017 03:19 UTC
still outputs 12345
Roxroy
@roxroy
Mar 27 2017 03:20 UTC
@revisualize , np. It happens at times - especially in an active chatroom like this.
Cryptonomy
@Cryptonomy
Mar 27 2017 03:22 UTC
@revisualize still outputs 12345 with arr.push()
Dana Aljirudi
@DanaJirudi
Mar 27 2017 03:23 UTC
Hello guys. I'm doing the "Chunky Monkey" algorithm challenge.. I managed to do it when "size" is 2. Any idea on how to make it work for any number?
```
```
Cryptonomy
@Cryptonomy
Mar 27 2017 03:23 UTC
Oh, I see. It just appends them to the end of the array @revisualize
Mike Echlin
@mechlin69
Mar 27 2017 03:23 UTC
really stuck on challenge 175
Dana Aljirudi
@DanaJirudi
Mar 27 2017 03:23 UTC
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var arrNum1 = arr.slice(size);
  var arrNum2 = arr.slice(0, size);
  var slicedArr = [arrNum2].concat([arrNum1]);

  return slicedArr;
}
ivorygrant
@ivorygrant
Mar 27 2017 03:23 UTC
@roxroy ok i thought about this. I want to see if contact equals contact, then check if the property exists so that i can return the property
Joseph
@revisualize
Mar 27 2017 03:24 UTC
@Cryptonomy What does the .push() method return?
ivorygrant
@ivorygrant
Mar 27 2017 03:24 UTC
*return the property value
Dana Aljirudi
@DanaJirudi
Mar 27 2017 03:26 UTC
Any idea on how to make the program work when size other than two?
Cryptonomy
@Cryptonomy
Mar 27 2017 03:26 UTC
@revisualize it returns 12345, unless I add a number in push ex arr.push(1); since it just appends.
Lee
@eightlimbs
Mar 27 2017 03:27 UTC
hey guys i'm stumped on the caseInSwitch challenge
this is what i have...

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (1) {
case "alpha":
break;}

switch (2) {
case "beta":
break;}

switch (3) {
case "gamma":
break;}

switch (4) {
case "delta":
break;}

// Only change code above this line
return answer;
}

Edward John
@eddmecha
Mar 27 2017 03:27 UTC
@eightlimbs you should scroll back up i have just complete it just now
Ronald Johnson
@ronnieg1988
Mar 27 2017 03:28 UTC
why so many switchs?
Roxroy
@roxroy
Mar 27 2017 03:28 UTC
@ivorygrant , did the update work for you? or do you have a question for me?
Joseph
@revisualize
Mar 27 2017 03:28 UTC
@Cryptonomy That's incorrect. You really should look your methods up.
ivorygrant
@ivorygrant
Mar 27 2017 03:29 UTC
@roxroy i updated to this, but still no go.
for (i=0; i<=contacts.length; i++) {

    if (contacts[i].firstName==firstName && contacts[i].hasOwnProperty==prop) {
      return firstName +", " + contacts[i].prop; 

    }

    else if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty!=prop) {
      return "No such property";
    }
    else if(contacts[i].firstName!=firstName){
      return "No such contact";
    }
  }
Joseph
@revisualize
Mar 27 2017 03:29 UTC
@ivorygrant Okay.
@ivorygrant Let me write something for you.
Roxroy
@roxroy
Mar 27 2017 03:30 UTC
@ivorygrant , try else if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)) {
ivorygrant
@ivorygrant
Mar 27 2017 03:30 UTC
ohhhhhhhhhhhhh
i deserve a virtual slap for that!
Lee
@eightlimbs
Mar 27 2017 03:30 UTC
@eddmecca I can't find it
Roxroy
@roxroy
Mar 27 2017 03:31 UTC
@ivorygrant , you have to tell it what property to check
Joseph
@revisualize
Mar 27 2017 03:32 UTC
var value = "e"
var arr = ["a", "b", "c", "d", "e"];
for (var i = 0; i < arr.length; i++) {
      if (value === arr[i]) { return "True"; }
      else if (value !=== arr[i]) { return "False" }
}
@ivorygrant How many times do you think this loop runs?
ivorygrant
@ivorygrant
Mar 27 2017 03:32 UTC
4 times
Joseph
@revisualize
Mar 27 2017 03:32 UTC
@ivorygrant Incorrect.
Edward John
@eddmecha
Mar 27 2017 03:32 UTC

@eightlimbs try this

switch (val) {
    case 1:
      answer = "alpha";
      break;
    case 2:
      answer = "beta";
      break;
    case 3:
      answer = "gamma";
      break;
    case 4:
      answer = "delta";
      break;

u only need to use switch once

Ronald Johnson
@ronnieg1988
Mar 27 2017 03:32 UTC
5 times
Joseph
@revisualize
Mar 27 2017 03:33 UTC
@ronnieg1988 Incorrect.
Ronald Johnson
@ronnieg1988
Mar 27 2017 03:33 UTC
really>
Joseph
@revisualize
Mar 27 2017 03:33 UTC
Really.
Edward John
@eddmecha
Mar 27 2017 03:33 UTC
and what you wanted it to switch is the value not the answer
Lee
@eightlimbs
Mar 27 2017 03:33 UTC
ahhh... thanks @eddmecha !!
CamperBot
@camperbot
Mar 27 2017 03:33 UTC
eightlimbs sends brownie points to @eddmecha :sparkles: :thumbsup: :sparkles:
:warning: @eddmecha's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Ronald Johnson
@ronnieg1988
Mar 27 2017 03:34 UTC
the array length is 5 tho
Joseph
@revisualize
Mar 27 2017 03:34 UTC
@ronnieg1988 So.
Ronald Johnson
@ronnieg1988
Mar 27 2017 03:34 UTC
arr.length = 5
Joseph
@revisualize
Mar 27 2017 03:34 UTC
Correct.
ivorygrant
@ivorygrant
Mar 27 2017 03:34 UTC
@revisualize well i can guess once, but i don't know why
Roxroy
@roxroy
Mar 27 2017 03:34 UTC
@revisualize , just once ---> returns false
Joseph
@revisualize
Mar 27 2017 03:34 UTC
@ivorygrant Let's walk you through it.
Chris Cullen
@123xylem
Mar 27 2017 03:35 UTC

Why are my flash messages always showing and acting like functions?
Here I defind error and success..

app.use(function(req,res,next){                                  
    res.locals.currentUser=req.user;                              //Looks in the requests local properties for req.user which gets stored in currentuser var

    //===================================Flash messages below. if  error or sucess is stored in flash make them equal to res.locals.error/sucess
    res.locals.error=flash("error");
    res.locals.success=flash("success");
    next();                                                        //then it allows the route to continue
});

Here i use it in a route middleware.. so when your not logged in it shows a message.

middlewareObj.isLoggedIn = function(req, res, next){
    if(req.isAuthenticated()){
        return next();
    }
    req.flash("error", "You need to be logged in to do that");
    res.redirect("/login");
}

And here i include it in my site via the header.. If the message exists and has more than 0 characters in it show it- else dont- But its just showing the function of the header instead.

<!--//==================================Flash Messages=================-->
  <div class="container">

        <% if(error && error.length > 0){
        console.log(error,error.length)%>
            <div class="alert alert-danger" role="alert">
                <%= error %>
            </div>
        <% } %>
        <% if(success && success.length > 3){ %>
            <div class="alert alert-success" role="alert">
                <%= success %>
            </div>
        <% } %>
    </div>

THe console.log shows function, 3
Any idea why the flash message is shwing as a function all the time and not waiting for the message to trigger?

Ronald Johnson
@ronnieg1988
Mar 27 2017 03:36 UTC
oh lol i didnt read the rest of it i just read the for loop
Cryptonomy
@Cryptonomy
Mar 27 2017 03:36 UTC
@revisualize I just looked it up. I'd been on that for quite a while, and was burnt out on it. I didn't know I could put it the two arguments in the push. If I would've known that it would have been a walk in the park.

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);

  return arr.shift();  // Change this line
}
Joseph
@revisualize
Mar 27 2017 03:37 UTC
var value = "e"
var arr = ["a", "b", "c", "d", "e"];
for (var i = 0; i < arr.length; i++) {
     // at the first iteration i is 0
     // arr[i] is arr[0] and arr[0] holds the value of "a"
     // if ("e" === "a") ... return "True" ... Well, "e" is not "a" so, no.
      if (value === arr[i]) { return "True"; }
     // okay so nest block
     // if "e" is not equal to "a" ... that's true ... so ... return "False"
      else if (value !=== arr[i]) { return "False" }
}
@ivorygrant
ivorygrant
@ivorygrant
Mar 27 2017 03:38 UTC
ok i follow, it only runs once
Joseph
@revisualize
Mar 27 2017 03:38 UTC
@ivorygrant Look at what you're doing with your Profile Lookup code.
@ivorygrant Your loop is NOT looping.
ivorygrant
@ivorygrant
Mar 27 2017 03:40 UTC
ahh ok perhaps my error is the order of my arguments
since it checks the first one and doesn't find it, it stops
Ronald Johnson
@ronnieg1988
Mar 27 2017 03:43 UTC
function chunkArrayInGroups(arr, size) {
var split = arr.slice(0, size);
  var splitAgain= arr.slice(size ,arr.length);
  var newArray = [];
  if (arr.length > size){
    newArray.push(split);
  }
  if (arr.length > size){
    newArray.push(splitAgain);
  }
  return newArray;

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
it returns 2 arrays but when i need 3 it only returns 2
Aaron Bell
@awb715
Mar 27 2017 03:43 UTC
does anyone know how to access a variable in the document object in jquery?
Roxroy
@roxroy
Mar 27 2017 03:44 UTC
@ivorygrant , the problem is that every one of your if/else has a return. And as such the whole 'for loop' is executed just once. It never goes to check the next name in the array. Check your if/else conditions
David Amanze
@GodKingShogun
Mar 27 2017 03:46 UTC
its been nice knowing all of you. ill go jump off a building now :smile:

function telephoneCheck(str) {
  // Good luck!
  var strikes=0;
  var digit= /\d/g;
  var allow= /[^\d\s()-]/;
  if (str.match(allow)===null) {

  } else{     
    strikes++;

    }
  if (str.indexOf("-")===0){
    strikes++;
    console.log(strikes);
  }
  if (str[0]==="1"&&str.match(digit).length!==11) {
    strikes++;
  } 
  if (str[0]!=="1"&& str.match(digit).length!==10){
     strikes++;
  } 
  if (/[()]/.test(str)===true){
    if (str.indexOf("(")===1||str.indexOf("(")===2||str.indexOf("(")===0&&str.indexOf(")")===5||str.indexOf(")")===6||str.indexOf(")")===4){

    } else {
        strikes++;
      console.log(strikes);
    }
  }


  if (strikes===0){
    return true;
  } else {
    return false;
  }
}
ivorygrant
@ivorygrant
Mar 27 2017 03:47 UTC
@roxroy My initial reaction is to create separate for loops for each situation but that seems repetitive
Kaue Rodrigo Pacheco
@kauepacheco
Mar 27 2017 03:49 UTC

function titleCase(str) {

  lowerCase = str.toLowerCase();

  var arr = lowerCase.split(" ");

  for (var i = 0; i < arr.length; i++) {
    upperCase = arr[i][0].toUpperCase() + arr[i];
    console.log(upperCase);
  }
}

titleCase("I'm a little tea pot");
How do I remove the first letter of arr[i]?
output:
Ii'm
Aa
Llittle
Ttea
Ppot
Chuck Taylor
@cbtaylor2
Mar 27 2017 03:50 UTC
I'm trying the suggestions from joseph@revisualize.
Jor
@joreyesl
Mar 27 2017 03:51 UTC
@kauepacheco you need to make a new string, try lookin at substring()
ivorygrant
@ivorygrant
Mar 27 2017 03:56 UTC
ok after some i thought i declared a local variable answer and to return the answer
var answer;
  for (i=0; i<=contacts.length; i++) {

    if (contacts[i].firstName!=firstName){
      answer = "No such contact";
    }
    else if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)) {
      answer = "No such property";
    }

     else if (contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)) {
      answer = firstName +", " + contacts[i].prop; 

    }
    return answer;
but still no go :(
the no such contact property works. but the others dont
ok if i change the second statement to an || expression, that checks out
Sandip Shrestha
@saninmersion
Mar 27 2017 03:59 UTC
@ivorygrant your both else if seem identical to me and for some reason I think they should not be
ivorygrant
@ivorygrant
Mar 27 2017 04:00 UTC
@saninmersion yes! i changed that
Sandip Shrestha
@saninmersion
Mar 27 2017 04:01 UTC
@ivorygrant I used a nested if statement for the second one. using a || operator will mean that it will pass if any of the conditionns are met. But for second property your First condition needs to met and second not met
@ivorygrant also you would like to check if
contacts[i].hasOwnProperty(prop) returns true or false
ivorygrant
@ivorygrant
Mar 27 2017 04:06 UTC
@saninmersion ok this is what i updated to:
var answer;
  for (i=0; i<=contacts.length; i++) {

    if (contacts[i].firstName!=firstName){
      answer = "No such contact";
    }
    else if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)!=prop) {
      answer = "No such property";
    }

     else if (contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)) {
      answer = firstName +", " + contacts[i].prop; 

    }
    return answer;

  }
i think i'm close! hmmmm
i tried adding == to the last else if but that didn't work
Sandip Shrestha
@saninmersion
Mar 27 2017 04:08 UTC
@ivorygrant why not use a nested if for second and third condition
Joseph
@revisualize
Mar 27 2017 04:09 UTC
@ivorygrant Your loop isn't looping.
ivorygrant
@ivorygrant
Mar 27 2017 04:10 UTC
argh! ok let me think about this...
Joseph
@revisualize
Mar 27 2017 04:10 UTC
@ivorygrant Your previous code was better.
ivorygrant
@ivorygrant
Mar 27 2017 04:10 UTC
@revisualize so my solution to declare a variable and return it at the end, is off?
Joseph
@revisualize
Mar 27 2017 04:10 UTC
@ivorygrant Look. You don't need everything inside of your for loop.
Bruno Teófilo
@Heirian
Mar 27 2017 04:11 UTC
How i can write this line return count + (count > 0 ? " Bet" : " Hold"); without ternary operator?
Joseph
@revisualize
Mar 27 2017 04:11 UTC
@ivorygrant You're the only one putting that constraint upon yourself.
@Heirian
if (count > 0) {
    return count + " Bet";
} else {
    return count + " Hold";
}
@ivorygrant This: contacts[i].prop
Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Bruno Teófilo
@Heirian
Mar 27 2017 04:13 UTC
ty
ivorygrant
@ivorygrant
Mar 27 2017 04:17 UTC
@revisualize when you say "dont neeed everything inside of your for loop" could you give an example?
please :)
Joseph
@revisualize
Mar 27 2017 04:18 UTC
@ivorygrant Let me think.

@ivorygrant If I was to do this example where I was looking for a letter in an array of strings.
If the letter is found return the string "True" otherwise return the string "False"

var value = "e"
var arr = ["a", "b", "c", "d", "e"];
for (var i = 0; i < arr.length; i++) {
      if (value === arr[i]) { return "True"; }
}
return "False";

Then if you redid that challenge with the letter "z" as the value of the variable value

Joseph
@revisualize
Mar 27 2017 04:27 UTC
@ivorygrant Do you see what I'm trying to get at with my example?
Chris Cullen
@123xylem
Mar 27 2017 04:27 UTC
 <div class="container">

        <% if(error&& error.length > 0){
        console.log(error,error.length)%>
            <div class="alert alert-danger" role="alert">
                <%= error %>
            </div>
        <% } %>
        <%  if(success && success.length > 3){ %>
            <div class="alert alert-success" role="alert">
                <%= success %>
            </div>
        <% } %>
    </div>

Why does this function which should look for error or successin flash messages give this response:::

function (req, res, next) { if (req.flash && safe) { return next(); } req.flash = _flash; next(); }

The function seems to just think itself is error and the length is 3 as it has 3 args///
How do i make the function work properly?

ivorygrant
@ivorygrant
Mar 27 2017 04:27 UTC
well i followed your first suggestion to update to bracket notation. did that. but as to your example...not seeing it
this is what i have now:
// Only change code below this line
var answer;
  for (i=0; i<=contacts.length; i++) {

    if (contacts[i].firstName!=firstName){
      answer = "No such contact";
    }
    else if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty[prop]!=prop) {
      answer = "No such property";
    }

     else if (contacts[i].firstName==firstName && contacts[i].hasOwnProperty[prop]) {
      answer = firstName +", " + contacts[i][prop]; 

    }
    return answer;

  }
Joseph
@revisualize
Mar 27 2017 04:28 UTC
@ivorygrant Your loop still isn't looping.
@ivorygrant You're now not doing .hasOwnProperty() correctly.
ivorygrant
@ivorygrant
Mar 27 2017 04:30 UTC
ok, so to reiterate, the .hasOwnProperty() returns a boolean response
Joseph
@revisualize
Mar 27 2017 04:30 UTC
@ivorygrant correct.
ivorygrant
@ivorygrant
Mar 27 2017 04:30 UTC
"check if this property exists"
ok
Joseph
@revisualize
Mar 27 2017 04:30 UTC
@ivorygrant You had .hasOwnProperty() correct before.
ivorygrant
@ivorygrant
Mar 27 2017 04:31 UTC
in the parentheses I should pass through prop
Joseph
@revisualize
Mar 27 2017 04:31 UTC
@ivorygrant .hasOwnProperty[prop]
Not parenthesis
Those are brackets
@ivorygrant But, still your loop is only running once.
ivorygrant
@ivorygrant
Mar 27 2017 04:33 UTC
hmm ok. i'm going to take a walk for a bit. If i'm understanding you correctly i'm making a very basic mistake.
brb!
harryMason
@harryMason
Mar 27 2017 04:36 UTC

Hey, would someone like to have a look at my switch statement code?
Instructions: Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

Here is my code:

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch(val) {
    case 1:
      console.log("alpha");
      break;
    case 2:
      console.log("beta");
      break;
    case 3:
      console.log("gamma");
      break;
    case 4:
      console.log("delta");
      break;
  }

  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(2);
Joseph
@revisualize
Mar 27 2017 04:36 UTC
@harryMason Console.log doesn't change the value of answer ... which at the end you're returning.
harryMason
@harryMason
Mar 27 2017 04:37 UTC
@revisualize ahaaa
@revisualize Thanks for the hint :)
CamperBot
@camperbot
Mar 27 2017 04:37 UTC
harrymason sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3601 | @revisualize |http://www.freecodecamp.com/revisualize
grantknaver
@grantknaver
Mar 27 2017 04:47 UTC
im trying to pass a value and update a the value to true, rather than false.
the value I am trying to effect is activated
here is the code...
```
function block(activated) {
  var checkArray = [
    //row
    ["#cell1", "#cell2", "#cell3"],
    ["#cell4", "#cell5", "cell6"],
    ["#cell7", "#cell8", "#cell9"],

    //column
    ["#cell1", "#cell4", "#cell7"],
    ["#cell2", "#cell5", "#cell8"],
    ["#cell3", "#cell6", "#cell9"],

    //diag
    ["#cell1", "#cell5", "#cell9"],
    ["#cell3", "#cell5", "#cell7"]
  ]
  //alert(checkArray);
  var emptySpot;
  for (var i = 0; i < 7; i++) {
    var prevention = 0;
    $(checkArray[i]).each(function(element,index){
      var target = $(index);
      var targetText = $(index).text();
      if(targetText === ''){
        emptySpot = index;
        alert(emptySpot);
      }
      if(targetText === playerChoice){
        prevention = prevention + 1;
        alert("playerChoice " + index);
        alert("prevention " + prevention);
      } 
    });//each
    if(prevention === 2 && emptySpot != undefined){
       $(emptySpot).html("<p>" + player2Choice + "</p>");
       gridAdjustment(emptySpot); 
       activated = true;
       return emptySpot;//false change maybe
    }
  }//for var i*/
}
```
Edward John
@eddmecha
Mar 27 2017 04:49 UTC
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[16];   // Change this Line
guys what did i wrote wrong?
grantknaver
@grantknaver
Mar 27 2017 04:49 UTC
the end goal is to change correction in the ticktac function
I dont want to do a global
screw that
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 04:49 UTC

Using Objects for Lookups -- I'm having trouble with converting the switch statements into a lookup table. This is what I have:

function phoneticLookup(val) {

var result = "";
var lookup = {
"alpha": "Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"

grantknaver
@grantknaver
Mar 27 2017 04:49 UTC
am I passing it wrong
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 04:49 UTC
Is that incorrect?
Joseph
@revisualize
Mar 27 2017 04:53 UTC
@AlanMcDowell888 Are you modifying result?
grantknaver
@grantknaver
Mar 27 2017 04:53 UTC
any ideas
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 04:54 UTC
@grantknaver I'll try to help after I learn
@revisualize that is a good question
Joseph
@revisualize
Mar 27 2017 04:55 UTC
@AlanMcDowell888 Great. Can you answer the question?
Travis Bryant
@t-bryant
Mar 27 2017 04:56 UTC

I'm having trouble comprehending the stand in line (queue) assignments...this is what I am given: function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

these are my instructions:
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
and the rules:nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
Joseph
@revisualize
Mar 27 2017 04:56 UTC
@t-bryant You haven't done anything.
harryMason
@harryMason
Mar 27 2017 04:56 UTC
@revisualize I did 'answer = "alpha";' instead of 'console.log'. That did the trick. Thanks again for the hint.
CamperBot
@camperbot
Mar 27 2017 04:56 UTC
harrymason sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: harrymason already gave revisualize points
Travis Bryant
@t-bryant
Mar 27 2017 04:57 UTC
i know i haven't done anything, i don't even know where to start
Joseph
@revisualize
Mar 27 2017 04:57 UTC
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. <-- This part has been done for you.
function nextInLine(arr, item) { <--
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 04:57 UTC
@revisualize I am returning "result" which indicates that it is a modifiable variable
Joseph
@revisualize
Mar 27 2017 04:57 UTC
@t-bryant Add the number to the end of the array
How do you add the number (item) to the end of the array (arr)?
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 04:58 UTC
var lookup is incorrect, I now see
grantknaver
@grantknaver
Mar 27 2017 04:58 UTC
dang @AlanMcDowell888 thanks I just really dont want to do a global var
CamperBot
@camperbot
Mar 27 2017 04:58 UTC
grantknaver sends brownie points to @alanmcdowell888 :sparkles: :thumbsup: :sparkles:
:cookie: 206 | @alanmcdowell888 |http://www.freecodecamp.com/alanmcdowell888
Joseph
@revisualize
Mar 27 2017 04:58 UTC
@AlanMcDowell888 Umm.. It looked correct to me.
Travis Bryant
@t-bryant
Mar 27 2017 04:59 UTC
would i do ([arr}, item)? but using actual numbers?
Joseph
@revisualize
Mar 27 2017 04:59 UTC
@t-bryant No.
Makrand R
@makrandr
Mar 27 2017 04:59 UTC
Guys how am I supposed to solve the Using Objects for Lookups?
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 04:59 UTC
@grantknaver in python I avoided using global variables by creating callable functions
Makrand R
@makrandr
Mar 27 2017 04:59 UTC
challenge
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 04:59 UTC
@grantknaver example: car(keys, wheels)
Travis Bryant
@t-bryant
Mar 27 2017 05:01 UTC
i know I am supposed to change something about the line with the return item, i'm just at a loss at to what
ivorygrant
@ivorygrant
Mar 27 2017 05:01 UTC
@revisualize ok after some thinking i think my loops runs once because it is not set to a variable?
Joseph
@revisualize
Mar 27 2017 05:01 UTC
@ivorygrant No.
ivorygrant
@ivorygrant
Mar 27 2017 05:01 UTC
yikes.
Joseph
@revisualize
Mar 27 2017 05:02 UTC
@t-bryant Add the number to the end of the array
How do you add the number (item) to the end of the array (arr)?
Travis Bryant
@t-bryant
Mar 27 2017 05:02 UTC
arr (2)?
Joseph
@revisualize
Mar 27 2017 05:03 UTC
@t-bryant Nope.
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 05:03 UTC

@grantknaver scratch that..
house(kitchen, heat):
heat =

kitchen(heat, floor)'
See how the variable is passed to another function?

Travis Bryant
@t-bryant
Mar 27 2017 05:03 UTC
([arr}, 1)?
Joseph
@revisualize
Mar 27 2017 05:03 UTC
@t-bryant Nope.
Makrand R
@makrandr
Mar 27 2017 05:04 UTC
The instruction reads -Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable... am i supposed to create a - var lookup? How am i supposed to add the val parameter within it?
Manish Giri
@Manish-Giri
Mar 27 2017 05:05 UTC
@makrandr the val gets passed in to your function..
you need to create an object called lookup.
Joseph
@revisualize
Mar 27 2017 05:05 UTC
@makrandr Have you converted the switch to an object?
grantknaver
@grantknaver
Mar 27 2017 05:05 UTC
@AlanMcDowell888 thanks
CamperBot
@camperbot
Mar 27 2017 05:05 UTC
grantknaver sends brownie points to @alanmcdowell888 :sparkles: :thumbsup: :sparkles:
:warning: grantknaver already gave alanmcdowell888 points
Makrand R
@makrandr
Mar 27 2017 05:06 UTC
I am not sure how the object is gonna look like.. var lookup{ what here? }
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 05:06 UTC
@revisualize any more hints?
Makrand R
@makrandr
Mar 27 2017 05:06 UTC
alpha:adams?
Travis Bryant
@t-bryant
Mar 27 2017 05:06 UTC
@revisualize , just so we are clear right now, I am so glad you are trying to get me to understand for myself what I need to do and not just giving me the answers...but this is one of those times I wish the answer would just fall into my lap, hahah
Joseph
@revisualize
Mar 27 2017 05:07 UTC
@t-bryant
Manipulate Arrays With push()
Manipulate Arrays With pop()
Manipulate Arrays With shift()
Manipulate Arrays With unshift()
grantknaver
@grantknaver
Mar 27 2017 05:08 UTC
kinda still confused by that reasoning my argument value should have passed
Doug Carter
@slowtraincar
Mar 27 2017 05:08 UTC
Understanding String Immutability

My code: // Setup
var myStr = "Jello World";

// Only change code below this line
myStr= "Hello world";
myStr[0] = "H"; // Fix Me
-what is wrong? thanks!

Joseph
@revisualize
Mar 27 2017 05:09 UTC
@slowtraincar You need to remove the line that has myStr[0] = "H"; // Fix Me Because you're supposed to fix that line.
Makrand R
@makrandr
Mar 27 2017 05:09 UTC
@slowtraincar myStr[0]="J";
Joseph
@revisualize
Mar 27 2017 05:09 UTC
@slowtraincar You ended up leaving that line in so. you didn't actually "fix" it.
Doug Carter
@slowtraincar
Mar 27 2017 05:09 UTC
ha! THANK YOU! stuck on this challenge for so long!
Matthew
@IMDBLM
Mar 27 2017 05:13 UTC
What's cracking, JS Magicians?
Or, what's good? What are the kids saying nowadays?
ivorygrant
@ivorygrant
Mar 27 2017 05:16 UTC
@revisualize i'm going to clear everything and start from scratch. does this initial set up solve the loop issue?
var answer;
  for (i=0; i<=contacts.length; i++){
    for (j=0; j<=contacts[i].length; j++){

      if (contacts[j].firstName==firstName && contacts[j].hasOwnProperty(prop)){

        answer = firstName + ", " + contacts[j].prop;

      }



    }
  }
I think it should as i'm telling it to run through each item in the sub arrays
Joseph
@revisualize
Mar 27 2017 05:20 UTC
@ivorygrant Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
@ivorygrant That's the first thing I saw.
@ivorygrant Let me look.
Ummm..
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 05:21 UTC

@revisualize // Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

result = {
"alpha": "Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

// Only change code above this line
return result[val];
}

// Change this value to test
phoneticLookup("charlie");

Joseph
@revisualize
Mar 27 2017 05:21 UTC
@ivorygrant Why do you have 2 for loops?
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 05:21 UTC
@revisualize That works, but I didn't follow the instructions
ivorygrant
@ivorygrant
Mar 27 2017 05:21 UTC
one for the objects in the contacts, and one for the objects within each contact
Joseph
@revisualize
Mar 27 2017 05:21 UTC
@ivorygrant Do Objects have .lengths?
ivorygrant
@ivorygrant
Mar 27 2017 05:22 UTC
no only arrays do.
Joseph
@revisualize
Mar 27 2017 05:22 UTC
@ivorygrant Oh.
Hmmm
@ivorygrant Why do you have 2 for loops?
ivorygrant
@ivorygrant
Mar 27 2017 05:23 UTC
hmmm
guess i'm making this more difficult then it s/b
Joseph
@revisualize
Mar 27 2017 05:24 UTC
@ivorygrant You are.
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 05:25 UTC

Got it!
// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

var lookup = {
"alpha": "Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

result = lookup[val];

// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");

thanks @revisualize
CamperBot
@camperbot
Mar 27 2017 05:25 UTC
alanmcdowell888 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3602 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 27 2017 05:26 UTC
@AlanMcDowell888 Do you realize when you pasted before you didn't actually paste the whole function?
Travis Bryant
@t-bryant
Mar 27 2017 05:26 UTC
@revisualize so on mine...I would jump down below var testArr and go testArr.push("{arr}",item)?
Joseph
@revisualize
Mar 27 2017 05:27 UTC
@t-bryant Nope
Travis Bryant
@t-bryant
Mar 27 2017 05:27 UTC
at least on the right track?
AlanMcDowell888
@AlanMcDowell888
Mar 27 2017 05:27 UTC
Yes.. btw that was a genuine thank you - caused me to think more
@revisualize
Joseph
@revisualize
Mar 27 2017 05:27 UTC
@t-bryant Nope.
@t-bryant The only thing correct in that was the .push() but, you didn't .push() correctly.
Travis Bryant
@t-bryant
Mar 27 2017 05:29 UTC
so am I going to push the nextInLine?
Joseph
@revisualize
Mar 27 2017 05:29 UTC
@t-bryant Look. If I have an array: var myArr = ["a", "e", "i"]; How do you add the value of var vowel = "o"; to then end of myArr?
Brian
@BeardedBry
Mar 27 2017 05:30 UTC
hey campers
ivorygrant
@ivorygrant
Mar 27 2017 05:30 UTC
@revisualize really appreciate your patience w/ me. if possible i'll go step by step w/ new code attempting to take in your suggestions. so to check if firstName and prop exist:
var answer;
  for (i=0; i<=contacts.length; i++){

    if (contacts[i][firstName]==firstName && contacts[i][prop]==prop){
      answer = firstName +", " + prop;
    }


      }
Travis Bryant
@t-bryant
Mar 27 2017 05:30 UTC
myArr.push("o", 3)?
Joseph
@revisualize
Mar 27 2017 05:30 UTC
@ivorygrant && contacts[i][prop]==prop this will never be true`
@t-bryant That is incorrect.
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 05:31 UTC
hello world
ivorygrant
@ivorygrant
Mar 27 2017 05:31 UTC
got it. s/b hasOwnProperty
Joseph
@revisualize
Mar 27 2017 05:31 UTC
@ivorygrant This: contacts[i][firstName]==firstNameis also incorrect.
Travis Bryant
@t-bryant
Mar 27 2017 05:32 UTC
myArr.push(["o"])?
Makrand R
@makrandr
Mar 27 2017 05:32 UTC

`// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {

// Your Code Here
if(myObj.hasOwnProperty(checkProp)){
return myObj.checkProp;
}
else{
return "Not Found";
}
}

// Test your code by modifying these values
checkObj("gift");`

anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 05:32 UTC
Joseph
@revisualize
Mar 27 2017 05:32 UTC
@makrandr Regarding: myObj.checkProp; .... Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
@t-bryant Incorrect.
Makrand R
@makrandr
Mar 27 2017 05:33 UTC
ohh @revisualize .. lemme try it out .Thanks
CamperBot
@camperbot
Mar 27 2017 05:33 UTC
makrandr sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3603 | @revisualize |http://www.freecodecamp.com/revisualize
ivorygrant
@ivorygrant
Mar 27 2017 05:33 UTC
@revisualize i understand why as there is no value associated with firstName, it's just firstName
Joseph
@revisualize
Mar 27 2017 05:34 UTC
@ivorygrant What?
ivorygrant
@ivorygrant
Mar 27 2017 05:34 UTC
This: contacts[i][firstName]==firstNameis also incorrect.
i'm asking a value of firstName here, but there is no value, right?
Joseph
@revisualize
Mar 27 2017 05:34 UTC
@ivorygrant That is incorrect.
ivorygrant
@ivorygrant
Mar 27 2017 05:35 UTC
hmm
Travis Bryant
@t-bryant
Mar 27 2017 05:35 UTC
myArr.push('o")?
Joseph
@revisualize
Mar 27 2017 05:35 UTC
@t-bryant Closer but still incorrect.
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 05:36 UTC
@revisualize hi bro
Travis Bryant
@t-bryant
Mar 27 2017 05:36 UTC
my bad it was supposed to have double quotes on both sides of the o
"o"
Joseph
@revisualize
Mar 27 2017 05:36 UTC
@t-bryant No you're supposed to actually be using the variable vowel
@t-bryant Look. If I have an array: var myArr = ["a", "e", "i"]; How do you add the value of var vowel = "o"; to then end of myArr?
Travis Bryant
@t-bryant
Mar 27 2017 05:36 UTC
so vowel.push("o")?
Joseph
@revisualize
Mar 27 2017 05:37 UTC
@t-bryant Is vowel an array?
myArr.push(vowel);
Travis Bryant
@t-bryant
Mar 27 2017 05:37 UTC
or myArr.vowel("o")?
ok...got it
rrbairar
@rrbairar
Mar 27 2017 05:38 UTC
what is the error in this code

var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line

var myOutfit= "sweater";

// Only change code above this line
return outerWear;
}

myOutfit();

Joseph
@revisualize
Mar 27 2017 05:38 UTC
@t-bryant Add the number to the end of the array
How do you add the number (item) to the end of the array (arr)?
Travis Bryant
@t-bryant
Mar 27 2017 05:39 UTC
arr.push(item)?
Joseph
@revisualize
Mar 27 2017 05:39 UTC
HEY!
And he gets one part of the challenge completed.
Markus Kiili
@Masd925
Mar 27 2017 05:40 UTC
@revisualize Good morning.
Travis Bryant
@t-bryant
Mar 27 2017 05:40 UTC
lol...with lots of help, thanks
Joseph
@revisualize
Mar 27 2017 05:41 UTC
@t-bryant then remove the first element of array.
How do you remove the first element from the array (arr)?
Markus Kiili
@Masd925
Mar 27 2017 05:41 UTC
@revisualize I finally ended my being stuck for a year period.
Joseph
@revisualize
Mar 27 2017 05:41 UTC
@Masd925 Your what?
Travis Bryant
@t-bryant
Mar 27 2017 05:41 UTC
arr.shift(item)?
Markus Kiili
@Masd925
Mar 27 2017 05:41 UTC
@revisualize I finally made my first FCC project.
Travis Bryant
@t-bryant
Mar 27 2017 05:41 UTC
or is it unshift?
Joseph
@revisualize
Mar 27 2017 05:42 UTC
@Masd925 Nice.
@t-bryant .shift() doesn't take an argument
Joseph
@revisualize
Mar 27 2017 05:42 UTC
@Masd925 Is this your tribute page?
Markus Kiili
@Masd925
Mar 27 2017 05:43 UTC
@revisualize Yes.
Joseph
@revisualize
Mar 27 2017 05:43 UTC
@Masd925 OMG.. The bug moving around freaked me out.
Markus Kiili
@Masd925
Mar 27 2017 05:44 UTC
@revisualize Good ;)
Joseph
@revisualize
Mar 27 2017 05:45 UTC
I seriously tried to squish it with my finger.
Then I realized it wasn't real.
Markus Kiili
@Masd925
Mar 27 2017 05:46 UTC
@revisualize You can debug it with the mouse cursor, but they come back...
Chris Cullen
@123xylem
Mar 27 2017 05:47 UTC

If i console.log error i get an empty array.

//res.locals:                                // req.flash::
{ currentUser: undefined, error: [], success: [] } '<<err' [Function: _flash]

res.locals.error should make an array that is populated by flash though.. As defined here in my middleware that calls flash>

middlewareObj.isLoggedIn = function(req, res, next){
    if(req.isAuthenticated()){
        return next();
    }
    else{
    req.flash("error", "You need to be logged in to do that");
    res.redirect("/login");}
};

Here is how I set up my app for flash::
res.locals.error=req.flash("error");

anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 05:51 UTC
@Lumexralph hi bro
Travis Bryant
@t-bryant
Mar 27 2017 05:52 UTC
ok...so if .shift() removes something at the beginning of an array, but .shift( ) doesn't take an argument...then is there another way to remove something at the beginning of an argument...i know .unshift( ) removes and adds at the same time
Travis Bryant
@t-bryant
Mar 27 2017 05:52 UTC
or at least from the instructions that what it seemed like
Joseph
@revisualize
Mar 27 2017 05:53 UTC
@t-bryant .unshift() doesn't remove anything.
Travis Bryant
@t-bryant
Mar 27 2017 05:53 UTC
so it just adds at the beginning instead of at the end like .push( )
Joseph
@revisualize
Mar 27 2017 05:53 UTC

Look:
The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

The shift() method removes the first element from an array and returns that element.

ivorygrant
@ivorygrant
Mar 27 2017 05:53 UTC
@revisualize is this any better?
var answer;
var nameLookup=firstName;

  for (i=0; i<=contacts.length; i++){

    if (contacts[i][firstName]==nameLookup && prop.hasOwnProperty(prop)){
      answer = contacts[firstName] +", " + contacts[prop];
    }


      }

    return answer;
Joseph
@revisualize
Mar 27 2017 05:54 UTC
@ivorygrant Nope
ivorygrant
@ivorygrant
Mar 27 2017 05:54 UTC
hmmm
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 05:54 UTC
@ivorygrant hi bro
loudnoyzez
@loudnoyzez
Mar 27 2017 05:54 UTC
sorry for such a basic question... can't get the fahrenheit algorithm fahrenheit *= 9/5;
fahrenheit += 32;
ivorygrant
@ivorygrant
Mar 27 2017 05:55 UTC
@Anifowose hi!
ivorygrant
@ivorygrant
Mar 27 2017 05:55 UTC
sure can help w/ that. what's your question
suhaschauhan
@suhaschauhan
Mar 27 2017 05:56 UTC
@loudnoyzez fahrenheit= celsius*(9/5)+32;
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 05:56 UTC
@ivorygrant Escaping Literal Quotes in Strings
ivorygrant
@ivorygrant
Mar 27 2017 05:57 UTC
@Anifowose yes, what is your question? :)
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 05:58 UTC
@ivorygrant i dont no how to do it ; Escaping Literal Quotes in Strings
ivorygrant
@ivorygrant
Mar 27 2017 06:00 UTC
@Anifowose what you want to do, is put a backlash before the quotes inside the quotes. so to make a string, you have "" outside the string. then what you want to quote, put a \ before
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:00 UTC
@ivorygrant k let me try
ivorygrant
@ivorygrant
Mar 27 2017 06:01 UTC
you can post your code here so we can see what you're doing
do you know how to do that?
Joseph
@revisualize
Mar 27 2017 06:02 UTC
@Anifowose How do you escape a double quote?
loudnoyzez
@loudnoyzez
Mar 27 2017 06:03 UTC
@suhaschauhan thanks!
CamperBot
@camperbot
Mar 27 2017 06:03 UTC
loudnoyzez sends brownie points to @suhaschauhan :sparkles: :thumbsup: :sparkles:
:warning: @suhaschauhan's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:04 UTC
@ivorygrant no bro
ivorygrant
@ivorygrant
Mar 27 2017 06:05 UTC
to post code do this: use ``` then paste your code ctrl+v, then press shift enter
sorry not shift enter. ctrl+enter
@Anifowose is it like that
ivorygrant
@ivorygrant
Mar 27 2017 06:08 UTC
you don't paste the link, you paste the actual code
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:09 UTC
@ivorygrant pls i dont understand the code
ivorygrant
@ivorygrant
Mar 27 2017 06:10 UTC
let me clarify: do this ```, then press shift+enter, copy and paste the code, then press ctrl + enter
Joseph
@revisualize
Mar 27 2017 06:10 UTC
@Anifowose How do you escape a double quote in a string?
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:11 UTC
@ivorygrant bro i mean i dont understand the word "code" i dont even no how i can locate it
ivorygrant
@ivorygrant
Mar 27 2017 06:12 UTC
when we refer to code it's the main part of the exercise
like this:
var myStr; // Change this line
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:13 UTC
@ivorygrant k
ivorygrant
@ivorygrant
Mar 27 2017 06:13 UTC
@Anifowose when you progress and you get stuck on harder challenges, you will have to share your code so others can help you
otherwise we can't see what you're oding
loudnoyzez
@loudnoyzez
Mar 27 2017 06:14 UTC
sharing code like this... var myStr = "He told me he was \"extremely hungry\"."; // Change this line
I think this exercise isn't working right
ivorygrant
@ivorygrant
Mar 27 2017 06:15 UTC
var myStr = "He told me he was \"extremely hungry\"."; // Change this line
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:15 UTC
@ivorygrant ```
var myStr = ""\"I am a "double quoted" string inside "double quotes\"
// Change this line
loudnoyzez
@loudnoyzez
Mar 27 2017 06:15 UTC
oh nevermind
haha got it
I thought we were picking our own sentence lol
ivorygrant
@ivorygrant
Mar 27 2017 06:16 UTC
np lol
@Anifowose don't delete the ``` at the end of the code
Damaris Muange
@ndush
Mar 27 2017 06:16 UTC
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
loudnoyzez
@loudnoyzez
Mar 27 2017 06:17 UTC
@ndush just set the variable to 11 % 3
thanks @ivorygrant
CamperBot
@camperbot
Mar 27 2017 06:18 UTC
loudnoyzez sends brownie points to @ivorygrant :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @ivorygrant |http://www.freecodecamp.com/ivorygrant
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:18 UTC
@ivorygrant ```var myStr = ""\"I am a "double quoted" string inside "double quotes\"
// Change this line
ivorygrant
@ivorygrant
Mar 27 2017 06:19 UTC
@Anifowose it's still not showing properly, the final result should look like this:
var myStr = ""\"I am a "double quoted" string inside "double quotes\"
// Change this line
Joseph
@revisualize
Mar 27 2017 06:19 UTC
@Anifowose How do you escape a double quote in a string?
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:20 UTC
@ivorygrant pls teach me step by step
Joseph
@revisualize
Mar 27 2017 06:20 UTC

@ndush What is the returned value of num ... var num = 4 + 3;
What is the returned value of num ... var num = 10 / 5;
What is the returned value of num ... var num = 5 * 3;

Remainder:
http://images.tutorvista.com/cms/images/38/remainder1.PNG
13 % 2 is 1 ... 26 % 5 is 1 ... 24 % 6 is 0
24 % 5 is 4 ... 219 % 20 is 19
Just like in my examples above you use the % operator just like any other math operator (+, -, *, /)

anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:20 UTC
@Anifowose the 1st thing to do is what?
Joseph
@revisualize
Mar 27 2017 06:20 UTC
@Anifowose How do you escape a double quote in a string?
This message was deleted
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:21 UTC
@revisualize i dont no how to do that i need help on it
ivorygrant
@ivorygrant
Mar 27 2017 06:21 UTC
sure. step 1. insert step 2. press shift + enter . step 3. copy and paste the code from the exercise. step 4. press ctrl + enter (do not delete the at the end)
Joseph
@revisualize
Mar 27 2017 06:21 UTC
\"
ivorygrant
@ivorygrant
Mar 27 2017 06:21 UTC
step 1.```
not sure why it came like that
Joseph
@revisualize
Mar 27 2017 06:22 UTC
How do you add a " to that string? Let's say you instantiated the string with double quotes and you want to put in a quote that someone said.
You have to use an escape character. \"
Example: var myQuote = "Happy Feet said, \"I really like the rhythm.\"";
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:22 UTC
@revisualize k
Joseph
@revisualize
Mar 27 2017 06:24 UTC

@Anifowose So, if you have a string:

var myStr = "I am a "double quoted" string inside "double quotes"."; // Change this line

How do you escape the "s inside of the string that you instantiated with double quotes?

@forkerino @GarrusNapp Thanks for your help! Instead of using console.log I used return and all test passed in one go! :-)
CamperBot
@camperbot
Mar 27 2017 06:24 UTC
l-ay sends brownie points to @forkerino and @garrusnapp :sparkles: :thumbsup: :sparkles:
:cookie: 747 | @garrusnapp |http://www.freecodecamp.com/garrusnapp
:star2: 1725 | @forkerino |http://www.freecodecamp.com/forkerino
Joseph
@revisualize
Mar 27 2017 06:26 UTC
@Anifowose You have to escape the double quotes inside of the string by escaping them with the corresponding escape character replacement: \"
Sammy
@ManBearPigg
Mar 27 2017 06:30 UTC
how is this cURL command different from this node request http post? To me they look identical but the request post is not working
curl https://svcs.sandbox.paypal.com/AdaptivePayments/Pay \
  -s \
  --insecure \
  -H "X-PAYPAL-SECURITY-USERID: caller_1312486258_biz_api1.gmail.com" \
  -H "X-PAYPAL-SECURITY-PASSWORD: 1312486294" \
  -H "X-PAYPAL-SECURITY-SIGNATURE: AbtI7HV1xB428VygBUcIhARzxch4AL65.T18CTeylixNNxDZUu0iO87e" \
  -H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" \
  -H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" \
  -H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" \
  -d '{
  "actionType":"PAY",
  "currencyCode":"USD",
  "receiverList":{
    "receiver":[
      {
        "amount":"1.00",
        "email":"rec1_1312486368_biz@gmail.com"
      }
    ]
  },
  "returnUrl":"http://www.example.com/success.html",
  "cancelUrl":"http://www.example.com/failure.html",
  "requestEnvelope":{
    "errorLanguage":"en_US",
    "detailLevel":"ReturnAll"
  }
}'



 request.post(
      "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay",
      {
          "headers": {
              "X-PAYPAL-SECURITY-USERID": "caller_1312486258_biz_api1.gmail.com",
              "X-PAYPAL-SECURITY-PASSWORD": "1312486294",
              "X-PAYPAL-SECURITY-SIGNATURE": "AbtI7HV1xB428VygBUcIhARzxch4AL65.T18CTeylixNNxDZUu0iO87e",
              "X-PAYPAL-REQUEST-DATA-FORMAT": "JSON",
              "X-PAYPAL-RESPONSE-DATA-FORMAT": "JSON",
              "X-PAYPAL-APPLICATION-ID": "APP-80W284485P519543T"
          },
          "data": {
              "actionType":"PAY",
              "currencyCode":"USD",
              "receiverList":{
                  "receiver":[
                      {
                          "amount":"1.00",
                          "email":"rec1_1312486368_biz@gmail.com"
                      }
                  ]
              },
              "returnUrl":"http://www.example.com/success.html",
              "cancelUrl":"http://www.example.com/failure.html",
              "requestEnvelope":{
                  "errorLanguage":"en_US",
                  "detailLevel":"ReturnAll"
              }
          }
      },
      function (error, response, body) {
         console.log(body);
      }
  );
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:31 UTC
@ivorygrant ```
var myStr = ""\"I am a "double quoted" string inside "double quotes\"
// Change this line
Damaris Muange
@ndush
Mar 27 2017 06:31 UTC
@revisualize its giving me" Refernce error:invalid assignment left-hand side"
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:32 UTC
var myStr = ""\"I am a "double quoted" string inside "double quotes\"
// Change this line
ivorygrant
@ivorygrant
Mar 27 2017 06:32 UTC
@Anifowose nice, you got it.
@Anifowose so as the challenge says you need to add a backslash before the quotes within the string
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:33 UTC
@ivorygrant yes sir
loudnoyzez
@loudnoyzez
Mar 27 2017 06:33 UTC
btw why is it a carriage return for line 3 here? FirstLine
\SecondLine\
ThirdLine
I don't get why it just isn't another newline like line 2
ivorygrant
@ivorygrant
Mar 27 2017 06:34 UTC
since double quoted has quotes around it, where do you think the backslash should go?
I am a "double quoted" string...
where do you think the backslash should go?
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:39 UTC
back
@revisualize how
ivorygrant
@ivorygrant
Mar 27 2017 06:40 UTC
@Anifowose where do you think the backslash in "double quoted" should go?
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:42 UTC
before n after the code
ivorygrant
@ivorygrant
Mar 27 2017 06:43 UTC
@Anifowose so the exercise to add the backslash before the quotes that you want to be double quoted
says*
redoz94
@redoz94
Mar 27 2017 06:44 UTC
How do i set a background image for one whole row in bootsstrap? looked everywhere couldnt find a thing
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:44 UTC
I am a "double quoted" string inside "double quotes".
ivorygrant
@ivorygrant
Mar 27 2017 06:45 UTC
@Anifowose right, so where should the backslash go in this example?
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:46 UTC
\I am a "double quoted" string inside "double quotes\".
ivorygrant
@ivorygrant
Mar 27 2017 06:47 UTC
@Anifowose try again
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 06:48 UTC
\I am a "double quoted" string inside "double quotes".
Joseph
@revisualize
Mar 27 2017 06:48 UTC

@Anifowose Look. If I wanted to make a string for a variable myQuote...
Let's say this was my quote: Happy Feet said, "I really like the rhythm."
I would have to create the variable:

var myQuote;

I would then have to instantiate that variable as a string:

var myQuote = "";

Now I add the string text into the variable.

var myQuote = "Happy Feet said, "I really like the rhythm."";

Then because I have instantiated the string with a double quote. I have to escape the quotes inside of the string.

var myQuote = "Happy Feet said, "I really like the rhythm."";

becomes:

var myQuote = "Happy Feet said, \"I really like the rhythm.\"";

Do you see how that works?
If I did not escape the double quote characters inside of the string text.
JavaScript would think that I am terminating my string.

...
Anyhow. That's all I have time for. Time for me to get to bed.
:v:
ivorygrant
@ivorygrant
Mar 27 2017 06:53 UTC
@revisualize thanks for your help! i'm going to give it another crack re: profile lookup
CamperBot
@camperbot
Mar 27 2017 06:53 UTC
ivorygrant sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3604 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 27 2017 06:54 UTC
@ivorygrant I'll re-link this: Gist by revisualize / FreeCodeCamp - Profile Lookup.js
Remember: We have an array of objects representing different people in our contacts lists.
Example: var contacts = [ { ... } , { ... } , { ... } , { ... } ];
javascript calc almost done
@revisualize how wasthe conference?
Ezeoke Onyekachi Samuel
@OnyekachiSamuel
Mar 27 2017 07:13 UTC
@awb715 Good job man; so much love your design
Jim
@JLOSS1
Mar 27 2017 07:30 UTC
hey, could someone take a look at my weather app and tell my why my png isn't working?
http://codepen.io/jloss1/pen/qrKRjV?editors=1111
naimatfz
@naimatfz
Mar 27 2017 07:31 UTC

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes"); Question : The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

anybody? plz
Markus Kiili
@Masd925
Mar 27 2017 07:35 UTC
@JLOSS1 You are trying to set the src of an img element?
Syntax should be $("#pic").attr("src", "source here");
Jim
@JLOSS1
Mar 27 2017 07:36 UTC
Yeah, I set it as a variable because it changes and then set it as an element for html
ahhhhh man. ok. I gotcha
Sammy
@ManBearPigg
Mar 27 2017 07:37 UTC

Why can I access an object inside of this callback but not it's properties?

function callback(error, response, body) {
            if (!error && response.statusCode == 200) {
                console.log(body);
            }
        }

        var result = request(options, callback);

I can log body which is a valid object, but I can't log any of the properties of body. I tried copying the object over to a regular javascript file for testing and I am using the correct notation. The problem has to do with this callback.

Brian
@BrianCodes33
Mar 27 2017 07:37 UTC
who wants to code
Jim
@JLOSS1
Mar 27 2017 07:38 UTC
@Masd925 changed it to
```
Sammy
@ManBearPigg
Mar 27 2017 07:38 UTC

I guess the var result is not necessary nor is the if statement

function callback(error, response, body) {
                console.log(body);
        }

        result(options, callback);

So why can I access the object but not its properties?

Jim
@JLOSS1
Mar 27 2017 07:38 UTC
var icon = wd.weather[0].icon;       
      var iconSrc = "http://openweathermap.org/img/w/" + icon + ".png";
      $('#outside').attr(src=iconSrc);
still not working
Markus Kiili
@Masd925
Mar 27 2017 07:39 UTC
@JLOSS1 Try $('#outside').attr("src", iconSrc);
Jim
@JLOSS1
Mar 27 2017 07:40 UTC
nope.
Markus Kiili
@Masd925
Mar 27 2017 07:42 UTC
@JLOSS1 Try logging iconSrc and try if the url works on another tab.
Jor
@joreyesl
Mar 27 2017 07:43 UTC
@ManBearPigg what does the it log? and how are you trying to access the properties?
Jim
@JLOSS1
Mar 27 2017 07:44 UTC
Hm, doesn't work. I wonder if I have to change the placement of the variable?
Sammy
@ManBearPigg
Mar 27 2017 07:44 UTC
@joreyesl It logs an object and I'm accessing the properties using dot notation. When I paste the object into a new js file I can access them just fine. It has something to do with this callback that's preventing me
Jor
@joreyesl
Mar 27 2017 07:45 UTC
@ManBearPigg hard to say what is going on without looking at the code
naimatfz
@naimatfz
Mar 27 2017 07:45 UTC

@naimatfz

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes"); Question : The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"
anybody? plz

Markus Kiili
@Masd925
Mar 27 2017 07:47 UTC
@JLOSS1 There might be some async problem too, because you have two ajax calls and you use the first response on the second. You don't really know the order of execution of those callbacks.
Jim
@JLOSS1
Mar 27 2017 07:47 UTC
Oh okay. that makes sense.
Markus Kiili
@Masd925
Mar 27 2017 07:48 UTC
@JLOSS1 Or is the second call inside the first callback?
Seems to be, so that is not the problem.
Jim
@JLOSS1
Mar 27 2017 07:50 UTC
yeah there isn't anything coming up in debug. I thought it would have to be .html and not attribute?
Markus Kiili
@Masd925
Mar 27 2017 07:50 UTC
@JLOSS1 The syntax I posted is the correct jQuery way to change image source.
Jim
@JLOSS1
Mar 27 2017 07:51 UTC
okay
well, ill continue researching. thanks for the help @Masd925 I must not be doing something right.
CamperBot
@camperbot
Mar 27 2017 07:51 UTC
jloss1 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3660 | @masd925 |http://www.freecodecamp.com/masd925
kirbyedy
@kirbyedy
Mar 27 2017 07:52 UTC
@Masd925 what does UUTUUS mean ?
in finish of course :)
ZaCk FroST
@zakwanahmed
Mar 27 2017 07:53 UTC
"FirstLine
\SecondLine\
ThirdLine"
i want to get this as out put in jscript
anybody there to help
Markus Kiili
@Masd925
Mar 27 2017 07:54 UTC
@kirbyedy It means Novelty.
Jor
@joreyesl
Mar 27 2017 07:55 UTC
@JLOSS1 you have that piece of code inside a click function. it only runs when you click the link#toggle. And then you also have that link nested inside a button which makes it impossible to actually click it.
heroiczero
@heroiczero
Mar 27 2017 07:55 UTC
@zakwanahmed use the \r and \n and make sure you escape your \
kirbyedy
@kirbyedy
Mar 27 2017 07:57 UTC
@Masd925 like new product or something ?
Markus Kiili
@Masd925
Mar 27 2017 07:57 UTC
@kirbyedy Yes.
kirbyedy
@kirbyedy
Mar 27 2017 07:58 UTC
ok thanks @Masd925
CamperBot
@camperbot
Mar 27 2017 07:58 UTC
kirbyedy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3661 | @masd925 |http://www.freecodecamp.com/masd925
Jim
@JLOSS1
Mar 27 2017 07:59 UTC
@joreyesl If I move the image variable anywhere else, for some reason all of my temperature data disapears
ZaCk FroST
@zakwanahmed
Mar 27 2017 08:00 UTC
var myStr='FirstLine \n\ SecondLine\ \rThirdLine'; @heroiczero this is my code but iamnot getting right answerr
Sammy
@ManBearPigg
Mar 27 2017 08:00 UTC
@joreyesl The body value returned was actually a string I had to JSON.parse() to get it into an object
Jor
@joreyesl
Mar 27 2017 08:00 UTC
@ManBearPigg ah that makes sense.
Sammy
@ManBearPigg
Mar 27 2017 08:00 UTC
@joreyesl it got me a downvote on stack overflow but it was worth it lol
heroiczero
@heroiczero
Mar 27 2017 08:00 UTC
@zakwanahmed no "space" get rid of the "spaces
ZaCk FroST
@zakwanahmed
Mar 27 2017 08:01 UTC
i have tried that too @heroiczero
heroiczero
@heroiczero
Mar 27 2017 08:02 UTC
\\n\ you want it to escape the \ not the \n @zakwanahmed
ZaCk FroST
@zakwanahmed
Mar 27 2017 08:02 UTC
var myStr="FirstLine\n\SecondLine\\rThirdLine"; @heroiczero
Jor
@joreyesl
Mar 27 2017 08:03 UTC

@JLOSS1 i change this

<button id="toggle" class = "button-standard"><a href="#" >C/F</a></button>

and this

$('#outside').attr('src',iconSrc);

and its working for me

ZaCk FroST
@zakwanahmed
Mar 27 2017 08:03 UTC
okay it worked thanks @heroiczero
CamperBot
@camperbot
Mar 27 2017 08:03 UTC
zakwanahmed sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1048 | @heroiczero |http://www.freecodecamp.com/heroiczero
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 08:13 UTC
@ivorygrant hi bro
CC
@Carlos-Cardenas
Mar 27 2017 08:14 UTC
<a href="#">
<span class="title">Texto</span>
</a> How to select the span text when you press <a> not using IDs
anifowosebabatunde@yahoo.com
@Anifowose
Mar 27 2017 08:15 UTC
@Anifowose @joseph is not too calm
i dont no this things and i appreciate u cos u are patient n calm
n am getting the steps
can we continue from where you stopped pls?
Harry
@HarryTgerman
Mar 27 2017 08:22 UTC

var count = 0;

function cc(card) {
// Only change code below this line
if (card = 2,3,4,5,6){
var count = count +1;
} else if (card = 10,"J","Q","K","A"){
var count = count -1;
}else if (count > 0){
return "Bet";
} else if (count < 0) {
return "Hold";
}

return card;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(5); cc("K");

i dont understand how i get i summe out of all this values
what im doing wrong ?
heroiczero
@heroiczero
Mar 27 2017 08:23 UTC
@HarryTgerman you cant do card = 2,3,4,5,6 that in conditional statement
@HarryTgerman either use a switch or use == and || or signs
@HarryTgerman you should also create a new if/else statement for
}else if (count > 0){
return "Bet";
} else if (count < 0) {
return "Hold";
}
Joy Ajuluchukwu
@joyajulz
Mar 27 2017 08:25 UTC
Screen Shot 2017-03-27 at 9.16.17 AM.png @forkerino @Lumexralph here is what I'm doing. This is at 'Word Blanks'. I need help.
heroiczero
@heroiczero
Mar 27 2017 08:27 UTC
@joyajulz parameters or variables. you do not need "" around it but you do need " " (spaces) between your words
tech-tron
@tech-tron
Mar 27 2017 08:31 UTC
im trying to add an object to an empty array. everytime the condition is met i add the object at the current index of that array to my empty array. when i return this it just says object Object instead of the key:value pair
Harry
@HarryTgerman
Mar 27 2017 08:34 UTC

@heroiczero hay thanks for advice !! but somehow i can't display the variable "count" ....
var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card == 4 || card==5 || card == 6){
count = count +1;
}else if (card = 10|| card == "J"|| card=="Q" || card =="K"|| card =="A"){
count = count -1;
}

if (count > 0){
   return "Bet";
 } else {
   return "Hold";
 } 

return card,count ;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(5); cc("K");

CamperBot
@camperbot
Mar 27 2017 08:34 UTC
harrytgerman sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1050 | @heroiczero |http://www.freecodecamp.com/heroiczero
heroiczero
@heroiczero
Mar 27 2017 08:36 UTC
@HarryTgerman because it return ends a function and returns the value for example it will return return "Bet"; Bet here if count>0 gotta append count to Bet with a +
iso
@iso1048
Mar 27 2017 08:38 UTC
What does "iterate" mean in js?
heroiczero
@heroiczero
Mar 27 2017 08:40 UTC
@gothamknight isn't to perform an action repeatedly like a for loop or while loop
Maks Ushakov
@maks-ushakov
Mar 27 2017 08:41 UTC
@gothamknight Get each element of array or object (collection)
iso
@iso1048
Mar 27 2017 08:43 UTC
@maks-ushakov could you also add that it does not change the original array/object?
Maks Ushakov
@maks-ushakov
Mar 27 2017 08:45 UTC
@gothamknight i am not sure but perhaps yes
Harry
@HarryTgerman
Mar 27 2017 08:48 UTC
@heroiczero you mean like this ?
if (count > 0){
   count + "Bet";
 } else {
  count + "Hold";
 } 
heroiczero
@heroiczero
Mar 27 2017 08:49 UTC
@HarryTgerman yes but make sure they are just not bunched together maybe add a space or something
Markus Kiili
@Masd925
Mar 27 2017 08:49 UTC
@HarryTgerman + " Bet"; <- space here
BlueShootingStar
@BlueShootingStar
Mar 27 2017 08:50 UTC
var myStr = "FirstLine \n \SecondLine\ \r ThirdLine"; //Change this line//
help me please
heroiczero
@heroiczero
Mar 27 2017 08:50 UTC
@BlueShootingStar delete your "spaces"
BlueShootingStar
@BlueShootingStar
Mar 27 2017 08:51 UTC
thanks @heroiczero
CamperBot
@camperbot
Mar 27 2017 08:51 UTC
blueshootingstar sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1052 | @heroiczero |http://www.freecodecamp.com/heroiczero
Harry
@HarryTgerman
Mar 27 2017 08:52 UTC
hmm my code is not working as is should ..... it should give out this : Example Output
"-3 Hold"
"5 Bet"

var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2 || card == 3 || card == 4 || card==5 || card == 6){
count = count +1;
}else if (card = 10|| card == "J"|| card=="Q" || card =="K"|| card =="A"){
count = count -1;
}

if (count > 0){
   count +  " Bet";
 } else {
  count + " Hold";
 } 

return count, card ;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(5); cc(3); cc("K");

it starts at var count = 0;
Markus Kiili
@Masd925
Mar 27 2017 08:53 UTC
@HarryTgerman }else if (card = 10|| use === for comparisons, not =.
heroiczero
@heroiczero
Mar 27 2017 08:54 UTC
@HarryTgerman delete return count, card ; and return count + " Bet"; or return count + " Hold";
Harry
@HarryTgerman
Mar 27 2017 08:56 UTC
@heroiczero but how i can now execute my funktion ?
redoz94
@redoz94
Mar 27 2017 08:56 UTC
any ideas on how to do my portfolio section on this webpage? I want it to show my projects in squares side by side. Can someone help, please?
http://codepen.io/Redoz12/pen/bqLNoK
Markus Kiili
@Masd925
Mar 27 2017 08:58 UTC
@redoz94 You can use Bootstrap col classes to split the space into sections.
CC
@Carlos-Cardenas
Mar 27 2017 08:59 UTC
<a href="#">
<span class="title">Text</span>
</a> How to select the span text when you press <a> not using IDs
Frank
@FrankMusic
Mar 27 2017 09:04 UTC
Counting Cards, how to do it
Harry
@HarryTgerman
Mar 27 2017 09:06 UTC
if someone just could copy paste his code form lection 197 it would be awsome .....
Frank
@FrankMusic
Mar 27 2017 09:06 UTC
[title](http://www.freecodecamp.cn/challenges/counting-cards#?solution=var%20count%20%3D%200%3B%0A%0Afunction%20cc(card)%20%7B%0A%20%20%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20%0A%20%20return%20count%2B%22%20%22%3B%0A%20%20%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Add%2Fremove%20calls%20to%20test%20your%20function.%0A%2F%2F%20%E6%8F%90%E7%A4%BA%3A%20Only%20the%20last%20will%20display%0Acc(2)%3B%20cc(3)%3B%20cc(7)%3B%20cc('K')%3B%20cc('A')%3B%0A)
Markus Kiili
@Masd925
Mar 27 2017 09:07 UTC
@Carlos-Cardenas JS or jQuery?
CC
@Carlos-Cardenas
Mar 27 2017 09:08 UTC
@Masd925 any
Markus Kiili
@Masd925
Mar 27 2017 09:09 UTC
@Carlos-Cardenas Something like this perhaps:
$("a").on("click", function(event){
            alert($(event.target).text());
        });
Maks Ushakov
@maks-ushakov
Mar 27 2017 09:09 UTC
@Carlos-Cardenas Do you want to click to a and get span?
CC
@Carlos-Cardenas
Mar 27 2017 09:10 UTC
my a have 3 spans inside display none, i want to get the text of all spans and save on array, i have 15 a with 3 spans inside, cant use id
Maks Ushakov
@maks-ushakov
Mar 27 2017 09:13 UTC
@Carlos-Cardenas Can you show this code?
redoz94
@redoz94
Mar 27 2017 09:15 UTC
anyone know how to link items in the navbar to respective parts of the same webpage? Cant figure it out!
Maks Ushakov
@maks-ushakov
Mar 27 2017 09:15 UTC
if div has id
$("#divId span").each( yourArray.push($(this).val())));
CC
@Carlos-Cardenas
Mar 27 2017 09:15 UTC
blob
i want to select this span text inside the <a>, whiout id, i want to use .closest or find span with class .mTitle
blob
Maks Ushakov
@maks-ushakov
Mar 27 2017 09:19 UTC
@Carlos-Cardenas
function addToList() {

// this = clicked a
var spanText = $(this).find('span').val();
.....
}
CC
@Carlos-Cardenas
Mar 27 2017 09:20 UTC
undefined
blob
Artyom
@Temmy1
Mar 27 2017 09:23 UTC

Hello! I do no t understand what is wrong with this code: function nextInLine(arr, item) {
// Your code here
testArr.push(item);
return testArr.shift(); // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(tes

easibee
@easibee
Mar 27 2017 09:23 UTC
Hi. I'm trying to work on this exercise which involves higher level functions : https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39/train/javascript
But I have no idea how seven(times(five())) would equal 35. Can anyone help?
Blauelf
@Blauelf
Mar 27 2017 09:26 UTC
@easibee In my solution, times(five()) returns a function returning its argument times five, so seven(times(five())) is like times(five())(7) or times(5)(7).
Markus Kiili
@Masd925
Mar 27 2017 09:27 UTC
@Carlos-Cardenas With pure JS, you can get an array of span texts with:
var arr = [];
var nodes = document.querySelectorAll("a>span");
for (var i=0; i<nodes.length; i++) arr.push(nodes[i].textContent);
console.log(arr);
Blauelf
@Blauelf
Mar 27 2017 09:28 UTC
@Temmy1 Use function parameter arr instead of testArr, those are the same only in the sample call, not in the test calls.
easibee
@easibee
Mar 27 2017 09:30 UTC
@Blauelf Thank you for your reply. But how would I write that in the function? I'm not sure how the values e.g. the 7 and 5 and X would be passed within the functions as I assume we do not use global variables
CamperBot
@camperbot
Mar 27 2017 09:30 UTC
easibee sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3867 | @blauelf |http://www.freecodecamp.com/blauelf
CC
@Carlos-Cardenas
Mar 27 2017 09:32 UTC
@Masd925 take all a>span in the document, i want only this a>spans
Blauelf
@Blauelf
Mar 27 2017 09:32 UTC
@easibee In my solution, five would test whether it got an argument, if not, return 5, if it got, it'd call its argument with an argument of 5.
times would return a function that multiplies times' argument with the returned function's argument.
Markus Kiili
@Masd925
Mar 27 2017 09:33 UTC
@Carlos-Cardenas That gives all the span texts on an array. Not what you wan't?
CC
@Carlos-Cardenas
Mar 27 2017 09:33 UTC
only the spans inside the clicked <a>
@Masd925
Markus Kiili
@Masd925
Mar 27 2017 09:34 UTC
@Carlos-Cardenas So there are multiple spans inside each a?
CC
@Carlos-Cardenas
Mar 27 2017 09:34 UTC
@Masd925 yes, and multiple <a> with spans inside
Artyom
@Temmy1
Mar 27 2017 09:35 UTC
@Blauelf Thank you!
CamperBot
@camperbot
Mar 27 2017 09:35 UTC
temmy1 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3868 | @blauelf |http://www.freecodecamp.com/blauelf
redoz94
@redoz94
Mar 27 2017 09:36 UTC
\
GUYS. PLEASE HELP. my message keeps getting lost. Im trying to link the items in my navbar to respective sections on the same webpage. How do i do this? http://codepen.io/Redoz12/pen/bqLNoK
CC
@Carlos-Cardenas
Mar 27 2017 09:39 UTC
<a href="#the id of the portfolio div id">Portfolio</a>
<a href="#portfolio">Portfolio</a>
@redoz94
@redoz94
redoz94
@redoz94
Mar 27 2017 09:49 UTC
@Carlos-Cardenas Thank You! been asking this for days!
CamperBot
@camperbot
Mar 27 2017 09:49 UTC
redoz94 sends brownie points to @carlos-cardenas :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @carlos-cardenas |http://www.freecodecamp.com/carlos-cardenas
Markus Kiili
@Masd925
Mar 27 2017 09:55 UTC
@Carlos-Cardenas This seems to log an array of span texts inside the clicked a:
document.querySelectorAll("a").forEach(function(elem){
            elem.addEventListener("click",function(){
                var texts = Array.prototype.map.call(elem.children, function(span){
                    return span.textContent;
                });
                console.log(texts);

            });
        });
Bina
@binakhalid
Mar 27 2017 09:58 UTC

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

testObj ["an entree"]; // Change this line
testObj ["the drink"]; // Change this line

whats the problem?
CC
@Carlos-Cardenas
Mar 27 2017 10:00 UTC
@Masd925 for some reason not work, btw thank you soo much for the help, going to sleep now
CamperBot
@camperbot
Mar 27 2017 10:00 UTC
carlos-cardenas sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3662 | @masd925 |http://www.freecodecamp.com/masd925
devpaaji
@devpaaji
Mar 27 2017 10:00 UTC
@Carlos-Cardenas
this span text I want to be adjacent to the hamburger menu
but somehow not appearing
https://jsfiddle.net/qsxzgve4/2/
Bina
@binakhalid
Mar 27 2017 10:00 UTC

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

testObj ["an entree"]; // Change this line
testObj ["the drink"]; // Change this line

wat is wrong with my code?
Stephen James
@sjames1958gm
Mar 27 2017 10:00 UTC
@binakhalid Weren't there variables that you were supposed to set those to? Did you remove those
@binakhalid var entreeValue =
Bina
@binakhalid
Mar 27 2017 10:02 UTC
yes i did
Stephen James
@sjames1958gm
Mar 27 2017 10:02 UTC
@binakhalid Those are required to assign them to entreeValue and drinkValue respectively.
Bina
@binakhalid
Mar 27 2017 10:03 UTC
thanks stephen
@sjames1958gm thanks
CamperBot
@camperbot
Mar 27 2017 10:03 UTC
binakhalid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6370 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Maks Ushakov
@maks-ushakov
Mar 27 2017 10:07 UTC
Stephen James
@sjames1958gm
Mar 27 2017 10:07 UTC
@binakhalid :+1:
Bina
@binakhalid
Mar 27 2017 10:11 UTC

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[playerNumber]; // Change this Line
var player = testObj[16];

what is wrong?
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:12 UTC
@binakhalid what property of the object has Montana has it's value?
CC
@Carlos-Cardenas
Mar 27 2017 10:12 UTC
@Masd925 it work, thank you so much, i appreciate it a lot, thank you
CamperBot
@camperbot
Mar 27 2017 10:12 UTC
carlos-cardenas sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: carlos-cardenas already gave masd925 points
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:12 UTC
@binakhalid store that property in the variable playerNumber and use that variable to access the object and assign the value to player
Markus Kiili
@Masd925
Mar 27 2017 10:12 UTC
@Carlos-Cardenas :+1:
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:13 UTC
@Masd925 @sjames1958gm Good Morning
Markus Kiili
@Masd925
Mar 27 2017 10:13 UTC
@Lumexralph @sjames1958gm Good morning.
Stephen James
@sjames1958gm
Mar 27 2017 10:13 UTC
@Lumexralph Morning @Masd925
CC
@Carlos-Cardenas
Mar 27 2017 10:14 UTC
@Masd925 i try something really similar but never use addToList(event), the result was ''" always
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:14 UTC
@Masd925 @sjames1958gm :smile:
Robert
@Ashkya
Mar 27 2017 10:22 UTC
Hi...I'm trying to do the "Escape Sequences in Strings" challenge and I must be retarded or something... 3/4 tasks are fine but the first one is still not working...that being having no spaces..
this is what I should have
FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:22 UTC
@Ashkya let's see your string
Robert
@Ashkya
Mar 27 2017 10:22 UTC
var myStr = 'FirstLine'\n \'SecondLine'\ \r'ThirdLine';
i know as a fact i fucked it up...just don't know what..
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:23 UTC
@Ashkya remove the ' there
@Ashkya backslash \\
newline \n carriage return \r without quotes '
Sameer khan
@smrkhan55
Mar 27 2017 10:26 UTC
hey guys
can anyone help me on "Stand in Line" chapter?
redoz94
@redoz94
Mar 27 2017 10:26 UTC
Hi guys im struggling with adding social media links to my profiles on the last section of my webpage. any Suggstions?http://codepen.io/Redoz12/pen/bqLNoK
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:27 UTC
@smrkhan55 what've you tried? you need to use 2 array methods
@redoz94 use links tag and make the URL the URL of your social media page using the href attribute
May Kittens Devour Your Soul
@diomed
Mar 27 2017 10:28 UTC
@redoz94 I don't see u struggling. u tried nothing.
also this is helpJavascript . not quite question for this room
Robert
@Ashkya
Mar 27 2017 10:29 UTC
@Lumexralph var myStr = "FirstLine\n\SecondLine\\rThirdLine"; <-- That worked...well thanks for the help
CamperBot
@camperbot
Mar 27 2017 10:29 UTC
ashkya sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1396 | @lumexralph |http://www.freecodecamp.com/lumexralph
redoz94
@redoz94
Mar 27 2017 10:29 UTC
@Lumexralph do i put images or use the button class?
@diomed i tried but deleted it
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:29 UTC
@redoz94 anyone you want
redoz94
@redoz94
Mar 27 2017 10:29 UTC
@diomed somehow my messages get lost in the main room
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:29 UTC
@redoz94 just make sure it's in a <a> tag
May Kittens Devour Your Soul
@diomed
Mar 27 2017 10:30 UTC
@redoz94 u also need to add jquery and bootstrap.js in Settings > JS in order for your menu to drop down in smaller screens
redoz94
@redoz94
Mar 27 2017 10:30 UTC
@diomed i have, havent i?
@diomed done...
May Kittens Devour Your Soul
@diomed
Mar 27 2017 10:31 UTC
:+1:
redoz94
@redoz94
Mar 27 2017 10:31 UTC
@Lumexralph hey man, nice speaking with you again
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:31 UTC
@redoz94 :smile:
cjchinmay
@cjchinmay
Mar 27 2017 10:31 UTC

I cant seem to understand the question!
It says:
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

And my code goes :
function abTest(a, b) {
// Only change code below this line

if(a || b < 0){
return undefined;
}

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);

redoz94
@redoz94
Mar 27 2017 10:31 UTC
@Lumexralph mind if i dm you??
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:32 UTC
@cjchinmay if(a || b < 0){...... if a is less than 0 or b is less than 0
Sameer khan
@smrkhan55
Mar 27 2017 10:32 UTC
@Lumexralph ya but I'm unable to understand
Markus Kiili
@Masd925
Mar 27 2017 10:32 UTC
@Lumexralph DOM traversing with pure JS is fun fun fun. Teaches serenity (to not lose all remaining hair).
Sameer khan
@smrkhan55
Mar 27 2017 10:32 UTC
how shoul i use that method
@Lumexralph ?
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:32 UTC
@redoz94 that'll be difficult to respond immediately but you can
@Masd925 yes :smile:
redoz94
@redoz94
Mar 27 2017 10:32 UTC
@Lumexralph look how far ive gotten with portfolio :D
http://codepen.io/Redoz12/pen/bqLNoK
Ogundele Olumide
@Lumexralph
Mar 27 2017 10:33 UTC
@Masd925 i just like using pure JS for now and forgetting about any frameworks, the fundamentals will help me stand the test of frameworks time
@Masd925 it's just very interesting to me
@redoz94 do you want me to look or is there a question?
May Kittens Devour Your Soul
@diomed
Mar 27 2017 10:35 UTC
@redoz94 u need to include fontawesome https://ma