These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Jan 2016
Jonathan Haggard
@jnhaggard
Jan 26 2016 00:00
I'm at a loss... getting "Maximum call stack size exceeded" with the following codejs function myFunction(a, b) { console.log(a + b); } myFunction(1, 2);
rphares
@rphares
Jan 26 2016 00:00
woah-- yours looks way different than mine, one sec, lemme re-read the directions, @redeyesblackdragon
@jnhaggard , have you tried refreshing?
@redeyesblackdragon , are you sure that is Use Conditional Logic with If Statements ? Did you change the code above the 'do not change' line?
Dariusz Biskupski
@Visiona
Jan 26 2016 00:01
@ArielLeslie wow, any tips? ;)
Jonathan Haggard
@jnhaggard
Jan 26 2016 00:01
Hah, genius thanks @rphares!
CamperBot
@camperbot
Jan 26 2016 00:01
jnhaggard sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1992 | @rphares | http://www.freecodecamp.com/rphares
Ariel
@ArielLeslie
Jan 26 2016 00:01
@Visiona What is your base case?
rphares
@rphares
Jan 26 2016 00:01
sure thing!
Dariusz Biskupski
@Visiona
Jan 26 2016 00:01
//if (arr.length<=size) {
// return newArr.push(arr);
earlier - newArr =[];
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:02
yeah thats the one @rphares
rphares
@rphares
Jan 26 2016 00:04
okay-it had been redone, so i redid it :)
Ariel
@ArielLeslie
Jan 26 2016 00:04
@Visiona For your base case, if arr's length is less than or equal to size you can just return arr
rphares
@rphares
Jan 26 2016 00:05
so, you need to make an if (conditional) @redeyesblackdragon
Ariel
@ArielLeslie
Jan 26 2016 00:05
@Visiona That's my tip before I leave for the day. I'm going to PM you may solution, but don't look at it until you've given up or want to check your solution against mine
rphares
@rphares
Jan 26 2016 00:05
@redeyesblackdragon , look at the example above for the format:
function ourFunction(testMe) {
  if (testMe ) { 
    return "Yes";
  }
  return "No";
}
Dariusz Biskupski
@Visiona
Jan 26 2016 00:06
@ArielLeslie Thank you so much, I will look at your solution when I totally give up
CamperBot
@camperbot
Jan 26 2016 00:06
visiona sends brownie points to @arielleslie :sparkles: :thumbsup: :sparkles:
:star: 998 | @arielleslie | http://www.freecodecamp.com/arielleslie
bpeters82
@bpeters82
Jan 26 2016 00:06
Ok. need some tips here, what have I done, clearly I'm missing a concept on this one ' replacing if else chains with switch' Challenge - Replacing If Else Chains with Switch (bpeters82's solution)
rphares
@rphares
Jan 26 2016 00:07
So, we have our if (thingWeAreChecking){what to do goes here} @redeyesblackdragon
what parameter did they tell you to check for, @redeyesblackdragon ? that should of in the ()
Kyle
@KyleJN8
Jan 26 2016 00:09

Hello JavaScript people. Out of my mind with confusion on this "Word Blanks" challenge. Here is the coding function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = "The " + myAdjective + myNoun + myVerb + myAdverb + ".";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog ", "big ", "ran ", "quickly");
wordBlanks("cat ", "little ", "hit ", "slowly");One of the failing points is: "wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib)."

rphares
@rphares
Jan 26 2016 00:09
oh, you are close, @KyleJN8
you just need to add the non-word characters in between the words,
example: myNoun + " " + myAdjective + " "
rushi
@rush86999
Jan 26 2016 00:10

hi guys just a newbie need advice on queue function on javascript challenge; here's my code function queue(arr, item) {
// Your code here
arr = [item];
var myArray = arr;

return myArray[0];
}

rphares
@rphares
Jan 26 2016 00:10
right now, you're result would equal The bigdogranquickly. @KyleJN8
Kyle
@KyleJN8
Jan 26 2016 00:11
I added "the" and "." Not sure what else it is asking for
Dariusz Biskupski
@Visiona
Jan 26 2016 00:11
@ArielLeslie do you think map function can be used for Chunky Monkey ?
rphares
@rphares
Jan 26 2016 00:12
just throw in some spaces using + " " + myBlahBlahBlah + " " :) :point_up: January 26, 2016 7:10 AM @KyleJN8
Ariel
@ArielLeslie
Jan 26 2016 00:12
@Visiona maybe reduce. I haven't thought about it. I just realized there is an error in my solution
Kyle
@KyleJN8
Jan 26 2016 00:12
Right now I am getting: The little cat hit slowly.
rphares
@rphares
Jan 26 2016 00:12
with spaces?
Ariel
@ArielLeslie
Jan 26 2016 00:12
(it still passes, but it doesn't give exactly the right result for the case where arr is already chunked
Kyle
@KyleJN8
Jan 26 2016 00:13
BlahBlah is worth a try
rphares
@rphares
Jan 26 2016 00:13
no no no!
don't use blah blah,
thats not the point,
the point is that you don't have spaces between the myNoun, myAdjective, myVerb
you need to concatenate those in, too
example:
result = "The " + myAdjective + " " + myNoun + " " + "banana" + " " + myVerb + "bob" + " " + myAdverb;
@KyleJN8
Mafalda
@otmeek
Jan 26 2016 00:15
this function if(val==='' || val===false || val===null || val===0 || val===undefined || val===NaN) isn't detecting NaN right, what am I doing wrong?
Kyle
@KyleJN8
Jan 26 2016 00:15
Ahh, be right back
Mafalda
@otmeek
Jan 26 2016 00:16
this if statement rather*
rphares
@rphares
Jan 26 2016 00:16
:)
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:16
can someone help?
var oldArray = [1,2,3,4,5];
var newArray = [];

// Only change code below this line.

newArray = oldArray;
var addThree = oldArray.map(function(val){
  return val + 3;
});
addThree(oldArray);
why isnt it recognizing addThree as a function
ArielLeslie @ArielLeslie just realized her solution was working. She just didn't read the instructions right.
rushi
@rush86999
Jan 26 2016 00:18
never mind thanks
William
@derpmanwilliam
Jan 26 2016 00:18
This message was deleted
Eina
@thelittleblacksmith
Jan 26 2016 00:20
@Mahin2k because it's not a function, it should be var addThree = function(parameters if necessary){-your map stuff in here-};
Jocelyn
@jocelyn-ong
Jan 26 2016 00:25
@Mahin2k @thelittleblacksmith alternatively, you can declare it with
function addThree(parameters){
do something
}
can any1 help me with this?
tskorupka
@tskorupka
Jan 26 2016 00:28
@deek28 Why are you tyring to split again array?
Jocelyn
@jocelyn-ong
Jan 26 2016 00:28
@deek28 you can't do array.split('');
Kyle
@KyleJN8
Jan 26 2016 00:28
Here is my coding: result = "The " + myAdjective + "fuzzy " + myNoun + "jumped and "+ myVerb + "the lazer " + myAdverb + "."; My result says: The little fuzzy cat jumped and hit the lazer slowly. But it is still asking for: wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
James C. Smith
@JamesCSmithPDX
Jan 26 2016 00:28
Trying to Filter Array
rphares
@rphares
Jan 26 2016 00:29
@KyleJN8 , closer, but you are still missing some spaces,
Deekshit.B.N
@deek28
Jan 26 2016 00:29
@tskorupka @tskorupka
Jocelyn
@jocelyn-ong
Jan 26 2016 00:29
@deek28 i think you don't need arr1?
rphares
@rphares
Jan 26 2016 00:29
now you need one at the beginning of fuzzy (ex " fuzzy ")
@KyleJN8
Deekshit.B.N
@deek28
Jan 26 2016 00:29
@jocelyn-ong i know now
but the substring
is coming error
rphares
@rphares
Jan 26 2016 00:30
And... at the beginning of " jumped and " and " the lazer" @KyleJN8
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:30

```js
// Example
function ourFunction(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}

// Setup
function myFunction(wasThatTrue) {

// Only change code below this line.

// Only change code above this line.

}

// Change this value to test
myFunction(true);

```'

Fahar Jatoi
@digitaleye
Jan 26 2016 00:30
help needed. profile lookup. i dont know how the second part of property to do in the if statement?
CamperBot
@camperbot
Jan 26 2016 00:30
no wiki entry for: needed profile lookup i dont know how the second part of property to do in the if statement
Fahar Jatoi
@digitaleye
Jan 26 2016 00:30
//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 lookUp(firstName, prop){
// Only change code below this line

  for(i = 0 ; i < contacts.length; i++)
  {
    if(contacts[i].firstName === firstName)
    return contacts[i][prop];
  }

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

// Change these values to test your function
lookUp("Akira", "lastName");
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:30
// Example
function ourFunction(isItTrue) {
  if (isItTrue) { 
    return "Yes, it's true";
  }
  return "No, it's false";
}

// Setup
function myFunction(wasThatTrue) {

  // Only change code below this line.



  // Only change code above this line.

}

// Change this value to test
myFunction(true);
Deekshit.B.N
@deek28
Jan 26 2016 00:30
Type Error:arr.str is not found
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:30
still need help
Deekshit.B.N
@deek28
Jan 26 2016 00:30
@jocelyn-ong
Fahar Jatoi
@digitaleye
Jan 26 2016 00:30
so in my if statement i guess i need to put && and check for property
I dont know how to do that
Jocelyn
@jocelyn-ong
Jan 26 2016 00:31
@deek28 what are you passing substr to?
rphares
@rphares
Jan 26 2016 00:31
@redeyesblackdragon , where is your if (condition){return} statement? :blush:
Netrunner12
@Netrunner12
Jan 26 2016 00:31
@Mahin2k have you been helped?
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:31
@Netrunner12 no
Netrunner12
@Netrunner12
Jan 26 2016 00:32
@Mahin2k repaste your code here.
rphares
@rphares
Jan 26 2016 00:32
@redeyesblackdragon , you want to follow the example in the one above, and build an if statement,
Jocelyn
@jocelyn-ong
Jan 26 2016 00:32
@Mahin2k actually we have mentioned that it's something to do with the declaration of your function, do you need us to explain further?
Deekshit.B.N
@deek28
Jan 26 2016 00:33
@jocelyn-ong
function end(str, target) {
  var arr=[];
  arr = str.split(" ");
  var len = arr.length;
  var arr1=[];
  if(len == 1)
    {
      arr1 = arr.substr(-1);
      if(target == arr1[0])
        return true;
    }
  else
    {
      if(target == arr1[len-1])
        return true;
      else
        return false;
    }
Jocelyn
@jocelyn-ong
Jan 26 2016 00:33
@deek28 why do you have the arr1?
Deekshit.B.N
@deek28
Jan 26 2016 00:33
to take the substring
rphares
@rphares
Jan 26 2016 00:33
the thing you are checking, your parameter, goes in the () @redeyesblackdragon ...
Create an if statement inside the function to return "That was true" if the parameter wasThatTrue is true and return "That was false" otherwise.
Jocelyn
@jocelyn-ong
Jan 26 2016 00:33
@deek28 .substr() should be passed to a string by the way, not to an array
Deekshit.B.N
@deek28
Jan 26 2016 00:34
yes, and arr1 is a string array
Jocelyn
@jocelyn-ong
Jan 26 2016 00:34
@deek28 no i mean, a string, as in "Hello" and not ["hello"]
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:34
@Netrunner12
var oldArray = [1,2,3,4,5];
var newArray = [];

// Only change code below this line.

newArray = oldArray;
var addThree = oldArray.map(function(val){
  return val + 3;
});
addThree(oldArray);
Netrunner12
@Netrunner12
Jan 26 2016 00:34
@Mahin2k what is the purpose of your last line of code?
Deekshit.B.N
@deek28
Jan 26 2016 00:35
so @jocelyn-ong should i split it?
or
Jocelyn
@jocelyn-ong
Jan 26 2016 00:35
@deek28 so you should do "hello".substr(-1)
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:35
@Netrunner12 so i call the function
Jocelyn
@jocelyn-ong
Jan 26 2016 00:35
@deek28 whereas if you are looking at the last item of an array, it's just array[array.length -1]
@Mahin2k you have to declare addThree as a function, to do that use
function addThree(val) {

}
Netrunner12
@Netrunner12
Jan 26 2016 00:36
@Mahin2k .map() automatically calls the function inside.
James C. Smith
@JamesCSmithPDX
Jan 26 2016 00:36
jsvar oldArray = [1,2,3,4,5,6,7,8,9,10];
var newArray = [];

// Only change code below this line.

var newArray = oldArray.filter(function(val) {
  return val < 5;
});
Netrunner12
@Netrunner12
Jan 26 2016 00:36
@Mahin2k you can get rid of that code that calls the function.
Jocelyn
@jocelyn-ong
Jan 26 2016 00:36
@Mahin2k with your current code, you are calling the map function and assigning it to addThree, so addThree is just a variable, it is not a function
rphares
@rphares
Jan 26 2016 00:37
@redeyesblackdragon , then you put what you want it to do i the {}... in this case, you want it to return "That was true"
Deekshit.B.N
@deek28
Jan 26 2016 00:37
function end(str, target) {
  var arr=[];
  arr = str.split(" ");
  var len = arr.length;
  var arr1;
  if(len == 1)
    {
      arr1 = arr[0].substr(-1);
      if(target == arr1)
        return true;
    }
  else
    {
      if(target == arr1[len-1])
        return true;
      else
        return false;
    }
  // "Never give up and good luck will find you."
  // -- Falcor

}

end("Connor", "n");
@jocelyn-ong
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:37
@jocelyn-ong oh ok
Deekshit.B.N
@deek28
Jan 26 2016 00:37
it shows true only for first one
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:37
// Example
function ourFunction(isItTrue) {
  if (isItTrue) { 
    return "Yes, it's true";
  }
  return "No, it's false";
}

// Setup
function myFunction(wasThatTrue) {

  // Only change code below this line.
  function myFunction(wasThatTrue) {
    if (wasThatTrue) {
      return "That was true";
    }
    return "That was false";
  }



  // Only change code above this line.

}

// Change this value to test
myFunction(true);
Jocelyn
@jocelyn-ong
Jan 26 2016 00:37
@deek28 you can't do this
arr1 = arr[0].substr(-1);
James C. Smith
@JamesCSmithPDX
Jan 26 2016 00:37
I am getting [1,2,3,4] but
oh wait greater than 5
ok
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:37
this is what i put but its still false
Jocelyn
@jocelyn-ong
Jan 26 2016 00:37
@deek28 oh wait, sorry you can, let me take another look
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:38
this is what i put but its still wrong
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:38
@jocelyn-ong so then how do i make the function affect the oldarray?
pravisti
@pravisti
Jan 26 2016 00:38

What am I doing wrong here?

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

function myTest(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;
}

Netrunner12
@Netrunner12
Jan 26 2016 00:38
@Mahin2k you've set newArray to equal to oldArray. By itself that code does nothing for you. NewArray should equal the output of your map method/function.
Jocelyn
@jocelyn-ong
Jan 26 2016 00:38
@Mahin2k can you let us know what is the question? it might be easier for us to help you there
Kyle
@KyleJN8
Jan 26 2016 00:38
That was it... that's all! Thanks I got, and I feel a little dense but I'll get over it.
Deekshit.B.N
@deek28
Jan 26 2016 00:39
wiki confirm the ending
CamperBot
@camperbot
Jan 26 2016 00:39

:point_right: bonfire confirm the ending [wiki]

Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the end('Bastian', 'n'); case.

:pencil: read more about bonfire confirm the ending on the FCC Wiki

Jocelyn
@jocelyn-ong
Jan 26 2016 00:40
@deek28 you shouldn't need to check if len==1, so run your function on the last item of arr all the time
Netrunner12
@Netrunner12
Jan 26 2016 00:40
@Mahin2k right now you've got it set to a new variable. You don't need to create a new variable. One has been created for you called newArray. WSet that equal to the output of the mapping of oldArray.
rphares
@rphares
Jan 26 2016 00:40
@redeyesblackdragon , you have duplicated a line,
Jocelyn
@jocelyn-ong
Jan 26 2016 00:40
@deek28 and under the else: arr1[len-1] isn't calling the last letter in arr1
rphares
@rphares
Jan 26 2016 00:41
you should only have one line that says function myFunction(wasThatTrue) {
@redeyesblackdragon
Chris Moore
@dooglus
Jan 26 2016 00:41
@pravisti you were asked to "set answer", but all you are doing is logging to the console
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:41
@Netrunner12 thanks i solved it
CamperBot
@camperbot
Jan 26 2016 00:41
mahin2k sends brownie points to @netrunner12 :sparkles: :thumbsup: :sparkles:
:star: 262 | @netrunner12 | http://www.freecodecamp.com/netrunner12
Netrunner12
@Netrunner12
Jan 26 2016 00:41
@Mahin2k var addThree doesn't need to be in your code. They've given you newArray instead
Kyle
@KyleJN8
Jan 26 2016 00:41
@rphares , I was putting spaces in the wordBlanks function instead of the passing words.
Khademul Islam Mahin
@Mahin2k
Jan 26 2016 00:42
@Netrunner12 i removed the var addthree
Jocelyn
@jocelyn-ong
Jan 26 2016 00:42
@deek28 my workflow was, determine the length of the target, then check the same number of letters in the str using str.substr(-X), where x = length of target
rphares
@rphares
Jan 26 2016 00:42
@KyleJN8 , sorry-- i don't understand your meaning--
you mean you caught it now? that you needed the spaces in the " " part, not in the code?
Netrunner12
@Netrunner12
Jan 26 2016 00:42
@Mahin2k no problem, glad you got it figured out.
rphares
@rphares
Jan 26 2016 00:43
@pravisti , you need to make those answer, not just console.log :)
Deekshit.B.N
@deek28
Jan 26 2016 00:43
@jocelyn-ong thank you
CamperBot
@camperbot
Jan 26 2016 00:43
deek28 sends brownie points to @jocelyn-ong :sparkles: :thumbsup: :sparkles:
:star: 434 | @jocelyn-ong | http://www.freecodecamp.com/jocelyn-ong
rphares
@rphares
Jan 26 2016 00:44
Also, i think you need one more? (maybe the exercise has changes since i did it) ... @pravisti
pravisti
@pravisti
Jan 26 2016 00:45
@rphares gotcha! Like this?
switch(val) {
case 1 :
answer = "alpha";
break;
Kyle
@KyleJN8
Jan 26 2016 00:45
@rphares , At the bottom of the code there was a function wordBlanks("cat" , "little", "etc") I was adding my spaces there instead of my string concatenation.
rphares
@rphares
Jan 26 2016 00:45
Much better, @pravisti :)
oooh, no! Im sorry i didn't notice that, @KyleJN8 , and congrats for figuring it out! :)
Jocelyn
@jocelyn-ong
Jan 26 2016 00:46
@KyleJN8 but does that pass the tests then?
pravisti
@pravisti
Jan 26 2016 00:46
@rphares @dooglus thanks!
CamperBot
@camperbot
Jan 26 2016 00:46
pravisti sends brownie points to @rphares and @dooglus :sparkles: :thumbsup: :sparkles:
Fahar Jatoi
@digitaleye
Jan 26 2016 00:46

please help. ```js
//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 lookUp(firstName, prop){
// Only change code below this line

for(i = 0 ; i < contacts.length; i++)
{
if(contacts[i].firstName === firstName)
return contacts[i][prop];
}

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

// Change these values to test your function
lookUp("Akira", "lastName");

```

CamperBot
@camperbot
Jan 26 2016 00:46
:star: 1994 | @rphares | http://www.freecodecamp.com/rphares
:star: 352 | @dooglus | http://www.freecodecamp.com/dooglus
Fahar Jatoi
@digitaleye
Jan 26 2016 00:46
//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 lookUp(firstName, prop){
// Only change code below this line

  for(i = 0 ; i < contacts.length; i++)
  {
    if(contacts[i].firstName === firstName)
    return contacts[i][prop];
  }

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

// Change these values to test your function
lookUp("Akira", "lastName");
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:46
@rphares what do you mean?
Fahar Jatoi
@digitaleye
Jan 26 2016 00:46
i need to put && in if statement
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
I have to check for prop
rphares
@rphares
Jan 26 2016 00:47
@redeyesblackdragon , one sec, ill scroll up, find your code, and paste it back to you with a comment :)
Fahar Jatoi
@digitaleye
Jan 26 2016 00:47
i am not able to do that
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:47
// Example
function ourFunction(isItTrue) {
  if (isItTrue) { 
    return "Yes, it's true";
  }
  return "No, it's false";
}

// Setup
function myFunction(wasThatTrue) {

  // Only change code below this line.
  function myFunction(wasThatTrue) {
    if (wasThatTrue) {
      return "That was true";
    }
    return "That was false";
  }

  function myFunction(wasThatTrue){

  // Only change code above this line.

}

// Change this value to test
myFunction(true);
Kyle
@KyleJN8
Jan 26 2016 00:47
@rphares Yeah it gave the same result and looked correct but failed because they were in the wrong place. Anyway I passed the challenge.
Netrunner12
@Netrunner12
Jan 26 2016 00:48
@redeyesblackdragon what is the name of the challenge?
rphares
@rphares
Jan 26 2016 00:48
This message was deleted
// Example
function ourFunction(isItTrue) {
  if (isItTrue) { 
    return "Yes, it's true";
  }
  return "No, it's false";
}

// Setup
function myFunction(wasThatTrue) {

  // Only change code below this line.
  function myFunction(wasThatTrue) {// THIS IS A REPEAT OF THE LINE ABOVE
//DELETE THE REPEAT LINE
    if (wasThatTrue) {
      return "That was true";
    }
    return "That was false";
  }

  function myFunction(wasThatTrue){// SO IS THIS DELETE ME

  // Only change code above this line.

}

// Change this value to test
myFunction(true);
Alex
@ahorton01
Jan 26 2016 00:49
I was about to ask for help on the Profile Lookup exercise, but I just realized it's 10 minutes to X-Files.
rphares
@rphares
Jan 26 2016 00:50
@redeyesblackdragon , do you see the two repeat lines you don't need?
@Netrunner12 , @redeyesblackdragon is on Use Conditional Logic with If Statements ,
Netrunner12
@Netrunner12
Jan 26 2016 00:51
@ahorton01 X-Files is on netflix, you can watch it later.
redeyesblackdragon
@redeyesblackdragon
Jan 26 2016 00:51
@rphares thanks man i got it
CamperBot
@camperbot
Jan 26 2016 00:51
redeyesblackdragon sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1995 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 26 2016 00:51
Yay! Congrats!~
Victor Osibajo
@victoroshi
Jan 26 2016 00:56
thanks @leftynaut for your help with Checkpoint: Record Collection
CamperBot
@camperbot
Jan 26 2016 00:56
victoroshi sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 405 | @leftynaut | http://www.freecodecamp.com/leftynaut
The Spiteful Octopus
@TheSpitefulOctopus
Jan 26 2016 01:00
Hey guys on the Pig Latin challenge what should glove return as?
Jocelyn
@jocelyn-ong
Jan 26 2016 01:03
@TheSpitefulOctopus oveglay?
rphares
@rphares
Jan 26 2016 01:03
@TheSpitefulOctopus , if i recall, ove glay?
oops-- one word
The Spiteful Octopus
@TheSpitefulOctopus
Jan 26 2016 01:03
thanks you @rphares
CamperBot
@camperbot
Jan 26 2016 01:03
thespitefuloctopus sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1997 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 26 2016 01:04
anytime-- and thanks @jocelyn-ong , been a while since I've looked at it :)
CamperBot
@camperbot
Jan 26 2016 01:04
rphares sends brownie points to @jocelyn-ong :sparkles: :thumbsup: :sparkles:
:star: 436 | @jocelyn-ong | http://www.freecodecamp.com/jocelyn-ong
Alex
@ahorton01
Jan 26 2016 01:07
@Netrunner12 , it's the reboot. New show - same cast. Didn't mean to spam up the help forum; just having a nerdgasm.
JackeL
@jackel27
Jan 26 2016 01:08
what am I missing....
switch (val){
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:08
Need helping pushing the plusThree to the newArray...
var oldArray = [1,2,3,4,5];
var newArray = [];

// Only change code below this line.
var plusThree = oldArray.map(function(val){
  return val + 3;
});
newArray = oldArray;
JackeL
@jackel27
Jan 26 2016 01:09
switch (val){
case a:
answer = "apple";
break;
.....
rphares
@rphares
Jan 26 2016 01:09
@jackel27 , is that all your code?
JackeL
@jackel27
Jan 26 2016 01:09
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val){
    case a:
      answer = "apple";
      break;

    case b:
      answer = "bird";
      break;

    case c:
      answer = "cat";
      break;

    default:
      answer = "stuff";

  }



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

// Change this value to test
myTest(a);
looks correct to me..
rphares
@rphares
Jan 26 2016 01:10
cases should be numbers for that one, no?
JackeL
@jackel27
Jan 26 2016 01:10
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
rphares
@rphares
Jan 26 2016 01:10
oh, looking at wrong one!
then-- missing ""
look at what you just sent,
"a"
JackeL
@jackel27
Jan 26 2016 01:11
I think I tried that.
ill test again
djeremy75
@djeremy75
Jan 26 2016 01:11
which waypoint is that jackel?
JackeL
@jackel27
Jan 26 2016 01:11
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val){
    case "a":
      answer = "apple";
      break;

    case "b":
      answer = "bird";
      break;

    case "c":
      answer = "cat";
      break;

    default:
      answer = "stuff";

  }



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

// Change this value to test
myTest(a);
maybe single quotes... ?>
rphares
@rphares
Jan 26 2016 01:12
Adding a default option in Switch statements , @djeremy75
JackeL
@jackel27
Jan 26 2016 01:12
199
hmmm....
rphares
@rphares
Jan 26 2016 01:12
(the numbers are your points, not the lesson numbers, @jackel27 :) )
JackeL
@jackel27
Jan 26 2016 01:12
oh. thanks lol
started from beginning, did I have to? :)
rphares
@rphares
Jan 26 2016 01:13
no worries, happens all the time :)
no, actually, you only have to do those marked with an * for the certification
JackeL
@jackel27
Jan 26 2016 01:13
well, might as well go through everything and greet the world a million times over.
rphares
@rphares
Jan 26 2016 01:14
yeah-- its good practice,
JackeL
@jackel27
Jan 26 2016 01:14
I was working on php, then switched to javascript.. is good practice
so, I am not sure, I will try to refresh page
rphares
@rphares
Jan 26 2016 01:15
man this is driving me nuts, one sec, ima keep toggling between your answer and mine, cause i don't see it...
djeremy75
@djeremy75
Jan 26 2016 01:15
how do I post code?
JackeL
@jackel27
Jan 26 2016 01:15
right
rphares
@rphares
Jan 26 2016 01:15
explain format
CamperBot
@camperbot
Jan 26 2016 01:15

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

JackeL
@jackel27
Jan 26 2016 01:15
right click on code, copy pretty style
or, highlight what you want to copy
djeremy75
@djeremy75
Jan 26 2016 01:15
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case "a":
      answer = "apple"
      break;
    case "b":
      answer = "bird"
      break;
    case "c":
      answer = "cat"
      break;
    default:
      answer = "stuff"

  }



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

// Change this value to test
myTest(1);
JackeL
@jackel27
Jan 26 2016 01:15
right.
omg.
okay....
djeremy75
@djeremy75
Jan 26 2016 01:16
i would refresh the page i guess
JackeL
@jackel27
Jan 26 2016 01:16
that was weird...
rphares
@rphares
Jan 26 2016 01:16
yes-- thats the same as mine, except i use the ; at end of line, like @jackel27 does
djeremy75
@djeremy75
Jan 26 2016 01:16
I had that happen to me before
JackeL
@jackel27
Jan 26 2016 01:16
it didnt work unless my test value was an integer
djeremy75
@djeremy75
Jan 26 2016 01:16
oh... hmm
Netrunner12
@Netrunner12
Jan 26 2016 01:16
are neither of your codes not working?
JackeL
@jackel27
Jan 26 2016 01:16
even though the case values were chars
rphares
@rphares
Jan 26 2016 01:16
oooh, thats it?
Mafalda
@otmeek
Jan 26 2016 01:16
I'm working on seek and destroy, and I'm a bit confused. Is arguments an array of all arguments for a function?
JackeL
@jackel27
Jan 26 2016 01:16
odd. case values=chars, test value needed to equal 1.....
djeremy75
@djeremy75
Jan 26 2016 01:16
If you put "a" it should work too haha
JackeL
@jackel27
Jan 26 2016 01:17
didn't work with a on mine
rphares
@rphares
Jan 26 2016 01:17
umma put a in mine :)
djeremy75
@djeremy75
Jan 26 2016 01:17
instead of a put "a"
JackeL
@jackel27
Jan 26 2016 01:17
ahhh, thats it
:)
forgot quotes on my test value char
should not have worked with 1 lol
djeremy75
@djeremy75
Jan 26 2016 01:18
haha
rphares
@rphares
Jan 26 2016 01:18
i would NEVER have noticed that, i gen ignore the tests-- thanks, @djeremy75 ~
CamperBot
@camperbot
Jan 26 2016 01:18
rphares sends brownie points to @djeremy75 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for djeremy75
rphares
@rphares
Jan 26 2016 01:18
(it does work with 1, though :) )
JackeL
@jackel27
Jan 26 2016 01:18
lol, why
djeremy75
@djeremy75
Jan 26 2016 01:18
now back to this waypoint that is simple but frying my brain ;_;
JackeL
@jackel27
Jan 26 2016 01:18
are the cases indexed?
whats the prob jeremy
rphares
@rphares
Jan 26 2016 01:18
which one, @djeremy75 ?
djeremy75
@djeremy75
Jan 26 2016 01:19
It's the waypoint "Using Objects for Lookups" I just don't understand it at all
rphares
@rphares
Jan 26 2016 01:19
ahh, that one comes up a lot,
what have you tried so far?
djeremy75
@djeremy75
Jan 26 2016 01:19
honestly not much, I was just staring at it trying to make sense of it haha
rphares
@rphares
Jan 26 2016 01:20
hahaha, fair.
djeremy75
@djeremy75
Jan 26 2016 01:20
I'm bad about googling stuff so I'm trying to just give it some thought first
JackeL
@jackel27
Jan 26 2016 01:20
well, looks like you replace your switch with the lookup table...
rphares
@rphares
Jan 26 2016 01:20
you make a table,
their example for making the table format,
var alpha = {
1:"Z",
2:"Y",
3:"X",
...
JackeL
@jackel27
Jan 26 2016 01:21

var val = {
alpha:"Adams",
brava:"Boston",
....

?

rphares
@rphares
Jan 26 2016 01:21
yours is gonna have a different name, and different contents
yep, but with some quotes on the alpha brava stuff
oh-- ooops
JackeL
@jackel27
Jan 26 2016 01:22
right, cause there strings
rphares
@rphares
Jan 26 2016 01:22
and yours is named lookup
JackeL
@jackel27
Jan 26 2016 01:22
thanks, almost forgot that again.. hah.
rphares
@rphares
Jan 26 2016 01:22
val is what we are looking for, our table starts
var lookup
integralnova
@integralnova
Jan 26 2016 01:23
Hey y'all. I am doing Nesting For Loops currently and I am stuck.
rphares
@rphares
Jan 26 2016 01:23
then, after our table, we make our search tool
Netrunner12
@Netrunner12
Jan 26 2016 01:23
@djeremy75 I wouldn't call your object val. Since you're looking for a value, it will get confusing unless you cal your argument something other than val or value.
rphares
@rphares
Jan 26 2016 01:23
yeah- it actually has to be named lookup, i think its in the directions, @Netrunner12
JackeL
@jackel27
Jan 26 2016 01:23
(Going to catch up to @djeremy75 )
rphares
@rphares
Jan 26 2016 01:24
and assign our search to the result (which we have to return) :)
Luciano Britis
@LucianoBritis
Jan 26 2016 01:26

@all Hello , Just for knowledge of all: my code WITH THIS bug but I spent freely in charged condition. var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
var result = "";
// for (var i = 0; i < myObj; i++){
//if (myObj.hasOwnProperty(checkProp));
if (result = myObj[checkProp]){
return result;
}
else {
return "Not Found";
}
}

Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:27
Anyone available for some help with "Condense arrays with Reduce"?
integralnova
@integralnova
Jan 26 2016 01:28
@LucianoBritiswhy you cannot assign in an if statement I believe.
Netrunner12
@Netrunner12
Jan 26 2016 01:28
@djeremy75 all you're doing is making an object with "property values" (lol) that relate to the switch statement. The result you return should be your object referencing your function's parameter.
@Rontastic I'll give it a shot. Paste your code.
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:29
@Netrunner12 I appreciate that!
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
});
singleVal = array;
Netrunner12
@Netrunner12
Jan 26 2016 01:30
@Rontastic give me a second to remember how I did it, hah.
Chris Moore
@dooglus
Jan 26 2016 01:30
@Rontastic it's ok until the last line - the number you want is in singleVal
@Rontastic you're declaring singleVal twice - you don't need the first one
Netrunner12
@Netrunner12
Jan 26 2016 01:31
@Rontastic I remember I based my code off of the example and it worked. I don't understand why it works though.
rphares
@rphares
Jan 26 2016 01:31
(would love if people talk about this one more... have an answer, but this is again one of those that i don't really get, just followed the pattern)
Chris Moore
@dooglus
Jan 26 2016 01:31
@Rontastic oh, but you're not allowed to edit above the line - so just don't put a val at the start of your reduce line
@rphares which one? this 'reduce' one?
JackeL
@jackel27
Jan 26 2016 01:32
So, question...
Netrunner12
@Netrunner12
Jan 26 2016 01:32
@dooglus I get the code right when I went through it, but I don't know why it works.
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:32
@dooglus Ok, let me try that and I'll let you know what I come up with
integralnova
@integralnova
Jan 26 2016 01:32
@LucianoBritis
if (myObj.hasOwnProperty(checkProp));
result = myObj.checkProp;
return result;
}
else {
return "Not Found";
}
rphares
@rphares
Jan 26 2016 01:32
yep-- have a working answer, but don't feel good about understanding it : / @dooglus
Netrunner12
@Netrunner12
Jan 26 2016 01:32
@dooglus of why it's called reduce.
JackeL
@jackel27
Jan 26 2016 01:32
I am on Multiple Identical Options in Switch Statements
JackeL
@jackel27
Jan 26 2016 01:33
Just curious on if my answer is logically accepted...
Netrunner12
@Netrunner12
Jan 26 2016 01:33
I remember now
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:33
Is this what you meant @dooglus
JackeL
@jackel27
Jan 26 2016 01:33

function myTest(val) {
var answer = "";
// Only change code below this line

switch(val){
case (val>=1 && val <=3):
// answer = "Low";
return ("Low");

case (val>=4 && val <=6):
 // answer = "Mid";
  return ("Mid");

case (val>=7 && val <=9):
 // answer = "High";
  return ("High");

default:
  answer = "Please input a valid response between 1 and 10.";

}

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

// Change this value to test
myTest(1);

rphares
@rphares
Jan 26 2016 01:33
not recently, haven't since i used it in BF-- ill take another look, maybe they willstick this time--
Netrunner12
@Netrunner12
Jan 26 2016 01:33
it's iterating through the array
rphares
@rphares
Jan 26 2016 01:33
thanks, @dooglus !
CamperBot
@camperbot
Jan 26 2016 01:33
rphares sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 353 | @dooglus | http://www.freecodecamp.com/dooglus
JackeL
@jackel27
Jan 26 2016 01:33

function myTest(val) {
var answer = "";
// Only change code below this line

switch(val){
case (val>=1 && val <=3):
// answer = "Low";
return ("Low");

case (val>=4 && val <=6):
 // answer = "Mid";
  return ("Mid");

case (val>=7 && val <=9):
 // answer = "High";
  return ("High");

default:
  answer = "Please input a valid response between 1 and 10.";

}

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

// Change this value to test
myTest(1);

Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:33
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
}, 0);
return singleVal;
JackeL
@jackel27
Jan 26 2016 01:33
not pasting properly.
Chris Moore
@dooglus
Jan 26 2016 01:33
@Netrunner12 Array.map() takes an array and gives you back another array of the same length - it maps each element into a new one. Array.reduce() takes an array and gives you back a single value - it reduces all the array elements into a single value
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:34
@dooglus Is this what you meant?
^^^
Chris Moore
@dooglus
Jan 26 2016 01:34
@Rontastic we're not writing a function, so you don't want to return anything at the end - but otherwise yes
JackeL
@jackel27
Jan 26 2016 01:34
function myTest(val) {
  var answer = "";
  // Only change code below this line

  switch(val){
    case (val>=1 && val <=3):
      // answer = "Low";
      return ("Low");

    case (val>=4 && val <=6):
     // answer = "Mid";
      return ("Mid");

    case (val>=7 && val <=9):
     // answer = "High";
      return ("High");

    default:
      answer = "Please input a valid response between 1 and 10.";

  }

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

// Change this value to test
myTest(1);
there we go.
rphares
@rphares
Jan 26 2016 01:34
@Rontastic , was your line 2 there when you started?
you need answers, not returns, @jackel27 :)
Netrunner12
@Netrunner12
Jan 26 2016 01:35
@dooglus I see thanks. Would you say it's iterating through the array, where previousVal is 4 and currentVal is 5? Then it goes on and previousVal is 9 and current Val is 6 and so on?
CamperBot
@camperbot
Jan 26 2016 01:35
netrunner12 sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 354 | @dooglus | http://www.freecodecamp.com/dooglus
JackeL
@jackel27
Jan 26 2016 01:35
right.
@rphares exclude the returns and uncomment the answer =
that would also work correct?
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:35
@rphares @dooglus Success with this:
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
}, 0);
sigleVal = array;
integralnova
@integralnova
Jan 26 2016 01:36

'''function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i = 0; i < arr.length; i++){
for(var x = 0; x < arr[i].length ; x++){
product *= parseInt(arr[i][x]);
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);'''

Chris Moore
@dooglus
Jan 26 2016 01:36
@Netrunner12 right, exactly. you can also give reduce() a 2nd argument, which is the starting value to use. then the first call of the function will use that initial value, and the first element
CamperBot
@camperbot
Jan 26 2016 01:36
:bulb: to format code use backticks! ``` more info
rphares
@rphares
Jan 26 2016 01:36
hahaha-- I'm exactly the wrong person to ask, @jackel27 :blush:
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:36
@dooglus Thanks!
CamperBot
@camperbot
Jan 26 2016 01:36
rontastic sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 355 | @dooglus | http://www.freecodecamp.com/dooglus
rphares
@rphares
Jan 26 2016 01:36
Oooh, congrats, @Rontastic ~
JackeL
@jackel27
Jan 26 2016 01:36
@rphares haha, okay. I'll just assume it will lol
Netrunner12
@Netrunner12
Jan 26 2016 01:36
@Rontastic seems you may not need the bottom line of your code.
integralnova
@integralnova
Jan 26 2016 01:36
I cannot figure out why I cannot pass the last test. Can anyone help me
JackeL
@jackel27
Jan 26 2016 01:36
@rphares it wants me to write out all the case statements... won't let me take the easy way out.
Chris Moore
@dooglus
Jan 26 2016 01:36
@Rontastic you don't need the , 0 in your reduce call, but it doesn't hurt to include it
Netrunner12
@Netrunner12
Jan 26 2016 01:37
@dooglus Great. Thanks.
CamperBot
@camperbot
Jan 26 2016 01:37
netrunner12 sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
rphares
@rphares
Jan 26 2016 01:37
(sorry, I'm hang out here to learn how stuff works. I'm okay at passing the tests but still struggling o get my head around JS, @jackel27 -- others may be able to answer better..)
CamperBot
@camperbot
Jan 26 2016 01:37
:warning: netrunner12 already gave dooglus points
Netrunner12
@Netrunner12
Jan 26 2016 01:37
@rphares same here
djeremy75
@djeremy75
Jan 26 2016 01:37
sorry guys I didn't mean to ignore you, I was just still trying to figure it out
Chris Moore
@dooglus
Jan 26 2016 01:37
@Rontastic your code will do: ((0+4)+5)+... - and if you leave the , 0 it will do one less addition: (4+5)+...
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:37
@dooglus Because it would automatically select the first # in the array anway, right?
JackeL
@jackel27
Jan 26 2016 01:37
back to catching up with @djeremy75
rphares
@rphares
Jan 26 2016 01:37
no no, thats good, @djeremy75 ! Did you get it? :blush:
Chris Moore
@dooglus
Jan 26 2016 01:38
@Rontastic because if you don't give it an initial value, it uses the first element of the array, and uses the 2nd element of the array for the first call...
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:38
@integralnova why are you using parseint?
djeremy75
@djeremy75
Jan 26 2016 01:38
no I'm ashamed to say I still don't quite understand it...
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:38
@dooglus Awesome, just wanted to make sure I understood!
djeremy75
@djeremy75
Jan 26 2016 01:38
// 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",

  };

  }

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

// Change this value to test
phoneticLookup("charlie");
rphares
@rphares
Jan 26 2016 01:38
okay, close!
Chris Moore
@dooglus
Jan 26 2016 01:39
@Rontastic try this one to see if you understand:
[1, 2, 3, 4].reduce(function(a, b) {
  a.push(b); a.push(b); return a;
}, ['start', 'value']);
rphares
@rphares
Jan 26 2016 01:39
now you just need your lookup part, @djeremy75 :)
djeremy75
@djeremy75
Jan 26 2016 01:39
I know I have to do the lookup, it's just confusing me haha
Chris Moore
@dooglus
Jan 26 2016 01:39
@Rontastic see if you can figure out what it returns, then run it to check
rphares
@rphares
Jan 26 2016 01:39
did you see the example, alpha[2] , @djeremy75 ?
Netrunner12
@Netrunner12
Jan 26 2016 01:39
@djeremy75 good work so far.
integralnova
@integralnova
Jan 26 2016 01:40
@NickEU Earlier '+' concatenated instead of adding. I find that worked. Is that bad way to do it.
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:40
@integralnova you have an array of numbers though
JackeL
@jackel27
Jan 26 2016 01:40

@rphares ```js

switch(val){
case val=1:
answer = "Low";
break;
case val=2:
answer = "Low";
break;
case val=3:
answer = "Low";
break;
case val=4:
answer = "Mid";
break;
case val=5:
answer = "Mid";
break;
case val=6:
answer = "Mid";
break;
case val=7:
answer = "High";
break;
case val=8:
answer = "High";
break;
case val=9:
answer = "High";
break;

default:
  answer = "Please input a valid response between 1 and 10.";

}

```

djeremy75
@djeremy75
Jan 26 2016 01:40
oh yeah I see that, I didn't notice it before
JackeL
@jackel27
Jan 26 2016 01:40
eew, bad paste.
djeremy75
@djeremy75
Jan 26 2016 01:40
I'm also getting syntax error: illegal return statement
rphares
@rphares
Jan 26 2016 01:41
so, they are looking up 2 from var alpha, @djeremy75 .... you are looking up what where? @djeremy75
right-- once you write that part,
JackeL
@jackel27
Jan 26 2016 01:41
but, @rphares, see.. so many cases that could of been said with (lessthan and equal operators)
rphares
@rphares
Jan 26 2016 01:41
then you need to assign it to result,
integralnova
@integralnova
Jan 26 2016 01:41
@NickEU I wanted to be safe. I could not figure it so I thought maybe that happened again.
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:41
@integralnova parseint() is to parse strings and get numbers out of strings... the array in your example is an array of numbers, you don't need parseint() for that lol, which challenge is that?
rphares
@rphares
Jan 26 2016 01:41
cause, you are gonna return result no matter what, @djeremy75 , its below the line,
so right now, you are just returning an empty string :)
integralnova
@integralnova
Jan 26 2016 01:41
Nesting for Loops
rphares
@rphares
Jan 26 2016 01:41
@jackel27 , did that pass?
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:42
@integralnova yeah, all the arrays only include numbers.... which challenge was the one where you needed to use parseint() again? The one that didn't pass without it? 0_0 cause i don't remember having to use it until the bonfires
integralnova
@integralnova
Jan 26 2016 01:43
@NickEU multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:43
@integralnova no strings here..
@integralnova you said "Earlier '+' concatenated instead of adding." what do you mean by that?
rphares
@rphares
Jan 26 2016 01:44
@jackel27 , you can slim that down some... using things like
switch(val){
case 1:
case 2:
case 3:
answer = "Low";
break;
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:45
plus + will concatenate if one of the operands is a string... if you're doing a + b and both are NUMBERS + will work as an arithmetic +
@integralnova
@integralnova why would you even consider using parseInt() there? i kinda don't get it... what made you do that?
CharmedSatyr
@CharmedSatyr
Jan 26 2016 01:48
wiki chunky monkey
CamperBot
@camperbot
Jan 26 2016 01:48

:point_right: bonfire chunky monkey [wiki]

Explanation

Our goal for this bonfire is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this bonfire:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the bonfire title and read the helpful links if you haven't yet.

:pencil: read more about bonfire chunky monkey on the FCC Wiki

integralnova
@integralnova
Jan 26 2016 01:49
@NickEU it was earlier way point. they were both numbers but it concatnated. Lets get past I am going to remove it.
Ronald Steadman-Keanon
@Rontastic
Jan 26 2016 01:49
@dooglus Woah, I'm feeling really lost...
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:49
@integralnova can you link that earlier waypoint?
@integralnova i mean give me the name?
integralnova
@integralnova
Jan 26 2016 01:50
@NickEU Give me a minute.
Andrew
@kakoonhead
Jan 26 2016 01:52

var oldArray = [1,2,3,4,5];
var newArray = [];

// Only change code below this line.
var array = newArray.map(function(val, array){
return val+3;
});

newArray = oldArray;
```
js

JackeL
@jackel27
Jan 26 2016 01:52
I don't know why this isn't working...
Jocelyn
@jocelyn-ong
Jan 26 2016 01:52
wiki no repeats please
CamperBot
@camperbot
Jan 26 2016 01:52

:point_right: bonfire no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about bonfire no repeats please on the FCC Wiki

Andrew
@kakoonhead
Jan 26 2016 01:52
i'm having some problems with this can anyone help?
explain formatting
CamperBot
@camperbot
Jan 26 2016 01:53

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

JackeL
@jackel27
Jan 26 2016 01:53
@kakoonhead which one are you on
Andrew
@kakoonhead
Jan 26 2016 01:53
iterate over arrays with .map
integralnova
@integralnova
Jan 26 2016 01:54
@NickEU I actually did figure out why that happened yesterday. I did
Andrew
@kakoonhead
Jan 26 2016 01:54
wondering how to "push" it I suppose, lol
Bill
@kirah1314
Jan 26 2016 01:54
@jackel27 what's your challenge title?
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:54
@integralnova ok, so it's all good? not gonna use parseint to add numbers anymore? :P
Andrew
@kakoonhead
Jan 26 2016 01:55
Iterate over Arrays with map is the chalenge title
challenge*
integralnova
@integralnova
Jan 26 2016 01:55
@NickEU However the problem still remains can you help me with that
Andrew
@kakoonhead
Jan 26 2016 01:55
oops, sorry, lol.
integralnova
@integralnova
Jan 26 2016 01:56
@NickEU GodDamnt found it. Thank you
CamperBot
@camperbot
Jan 26 2016 01:56
integralnova sends brownie points to @nickeu :sparkles: :thumbsup: :sparkles:
:star: 366 | @nickeu | http://www.freecodecamp.com/nickeu
Nikolajs Korolkovs
@NickEU
Jan 26 2016 01:56
@integralnova :clap:
JackeL
@jackel27
Jan 26 2016 01:56
@kakoonhead , something like newArray = oldArray.map(newArray..... ?
my # is...
Return Early Pattern for Functions
// Setup
function abTest(a, b) {
  // Only change code below this line

  if (a < 0 || 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);
rphares
@rphares
Jan 26 2016 01:57
so, undefined is a special value, @jackel27
Andrew
@kakoonhead
Jan 26 2016 01:57
wow @jackel27 thank you. that worked, lol.
CamperBot
@camperbot
Jan 26 2016 01:57
kakoonhead sends brownie points to @jackel27 :sparkles: :thumbsup: :sparkles:
:star: 204 | @jackel27 | http://www.freecodecamp.com/jackel27
rphares
@rphares
Jan 26 2016 01:57
in quotes, "undefined" is just a string :) @jackel27
(you wanna return the value)
JackeL
@jackel27
Jan 26 2016 01:58
oh
dangit
rphares
@rphares
Jan 26 2016 01:58
Happens all the time~
JackeL
@jackel27
Jan 26 2016 01:58
just going through the instructions lol
rphares
@rphares
Jan 26 2016 01:58
oh, sorry sorry, didn't mean to give a spoiler!
Satchmo37
@Satchmo37
Jan 26 2016 01:58
This message was deleted
rphares
@rphares
Jan 26 2016 01:58
thought you were pasting cause you were stuck!
JackeL
@jackel27
Jan 26 2016 01:59
no, I see the instructions clearly state return with the value of undefined.. so thats what I did
lol
rphares
@rphares
Jan 26 2016 01:59
:blush: it is one of the most common questions here :)
(i think i got it cause i didn't know any better and 'forgot' the quotes, lol)
JackeL
@jackel27
Jan 26 2016 02:00
okay..
I suck at the little stuff haha
rphares
@rphares
Jan 26 2016 02:01
we all do, thats why debugging is suck a big job :)
Satchmo37
@Satchmo37
Jan 26 2016 02:01

Accessing Nested Arrays in JSON

// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

I'm trying to access the array in the second object, type: "trees", but I'm not sure how to use dot and bracket notation to get there...

myPlants.list[1];

Is going to return the second array index of both objects. How can I return just the trees array?

JackeL
@jackel27
Jan 26 2016 02:01
well, I could use the debugger if this was a different IDE..
rphares
@rphares
Jan 26 2016 02:01
okay, you are very close, @ddeason37
but, you forgot an index for myPlants, @ddeason37
see how there are two parts of myPlants?
Chris Moore
@dooglus
Jan 26 2016 02:02
@ddeason37 myPlants is an array, so you have to use [number] notation to access its elements
Satchmo37
@Satchmo37
Jan 26 2016 02:02
oh duh!!! the little things eh?
JackeL
@jackel27
Jan 26 2016 02:02
so, [x,2] .. x=key 2=nested?
Satchmo37
@Satchmo37
Jan 26 2016 02:02
Multiple objects are always stored in an array I assume?
thanks @rphares @dooglus @jackel27
CamperBot
@camperbot
Jan 26 2016 02:03
ddeason37 sends brownie points to @rphares and @dooglus and @jackel27 :sparkles: :thumbsup: :sparkles:
Chris Moore
@dooglus
Jan 26 2016 02:03
@ddeason37 often we'd use an associative array, where the elements are accessed by name, not number
CamperBot
@camperbot
Jan 26 2016 02:03
:star: 2001 | @rphares | http://www.freecodecamp.com/rphares
:star: 205 | @jackel27 | http://www.freecodecamp.com/jackel27
:star: 356 | @dooglus | http://www.freecodecamp.com/dooglus
rphares
@rphares
Jan 26 2016 02:04
Anytime :)
JackeL
@jackel27
Jan 26 2016 02:04
.. still on that same one. what am i missing
Satchmo37
@Satchmo37
Jan 26 2016 02:04
@dooglus associative arrays...would JSON be an example of that?
rphares
@rphares
Jan 26 2016 02:04
the same one as @ ddeason37 or the same one as before?
JackeL
@jackel27
Jan 26 2016 02:04
same as before lol
I'm trying to understand it, but dont
so if its not this, then return undefined... hmm.
Chris Moore
@dooglus
Jan 26 2016 02:05
@ddeason37 JSON lets you write out any javascript object in plain text
djeremy75
@djeremy75
Jan 26 2016 02:05
ok I feel stupid, how do I add to result?
// 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",

  };

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

// Change this value to test
phoneticLookup("");
CharmedSatyr
@CharmedSatyr
Jan 26 2016 02:05
Hey, can somebody help me with Chunky Monkey?
Satchmo37
@Satchmo37
Jan 26 2016 02:05
@djeremy75 you need to change the var result before you return it...
rphares
@rphares
Jan 26 2016 02:06
without those quotes, it looks okay to me, @jackel27 , can you repaste?
@djeremy75 , so you can say result =...
JackeL
@jackel27
Jan 26 2016 02:06
@rphares dang refresh! - works now
rphares
@rphares
Jan 26 2016 02:06
phew!
I was beginning to doubt myself,lol
JackeL
@jackel27
Jan 26 2016 02:06
@rphares thanks
CamperBot
@camperbot
Jan 26 2016 02:06
jackel27 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2002 | @rphares | http://www.freecodecamp.com/rphares
Chris Moore
@dooglus
Jan 26 2016 02:06

@ddeason37 maybe something like this:

{
  trees: {
    class: "vegetable",
    examples: ['fir', 'pine']
  },
  fruit: {
    class: "vegetable",
    examples: ['orange', 'apple']
  },
  pets: {
    class: "animal",
    examples: ['dog', 'cat']
  }
}

you can access the various objects without having to search, or know their number

rphares
@rphares
Jan 26 2016 02:07
anytime, @jackel27 :)
JackeL
@jackel27
Jan 26 2016 02:07
brb - need snacks
rphares
@rphares
Jan 26 2016 02:07
(well, not too much longer, you will pass me shortly :) )
and you want to change result to use your nice lookup table, @djeremy75 ... remember the example, alpha[2]?
djeremy75
@djeremy75
Jan 26 2016 02:09
Ok I get that I just do result = lookup["alpha"] and I get Adams
o-ndr
@o-ndr
Jan 26 2016 02:09
Hi, I am at a very basic level. I need help figuring this exercise: http://www.freecodecamp.com/challenges/stand-in-line
djeremy75
@djeremy75
Jan 26 2016 02:09
But how do I do that for all 6 at once?
rphares
@rphares
Jan 26 2016 02:09
very close, @djeremy75 .... look again at the instructions--
what were you told to lookup?
Pandarati
@Pandarati
Jan 26 2016 02:10
@o-ndr arr.push() adds elements onto the end of an array. arr.shift() deletes the first element in the array
Tharun James
@xplorejames
Jan 26 2016 02:10

If you'll recall from our discussion of Storing Values with the Equal Operator, everything to the right of the equal sign is resolved before the value is assigned. This means we can take the return value of a function and assign it to a variable.

Assume we have pre-defined a function sum which adds two numbers together, then:

ourSum = sum(5, 12);

will call sum function, which returns a value of 17 and assigns it to ourSum variable.

Instructions
Call the process function with an argument of 7 and assign its return value to the variable processed.

// Setup
var processed = 0;

function process(num) {
return (num + 3) / 5;
}

function process(num)
{

processed=

}

// Only change code below this line

rphares
@rphares
Jan 26 2016 02:10
@djeremy75 Use it to lookup val and return the associated string.
hiya, @xplorejames !
you are so close!
o-ndr
@o-ndr
Jan 26 2016 02:11
@Pandarati this is what I do: function queue(arr, item) {
// Your code here
arr.push(item);
return arr.shift(); // Change this line
}
Tharun James
@xplorejames
Jan 26 2016 02:11
@rphares Please help me to fix this code challenge ..
:/
rphares
@rphares
Jan 26 2016 02:11
of course, no worries,
first, can i ask you to paste it formatted? Here is how:
explain format
CamperBot
@camperbot
Jan 26 2016 02:12

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Pandarati
@Pandarati
Jan 26 2016 02:12
@o-ndr Assign the value to a variable and then return it
rphares
@rphares
Jan 26 2016 02:13
@xplorejames -- i don't need the directions, just your code pasted between two rows of ``` :)
Satchmo37
@Satchmo37
Jan 26 2016 02:13
@djeremy75 you need to pass the val to lookup and assign the result to....result
Bryse
@Sox8999
Jan 26 2016 02:13

Hello everyone, I am struggling with the Using Objects for Lookups; converting a switch statement to a lookup table and using it to lookup val and return the associated string: ```js
// Setup
function phoneticLookup(val) {
var result = "val";

// Only change code below this line
var lookup = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"

};

// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("echo");```

rphares
@rphares
Jan 26 2016 02:13
oooh, you are also close, @Sox8999
so, now, you want to make your lookup part, right, @Sox8999 ?
Pandarati
@Pandarati
Jan 26 2016 02:13
@Sox8999 Use [shift+enter] to help format code
rphares
@rphares
Jan 26 2016 02:14
check out the example, alpha[2] on the left
Tharun James
@xplorejames
Jan 26 2016 02:14

<'//
var processed = 0;

function process(num) {
return (num + 3) / 5;
}

function process(7)
{

processed=

}

// Only change code below this line
'>

stacyHere
@stacyHere
Jan 26 2016 02:14
Can someone please help me with Return largest Number? This only returns an empty array or whatever I initialize it with. ```
function largestOfFour(arr) {
  var arrNew = [];
  for (var i=0;i<largestOfFour.length;i++){      
    for (var x=0;x<i.length;x++){  
      var temp=0;
      if (x>temp){
        temp=x;       
      }
   arrNew.push(temp); 
    }    
  }
  return arrNew;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
rphares
@rphares
Jan 26 2016 02:14
see how they put their table (alpha) outside, and what the are accessing (2) inside the brackets, @Sox8999 ?
Pandarati
@Pandarati
Jan 26 2016 02:15
@xplorejames You aren't assigning a value to processed
rphares
@rphares
Jan 26 2016 02:15
hahaha, okay,we can start there, @xplorejames .
var processed = 0;
function process(num) {
return (num + 3) / 5;
}
above part is correct
@xplorejames
Pandarati
@Pandarati
Jan 26 2016 02:15
@stacyHere For your second for-loop trying using largestOfFour[i].length
rphares
@rphares
Jan 26 2016 02:16
but the bottom part-- you have the pieces correct, but need to put them together in the right way
stacyHere
@stacyHere
Jan 26 2016 02:16
thanks @Pandarati , I'll try that
CamperBot
@camperbot
Jan 26 2016 02:16
stacyhere sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 334 | @pandarati | http://www.freecodecamp.com/pandarati
Tharun James
@xplorejames
Jan 26 2016 02:16
@rphares i tried diffrent way but colnt find any solution
Bill
@kirah1314
Jan 26 2016 02:17
@stacyHere your loops aren't targeting correctly. It should be:
i<arr.length and x<arr[i].length
rphares
@rphares
Jan 26 2016 02:17
@xplorejames
function process(7) wrong place, and you don't need the word function
{ delete this extra bracket
processed= THIS is where you want to assign process(7) to :)
} delete this extra bracket
Bill
@kirah1314
Jan 26 2016 02:18
@stacyHere arr is your array argument, it's what you passed to the function.
This is arr:
[[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]
rphares
@rphares
Jan 26 2016 02:19
try to clean that up, please, @xplorejames and run tests. If it fails, please come back and paste what you just tried again-- so we can practice formatting, too :blush:
@Sox8999 , you get it?
stacyHere
@stacyHere
Jan 26 2016 02:20
thanks @kirah1314 , that should have been so obvious
CamperBot
@camperbot
Jan 26 2016 02:20
stacyhere sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 861 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Tharun James
@xplorejames
Jan 26 2016 02:22
@rphares ok
matthew3454
@matthew3454
Jan 26 2016 02:25
Can someone please help me on the Testing Objects for Properties exercise?
cannelflow
@cannelflow
Jan 26 2016 02:27
@matthew3454 tried something?
rphares
@rphares
Jan 26 2016 02:27
erm-- i won't be able to explain, @matthew3454 , but--
Bryse
@Sox8999
Jan 26 2016 02:27
@rphares No, not yet.
rphares
@rphares
Jan 26 2016 02:27
oh, yay, @cannelflow to the rescue!
matthew3454
@matthew3454
Jan 26 2016 02:27
@cannelflow yes
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  function checkObj("gift");
  return "pony";
}

// Test your code by modifying these values
checkObj("gift");
rphares
@rphares
Jan 26 2016 02:27
Okeydoke, have you built your lookup part, @Sox8999 ?
Tharun James
@xplorejames
Jan 26 2016 02:28
@rphares Thank you so much
CamperBot
@camperbot
Jan 26 2016 02:28
xplorejames sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2005 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 26 2016 02:28
anytime!
Bryse
@Sox8999
Jan 26 2016 02:28
// 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"

  };

  // Only change code above this line
   result = lookup.charlie;

}
// Change this value to test
phoneticLookup("charlie");
cannelflow
@cannelflow
Jan 26 2016 02:28
@matthew3454 Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty(propname) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.
@matthew3454 see instruction carefully
rphares
@rphares
Jan 26 2016 02:29
ooh, you are close, @Sox8999
matthew3454
@matthew3454
Jan 26 2016 02:29
@cannelflow @cannelflow ok
rphares
@rphares
Jan 26 2016 02:29
but, you aren't looking up charlie, for one,
cannelflow
@cannelflow
Jan 26 2016 02:29
@Sox8999 think if result = lookup.charlie is ok
rphares
@rphares
Jan 26 2016 02:30
@Sox8999 Use it to lookup val and return the associated string.
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:30
sounds legit if Charlie is what you want
Justin Lewis
@lewisjustin26
Jan 26 2016 02:30
I could use some help on the card counting challenge
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:30
yes lewis
cannelflow
@cannelflow
Jan 26 2016 02:30
@lewisjustin26 tried anything yet
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:30
where are you stuck
Justin Lewis
@lewisjustin26
Jan 26 2016 02:31
Just a bunch of if statements. Do I need to use an array so it counts multiple cards
cannelflow
@cannelflow
Jan 26 2016 02:31
@lewisjustin26 you can use switch its cleaner then if
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:31
I was going to hint at that especially given how many ifs there are in that
rphares
@rphares
Jan 26 2016 02:31
ifs will work
cannelflow
@cannelflow
Jan 26 2016 02:32
@lewisjustin26 or as @rphares said if will also work
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:32
remember that in coding there are many situation where a big bunch of spaghetti code works, but a tightly written small amount of code works better :)
Justin Lewis
@lewisjustin26
Jan 26 2016 02:33
How do i get it to keep counting with the next card
djeremy75
@djeremy75
Jan 26 2016 02:33
.........
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:33
in the case of counting cards there are three fundamental ifs
djeremy75
@djeremy75
Jan 26 2016 02:33
I finally got it but I am still so confused
rphares
@rphares
Jan 26 2016 02:33
ouch, @gordondavidescu !
Bill
@kirah1314
Jan 26 2016 02:33
@lewisjustin26 care to post what you tried here?
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:33
which is why a switch is better
my kid bruised his lip really badly, sorry if I am being ouchy :)
Justin Lewis
@lewisjustin26
Jan 26 2016 02:34
I just deleted it to try working on case instead. if's were really messy anyway
rphares
@rphares
Jan 26 2016 02:34
ah, sorry to hear about your child :)
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:34
yeah he was halfway in the tub and slipped.
Dino Heras
@DinoHeras
Jan 26 2016 02:34
Hello I was wondering if someone could help me figure out a problem
Bill
@kirah1314
Jan 26 2016 02:34
@lewisjustin26 ok, but even if you use a switch, you still have to use if to do the final count comparison
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:34
yes @newCoder17 what's going on
true @kirah1314
Justin Lewis
@lewisjustin26
Jan 26 2016 02:35
Noted
Dino Heras
@DinoHeras
Jan 26 2016 02:35

function queue(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(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

I have to "Write a function queue 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 queue function should then return the element that was removed."
Satchmo37
@Satchmo37
Jan 26 2016 02:35
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {
  if(value !== "" && prop !== "tracks"){
    collection.id.prop = value;
  } else if (prop == 'tracks' && value !== ''){
    collection.id.push(value);
  } else if (value === ''){
    delete collection.id.prop;
  }

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
I'm really not understanding why I'm getting Type Error: Cannot set property 'prop' of undefined
cannelflow
@cannelflow
Jan 26 2016 02:36
@newCoder17 which exercise ? you need to push a value and need to shift a value
JackeL
@jackel27
Jan 26 2016 02:36
okay, anyone wanna help
rphares
@rphares
Jan 26 2016 02:36
maybe, what're you on, @jackel27 ?
Dino Heras
@DinoHeras
Jan 26 2016 02:36
Stand in Line is the exercise @cannelflow
JackeL
@jackel27
Jan 26 2016 02:36
counting cards
Bill
@kirah1314
Jan 26 2016 02:36
@ddeason37 id and prop are parameter variables, they cannot be accessed using dot notation since they're not object properties
matthew3454
@matthew3454
Jan 26 2016 02:36
@cannelflow check out my update. I did something right but I'm still not quite there.
JackeL
@jackel27
Jan 26 2016 02:36
var count = 0;
var bet;

function cc(card) {
  // Only change code below this line
  if (card = 2,3,4,5,6){
    count++;
    bet = "Bet";
  }else if (card = 10,'J','Q','K','A'){
    count--;
    bet = "Hold";
  }else if (card = 7,8,9){
    count = 0;
    bet = "Hold";
  }


  return count + " " + bet;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
matthew3454
@matthew3454
Jan 26 2016 02:36
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty("gift");
   myObj.hasOwnProperty("pet");
   myObj.hasOwnProperty("bed");
  return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:37
ok @jackel27 I see your issue
cannelflow
@cannelflow
Jan 26 2016 02:37
@newCoder17 yes you need to push a value then shift a value
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:37
that is not how you make a list of different ifs
JackeL
@jackel27
Jan 26 2016 02:37
hmm
Calvoxel
@Calvoxel
Jan 26 2016 02:37

Hey, I'm supposed to create a function to reverse a string, but I don't understand how. They mentioned turning a string into an array, and my result needs to be a string again, but how do I do this? Here is my code: ```js
function reverseString(str) {
var newSTR = str.split();
newSTR.reverse();
newSTR.join(" ");
newSTR.toString();
return newSTR;
}

reverseString("hello");

```

function reverseString(str) {
  var newSTR = str.split();
  newSTR.reverse();
  newSTR.join(" ");
  newSTR.toString();
  return newSTR;
}

reverseString("hello");
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:37
you want to read up on using the switch statement for that exercise
Dino Heras
@DinoHeras
Jan 26 2016 02:37
Alright I'll give it a shot. Thank you @cannelflow
Bryse
@Sox8999
Jan 26 2016 02:37
@jackel27 - as a fellow newbie, the switch is so much easier for that exercise!
CamperBot
@camperbot
Jan 26 2016 02:37
newcoder17 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
JackeL
@jackel27
Jan 26 2016 02:37
k, let me try that
CamperBot
@camperbot
Jan 26 2016 02:37
:star: 551 | @cannelflow | http://www.freecodecamp.com/cannelflow
CharmedSatyr
@CharmedSatyr
Jan 26 2016 02:38
hey, could somebody help me with Chunky Monkey?
function chunk(arr, size) {

  var multi = [];

  for (var i = 0; i < arr.length / size; i++) {

    for (var j = 0; j < arr.length; j += size) {
      multi[i] = arr.slice(j, j + size);

    }
  }
  return multi;
}

chunk([0, 1, 2, 3, 4, 5], 2);
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:38

@jackel27 just to give you a taste:

```

switch (card) {
  case 2:
  case 3:
Ryan
@ashket
Jan 26 2016 02:38
@Calvoxel You have the right idea with your join. Try that with your split as well.
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:38
that's partially how it looks
matthew3454
@matthew3454
Jan 26 2016 02:39
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty("gift");
   myObj.hasOwnProperty("pet");
   myObj.hasOwnProperty("bed");
  return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
cannelflow
@cannelflow
Jan 26 2016 02:39
@matthew3454 ok you are their but you can pass checkProp instead gift pet and bet so remove all and pass checkprop
Calvoxel
@Calvoxel
Jan 26 2016 02:39
@ashket what do you mean?
CharmedSatyr
@CharmedSatyr
Jan 26 2016 02:39
I get output [[4,5], [4,5], [4,5]]
Ryan
@ashket
Jan 26 2016 02:39
@Calvoxel Look at your parenthases with your join.
Satchmo37
@Satchmo37
Jan 26 2016 02:39
@kirah1314 ahhhh, so since i'm accessing the id and creating the new prop based off the parameters they have to be in brackets?
matthew3454
@matthew3454
Jan 26 2016 02:39
@cannelflow okay
Calvoxel
@Calvoxel
Jan 26 2016 02:39
@ashket what about them?
Ryan
@ashket
Jan 26 2016 02:39
@Calvoxel Try that with .split as well.
Bill
@kirah1314
Jan 26 2016 02:40
@JosephWolfe you're pretty close but you just need 1 loop and need to use push method
Ryan
@ashket
Jan 26 2016 02:40
@Calvoxel What character are you splitting your sentence with?
@Calvoxel A space.
Calvoxel
@Calvoxel
Jan 26 2016 02:40
@ashket still doesn't work. My output is ["hello"]
CharmedSatyr
@CharmedSatyr
Jan 26 2016 02:40
@kirah1314 My output is [[4,5],[4,5],[4,5]]
Bill
@kirah1314
Jan 26 2016 02:40
@ddeason37 any time you use a variable to access an object then yes you have to use bracket notation
Ryan
@ashket
Jan 26 2016 02:40
var newStr = str.split(“ “);
Satchmo37
@Satchmo37
Jan 26 2016 02:41
@kirah1314 brilliant, thanks!
CamperBot
@camperbot
Jan 26 2016 02:41
ddeason37 sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:41
@jackel27 you're also missing the fundamental part where you need to differentiate between three different outcomes
CamperBot
@camperbot
Jan 26 2016 02:41
:star: 862 | @kirah1314 | http://www.freecodecamp.com/kirah1314
cannelflow
@cannelflow
Jan 26 2016 02:41
@matthew3454 perhaps you can make if else their
JackeL
@jackel27
Jan 26 2016 02:41
okay, think I got this
var count = 0;
var bet;

function cc(card) {
  // Only change code below this line

  switch (card){
      case 2,3,4,5,6:
      count = 5;
      bet = "Bet";
      break;

    case 10,'J','Q','K','A':
      count = -5;
      bet = "Hold";
      break;

    case 7,8,9:
      count = 0;
      bet = "Hold";
      break;

    case 3,2,'A',10,'K':
      count = -1;
      bet = "Hold";
  }



  return count + " " + bet;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Bill
@kirah1314
Jan 26 2016 02:41
@JosephWolfe yes I noticed, use one loop and push method
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:41
sorry, two different outcomes @jackel27 -- you're not just saying the count and bet
you also need to say IF you are betting or holding
Calvoxel
@Calvoxel
Jan 26 2016 02:41
@ashket I tried it with that, but still the output is the same: the code is:
function reverseString(str) {
  var newStr = str.split(" ");
  newStr.reverse();
  newStr.join(" ");
  newStr.toString();
  return newStr;
}

reverseString("hello");
JackeL
@jackel27
Jan 26 2016 02:42
looks like it worked
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:42
you only bet in one situation, and hold in the other
cannelflow
@cannelflow
Jan 26 2016 02:42
@jackel27 not cout=5 it should count++ count 1 for each
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:42
oh good
Ryan
@ashket
Jan 26 2016 02:42
@Calvoxel You can also link them together.
JackeL
@jackel27
Jan 26 2016 02:42
could do one if statement else hold
matthew3454
@matthew3454
Jan 26 2016 02:42
@cannelflow what would be my conditional?
Calvoxel
@Calvoxel
Jan 26 2016 02:42
@ashket how?
cannelflow
@cannelflow
Jan 26 2016 02:42
@jackel27 you need if else
Ryan
@ashket
Jan 26 2016 02:42
@Calvoxel like
var newStr = str.split(“ “).reverse().join(“ “);
JackeL
@jackel27
Jan 26 2016 02:43
@cannelflow I could do if (card = 2,3,4,5,6) bet.. else hold
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:43
agreed -- that's what I used at the end
cannelflow
@cannelflow
Jan 26 2016 02:43
@matthew3454 like if that property is found return result otherwise not found
JackeL
@jackel27
Jan 26 2016 02:43
but, I also need to display the count also.
Ryan
@ashket
Jan 26 2016 02:43
@Calvoxel Scratch that you don’t want the space between the “”. I was thinking of a different problem.
cannelflow
@cannelflow
Jan 26 2016 02:43
@jackel27 yes like count + " Hold"
Calvoxel
@Calvoxel
Jan 26 2016 02:43
@ashket oh, ok
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:43
@jackel27 again, that's not how multiple ifs work :)
Ryan
@ashket
Jan 26 2016 02:43
@Calvoxel Since it’s one word you need to break it apart by each letter. So it would be .split(“”);
cannelflow
@cannelflow
Jan 26 2016 02:43
@jackel27 yes you can use if but switch is cleaner
Calvoxel
@Calvoxel
Jan 26 2016 02:44
@ashket yeah, just figured that out. Thanks!
CamperBot
@camperbot
Jan 26 2016 02:44
calvoxel sends brownie points to @ashket :sparkles: :thumbsup: :sparkles:
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:44
remember if the count is zero or negative, hold
CamperBot
@camperbot
Jan 26 2016 02:44
:star: 273 | @ashket | http://www.freecodecamp.com/ashket
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:44
if it's positive, bet
Justin Lewis
@lewisjustin26
Jan 26 2016 02:44

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2,3,4,5,6:
count = count ++;
break;
}
switch(card){
case 7,8,9:
count = count;
break;
}
switch(card){
case 10,'J','Q','K','A':
count = count --;
break;
}

if (count > 0){
return count + " Bet";
}
else if (count <= 0){
return count + " Hold";
}
// Only change code above this line
}

JackeL
@jackel27
Jan 26 2016 02:44
@gordondavidescu how do you do multiple values like that in ifs? the or || or seperated by???
Ryan
@ashket
Jan 26 2016 02:44
@Calvoxel Awesome. Yeah. Try linking when you can to keep your code cleaner.
JackeL
@jackel27
Jan 26 2016 02:44
or just resort to switch?
Calvoxel
@Calvoxel
Jan 26 2016 02:44
@ashket Got it! Thanks a lot. That'll be useful
CamperBot
@camperbot
Jan 26 2016 02:44
calvoxel sends brownie points to @ashket :sparkles: :thumbsup: :sparkles:
:warning: calvoxel already gave ashket points
JackeL
@jackel27
Jan 26 2016 02:44
sounds like a lot of 'or' statements
Slima Saad
@aqwzs12
Jan 26 2016 02:44

function chunk(arr, size) {
var arr2=[];
var a=0;
for(var i=0;i<arr.length/size;i++)
{
for(var j=0;j<size;j++)
{
arr2[i][j]=arr[a];
a++;
}
}
return arr2;
}

chunk([0, 1, 2, 3, 4, 5], 2);

Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:44
you could do that but all you really need at the end is -- if it's zero or under, hold
Justin Lewis
@lewisjustin26
Jan 26 2016 02:44
am I close at all
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:44
if it's not, bet
matthew3454
@matthew3454
Jan 26 2016 02:44
@cannelflow I updated my code in this manner:
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
JackeL
@jackel27
Jan 26 2016 02:45
good point
@gordondavidescu thanks
CamperBot
@camperbot
Jan 26 2016 02:45
jackel27 sends brownie points to @gordondavidescu :sparkles: :thumbsup: :sparkles:
:star: 358 | @gordondavidescu | http://www.freecodecamp.com/gordondavidescu
cannelflow
@cannelflow
Jan 26 2016 02:45
@lewisjustin26 you can't do like case 2,3,4,5,6: do like case 2: case 3: standered switch format
Slima Saad
@aqwzs12
Jan 26 2016 02:45
function chunk(arr, size) {
  var arr2=[];
  var a=0;
  for(var i=0;i<arr.length/size;i++)
    {
      for(var j=0;j<size;j++)
        {
          arr2[i][j]=arr[a];
          a++;
        }
    }
  return arr2;
}

chunk([0, 1, 2, 3, 4, 5], 2);
Gordon Davidescu
@gordondavidescu
Jan 26 2016 02:45
:)
CharmedSatyr
@CharmedSatyr
Jan 26 2016 02:45
@kirah1314 Thanks, I got it.
CamperBot
@camperbot
Jan 26 2016 02:45
josephwolfe sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 863 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Slima Saad
@aqwzs12
Jan 26 2016 02:46
why it's a wrong answer
Bill
@kirah1314
Jan 26 2016 02:46
@JosephWolfe glad to help! :thumbsup:
Slima Saad
@aqwzs12
Jan 26 2016 02:46
i have a problem they said that i cannot set property '0' of undefined ?!!
JuanFer253
@juanfer25
Jan 26 2016 02:46
how make this ??
Call the process function with an argument of 7 and assign its return value to the variable processed.
Bill
@kirah1314
Jan 26 2016 02:46
@aqwzs12 use one loop and look into the push and sliceor splice methods
matthew3454
@matthew3454
Jan 26 2016 02:46
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Slima Saad
@aqwzs12
Jan 26 2016 02:47
Ok i will try kirah
Justin Lewis
@lewisjustin26
Jan 26 2016 02:47
Alright i have it charged to the standard case format. Still isn't doing multiple cards
rphares
@rphares
Jan 26 2016 02:47
varName = functionName(whatIsCalled) @juanfer25
Ryan
@ashket
Jan 26 2016 02:47
@lewisjustin26 Can you paste your whole code please?
JuanFer253
@juanfer25
Jan 26 2016 02:48
ohh thanks @rphares
CamperBot
@camperbot
Jan 26 2016 02:48
juanfer25 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2007 | @rphares | http://www.freecodecamp.com/rphares
Justin Lewis
@lewisjustin26
Jan 26 2016 02:48
var count = 0;

function cc(card) {
  // Only change code below this line
    switch(card){
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
        count = count ++;
        break;
    }
    switch(card){
      case 7:
      case 8:
      case 9:
        count = count;
        break;
    }
    switch(card){
      case 10:
      case 'J':
      case 'Q':
      case 'K':
      case 'A':
      count = count --;
      break;
    }

  if (count > 0){
    return count + " Bet";
  }
  else if (count <= 0){
    return count + " Hold";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
rphares
@rphares
Jan 26 2016 02:48
sure thing :)
Ryan
@ashket
Jan 26 2016 02:48
@lewisjustin26 I found an if else statement to be easier for this one.
cannelflow
@cannelflow
Jan 26 2016 02:48
@matthew3454 checking
rphares
@rphares
Jan 26 2016 02:48
(feels the same, but everyone else says switch )
Rex Schrader
@SaintPeter
Jan 26 2016 02:49
@rphares Aww, you have your code private. I wanted to see how you were doing. ;)
Ryan
@ashket
Jan 26 2016 02:49
@lewisjustin26 Try it with something like
card > 1 && card < 7
matthew3454
@matthew3454
Jan 26 2016 02:49
@cannelflow ok
rphares
@rphares
Jan 26 2016 02:49
hahaha, I'm pretty sure you have magical ways around that, @SaintPeter ... :blush:
Rex Schrader
@SaintPeter
Jan 26 2016 02:50
@rphares Nope. My magical powers are strictly limited.
Bill
@kirah1314
Jan 26 2016 02:50
@lewisjustin26 you don't even need the else if condition, just use else
Justin Lewis
@lewisjustin26
Jan 26 2016 02:50
I had a few people suggest case for this one.
rphares
@rphares
Jan 26 2016 02:50
Well thats reassuring :)
Ryan
@ashket
Jan 26 2016 02:50
@lewisjustin26 Use that within an if else statement and then return out Your string and coiunt
Rex Schrader
@SaintPeter
Jan 26 2016 02:50
@rphares Also, I swore to never use them for personal gain.
rphares
@rphares
Jan 26 2016 02:50
haha, dunno what gain would come from that, but genuinely appreciate the integrity :)
Bill
@kirah1314
Jan 26 2016 02:51
@lewisjustin26 also it should be count = count - 1 or count--
cannelflow
@cannelflow
Jan 26 2016 02:53
@matthew3454 I CLEANED YOUR CODE CHECK IT NOW
// 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");
Justin Lewis
@lewisjustin26
Jan 26 2016 02:54

I got it to work. With this code: ```js
var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count ++;
break;
}
switch(card){
case 7:
case 8:
case 9:
count = count;
break;
}
switch(card){
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count --;
break;
}

if (count <= 0) {
return count + " Hold";
}
else {
return count + " Bet";
}
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
```

JuanFer253
@juanfer25
Jan 26 2016 02:54

// Setup
var processed = 2;

function process(num) {
return (num + 3) / 6;
}

// Only change code below this line
proccesed = process(6);

what is the fail ??
matthew3454
@matthew3454
Jan 26 2016 02:54
@cannelflow Thank You
CamperBot
@camperbot
Jan 26 2016 02:54
matthew3454 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 552 | @cannelflow | http://www.freecodecamp.com/cannelflow
Rex Schrader
@SaintPeter
Jan 26 2016 02:54
@lewisjustin26 BTW, you don't even need case statements for 7,8, and 9 - because count does not change at all.
cannelflow
@cannelflow
Jan 26 2016 02:55
@juanfer25 WHICH EXERCISE ?
Rex Schrader
@SaintPeter
Jan 26 2016 02:55
@juanfer25 Your math is wrong. it's 7, not 6. Everything else is correct.
Justin Lewis
@lewisjustin26
Jan 26 2016 02:55
That makes sense. Thanks everyone
JuanFer253
@juanfer25
Jan 26 2016 02:55
179
cannelflow
@cannelflow
Jan 26 2016 02:55
@juanfer25 btr if you write a name
rphares
@rphares
Jan 26 2016 02:55
@SaintPeter , did Assignment with a Returned Value get updated with different numbers?
Rex Schrader
@SaintPeter
Jan 26 2016 02:55
@juanfer25 That is not an exercise number, that's your brownie points. We need the name of the exercise.
rphares
@rphares
Jan 26 2016 02:56
its Assignment with a Returned Value
Rex Schrader
@SaintPeter
Jan 26 2016 02:56
@rphares I don't think so. Maybe that person modified the code?
JuanFer253
@juanfer25
Jan 26 2016 02:56
@SaintPeter thanks
CamperBot
@camperbot
Jan 26 2016 02:56
juanfer25 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2387 | @saintpeter | http://www.freecodecamp.com/saintpeter
matthew3454
@matthew3454
Jan 26 2016 02:56
@cannelflow So it was only the myObj[checkProp]that I was missing? Why didn't it work when I just used result?
Rex Schrader
@SaintPeter
Jan 26 2016 02:56
@juanfer25 Did you change the code?
rphares
@rphares
Jan 26 2016 02:57
thats what i was wondering-- today i advised someone incorrectly as the exercise had been updated, heh ... but that looks diff than mine above the line and the call :blush:
cannelflow
@cannelflow
Jan 26 2016 02:57
@matthew3454 because you didn'i assigned anything to result then
rphares @rphares heads out for a while... happy coding, all :blush:
JuanFer253
@juanfer25
Jan 26 2016 02:58
what change ??

// Setup
var processed = 2;

function process(num) {
return (num + 3) / 7;
}

// Only change code below this line
proccesed = process(6);

Rex Schrader
@SaintPeter
Jan 26 2016 02:59
@juanfer25 in order for processed to be 2, you need to pass a 7: (7 + 3)/5
@juanfer25 You see the "Only change code below this line"? We REALLY mean that.
@juanfer25 Click "Reset" on that exercise and get it back to the default code.
matthew3454
@matthew3454
Jan 26 2016 02:59
@cannelflow I see. Why specifically was the myObj[checkProp] necessary and not just something like say property?
JuanFer253
@juanfer25
Jan 26 2016 03:00
you can send the code please ??
Rex Schrader
@SaintPeter
Jan 26 2016 03:00
@matthew3454 checkProp is a variable which contains the name of a property to check. It's a parameter in the function.
@juanfer25 Click Reset. Big button, left hand side, under the run button.
JuanFer253
@juanfer25
Jan 26 2016 03:01
ready

// Setup
var processed = 2;

function process(num) {
return (num + 3) / 5;
}

// Only change code below this line
proccesed = process(7);

matthew3454
@matthew3454
Jan 26 2016 03:01
@SaintPeter okay, and property by itself is not associated with any of the properties? correct?
Rex Schrader
@SaintPeter
Jan 26 2016 03:01
@juanfer25 THen: processed = process(7); Note that I have corrected the spelling of processed
cannelflow
@cannelflow
Jan 26 2016 03:01
@matthew3454 as @SaintPeter said checkProp is a variable
matthew3454
@matthew3454
Jan 26 2016 03:02
@cannelflow thank you
CamperBot
@camperbot
Jan 26 2016 03:02
matthew3454 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:warning: matthew3454 already gave cannelflow points
Rex Schrader
@SaintPeter
Jan 26 2016 03:02
@matthew3454 property is not a variable. It's a description.
matthew3454
@matthew3454
Jan 26 2016 03:02
@SaintPeter oh
JuanFer253
@juanfer25
Jan 26 2016 03:02
ohh thanks much thanks you´re amazing @SaintPeter
CamperBot
@camperbot
Jan 26 2016 03:02
juanfer25 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: juanfer25 already gave saintpeter points
Rex Schrader
@SaintPeter
Jan 26 2016 03:03
@juanfer25 NP
matthew3454
@matthew3454
Jan 26 2016 03:03
@SaintPeter thank you
CamperBot
@camperbot
Jan 26 2016 03:03
matthew3454 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2388 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Jan 26 2016 03:03
@matthew3454 Now you've got me looking up that challenge, becuse I wonder if we inappropriately highlighted property
matthew3454
@matthew3454
Jan 26 2016 03:06
@SaintPeter sorry for the confusion. I don't think property is highlighted I was just confused and thought you could replace property with the the actual variable of checkProp
Alex
@wiscoay521
Jan 26 2016 03:06
im on the mutations bonfire... how do I use the string.indexOf to compare two different strings in an array?
Rex Schrader
@SaintPeter
Jan 26 2016 03:06
@matthew3454 Ah, ok
JackeL
@jackel27
Jan 26 2016 03:07
Another roadblock
Rex Schrader
@SaintPeter
Jan 26 2016 03:07
@wiscoay521 You can loop through one string, searching for one character at a time
JackeL
@jackel27
Jan 26 2016 03:07
with lookups.
'Using Objects for Lookups'
var count = 0;
var bet;

function cc(card) {
  // Only change code below this line

  switch (card){
      case 2,3,4,5,6:
      count = 5;
      bet = "Bet";
      break;

    case 10,'J','Q','K','A':
      count = -5;
      bet = "Hold";
      break;

    case 7,8,9:
      count = 0;
      bet = "Hold";
      break;

    case 3,2,'A',10,'K':
      count = -1;
      bet = "Hold";
  }



  return count + " " + bet;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
oops
wrong paste
// Setup
function phoneticLookup(val) {
  var result = lookup[val];

  // Only change code below this line

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

  };




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

// Change this value to test
phoneticLookup("charlie");
djeremy75
@djeremy75
Jan 26 2016 03:09
@jackel27 uh-oh you're to the one I got stuck on :p
JackeL
@jackel27
Jan 26 2016 03:10
I don't get it.. looks like it makes complete sense
djeremy75
@djeremy75
Jan 26 2016 03:10
i think you have the list but you have to lookup now
JackeL
@jackel27
Jan 26 2016 03:10
my var result does the lookup for me
lol
Ryan
@ashket
Jan 26 2016 03:11
@jackel27 Is that your code? or the default ?
djeremy75
@djeremy75
Jan 26 2016 03:11
oh whoops
JackeL
@jackel27
Jan 26 2016 03:11
my code
Rex Schrader
@SaintPeter
Jan 26 2016 03:11
@jackel27 Does that code work? It might actually work.
JuanFer253
@juanfer25
Jan 26 2016 03:11
i need help in stan in line in this who i can make this queue([], 1) should return 1
queue([2], 1) should return 2
queue([5,6,7,8,9], 1) should return 5
After queue(testArr, 10), myArr[4] should be 10
JackeL
@jackel27
Jan 26 2016 03:11
it states "cannot read property ;charlie' of undefined
@SaintPeter Yeah, I thought so too lol
Satchmo37
@Satchmo37
Jan 26 2016 03:11
@jackel27 where you're passing val to lookup is throwing you off. You need to rearrange the order of when you're looking up val
Rex Schrader
@SaintPeter
Jan 26 2016 03:12
@jackel27 The problem is that you'er accessing lookup before you define it.
JackeL
@jackel27
Jan 26 2016 03:12
oh @SaintPeter . Good call
@SaintPeter a duh moment there
@SaintPeter thanks
CamperBot
@camperbot
Jan 26 2016 03:12
jackel27 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2390 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Jan 26 2016 03:12
@jackel27 You could technically get away with it if you assigned it to result on another line. Because of hoisting - which is a real mind blower.
JackeL
@jackel27
Jan 26 2016 03:13
// Setup
function phoneticLookup(val) {


  // Only change code below this line

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

  };
  var result = lookup[val];




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

// Change this value to test
phoneticLookup("charlie");
that seemed to work, with the exception of undefined.
so i guess you can't use "" ... how about null? or isempty?
idk
djeremy75
@djeremy75
Jan 26 2016 03:15
I didn't have "" : undefined at all
JackeL
@jackel27
Jan 26 2016 03:15
right. so it defaults to undefined if nothing is assigned
I'm guessing
djeremy75
@djeremy75
Jan 26 2016 03:15
yeah I'm pretty sure
JackeL
@jackel27
Jan 26 2016 03:15
yup, that was it..
@djeremy75 thanks
djeremy75
@djeremy75
Jan 26 2016 03:16
no problem :)
Rex Schrader
@SaintPeter
Jan 26 2016 03:17
@jackel27 You should probably, technically, leave the definition of result up at the top and just do the assignment where you're assigning it.
Jean-Hubert
@teskar
Jan 26 2016 03:18

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty() === true) {
return result;
} else {
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("gift");

Need to have the value of a given property returned if it is found.
Else, it has to return "Not Found"
What would I put inside the brackets after property to have it return the value for a given property?
djeremy75
@djeremy75
Jan 26 2016 03:23
I can show you what I came up with, if you like
I don't want to spoil it for you though
Jean-Hubert
@teskar
Jan 26 2016 03:23
Maybe a hint
I want to be pointed in the right direction
Ryan
@ashket
Jan 26 2016 03:24
@teskar Which lesson is that?
Jean-Hubert
@teskar
Jan 26 2016 03:24
Basic JS "Testing Objects for Properties" near the end
Rex Schrader
@SaintPeter
Jan 26 2016 03:25
@teskar You need to pass hasOwnProperty the name of the property to check for.
Ryan
@ashket
Jan 26 2016 03:25
@teskar You’ll need somehting in the .hasOwnProperty().
@SaintPeter beat me to it lol
Jean-Hubert
@teskar
Jan 26 2016 03:26
("") don't work, but anything specific will only bring up that value
Yeondam Park
@yeondam88
Jan 26 2016 03:26
function truncate(str, num) {
  // Clear out that junk in your trunk

  if ( str.length > num) {
    return str.slice(0, ((num-3)-str.length)) + "...";
  } 

  if ( num <= 3 ){
    return str.slice(0,(num-str.length)) + "...";
  }

  //return str;
}

truncate("A-tisket a-tasket A green and yellow basket", 11);
How can I use those both if statement by case?
else if is not working
Satchmo37
@Satchmo37
Jan 26 2016 03:27
```
//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 lookUp(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)){
      //Something is off with how I'm returning the prop parameter
     return contacts[i][prop];
   } else if (contacts[i].firstName !== firstName){
     //This works!
     return "No such contact";
   } else if (contacts[i].hasOwnProperty(prop) === false){
     //This works!!
     return "No such property";
   }
  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
I get Akira's likes returned properly when i test the function. But when the challenges run all its tests, none of the correct props are returned