These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Jan 2016
Gregory Bilecki
@gbilecki
Jan 19 2016 00:00

``` function lookUp(firstName, prop) {
// Only change code below this line
var chex;
var chexl;

for (i = 0; i < contacts.length; i++) {
chex = contacts[i][prop];
if (contacts.hasOwnProperty(prop) === false) {
return "No such property";
} else {
return chex;
}
}
}
```

Brian
@sludge256
Jan 19 2016 00:00
@jvhensley I can explain less cryptically if you need further assistance
Gregory Bilecki
@gbilecki
Jan 19 2016 00:00
why isnt that working
Erland Lami
@Texber
Jan 19 2016 00:00
@sludge256 I'm not sure I understand
@sludge256 this is the example that it gives
Luke Wood
@LeWood16
Jan 19 2016 00:00
Does anyone know how to disable the super-annoying modal that comes up when you select your code (the one that says "Copy Link, Copy as Pretty Code, Copy as Plain Code")? It's taking me ten times as long to write something because of it
Erland Lami
@Texber
Jan 19 2016 00:00
var myObj = {
  prop1: "val1",
  prop2: "val2"
};
myObj.prop1; // val1
myObj.prop2; // val2
Brian
@sludge256
Jan 19 2016 00:01
that's how you would access the values
you should store them in a variable though to save them
I believe the code test checks the values of the variables that were provided on initial code load
Erland Lami
@Texber
Jan 19 2016 00:02
Yes so hat would be ballcap
and shirt would be jersey
but I'm not clear how to declare those from the testObj.hat; line
Devyn Hedin
@djhedin
Jan 19 2016 00:02
Hey @noeladd sorry but I have to go, I hope someone else can help you. I vaguely remember using a nested for loop when I did the challenge but I don't remember fully.
Rachel
@noeladd
Jan 19 2016 00:03
Thats ok @djhedin thanks for your help.
CamperBot
@camperbot
Jan 19 2016 00:03
noeladd sends brownie points to @djhedin :sparkles: :thumbsup: :sparkles:
:star: 244 | @djhedin | http://www.freecodecamp.com/djhedin
Brian
@sludge256
Jan 19 2016 00:03
@Texber these were the initial variables
var hatValue = testObj;      // Change this line
var shirtValue = testObj;    // Change this line
Erland Lami
@Texber
Jan 19 2016 00:04
yes
Gregory Bilecki
@gbilecki
Jan 19 2016 00:05
//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
 var chex;
 var chexl;

 for (i = 0; i < contacts.length; i++) {
   chex = contacts[i][prop];
   if (contacts.hasOwnProperty(prop) === false) {
     return "No such property"; 
   } else {
    return chex;
}
}
}
// Change these values to test your function

lookUp("Akira", "likes");
Erland Lami
@Texber
Jan 19 2016 00:06
do I then change the first line to : var testObj.hat; ?
Gregory Bilecki
@gbilecki
Jan 19 2016 00:06
why is my return chex; completely getting bypassed?
Brian
@sludge256
Jan 19 2016 00:06
@Texber no keep the variable name as hatValue
but assign the value of testObj.hat
Jessie
@jvhensley
Jan 19 2016 00:07
@sludge256 yeah, i do need further assistance. i've read all the threads on this lesson, and i went into github and looked at the code when they created the lesson, and i still don't get it. i've tried removing the final else statement, and it still doesn't work, like so:
function lookUp(firstName, prop){
// Only change code below this line
 for (i=0; i<contacts.length; i++) {

   if (contacts[i].hasOwnProperty(firstName)) {

     if (contacts[i].hasOwnProperty(prop)) {
       return contacts[i][prop];
     } else {
       return "No such property";
     } 
   } 
 } 
  return "No such contact";
// Only change code above this line
}
Erland Lami
@Texber
Jan 19 2016 00:07
I
I see like this.
var hatValue = testObj.hat;      // Change this line
var shirtValue = testObj.jersey;
Gregory Bilecki
@gbilecki
Jan 19 2016 00:08
@jvhensley this waypoint is killing me
Brian
@sludge256
Jan 19 2016 00:08
jersey is the value not the property name @Texber
Jessie
@jvhensley
Jan 19 2016 00:08
@gbilecki tell me about it. i've even tried code that people said worked, and it still doesn't work
Erland Lami
@Texber
Jan 19 2016 00:09
I'm still confused @sludge256
var hat = testObj.hat;      // Change this line
var jersey = testObj.jersey;
Rachel
@noeladd
Jan 19 2016 00:09
@gbilecki and @jvhensley it’s killing me too. Here’s my try.
for (i = 0; i<contacts.length; i++){
  if (contacts[i].firstName == firstName){
    if (contacts[i].hasOwnProperty(prop) === true){
      return contacts[i].prop;
  } else {
    return "No such property";
  }
  }
   else {
    return "No such contact";
  }
 }
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:09
@jvhensley When should your first condition be true?
inkmotor
@inkmotor
Jan 19 2016 00:10
@jvhensley dude, for what it's worth, I've gone bald and developed a duodenal ulcer trying to get past this waypoint too.
Brian
@sludge256
Jan 19 2016 00:10
@Texber notice how property names are on the leftside?
// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:10
@noeladd return; will leave the for loop. try moving the last return behind it
Gregory Bilecki
@gbilecki
Jan 19 2016 00:10
@noeladd your return contacts[i].prop should be return contacts[i][prop] imo
Erland Lami
@Texber
Jan 19 2016 00:11
yes
Brian
@sludge256
Jan 19 2016 00:11
@jvhensley this is your problem now
if (contacts[i].hasOwnProperty(firstName)) {
also you should add var in your for loop in front of i=0
Dan
@dan-fahey
Jan 19 2016 00:12
Hi has anyone managed to solve http://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables ? Can't pass the final test, think there's a bug?
Brian
@sludge256
Jan 19 2016 00:12
@Texber so you are trying to access the value of the one named shirt
there is no property name of jersey
Jessie
@jvhensley
Jan 19 2016 00:13
@maxschlosser the first condition should be true when the ith contact has a property that matches the argument for firstName. Such as, in the first test, if contact[0] has a property matching Akira, that would be true. correct?
Heriberto Sosa
@sosaheri
Jan 19 2016 00:14
help me what is wrong
CamperBot
@camperbot
Jan 19 2016 00:14
no wiki entry for: me what is wrong
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:14
@jvhensley yes. but you are calling .hasOwnProperty(). What is this function doing?
Heriberto Sosa
@sosaheri
Jan 19 2016 00:14
function myTest(val) {
  // Only change code below this line

  if ((val >= 10) || (val <= 20) ) {
    return "Outside";
  }


  // Only change code above this line
  return "Inside";
}

// Change this value to test
myTest(15);
Brian
@sludge256
Jan 19 2016 00:14
@jvhensley It's checking to see if the contact object has a property name of firstName but it won't check if the value matches the one you're searching for
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:14
@sludge256 I'm trying to have him realize that for himself x)
Rachel
@noeladd
Jan 19 2016 00:15
@maxschlosser tried that still not working
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:15
or her
sciand6
@sciand6
Jan 19 2016 00:15
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
Rachel
@noeladd
Jan 19 2016 00:15
function lookUp(firstName, prop){
// Only change code below this line
 for (i = 0; i<contacts.length; i++){
  if (contacts[i].firstName == firstName){
    if (contacts[i].hasOwnProperty(prop) === true){
      return contacts[i].prop;
  } else {
    return "No such property";

 }
  }
 }
  return "No such contact";
Brian
@sludge256
Jan 19 2016 00:15
@maxschlosser sorry I missed the in between messages
Jessie
@jvhensley
Jan 19 2016 00:15
@maxschlosser @sludge256 okay thanks, i will go back and look again.
CamperBot
@camperbot
Jan 19 2016 00:15
jvhensley sends brownie points to @maxschlosser and @sludge256 :sparkles: :thumbsup: :sparkles:
:warning: jvhensley already gave sludge256 points
:star: 281 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Brian
@sludge256
Jan 19 2016 00:15
I lose some chat awareness when I help more than one person
Erland Lami
@Texber
Jan 19 2016 00:15
@sludge256 I'm trying to understand
Brian
@sludge256
Jan 19 2016 00:16
leave your variable names as they were originally
Erland Lami
@Texber
Jan 19 2016 00:16
so the property of shift has a value of jersey?
Brian
@sludge256
Jan 19 2016 00:16
yes
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:16
@noeladd try changing contacts[i].prop to contacts[i][prop]
Brian
@sludge256
Jan 19 2016 00:16
you are accessing the the value hat correctly
but not of shirt
Erland Lami
@Texber
Jan 19 2016 00:16
so I'm trying to give the var of hatValue a property?
Rachel
@noeladd
Jan 19 2016 00:18
ok thanks @maxschlosser that worked. I’m slightly confused as to why that made a difference. I’ll go back and see if I can understand.
CamperBot
@camperbot
Jan 19 2016 00:18
noeladd sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 282 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Erland Lami
@Texber
Jan 19 2016 00:18
ok so then it follows that : var shirtvalue = testObj.jersey; no?
liiam89
@liiam89
Jan 19 2016 00:18
Can somebody help me with a JavaScript lesson? The lesson is <i>Testing Objects for Properties</i>
Brian
@sludge256
Jan 19 2016 00:18
the value of jersey is accessible under the property name of shirt
liiam89
@liiam89
Jan 19 2016 00:19
Thought the italics would work.
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:19
@noeladd [prop] will be replaced by the value of prop while .prop tries to read a value namend prop, if I'm not mistaken
Brian
@sludge256
Jan 19 2016 00:19
@Texber notice how you're not doing testObj.ballcap?
for hat
but that's what you're attempting to do with the shirtValue
Erland Lami
@Texber
Jan 19 2016 00:20
I see. So by putting in shirt, I'm telling it to pull up the shiftvalue of jersey?
Rachel
@noeladd
Jan 19 2016 00:20
@maxschlosser Ok that makes sense I think the firstName part was confusing me because firstName was both the variable and the prop name so the dot notation worked there.
Brian
@sludge256
Jan 19 2016 00:20
@Texber well you don't know that it will be jersey in some other code
you just want whatever the shirt is
liiam89
@liiam89
Jan 19 2016 00:20
Can somebody tell me why this is returning the property name rather than the value?

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

function checkObj(checkProp) {
// Your Code Here

if(myObj.hasOwnProperty(checkProp)){
return checkProp;
}else{
return "Not Found";
}

}

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

Erland Lami
@Texber
Jan 19 2016 00:20
I see
liiam89
@liiam89
Jan 19 2016 00:21
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here



  if(myObj.hasOwnProperty(checkProp)){
    return checkProp;
  }else{
    return "Not Found";
  }




}

// Test your code by modifying these values
checkObj("gift");
Brian
@sludge256
Jan 19 2016 00:21
@Texber but in this case yes you are getting a value of jersey
Erland Lami
@Texber
Jan 19 2016 00:21
I see
thanks so much @sludge256
CamperBot
@camperbot
Jan 19 2016 00:21
texber sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:warning: texber already gave sludge256 points
liiam89
@liiam89
Jan 19 2016 00:22
Anybody?
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:22
@liiam89 What will be the value returned by return checkProp;
liiam89
@liiam89
Jan 19 2016 00:22
pony
@maxschlosser
Rather, that is the value I'm trying to get it to return. It's returning 'gift'/
The property name.
Ettiene Grobler
@egrobler
Jan 19 2016 00:24
@liiam89 you're just returning the string that got passed in the function. you need to do something with that string.
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:24
@liiam89 You need to actually read from your object using that string as a key.
liiam89
@liiam89
Jan 19 2016 00:24
Yeah I figured I had to use dot notation to access its value. But return checkProp.value did not work for me.
Ettiene Grobler
@egrobler
Jan 19 2016 00:25
@liiam89 bracket notation?
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:25
checkProp is the name of the property you want to access, not the object with the property
Ettiene Grobler
@egrobler
Jan 19 2016 00:26
@liiam89 yeah so myObj is the object you're looking at.
liiam89
@liiam89
Jan 19 2016 00:28
Oh sorry. myObj.checkProp
But what goes inside the brackets?
Ettiene Grobler
@egrobler
Jan 19 2016 00:29
@liiam89 sorry I didn't read your reply properly. you could use either bracket or dot notation (unless the exercise specifies one) to access a property of an object in most cases.
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:29
@liiam89 obj.prop will look for a property named prop. obj[prop] will look for a property with a name equal to props value, at least it did in all examples i tried
Ettiene Grobler
@egrobler
Jan 19 2016 00:29
@liiam89 so either myObj.checkProp like you said or else myObj[checkProp] .
liiam89
@liiam89
Jan 19 2016 00:30
What's the syntax for returning the value of a property?
Or accessing it, rather.
Ettiene Grobler
@egrobler
Jan 19 2016 00:30
@maxschlosser bracket notation is usually used for properties with strings as names (where there are spaces in the string, etc.)
@liiam89 you access it like we just explained above. return it by saying return myObj.prop or whatever.
@liiam89 show us your code again if you're still stuck
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:32
This message was deleted
liiam89
@liiam89
Jan 19 2016 00:32
// 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");
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:32
@egrobler Yes, but as far as i know it will also replace variables with their value.
@egrobler Which means myObj[checkProp] == myObj["gift"] while myObj.checkProp != myObj.gift
Warren
@warrenonline
Jan 19 2016 00:34
wiki profile lookup
CamperBot
@camperbot
Jan 19 2016 00:34

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

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

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

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

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:34
Use bracket notation:
  • When the property name is contained in a variable, e.g. obj[foo].
  • The property name contains characters not permitted in identifiers, e.g. starts >with a digit†, or contains a space or dash (-), e.g. obj["my property"].
@egrobler exactly what i was getting at
Ettiene Grobler
@egrobler
Jan 19 2016 00:35
@liiam89 have you tried bracket notation
@liiam89 ?
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:35
@liiam89 checkProp is a variable so you have to use bracket notation since the dot notation wont replace it with the actual value
liiam89
@liiam89
Jan 19 2016 00:35
No. I'll try now.
Omg.
Ettiene Grobler
@egrobler
Jan 19 2016 00:36
@maxschlosser ok then we are in agreement :)
liiam89
@liiam89
Jan 19 2016 00:36
That worked.
Ettiene Grobler
@egrobler
Jan 19 2016 00:36
@liiam89 nice one man. congrats! :)
liiam89
@liiam89
Jan 19 2016 00:38
Okay.
Thanks @egrobler @maxschlosser @warrenonline
CamperBot
@camperbot
Jan 19 2016 00:39
liiam89 sends brownie points to @egrobler and @maxschlosser and @warrenonline :sparkles: :thumbsup: :sparkles:
:star: 283 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
:star: 267 | @egrobler | http://www.freecodecamp.com/egrobler
:star: 225 | @warrenonline | http://www.freecodecamp.com/warrenonline
Maximilian Schlosser
@maxschlosser
Jan 19 2016 00:39
@camperbot Wat? x)
Wilson Heres
@hereswilson
Jan 19 2016 00:42
function destroyer(arr) {
  function match(value){
    for(var i=1; i<arguments.length;i++){    
     if(value===arguments[i]){
     return false;  
    }
   }
   return true;
  }
   var destroyed = arr.filter(match); 
    return destroyed;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Trying to get an output of [1,1], what am I doing wrong?
moukhtari
@moukhtari
Jan 19 2016 00:42
Who else in here is still doing the profile lookup challenge?
Javier Madrid
@jamc92
Jan 19 2016 00:49
Hi campers! :)
I'm having some waypoint troubles
Andrew Bales
@agbales
Jan 19 2016 00:51
@jamc92 What seems to be the trouble?
William Reed
@reforma
Jan 19 2016 00:55
can anyone tell me what i have done wrong here
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (answer){
    case 1:
      "alpha";
      break;
    case 2:
      "beta";
      break;
    case 3:
      "gamma";
      break;
    case 4:
      "delta";
      break;

  }


  // Only change code above this line  
  return answer;  
}
Andrew Bales
@agbales
Jan 19 2016 00:57
@reforma You'll want to return answer as "alpha" or "beta" etc.
Munish Tayal
@munishtayal
Jan 19 2016 00:57
@reforma you are not storing the strings in variable "answer"
William Reed
@reforma
Jan 19 2016 00:57
@agbales @munishtayal Thanks
CamperBot
@camperbot
Jan 19 2016 00:57
reforma sends brownie points to @agbales and @munishtayal :sparkles: :thumbsup: :sparkles:
:star: 263 | @munishtayal | http://www.freecodecamp.com/munishtayal
Venkat Polumahanti
@venkat4541
Jan 19 2016 00:59
Hi, I need help with 'Stand in Line' exercise. It is adding and removing elements to/from queues
function queue(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(Arr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
CypherY
@CypherY
Jan 19 2016 00:59
Instructions
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 value1:
"alpha";
break;
switch (val) {
case value2:
"beta";
break;
switch (val) {
case value3:
"gamma";
break;
switch (val) {
case value4:
"delta";
break;

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

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

cant figure out how to do this one.... this is what I have thus far...?
Munish Tayal
@munishtayal
Jan 19 2016 01:01
@CypherY switch will be used only once, Rest will be cases inside switch
Venkat Polumahanti
@venkat4541
Jan 19 2016 01:01
I'm getting a 'RangeError: Maximum call stack size exceeded' error in console output
Munish Tayal
@munishtayal
Jan 19 2016 01:02
switch (answer){ case 1: answer = "alpha"; break; case 2: answer = "beta"; @CypherY
Herman Fassett
@HermanFassett
Jan 19 2016 01:02
@venkat4541 when that happens, just reload the page
Eric Saldivar
@esaldivar
Jan 19 2016 01:03
hello I need a little help with the Golf Code challenge:
function golfScore(par, strokes) {
  // Only change code below this line

  if(strokes>=par+3) {
    return "Go Home!";
  } else if(strokes==par+2) {
    return "Double Bogey";
  } else if(strokes==par+1) {
    return "Bogey"; 
  } else if(strokes==par) {

    return "Par";
  } else if(strokes==par-1) {
    return "Birdie";
  } else if(strokes==2) {
    return "Eagle";
    } else if(strokes== 1) {

      return "Hole-in-one!";
    }



  return "Change me.";
  // Only change code above this line
}

// Change these values to test
golfScore(1, 1);
Andrew Bales
@agbales
Jan 19 2016 01:03
@venkat4541 The code looks good to me. Rechecked mine, and they're identical
Javier Madrid
@jamc92
Jan 19 2016 01:04
@agbales Thank you. I already fixed it! :)
CamperBot
@camperbot
Jan 19 2016 01:04
jamc92 sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 286 | @agbales | http://www.freecodecamp.com/agbales
Andrew Bales
@agbales
Jan 19 2016 01:05
:)
Erland Lami
@Texber
Jan 19 2016 01:05
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16];       // Change this Line
var player = "Montana";   // Change this Line
frostmere
@removed~frostmere
Jan 19 2016 01:05
Need help with 'Smallest Common Multiple'
Erland Lami
@Texber
Jan 19 2016 01:06
It's not accepting testObj[16]; as an answer
frostmere
@removed~frostmere
Jan 19 2016 01:06
I have no idea how to solve it..
Venkat Polumahanti
@venkat4541
Jan 19 2016 01:06
@agbales no luck for me
Can you share your code?
@HermanFassett didn't work
Erland Lami
@Texber
Jan 19 2016 01:06
Please help anyone.. I'm trying to use the playerNumber variable to lookup player 16 in testObj
Pete Considine
@pjconsidine
Jan 19 2016 01:06
you can't use numbers for field names
Andrew Bales
@agbales
Jan 19 2016 01:06
@venkat4541 Yes, let me grab that.
Pete Considine
@pjconsidine
Jan 19 2016 01:07
(hi everyone)
Andrew Bales
@agbales
Jan 19 2016 01:07
function queue(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();

}

// Test Setup
var testArr = [1,2,3,4,5];
Pete Considine
@pjconsidine
Jan 19 2016 01:07
@Texber object names have to be valid variable names
so no numbers or symbols
Eric Saldivar
@esaldivar
Jan 19 2016 01:08
hello I need a little help with the Golf Code challenge:
function golfScore(par, strokes) {
  // Only change code below this line

  if(strokes>=par+3) {
    return "Go Home!";
  } else if(strokes==par+2) {
    return "Double Bogey";
  } else if(strokes==par+1) {
    return "Bogey"; 
  } else if(strokes>=par){
    return "Par";
  } else if(strokes==par-1){
    return "Birdie";
  } else if(strokes==2) {
    return "Eagle";
    } else if(strokes==1) {

      return "Hole-in-one!";
    }



  return "Change me.";
  // Only change code above this line
}

// Change these values to test
golfScore(4,1);
Erland Lami
@Texber
Jan 19 2016 01:08
So if I'm trying to lookup player 16
how would I go about that?
Pete Considine
@pjconsidine
Jan 19 2016 01:09
easiest way would be to write out sixteen instead of numbers
I guess
Andrew Bales
@agbales
Jan 19 2016 01:09
@esaldivar Are any of your responses working so far?
Pete Considine
@pjconsidine
Jan 19 2016 01:09
"sixteen" : "Montana" or whatever
I'd say you could try "16" as a string instead, but I don't know if it gets automatically converted to a number
I'd try that, though
probably easier than using words
Erland Lami
@Texber
Jan 19 2016 01:10
it's not being accepted
Pete Considine
@pjconsidine
Jan 19 2016 01:10
what is it you're working on @Texber ?
one of the FCC challenges?
Erland Lami
@Texber
Jan 19 2016 01:11
Accessing Objects Properties with Variables
it's in basic javascript
Pete Considine
@pjconsidine
Jan 19 2016 01:11
oh
one sec
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:12
hi guys, i need a little help with the challenge "Stand In Line"
function queue(arr, item) {
  // Your code here

  arr=arr.push(item);

  arr=arr.shift();


  return arr; // 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));
Erland Lami
@Texber
Jan 19 2016 01:12
np @pjconsidine
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:12
i don't really understand what i have to do... and I always get the RANGEERROR: Maximum call stack size exceeded
Andrew Bales
@agbales
Jan 19 2016 01:12
@bcnjordi9 You don't need to assign arr that way for this one.
Mike Morkes
@TheMorkDaddy
Jan 19 2016 01:13

okay, so I'm so close on Falsy Bouncer, but I can't quite put it to bed. I have a few questions about .filter, too, because I'm not sure I really understand it. So here's where I am:

function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  var newArr = arr.filter(function(el) { return el !== false && el !== null && el !== 0 && el !== "" && el !== undefined;  });

return newArr;

}

bouncer([false, null, 0, NaN, undefined, ""]);

This solution checks off any array with regular strings and numbers, as well as any array with a random falsy in it, but the falsy array with NaN is tripping me up. I don't think I understand what I need to do to get NaN to drop off. Also, I figured out through trial and error that I needed to connect all my comparisions via && - why doesn't || work?

Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:13
what do you mean @agbales
Pete Considine
@pjconsidine
Jan 19 2016 01:13
@Texber I see the problem. the challenge is asking you to make the variable the thing you want to look up and then plug in the variable name in the next statement
William Reed
@reforma
Jan 19 2016 01:14
can anyone tell me what i have wrong here
// Setup
function abTest(a, b) {
  // Only change code below this line
  if ((a,b)<0) 
  {return "undefined";}


  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);
Andrew Bales
@agbales
Jan 19 2016 01:14
Right now you're saying arr = ... if you wanted to assign it to a new variable you could say var newVariable = ... , but in this case you can perform the push and shift without that.
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:14
do you mean this:
function queue(arr, item) {
  // Your code here

  arr.push(item);

  arr.shift();


  return arr; // Change this line
}
Erland Lami
@Texber
Jan 19 2016 01:15
@pjconsidine I'm having a hard time comprehending what that means on this one
Andrew Bales
@agbales
Jan 19 2016 01:15
@bcnjordi9 Very close. But you're wanting to return that shift item, right?
(the number that's shifted, I should say)
Pete Considine
@pjconsidine
Jan 19 2016 01:16
@Texber you've got testObj[16], right? It wants you to add an extra step to put that 16 in there
Erland Lami
@Texber
Jan 19 2016 01:17
add another variable?
Pete Considine
@pjconsidine
Jan 19 2016 01:17
yup
they put the variables in there for you
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:17
oh, i think i get your point @agbales
let me try
Pete Considine
@pjconsidine
Jan 19 2016 01:17
you just need to put the pieces together the way they want you to
Andrew Bales
@agbales
Jan 19 2016 01:17
@bcnjordi9 Notice the " //change this line " comment. Right now it's returning the array that was passed in, right?
Erland Lami
@Texber
Jan 19 2016 01:19
@pjconsidine so to complete it I need to add var testObj ?
Pete Considine
@pjconsidine
Jan 19 2016 01:19
@Texber you need to assign something to var playerNumber and then use it to get the result
you shouldn't need to add any lines or anything. Just edit the ones that are there.
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:20

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


  arr.push(item);

  var solution = arr[0];

  arr.shift();

  return solution;// Change this line
}
Erland Lami
@Texber
Jan 19 2016 01:21
@pjconsidine I'm still a bit lost
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:21
i think this would work, but I don't really get what they want to get out of the function
Andrew Bales
@agbales
Jan 19 2016 01:21
@bcnjordi9 the last version seemed a bit closer, actually. Maybe we should just talk through what it's asking for.
Pete Considine
@pjconsidine
Jan 19 2016 01:21
`var playerNumber ; var player;
var playerNumber ; // Change this Line var player ; // Change this Line
NemanjaMandic
@NemanjaMandic
Jan 19 2016 01:22

Can someone help me with Profile lookup practice:
function lookUp(firstName, prop){

for(var i=0; i < contacts.length; i++){
if(firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such contact";
}
}
// Only change code above this line
}

What am i doing wrong here??

Andrew Bales
@agbales
Jan 19 2016 01:22
@bcnjordi9 So, it wants you to push a new number (item) and then take the first number off. Then return that number you took off, right?
Pete Considine
@pjconsidine
Jan 19 2016 01:22
@Texber It's asking you to edit the line that says "var playerNumber"
so you need to assign that variable a value
var playerNumber = something
Erland Lami
@Texber
Jan 19 2016 01:23
ok but the line underneath it does assign it a value. It assigns it the value of Montana
Andrew Bales
@agbales
Jan 19 2016 01:23

Your last code was this:

 arr.push(item);

  arr.shift();

  return arr; // Change this line

And I was saying that you weren't returning the shifted number, but instead arr

Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:24
@agbales yes, but I'm afraid if i use the shift method, the number gets lost
Andrew Bales
@agbales
Jan 19 2016 01:24
Right.
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:24
thats why i created a var "solution" to store the number
Pete Considine
@pjconsidine
Jan 19 2016 01:24
@Texber you may want to reset the challenge.
when I look at it I see this:
var playerNumber;       // Change this Line
var player = testObj;   // Change this Line
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:25
and if I use return before the shift, the function doesn't go to the end
Pete Considine
@pjconsidine
Jan 19 2016 01:25
(those are the last two lines)
Erland Lami
@Texber
Jan 19 2016 01:25
yes I did
I have the same now too
Pete Considine
@pjconsidine
Jan 19 2016 01:25
okay
Andrew Bales
@agbales
Jan 19 2016 01:25
Try having your return be your .shift()
Pete Considine
@pjconsidine
Jan 19 2016 01:26
so they want you to assign the variable a number and then use the variable to assign a value to "player"
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:26
do you mean:
```
function queue(arr, item) {
  // Your code here


  arr.push(item);

  return arr.shift();// Change this line
}
Erland Lami
@Texber
Jan 19 2016 01:27
so assign var playerNumber a number?
Pete Considine
@pjconsidine
Jan 19 2016 01:27
@Texber exactly
Andrew Bales
@agbales
Jan 19 2016 01:28
@bcnjordi9 That solution should work.
Erland Lami
@Texber
Jan 19 2016 01:28
var playerNumber = 16;       // Change this Line
var player = "Montana";   // Change this Line
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:28
the problem is that I can never see what I am returning... cause the console says all the time: RangeError: Maximum call stack size exceeded
Pete Considine
@pjconsidine
Jan 19 2016 01:28
almost @Texber
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:28
I reset many times and just write the solution I just showed you and seems not to work :(
Pete Considine
@pjconsidine
Jan 19 2016 01:28
var player should be defined in terms of testObj
Eric Saldivar
@esaldivar
Jan 19 2016 01:29
having trouble with Switch:
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case value1:
      "alpha";
      break;
      case value2:
      beta;
      break;
      case value3:
      gamma;
      break; 
  }


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

// Change this value to test
myTest(1);
Andrew Bales
@agbales
Jan 19 2016 01:29
@bcnjordi9 :( -- it's a solution that worked for me. I was also able to do it by setting the shifted number as a variable and then returning that variable.
Erland Lami
@Texber
Jan 19 2016 01:29
var playerNumber = 16;       // Change this Line
var player = testObj[Montana];
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:29
@agbales it's so weird...
Eina
@thelittleblacksmith
Jan 19 2016 01:30
@esaldivar you should assign alpha etc to answer
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:30
thats my code
```
function queue(arr, item) {
  // Your code here

  arr.push(item);

  return arr.shift();  // 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));
Eric Saldivar
@esaldivar
Jan 19 2016 01:30
@thelittleblacksmith so var answer ="alpha"?
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:30
all of it, and it returns always the same error... Maximum call stack size exceeded :(
Pete Considine
@pjconsidine
Jan 19 2016 01:31
closer, @Texber
Erland Lami
@Texber
Jan 19 2016 01:31
lol
Eina
@thelittleblacksmith
Jan 19 2016 01:31
@esaldivar you've already defined answer outside of the function right, so you just have to update it answer= 'alpha';
Pete Considine
@pjconsidine
Jan 19 2016 01:31
you're trying to get "Montana" without actually saying "montana"
Erland Lami
@Texber
Jan 19 2016 01:31
but I can't type 16 to call montana
Pete Considine
@pjconsidine
Jan 19 2016 01:32
right, but you have something else that means the same as "16" right?
you set it up in the line right before
Erland Lami
@Texber
Jan 19 2016 01:32
```
var playerNumber = 16;       // Change this Line
var player = testObj[playerNumber];
aha
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:32
okay... its a kind of bug @agbales
Erland Lami
@Texber
Jan 19 2016 01:33
thanks so much. You explained it very patiantly @pjconsidine
CamperBot
@camperbot
Jan 19 2016 01:33
texber sends brownie points to @pjconsidine :sparkles: :thumbsup: :sparkles:
:star: 348 | @pjconsidine | http://www.freecodecamp.com/pjconsidine
Pete Considine
@pjconsidine
Jan 19 2016 01:33
and there was much rejoicing!
;-)
CypherY
@CypherY
Jan 19 2016 01:33
Instructions
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 (answer) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "car";
break;
default:
answer = "stuff";
}

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

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

Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:33
i opened the same page on another tab
write the same code
CypherY
@CypherY
Jan 19 2016 01:33
error: b is not defined
Pete Considine
@pjconsidine
Jan 19 2016 01:33
my pleasure, @Texber
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:33
and the challenge is solved
CypherY
@CypherY
Jan 19 2016 01:33
how do I define a, b, and c?
Andrew Bales
@agbales
Jan 19 2016 01:33
@bcnjordi9 Yes! That's great.
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 01:33
however if I copy the right code into this tab, it won't be solved
thank you man @agbales ;)
CamperBot
@camperbot
Jan 19 2016 01:33
bcnjordi9 sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 287 | @agbales | http://www.freecodecamp.com/agbales
Eina
@thelittleblacksmith
Jan 19 2016 01:34
@CypherY they're supposed to be strings not variables
Andrew Bales
@agbales
Jan 19 2016 01:34
Glad it worked out in the end.
Eina
@thelittleblacksmith
Jan 19 2016 01:34
so case 'a': @CypherY
Venkat Polumahanti
@venkat4541
Jan 19 2016 01:35
thanks @agbales @bcnjordi9
CamperBot
@camperbot
Jan 19 2016 01:35
venkat4541 sends brownie points to @agbales and @bcnjordi9 :sparkles: :thumbsup: :sparkles:
:star: 237 | @bcnjordi9 | http://www.freecodecamp.com/bcnjordi9
:star: 288 | @agbales | http://www.freecodecamp.com/agbales
CypherY
@CypherY
Jan 19 2016 01:36
hmm... error message is gone but the code still isn't passing...?
Eina
@thelittleblacksmith
Jan 19 2016 01:36
what error is it giving you @CypherY ?
CypherY
@CypherY
Jan 19 2016 01:37
it is just giving me the default string
stuff
Eina
@thelittleblacksmith
Jan 19 2016 01:37
try refreshing the page?
Eric Saldivar
@esaldivar
Jan 19 2016 01:37
okay still working on switch coding :
function myTest(val) {
  var answer = "";
  // Only change code below this line
  answer= "alpha";
  answer= "beta";
  answer= "gamma";
  answer= "delta";

  switch (val){
    case value1:
      statement1;
      break;
  }

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

// Change this value to test
myTest(1);
having an error on statement1
Eina
@thelittleblacksmith
Jan 19 2016 01:38
@esaldivar you should assign values to answer depending on the case
Andrew Bales
@agbales
Jan 19 2016 01:38
@esaldivar Within each case you'll want to assign answer to a different word.
CypherY
@CypherY
Jan 19 2016 01:38
nothing
Eina
@thelittleblacksmith
Jan 19 2016 01:38
@CypherY you passed all the tests?
Eric Saldivar
@esaldivar
Jan 19 2016 01:39
like this:
  switch (val){
    case value1:
      "alpha";
      break;
?
CypherY
@CypherY
Jan 19 2016 01:39
No. It's still showing that I haven't passed the first three
myTest("a") should have a value of "apple" 1
myTest("b") should have a value of "bird" 2
myTest("c") should have a value of "cat" 3
Eina
@thelittleblacksmith
Jan 19 2016 01:40
case whatever:
answer = 'alpha';
break;
Pete Considine
@pjconsidine
Jan 19 2016 01:40
@CypherY your switch isn't set up correctly
Andrew Bales
@agbales
Jan 19 2016 01:40
@esaldivar Close. but set answer with answer= "alpha"
Pete Considine
@pjconsidine
Jan 19 2016 01:40
your options need to be within the switch statement
Andrew Bales
@agbales
Jan 19 2016 01:40
what @thelittleblacksmith posted, but be sure to have the ; after break.
Eina
@thelittleblacksmith
Jan 19 2016 01:40
edited lol
Andrew Bales
@agbales
Jan 19 2016 01:41
:)
Eina
@thelittleblacksmith
Jan 19 2016 01:41
@CypherY do you want to post your code here? or is it all good now?
CypherY
@CypherY
Jan 19 2016 01:42

function myTest(val) {
var answer = "";
// Only change code below this line
switch(a, b, c) {
case 'a':
answer = "apple";
break;
case 'b':
answer = "bird";
break;
case 'c':
answer = "car";
break;
default:
answer = "stuff";
}

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

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

Eina
@thelittleblacksmith
Jan 19 2016 01:42
@CypherY you need to put val in your switch, since that's what you're using to compare things to
CypherY
@CypherY
Jan 19 2016 01:43
Got it. thank you thank you
Daniel Starr
@dstarr1492
Jan 19 2016 01:46
I keep getting an error that says: Cannot assign to read only property
Eric Saldivar
@esaldivar
Jan 19 2016 01:46
still on switch :
function myTest(val) {
  var answer = "";
  // Only change code below this line

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

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

// Change this value to test
myTest(1);
all test answers is delta
Daniel Starr
@dstarr1492
Jan 19 2016 01:47
function titleCase(str) {

str = str.split(" ");

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

 str[i][0] =  str[i][0].toUpperCase();
  }


  return str;
}

titleCase("I'm a little tea pot");
Eina
@thelittleblacksmith
Jan 19 2016 01:47
@esaldivar you need to assign val to your switch as well, since that's what you're comparing it to
Eric Saldivar
@esaldivar
Jan 19 2016 01:48
@thelittleblacksmith Thanks!
CamperBot
@camperbot
Jan 19 2016 01:48
esaldivar sends brownie points to @thelittleblacksmith :sparkles: :thumbsup: :sparkles:
:star: 304 | @thelittleblacksmith | http://www.freecodecamp.com/thelittleblacksmith
Daniel Starr
@dstarr1492
Jan 19 2016 01:51

I keep getting an error that says: Cannot assign to read only property

function titleCase(str) {

str = str.split(" ");

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

 str[i][0] =  str[i][0].toUpperCase();
  }


  return str;
}

titleCase("I'm a little tea pot");

Does anyone know what could be the issue?

Gristel Periwinkle
@gristel
Jan 19 2016 01:53
I’m not getting that error
Did you try refreshing your page?
Daniel Starr
@dstarr1492
Jan 19 2016 01:53
yeah ive tried that.
Im guessing str[i][0] is read only because its declared outside the for loop?
Erland Lami
@Texber
Jan 19 2016 01:58
This is what I have so far, it's saying to Convert the switch statement into a lookup table called lookup. Use it to lookup val and return the associated string.
// 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");
Can anyone please help?
rphares
@rphares
Jan 19 2016 02:02
Sure--
so, you just need one more part, @Texber
you know you are going to return result,
fernandoRj
@fernandoRj
Jan 19 2016 02:02
[title](http://facebook.com)
Erland Lami
@Texber
Jan 19 2016 02:03
@rphares yes
rphares
@rphares
Jan 19 2016 02:03
but right now, result = " "
fernandoRj
@fernandoRj
Jan 19 2016 02:03
var code = "formatted";
Erland Lami
@Texber
Jan 19 2016 02:03
so result = "undefined"; ?
rphares
@rphares
Jan 19 2016 02:03
So you are probably going to want to assign it to lookup val
("Use it to lookup val and return the associated string.")
the examples of how to write that from the directions:
alpha[2]; // "Y"
alpha[24]; // "C"
Eric Saldivar
@esaldivar
Jan 19 2016 02:05
having trouble defining a :
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(4);
`
Erland Lami
@Texber
Jan 19 2016 02:06
@rphares I'm trying to figure out how to go about that
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:06
@Texber so in @rphares example. alpha should be lookup.
Erland Lami
@Texber
Jan 19 2016 02:06
you mean phoneticLookup?
rphares
@rphares
Jan 19 2016 02:07
no-- look at the var name
fernandoRj
@fernandoRj
Jan 19 2016 02:07
`var fernando = "burro"`
Munish Tayal
@munishtayal
Jan 19 2016 02:07
@esaldivar use "a"
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:08
no @Texber the lookup variable name
Teyanna Johnson
@teyanna
Jan 19 2016 02:08
Having some trouble as well

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

}

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

Eric Saldivar
@esaldivar
Jan 19 2016 02:08
@munishtayal Thanks!
CamperBot
@camperbot
Jan 19 2016 02:08
esaldivar sends brownie points to @munishtayal :sparkles: :thumbsup: :sparkles:
:star: 264 | @munishtayal | http://www.freecodecamp.com/munishtayal
Erland Lami
@Texber
Jan 19 2016 02:08
```
Eina
@thelittleblacksmith
Jan 19 2016 02:08
@teyanna you need to assign the strings to answer
Erland Lami
@Texber
Jan 19 2016 02:08

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

// 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;
}

lookup[alpha];
// Change this value to test
phoneticLookup("charlie");

Teyanna Johnson
@teyanna
Jan 19 2016 02:09
My
Erland Lami
@Texber
Jan 19 2016 02:09
// Setup
function phoneticLookup(val) {
  var result = "phoneticLookup";

  // 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;
}

lookup[alpha];
// Change this value to test
phoneticLookup("charlie");
rphares
@rphares
Jan 19 2016 02:09
closer,
but two things,
Teyanna Johnson
@teyanna
Jan 19 2016 02:09
mytest(4);
rphares
@rphares
Jan 19 2016 02:09
you aren't looking up alpha, @Texber , that was the example :blush: you are looking up val :)
Teyanna Johnson
@teyanna
Jan 19 2016 02:09
It did print with the first
John Cerpa
@johncerpa
Jan 19 2016 02:10
@rphares :hand:
rphares
@rphares
Jan 19 2016 02:10
that's just hanging out at the bottom, after the return, @Texber
Munish Tayal
@munishtayal
Jan 19 2016 02:10
@teyanna store the strings in variable
rphares
@rphares
Jan 19 2016 02:10
Hey, @johncerpa ! :hand:
Munish Tayal
@munishtayal
Jan 19 2016 02:11
@teyanna like answer = "alpha";
Erland Lami
@Texber
Jan 19 2016 02:11
I'm so confused lol
so I'm creating var lookup with all the parameters
Steven Ni
@Steven-C-Ni
Jan 19 2016 02:11
Hi I am stuck on the "Understand String Immutability" task. How do you include a screenshot in this chat forum?
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:11
@Texber delete phonetic lookup from your variable
you want lookup to be an empty string. " "
Eina
@thelittleblacksmith
Jan 19 2016 02:11
help format
CamperBot
@camperbot
Jan 19 2016 02:11

: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

Eina
@thelittleblacksmith
Jan 19 2016 02:11
@Steven-C-Ni :point_up:
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:12
sorry @Texber delete phonetic lookup from your result variable
rphares
@rphares
Jan 19 2016 02:12
ooh, i didn't even notice that change, lol-- def bedtime, all you @Nyarlat-hotep :)
Steven Ni
@Steven-C-Ni
Jan 19 2016 02:12
@thelittleblacksmith thank you!
CamperBot
@camperbot
Jan 19 2016 02:12
steven-c-ni sends brownie points to @thelittleblacksmith :sparkles: :thumbsup: :sparkles:
:star: 306 | @thelittleblacksmith | http://www.freecodecamp.com/thelittleblacksmith
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:12
you with me @Texber ?
Erland Lami
@Texber
Jan 19 2016 02:12
ok so by doing that
Yes I deleted it
so I'm returning the variable result which is an empty string
which will then be replaced by one of the parimeters I assigned to var lookup?
Gaege Root
@GaegeRoot
Jan 19 2016 02:14
What's good campers?
Erland Lami
@Texber
Jan 19 2016 02:15
  // 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;
}
this is what I have now

// 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");

[Challenge - Using Objects for Lookups (texber's solution)](http://www.freecodecamp.com/challenges/using-objects-for-lookups#?solution=%2F%2F%20Setup%0Afunction%20phoneticLookup(val%29%20%7B%0A%20%20var%20result%20%3D%20%22%22%3B%0A%0A%20%20%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20var%20lookup%20%3D%20%7B%0A%20%20%20%20%0A%20%20%20%20%22alpha%22%20%3A%20%22adams%22%2C%0A%20%20%20%20%22bravo%22%20%3A%20%22boston%22%2C%20%0A%20%20%20%20%22charlie%22%20%3A%20%22Chicago%22%2C%20%0A%20%20%20%20%22delta%22%20%3A%20%22Denver%22%2C%20%0A%20%20%20%20%22echo%22%20%3A%20%22Easy%22%2C%20%0A%20%20%20%20%22foxtrot%22%20%3A%20%22frank%22%2C%20%0A%20%20%7D%3B%0A%20%20%20%0A%20%20%2F%2F%20Only%20change%20code%20above%20this%20line%0A%20%20return%20result%3B%0A%7D%0A%0A%2F%2F%20Change%20this%20value%20to%20test%0AphoneticLookup(%22charlie%22%29%3B%0A)
// 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");
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:19
@Texber so we need to change our result variable before we return it.
Steven Ni
@Steven-C-Ni
Jan 19 2016 02:19

`// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
myStr = "Hello World";`

Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:19
Also capitalize your names
Steven Ni
@Steven-C-Ni
Jan 19 2016 02:20

`<// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
myStr = "Hello World";>`

Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:20
@Texber we are trying to lookup a value. In this case they have said that val will equal any value passed to the phoneticLookup function. In this case charlie is val
@Texber however we cannot lookup[charlie] because that is too specific. We can however lookup[val].
Christian Rosa
@ChristianRosa
Jan 19 2016 02:22
@Texber below your existing code try result = lookup.val
Erland Lami
@Texber
Jan 19 2016 02:27
  var lookup = {

    "alpha" : "adams",
    "bravo" : "boston", 
    "charlie" : "Chicago", 
    "delta" : "Denver", 
    "echo" : "Easy", 
    "foxtrot" : "frank", 
  };
   result = lookup.val
  // Only change code above this line
  return result;
like that? @Nyarlat-hotep
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:27
you have to captalize your names @Texber or it won't work. But yes
semi colon after val remember
this exercise is basically looking up a value with dot or bracket notation within our lookup object. What is confusing is that you are setting that lookup.val equal to a variable
Erland Lami
@Texber
Jan 19 2016 02:28
which names are you referring to?
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:28
adams, boston, frank
Erland Lami
@Texber
Jan 19 2016 02:28
o I see
I made that correction
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:29
did you succeed?
Erland Lami
@Texber
Jan 19 2016 02:29
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {

    "alpha" : "Adams",
    "bravo" : "Boston", 
    "charlie" : "Chicago", 
    "delta" : "Denver", 
    "echo" : "Easy", 
    "foxtrot" : "Frank", 
  };
   result = lookup.val;
  // Only change code above this line
  return result;
}


``````js
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {

    "alpha" : "Adams",
    "bravo" : "Boston", 
    "charlie" : "Chicago", 
    "delta" : "Denver", 
    "echo" : "Easy", 
    "foxtrot" : "Frank", 
  };
   result = lookup.val;
  // Only change code above this line
  return result;
}
sorry for double paste but this is what I have and it's not succeeding
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:30
so you do not need that last comma after frank. Also use [] around val.
@Texber you get a pass?
Erland Lami
@Texber
Jan 19 2016 02:31
it says phoneticLookup("alpha") should equal "Adams" and so forth
it says that for all of them
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:31
paste again please
all of it
Erland Lami
@Texber
Jan 19 2016 02:32
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {

    "alpha" : "Adams",
    "bravo" : "Boston", 
    "charlie" : "Chicago", 
    "delta" : "Denver", 
    "echo" : "Easy", 
    "foxtrot" : "Frank"
  };
   result = lookup.[val];
  // Only change code above this line
  return result;
}


// Change this value to test
phoneticLookup("charlie");
Jeremy Roe
@jeremyroe
Jan 19 2016 02:32
Hey guys - running into readonly error on the Record Collection challenge - is that something any of you have seen?
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:32
remove that . befor [val]
@jeremyroe I think you have to refresh
Erland Lami
@Texber
Jan 19 2016 02:32
YES!
Jeremy Roe
@jeremyroe
Jan 19 2016 02:33
Ok I'll give that a shot thanks @Nyarlat-hotep
CamperBot
@camperbot
Jan 19 2016 02:33
jeremyroe sends brownie points to @nyarlat-hotep :sparkles: :thumbsup: :sparkles:
:star: 128 | @nyarlat-hotep | http://www.freecodecamp.com/nyarlat-hotep
Erland Lami
@Texber
Jan 19 2016 02:33
thanks so much @Nyarlat-hotep
CamperBot
@camperbot
Jan 19 2016 02:33
texber sends brownie points to @nyarlat-hotep :sparkles: :thumbsup: :sparkles:
:star: 129 | @nyarlat-hotep | http://www.freecodecamp.com/nyarlat-hotep
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:33
@Texber you got it. I was stuck for a while too.
Erland Lami
@Texber
Jan 19 2016 02:33
so at the end where it says change this value to test
Steven Ni
@Steven-C-Ni
Jan 19 2016 02:34

```
// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
myStr = "Hello World";

Erland Lami
@Texber
Jan 19 2016 02:34
if I change it to bravo lets say... how would I test it?
Steven Ni
@Steven-C-Ni
Jan 19 2016 02:34
```

```// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
myStr = "Hello World";
```

Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:34
just delete what's in there and add "bravo"
@Texber
Jeremy Roe
@jeremyroe
Jan 19 2016 02:34
No go unfortunately - The specific error is "TypeError: Cannot assign to read only property 'artist' of 5439"
Erland Lami
@Texber
Jan 19 2016 02:34
right but nothing changes
how do I see the difference?
Bakari Holmes
@bakarih
Jan 19 2016 02:35

Having trouble understanding why this code chunk always returns Not Found: ```js
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here

var value = myObj.hasOwnProperty(checkProp);
if (value)
return myObj.checkProp;
else return "Not Found";
}

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

Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:35
@Texber you should see something different logged in the left hand column of the screen
Erland Lami
@Texber
Jan 19 2016 02:36
I see on the black bar
Munish Tayal
@munishtayal
Jan 19 2016 02:36
@bakarih kitten is a value not property. So it will return not found
Andrew Nguyen
@anguy95
Jan 19 2016 02:36
can someone help me with regex? how do i remove spaces, commas, and periods. im attempting to use /\s,./gi
however, its not working
Raymond To
@rayto510
Jan 19 2016 02:37
@anguy95 are you doing the bonfire?
Fidel Severino
@fidelscodes
Jan 19 2016 02:38
@anguy95 there's a way to remove all non alphanumeric characters
Raymond To
@rayto510
Jan 19 2016 02:38
/[\W_]/g
Fidel Severino
@fidelscodes
Jan 19 2016 02:39
www.regexr.com is helpful for sorting out regex
Tiago
@Kakouz
Jan 19 2016 02:39
function golfScore(par, strokes) {
  if (par && strokes < 2){
    return "Hole-in-one!";}
  else if (par && strokes < 3){
    return "Eagle";}
  else if (par  && strokes < 4){
    return "Birdie";}
  else if (par  && strokes < 5){
    return "Par";}
  else if (par  && strokes < 6){
   return "Bogey";} 
  else if (par  && strokes < 7){
     return "Double Bogey";}
  else if (par && strokes >=7)
     return "Go Home!";
}
golfScore(5, 5);
Can't figure it out why 5,5 doesn't return "Par"... On this challenge for like an hour :/ Am I missing something really bad?
John Cerpa
@johncerpa
Jan 19 2016 02:40
why par and strokes
Bakari Holmes
@bakarih
Jan 19 2016 02:40
@munishtayal changed to property. Get a blank output for existing properties
but get Not Found (which I should) for non-existent properties
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:41
@Kakouz you have to do some addition and subtraction in your statements.
Fidel Severino
@fidelscodes
Jan 19 2016 02:41
@Kakouz you don't really need to check for two conditions in each conditional
John Cerpa
@johncerpa
Jan 19 2016 02:41
for example
(strokes <= par - 2)
Fidel Severino
@fidelscodes
Jan 19 2016 02:41
^
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:41
if (strokes == 1) {
    return "Hole-in-one!";
  }
  else if (strokes <= par - 2) {
    return "Eagle";
  }
@Kakouz to get you started
Tiago
@Kakouz
Jan 19 2016 02:41
Hmmm
THX will check it out
@Nyarlat-hotep @fidelscodes @johncerpa Ty all!
John Cerpa
@johncerpa
Jan 19 2016 02:42
@Kakouz :+1:
Fidel Severino
@fidelscodes
Jan 19 2016 02:43
np :)
Bakari Holmes
@bakarih
Jan 19 2016 02:43
@munishtayal my question is -- does myObj.checkProp return the value if it exists? Or something else?
Fidel Severino
@fidelscodes
Jan 19 2016 02:44
@bakarih if you do myObj.checkProp it will literally look for a property named "checkProp"
Bakari Holmes
@bakarih
Jan 19 2016 02:45

function checkObj(checkProp) {
// Your Code Here

var value = myObj.hasOwnProperty(checkProp);
if (value)
return myObj.checkProp;
else return "Not Found";

@fidelscodes I passed checkProp as a parameter to a function hoping it would be replaced by the string property w/in the function
Fidel Severino
@fidelscodes
Jan 19 2016 02:48
Hmm try myObj.hasOwnProperty(checkProp) inside the condition for if (as opposed to assigning it to value
Andrew Nguyen
@anguy95
Jan 19 2016 02:49
@rayto510
Bakari Holmes
@bakarih
Jan 19 2016 02:50
@fidelscodes tried that. Same result
Andrew Nguyen
@anguy95
Jan 19 2016 02:50
@rayto510 hey sorry, thans. can tou explain to me the /[\W_]/g syntaax
Kevin
@KAlanHicks
Jan 19 2016 02:50
I'm struggling with Chunky Monkey. Anyone care to look at my code? Also, how do I paste my code in so it's that nice looking picture I see everyone posting?
Fidel Severino
@fidelscodes
Jan 19 2016 02:50
@bakarih can you paste the full code?
Raymond To
@rayto510
Jan 19 2016 02:50
@anguy95 sure. it's what i used to replace all non-alphanumeric characters with spaces
Bakari Holmes
@bakarih
Jan 19 2016 02:51

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

function checkObj(checkProp) {
// Your Code Here

//var value = myObj.hasOwnProperty(checkProp);
if (myObj.hasOwnProperty(checkProp))
return myObj.checkProp;
else return "Not Found";
}

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

Fidel Severino
@fidelscodes
Jan 19 2016 02:51
This message was deleted
This message was deleted
Raymond To
@rayto510
Jan 19 2016 02:52
@anguy95 like on the bonfire, i input a string like "00 (: /-\ :) 0-0". then the code str.replace(/[\W]/g,''); will output the string into "0000"
Andrew Nguyen
@anguy95
Jan 19 2016 02:52
@bakarih have you tried return myObj[checkProp];
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 02:52
@KAlanHicks hit the ``` key 3 times. Then hit shift + enter. paste your code into the white space
Raymond To
@rayto510
Jan 19 2016 02:53
str.replace(/[\W_]/g,'');
Bakari Holmes
@bakarih
Jan 19 2016 02:53
@anguy95 that did it!
Andrew Nguyen
@anguy95
Jan 19 2016 02:53
@rayto510 Yeah im on the same one, your thing works. thanks. Everything was working mying the non-alphanumeric. So was trying to see if there was a way
CamperBot
@camperbot
Jan 19 2016 02:53
anguy95 sends brownie points to @rayto510 :sparkles: :thumbsup: :sparkles:
:star: 254 | @rayto510 | http://www.freecodecamp.com/rayto510
Bakari Holmes
@bakarih
Jan 19 2016 02:53
Thanks @anguy95 !!!!
CamperBot
@camperbot
Jan 19 2016 02:53
bakarih sends brownie points to @anguy95 :sparkles: :thumbsup: :sparkles:
:star: 249 | @anguy95 | http://www.freecodecamp.com/anguy95
Kevin
@KAlanHicks
Jan 19 2016 02:54
function chunk(arr, size) {
  // Break it up.
  var newArray = [];
  var holderArray = [];
    for (var subIndex = 0; subIndex < arr.length; subIndex++){
      var counter = 0;
      holderArray.push(arr[subIndex]);
      if (counter == size){
        newArray.push(holderArray);
        holderArray = [];
      }
      if (counter < size){
        counter++;
      }
      else
        counter = 0;
    }
  return newArray;
}

chunk(["a", "b", "c", "d"], 2);
Andrew Nguyen
@anguy95
Jan 19 2016 02:54
@bakarih when you use a function parameter to check an object use the bracket. The dot notation will add that function parameter name to the object
Kevin
@KAlanHicks
Jan 19 2016 02:54
thanks @Nyarlat-hotep
CamperBot
@camperbot
Jan 19 2016 02:54
kalanhicks sends brownie points to @nyarlat-hotep :sparkles: :thumbsup: :sparkles:
:star: 130 | @nyarlat-hotep | http://www.freecodecamp.com/nyarlat-hotep
Kevin
@KAlanHicks
Jan 19 2016 02:54
Here is the goal in case you've forgotten "Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array."
Bakari Holmes
@bakarih
Jan 19 2016 02:55
@anguy95 OH! Whoops!
Thanks @anguy95
CamperBot
@camperbot
Jan 19 2016 02:55
bakarih sends brownie points to @anguy95 :sparkles: :thumbsup: :sparkles:
:warning: bakarih already gave anguy95 points
Fernando Ramirez
@Gords
Jan 19 2016 02:55
could someone help me? im stuck at caesar cipher
function rot13(str) { // LBH QVQ VG!
  var j = "";
  var x;
  for(var i = 0; i<str.length; i++)
  {
    x = str.charCodeAt(i)+13;
    if(x<65){
      x = str.charCodeAt(i);
    }
    else if(x > 90 )
    {
      x = x - 26;
    }
    j += String.fromCharCode(x);
  }


  return j;

}
Andrew Nguyen
@anguy95
Jan 19 2016 02:57
@Gords is this the one where the alphabet is shifted over?
Fernando Ramirez
@Gords
Jan 19 2016 02:57
yup
Kevin
@KAlanHicks
Jan 19 2016 02:57
I have an idea using the slice method that might work
Andrew Nguyen
@anguy95
Jan 19 2016 02:58
Is it shifted over only by one?
Fernando Ramirez
@Gords
Jan 19 2016 02:58
nope, by 13, it works, except with "?"
i don't know why
Andrew Nguyen
@anguy95
Jan 19 2016 02:58
hmm. I can tell you how to do it extremely inefficiently
Fernando Ramirez
@Gords
Jan 19 2016 02:59
it returns the expected result in all except in rot13("SERR YBIR?")
Andrew Nguyen
@anguy95
Jan 19 2016 02:59
You can do a for loop, and inside that for loop and use 26 switch cases, for the shift of 13
Fernando Ramirez
@Gords
Jan 19 2016 03:00
hmmmmm, well, yeah, that could work, but as you said
is extremely inefficient xdddd
Kevin
@KAlanHicks
Jan 19 2016 03:03
okay, my new code has got the first part fixed, I think I'm on the right track now.
function chunk(arr, size) {
  // Break it up.
  var newArray = [];
  var holder = 1;
  for (var i = 0; i < size; i++){
    newArray[i] = arr.slice(i * size,[holder * size]);
    holder *= size;
  }
  return newArray;
}

chunk(["a", "b", "c", "d"], 2);
Ron
@rphill03
Jan 19 2016 03:06
Stuck on "Check for Palindromes" Bonfire ...from researching I am aware there is an easier way using .split .reverse .join but I am trying to see my way through so all the effort isn't lost to some online code ...can someone take a look and let me know what is broken ..it only partially works
function palindrome(str) {
  // Good luck!
  var lowerClean = str.replace(/[^a-zA-Z]/g, "").toLowerCase();

  var length = lowerClean.length;
  var arr = [];
   arr = lower.split();

  var forward = "";
  var backward = "";
  for (var i = 0; i< length; i++)
    {
      forward = forward + arr[i];
    }
   for (var z = length; z > 0; z--)
     {
       backward = backward + arr[z];
     }
  if (forward === backward)
  {
   return true; 
  }
  else
    {
      return false;
    }
}



palindrome("race car");
the idea was to iterate forward through the array and store it as a variable then iterate in reverse and store that as a variable then compare the two "forward === backward"
Andrew Nguyen
@anguy95
Jan 19 2016 03:09
@rphill03 you can interate forward and backward with one for/while loop
Ron
@rphill03
Jan 19 2016 03:11
okay that would simplify it more but is there something wrong with the logic or syntax .. or should what I'm doing work?
Venkat Polumahanti
@venkat4541
Jan 19 2016 03:11
I'm stuck with "Return Early Pattern for Functions" exercise.
Can anyone help?
Andrew Nguyen
@anguy95
Jan 19 2016 03:11
@venkat4541 what are you having toruble with
Venkat Polumahanti
@venkat4541
Jan 19 2016 03:12

My code : ```js
// 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);
```

// 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);
Conditions that should return undefined are failing despite getting undefined printed in console
Andrew Nguyen
@anguy95
Jan 19 2016 03:13
@venkat4541 just get rid of that string undefined and put return;
'''return;'''
CamperBot
@camperbot
Jan 19 2016 03:13
:bulb: to format code use backticks! ``` more info
Andrew Nguyen
@anguy95
Jan 19 2016 03:13
return;
Venkat Polumahanti
@venkat4541
Jan 19 2016 03:13
@anguy95 wow thanks :)
CamperBot
@camperbot
Jan 19 2016 03:13
venkat4541 sends brownie points to @anguy95 :sparkles: :thumbsup: :sparkles:
:star: 251 | @anguy95 | http://www.freecodecamp.com/anguy95
Andrew Nguyen
@anguy95
Jan 19 2016 03:13
@venkat4541 No problem :smile:
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 03:20
hey @anguy95 you familiar with the Iterate over Arrays with map exercise?
Zach Valenta
@zachvalenta
Jan 19 2016 03:30

Random: anyone else stumped by 'Return Early Pattern for Functions'?

I can figure out how to return ‘undefined’, but stumped on how to return the numbers in the instructions based on the arguments provided.

// Setup
function abTest(a, b) {
  // Only change code below this line



  // 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);

And here are the arguments/return values:

abTest(2,2) should return a number
abTest(2,2) should return 8
abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
abTest(2,8) should return 18
abTest(3,3) should return 12

if (a < 0 || b < 0){return undefined;}
will get you undefined
but the arguments, just don't see how those work algebraically
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 03:32
@zachvalenta I believe that since neither 2 or 8 is less than 0. you are returning a random number
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 03:35
hi, i've got trouble with Accessing Nested Arrays in JSON
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line
I need to access "pine", but i don't come clear with the declaration they made separating "type" and "list"
the example they give is different, doesn't have such grups as type and list
Nyarlat-hotep
@Nyarlat-hotep
Jan 19 2016 03:37
@bcnjordi9 you are on the right track with myPlants. However there are two arrays within myPlants. You have to access the second array of myPlants. Trees is not something you can access, it is the value. You can however access what is inside the list array.
Zach Valenta
@zachvalenta
Jan 19 2016 03:37
@Nyarlat-hotep thanks for the help! I figured out what the issue was; I simply wasn't including:
CamperBot
@camperbot
Jan 19 2016 03:37
zachvalenta sends brownie points to @nyarlat-hotep :sparkles: :thumbsup: :sparkles:
:star: 131 | @nyarlat-hotep | http://www.freecodecamp.com/nyarlat-hotep
Zach Valenta
@zachvalenta
Jan 19 2016 03:37
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
inside my function
I thought we had to come up with the statement that would perform the operation
Jordi Vilagut Treserra
@jordivilagut
Jan 19 2016 03:39
thanks @Nyarlat-hotep , problem solved! ;)
CamperBot
@camperbot
Jan 19 2016 03:39
bcnjordi9 sends brownie points to @nyarlat-hotep :sparkles: :thumbsup: :sparkles:
:star: 132 | @nyarlat-hotep | http://www.freecodecamp.com/nyarlat-hotep
Wiley Debs
@Colortear
Jan 19 2016 03:45
I think im totally missing some things.
Kevin
@KAlanHicks
Jan 19 2016 03:46
I finally figured it out! And without any help
```
Wiley Debs
@Colortear
Jan 19 2016 03:46
this is what I have for the return largets numbers in an array bonfire:
Kevin
@KAlanHicks
Jan 19 2016 03:46
function chunk(arr, size) {
  // Break it up.
  var newArray = [];
  var holder = 0;
  var holderArray = [];
  for (var i = 0; i < arr.length; i++){
    holderArray.push(arr[i]);
    if(holderArray.length == size){
      newArray[holder] = holderArray;
      holderArray = [];
      holder++;
    }
    else if (i == arr.length -1){
      newArray[holder] = holderArray;
    }
  }
  return newArray;
}

chunk([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);
Was there a better way to do this?
Wiley Debs
@Colortear
Jan 19 2016 03:46
function largestOfFour(arr) {
var arrTest = arr[0][0];
  for (var x  = 0; x < arr.length; x++) {
    for (var y = 0; y < arr[x].length; y++) {
      if (arrTest < arr[x][y]){
        arrTest = arr[x][y].push;
      }
        }
  }
  return arrTest;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Bill Hinostroza
@billh93
Jan 19 2016 03:51

function lookUp(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++){
    if(contacts[firstName].i === firstName && contacts.hasOwnProperty(prop)){
      return contacts.prop[i];
    }else if(contacts.firstName[i] === false){
      return "No such contact";
    }else if(!contacts.hasOwnProperty(prop)){
      return "No such property";
    }
  }
// Only change code above this line
}
Can anyone help me with the profile lookup challenge? I don't know how to solve it. I tried everything.
Fidel Severino
@fidelscodes
Jan 19 2016 03:56
@billh93 I'm on the same challenge at the moment
This is what I have so far but it's still not working
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) ) {
      return contacts[i][prop];
    } else if ( contacts[i].firstName !== firstName ) {
      return 'No such contact';
    } else if ( !contacts[i].hasOwnProperty(prop) ) {
      return 'No such property';
    }
  }
// Only change code above this line
}
Bill Hinostroza
@billh93
Jan 19 2016 03:58
@fidelscodes Nice! With your code I have accomplished another task. We just need the first two tasks.
3*
Fidel Severino
@fidelscodes
Jan 19 2016 03:59
Yeah
I just feel like return contacts[i][prop] should work
I have a feeling there's something missing in my first conditional
eeflores
@eeflores
Jan 19 2016 04:01
@fidelscodes you can return "no such contact" when the for loop exits
Fidel Severino
@fidelscodes
Jan 19 2016 04:03
Hmm
so that worked. But I don't understand why
eeflores
@eeflores
Jan 19 2016 04:03
the for loop iterates through all contacts
Fidel Severino
@fidelscodes
Jan 19 2016 04:03
care to explain a bit? And thanks @eeflores
CamperBot
@camperbot
Jan 19 2016 04:03
fidelscodes sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 415 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 19 2016 04:04
you do a test for firstname against each contact
Bill Hinostroza
@billh93
Jan 19 2016 04:04
Can you show us the code?
eeflores
@eeflores
Jan 19 2016 04:04
mine?
Bill Hinostroza
@billh93
Jan 19 2016 04:04
Yes
Fidel Severino
@fidelscodes
Jan 19 2016 04:04
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) ) {
      return contacts[i][prop];
    } else if ( !contacts[i].hasOwnProperty(prop) ) {
      return 'No such property';
    }
  }

  return 'No such contact';
// Only change code above this line
}
Oliver Jan
@loliverjan
Jan 19 2016 04:05
Hello
Fidel Severino
@fidelscodes
Jan 19 2016 04:05
That worked to pass the challenge
Oliver Jan
@loliverjan
Jan 19 2016 04:05
I need some help with this code
eeflores
@eeflores
Jan 19 2016 04:05
it looks like @fidelscodes
Oliver Jan
@loliverjan
Jan 19 2016 04:05
// 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);
eeflores
@eeflores
Jan 19 2016 04:05
hello @loliverjan
Oliver Jan
@loliverjan
Jan 19 2016 04:05
I am not sure why my code is not stopping once the if statement is validated
eeflores
@eeflores
Jan 19 2016 04:05
@fidelscodes does it make sense to you?
Oliver Jan
@loliverjan
Jan 19 2016 04:05
for (-2, 2)
or (2,-2)
Fidel Severino
@fidelscodes
Jan 19 2016 04:06
@loliverjan undefined is an actual JS value. You're returning a string "undefined"
eeflores
@eeflores
Jan 19 2016 04:06
@loliverjan yep just take the quotes out
Oliver Jan
@loliverjan
Jan 19 2016 04:06
oh i see!
Thank you
eeflores
@eeflores
Jan 19 2016 04:06
all good then
Bill Hinostroza
@billh93
Jan 19 2016 04:07
@eeflores It does make sense now because if there was no firstName the first if statement would never run thus it would return "No such contact"
thanks @eeflores !!
CamperBot
@camperbot
Jan 19 2016 04:07
billh93 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 416 | @eeflores | http://www.freecodecamp.com/eeflores
Fidel Severino
@fidelscodes
Jan 19 2016 04:07
@eeflores Just to make sure: Since I'm checking for a match within the for loop, it's not necessary to check again for the cases when it doesn't match.
iokonokh
@iokonokh
Jan 19 2016 04:07
how do you remove comma in a string?
Charles Stoy
@charst46
Jan 19 2016 04:08

Working Factorialize a Number (http://www.freecodecamp.com/challenges/factorialize-a-number) and have tried several solutions. None are working. This is the last one I tried: function factorialize(num) {
if (num === 0) {
return 1;
}

return num * factorial(num - 1);

} Where is my logic creating the train wreck?

eeflores
@eeflores
Jan 19 2016 04:08
@fidelscodes ummm ... yeah
Fidel Severino
@fidelscodes
Jan 19 2016 04:08
@iokonokh you need to use regex
Bill Hinostroza
@billh93
Jan 19 2016 04:09
@iokonokh backslash the commas or just double or single quotes
iokonokh
@iokonokh
Jan 19 2016 04:09
@fidelscodes for the Palindromes question?
Fidel Severino
@fidelscodes
Jan 19 2016 04:09
yup
eeflores
@eeflores
Jan 19 2016 04:10
@charst46 tried refreshing the page?
Fidel Severino
@fidelscodes
Jan 19 2016 04:11
you have to combine the string method .replace() with some regex to remove unwanted characters @iokonokh
iokonokh
@iokonokh
Jan 19 2016 04:22
function palindrome(str) {
  // Good luck!
  str = str.replace(/\s+/g, '');
  str = str.replace(/\./g, '');
  var regex = new RegExp(/,/, 'g');
  str = str.replace(regex, '');
  var strR = str.toLowerCase().split('').reverse('').join('');

  if (str === strR) {
    return true;
  } else if (str !== strR) {
    return false;
  } else 
  return true;
}

palindrome("race car");
Mrs. B.
@jazzydelta99
Jan 19 2016 04:25
hi @bakarih. Did you remove one of the returns for testing object properties? Mine won't accept else after the 1st return
TuanTM
@TuanTM93
Jan 19 2016 04:29
i problem with math.random:
var num;
num = Math.random();
return num;
Math.random not activity
Mrs. B.
@jazzydelta99
Jan 19 2016 04:37
nevermind @bakarih i got it now. brackets were in the wrong place
mindsoffire
@mindsoffire
Jan 19 2016 04:40
This message was deleted
This message was deleted

What is wrong with this that I cannot proceed past it? // 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);

Alex
@ahorton01
Jan 19 2016 04:47
@mindsoffire I'm having the exact same problem with the exact same code
The tests evaluate correctly, so it must be that the waypoint doesn't like this formatting of the solution
Kyle Roach
@iRoachie
Jan 19 2016 04:48
@mindsoffire if you want to return undefined just return;
samwyz
@samwyz
Jan 19 2016 04:48
thanks @CaroleAnneHannon for your help with Checkpoint: Stand in Line
CamperBot
@camperbot
Jan 19 2016 04:48
samwyz sends brownie points to @caroleannehannon :sparkles: :thumbsup: :sparkles:
:star: 709 | @caroleannehannon | http://www.freecodecamp.com/caroleannehannon
Alex
@ahorton01
Jan 19 2016 04:49
Ohhhhhhh!! Thanks @iRoachie.
CamperBot
@camperbot
Jan 19 2016 04:49
ahorton01 sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 322 | @iroachie | http://www.freecodecamp.com/iroachie
Yeondam Park
@yeondam88
Jan 19 2016 04:49

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

// Only change code below this line
var val = {
"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");

I cant figure it out this one
can anyone help me?
Kyle Marshall
@Nonprofitflight
Jan 19 2016 04:50

ok, can someone help me with this code? I'm failing to see how its any different then the test example.....

function myFunction(a, b) {
  console.log(a + b);
}
myFunction(1, 2);

test example:

// Example
function ourFunction(a, b) {
  console.log(a - b);
}
ourFunction(10, 5); // Outputs 5

// Only change code below this line
Alex
@ahorton01
Jan 19 2016 04:50
@mindsoffire , that did the trick. the problem was the exercise is looking to the return the VALUE of undefined, not the string "undefined"
Nick Robson
@nickrobson
Jan 19 2016 04:50
@yeondam88 You're asked to return the value of the object's property.
You've already been told how to do that: object["property"] gives you the value.
@Nonprofitflight What's the expected output?
Yeondam Park
@yeondam88
Jan 19 2016 04:51
Still don't get it...
it shows me val is already defined..
I have to use different var?
Nick Robson
@nickrobson
Jan 19 2016 04:52
That's because the object is meant to be called something else, say, lookup.
Your function parameter is called val, so you can't have a variable called val too!
Brett Felts
@brettfelts
Jan 19 2016 04:52
@brettfelts
I'm having trouble with the calculator. My first problem is that my function won't display more than one digit at a time, and I can't get the array to hold that digit.
http://codepen.io/brettfelts/pen/zrdQJW?editors=001
I think I'm pretty close, but I just can't quite get it
Kyle Marshall
@Nonprofitflight
Jan 19 2016 04:53
expected output is 3. but i'm getting a rangeError: Maximum call stack size exceeded error.
no idea whats wrong.
Nick Robson
@nickrobson
Jan 19 2016 04:53
@Nonprofitflight Reload the page.
Kyle Marshall
@Nonprofitflight
Jan 19 2016 04:53
friggin seriously?!... thanks. lol
Yeondam Park
@yeondam88
Jan 19 2016 04:54
@nickrobson how can I attached here my code editor like someone else do
Kyle Marshall
@Nonprofitflight
Jan 19 2016 04:55
it worked. I guess thats what I get for doin like 150 challenges in one sitting...
Nick Robson
@nickrobson
Jan 19 2016 04:55
@brettfelts I suggest you use a single global variable that holds the current answer, instead of using an array for that.
@yeondam88
Put ```js, then your code, then three more backticks
make sure the lines with the backticks are on their own lines, though
Kyle Roach
@iRoachie
Jan 19 2016 04:56
@Nonprofitflight a + b, reverses the sort direction
Yeondam Park
@yeondam88
Jan 19 2016 04:57
// 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");
I have to change my parameter?
Kyle Marshall
@Nonprofitflight
Jan 19 2016 04:57
@iRoachie meaning? I'm not sure if I missed that part of the lesson. kinda cheating by just leaving a java1 class at comm college
Kyle Roach
@iRoachie
Jan 19 2016 04:58
@Nonprofitflight You asked the difference between your code, there’s is a-b and yours is a + b
John Cerpa
@johncerpa
Jan 19 2016 04:59
return result = lookup[val];
Kyle Marshall
@Nonprofitflight
Jan 19 2016 04:59
oh. lol yea. test wanted the sum, not the difference that was different, tho.
John Cerpa
@johncerpa
Jan 19 2016 04:59
is that right?
Yeondam Park
@yeondam88
Jan 19 2016 04:59
oh
John Cerpa
@johncerpa
Jan 19 2016 05:00
@yeondam88 is it?
Yeondam Park
@yeondam88
Jan 19 2016 05:00
it works
Thank you
@johncerpa Thanks!
CamperBot
@camperbot
Jan 19 2016 05:00
yeondam88 sends brownie points to @johncerpa :sparkles: :thumbsup: :sparkles:
:star: 272 | @johncerpa | http://www.freecodecamp.com/johncerpa
Yeondam Park
@yeondam88
Jan 19 2016 05:00
@nickrobson Thanks!
CamperBot
@camperbot
Jan 19 2016 05:00
yeondam88 sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 338 | @nickrobson | http://www.freecodecamp.com/nickrobson
John Cerpa
@johncerpa
Jan 19 2016 05:00
@yeondam88 :)
Nick Robson
@nickrobson
Jan 19 2016 05:01
np
Thequadehunter
@Thequadehunter
Jan 19 2016 05:03

Having a log of trouble with "Profile Lookup" in Javascript.

I'm getting the error "TypeError: Cannot read the property 'likes' of undefined"

Anybody know what I'm doing wrong?

```

KaiserBakunawa
@KaiserBakunawa
Jan 19 2016 05:03
Bonfire: Return Largest Numbers in Arrays
CamperBot
@camperbot
Jan 19 2016 05:03

:fire:Bonfire: Return Largest Numbers in Arrays :link:

function largestOfFour(arr) {
  // You can do this!
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.

more info:  bf details | bf links | hint

Thequadehunter
@Thequadehunter
Jan 19 2016 05:03
//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

  var firstNameFound = false;
  var i = 0;
  var propFound = false;

  while(i < contacts.length){
    if(contacts[i].firstName === firstName){
       firstNameFound = true;
      }
        i++;
    }

  if (firstNameFound ===true && contacts[i][prop] !== null){
    return contacts[i][prop];
  }    
  else if (firstNameFound === true && contacts[i][prop] === null){
    return "No such property";
  }
  else{
    return "No such contact";
  }

  // Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
KaiserBakunawa
@KaiserBakunawa
Jan 19 2016 05:03
function largestOfFour(arr) {
  // You can do this!
  var largeArr = [];
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      if (arr[i][j] > arr[i][j +1]) {
        largeArr.push(arr[i][j]);
      }  
    }

  }


  return largeArr;
}
Jose Ceballos
@lazypepe
Jan 19 2016 05:04
Hi guys
KaiserBakunawa
@KaiserBakunawa
Jan 19 2016 05:04
Can ayone help? My code returns the last set of arrays completely instead of just the largest number
Kyle Roach
@iRoachie
Jan 19 2016 05:05
@KaiserBakunawa what challenge is that?
KaiserBakunawa
@KaiserBakunawa
Jan 19 2016 05:05
Bonfire: Return Largest Numbers in Arrays
CamperBot
@camperbot
Jan 19 2016 05:05

:fire:Bonfire: Return Largest Numbers in Arrays :link:

function largestOfFour(arr) {
  // You can do this!
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.

more info:  bf details | bf links | hint

Thequadehunter
@Thequadehunter
Jan 19 2016 05:06
Nevermind about my problem guys, I think I just found the problem. I let my 'i' var keep incrimenting.
KaiserBakunawa
@KaiserBakunawa
Jan 19 2016 05:06
@iRoachie My code works right for the first two arrays, misses the third, and then returns the last array completely
Kyle Roach
@iRoachie
Jan 19 2016 05:07
@KaiserBakunawa Okay you need to add a varialbe to keep track of the largest element in each sub array
Jose Ceballos
@lazypepe
Jan 19 2016 05:08
I have a question with Testing Objects for properties.
Kyle Roach
@iRoachie
Jan 19 2016 05:09
This message was deleted
@KaiserBakunawa
function largestOfFour(arr) {
  // You can do this!
  var largeArr = [];

  for (var i = 0; i < arr.length; i++) {
    var largest = 0;
    for (var j = 0; j < arr[i].length; j++) {
      if (largest < arr[i][j]){
        largest = arr[i][j];
      }  
    }
    largeArr.push(largest);
  }

  return largeArr;
}
Jose Ceballos
@lazypepe
Jan 19 2016 05:11
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Why does myObj.checkProp return undefined instead of the value??
KaiserBakunawa
@KaiserBakunawa
Jan 19 2016 05:12
@iRoachie thanks. That worked.
CamperBot
@camperbot
Jan 19 2016 05:12
kaiserbakunawa sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 324 | @iroachie | http://www.freecodecamp.com/iroachie
Jose Ceballos
@lazypepe
Jan 19 2016 05:13
Bonfire: Testing Objects for Properties
CamperBot
@camperbot
Jan 19 2016 05:13
Sorry, can't find a bonfire called testing objects for properties . [ Check the map? ]
Kyle Roach
@iRoachie
Jan 19 2016 05:14
@lazypepe Hey when using variables to access objects you have to use the bracket notation.
myObj[checkProp]
liximomo
@liximomo
Jan 19 2016 05:14
@lazypepe it should be return myObj[checkProp];
Jose Ceballos
@lazypepe
Jan 19 2016 05:14
So the dot operator doesn't work?
aikatarine
@aikatarine
Jan 19 2016 05:14
function queue(arr, item) {
  // Your code here

  arr.push(item); return arr.shift(); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I am having problems getting through "Stand in Line." What am I doing wrong?
Adam Yuhasz
@jayuhasz
Jan 19 2016 05:15
@aikatarine which module is that?
Kyle Roach
@iRoachie
Jan 19 2016 05:15
@aikatarine Nothing wrong just put the return on it’s own line
Adam Yuhasz
@jayuhasz
Jan 19 2016 05:15
how do you link your inputs like that?
Kyle Roach
@iRoachie
Jan 19 2016 05:16
@jayuhasz What do you mean?
Jose Ceballos
@lazypepe
Jan 19 2016 05:16
When do we use the dot operator?
Adam Yuhasz
@jayuhasz
Jan 19 2016 05:16
when aikatarine chatted you could see his javascript "playground"
Kyle Roach
@iRoachie
Jan 19 2016 05:18
@lazypepe we use dot operator when you know what the property is for sure, when you can type the literal key you’re search for
Jose Ceballos
@lazypepe
Jan 19 2016 05:19
@iRoachie Thank you. I understand now.
CamperBot
@camperbot
Jan 19 2016 05:19
lazypepe sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 325 | @iroachie | http://www.freecodecamp.com/iroachie
Adam Yuhasz
@jayuhasz
Jan 19 2016 05:20
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line
I'm not understanding why this isn't working to select the 2nd tree.
aikatarine
@aikatarine
Jan 19 2016 05:21
@iRoachie I keep getting error code "RangeError: Maximum call stack size exceeded"
Kyle Roach
@iRoachie
Jan 19 2016 05:21
@aikatarine On what? Whats you’re code like?
Yeondam Park
@yeondam88
Jan 19 2016 05:22
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.list[1]; // Change this line
There are two list in myPlants obj, then how can I call second list array?
Kyle Roach
@iRoachie
Jan 19 2016 05:22
@jayuhasz Hey myPlants is an array that has 2 objects inside. The only way to access the elements of an array is by their index
@jayuhasz remember that indexes start at 0;
myPlants[0]
aikatarine
@aikatarine
Jan 19 2016 05:23

```js
function queue(arr, item) {
// Your code here

arr.push(item); return arr.shift(); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
```
I am having problems getting through "Stand in Line." What am I doing wrong?
@iRoachie this code I posted just now

Kyle Roach
@iRoachie
Jan 19 2016 05:27
@aikatarine put the return statement on a separate line
@aikatarine
function queue(arr, item) {
  // Your code here

  arr.push(item);  
  return arr.shift();
}
bhartisachdeva
@bhartisachdeva
Jan 19 2016 05:28

// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 8;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.length;

THERE IS DIIFERENT WAY ALSO?
Adam Yuhasz
@jayuhasz
Jan 19 2016 05:29
@iRoachie I don't understand why referencing the "trees" property isn't a valid method.
bhartisachdeva
@bhartisachdeva
Jan 19 2016 05:29
HI
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 05:29
How do I check if a number is in a range?
bhartisachdeva
@bhartisachdeva
Jan 19 2016 05:30
i need help
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 05:30
javascript
wiki range
CamperBot
@camperbot
Jan 19 2016 05:30

:point_right: bonfire friendly date ranges [wiki]

Problem Explanation:

  • Create a program that will take two dates and convert them into a more easy to understand date such as January 1st, 2017. It will also check the difference between them, and handles cases with no difference, more than a day, more than a month, more than a year, and more than a month and less than a year respectively.
:pencil: read more about bonfire friendly date ranges on the FCC Wiki
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 05:30
wiki isinrange
CamperBot
@camperbot
Jan 19 2016 05:30
no wiki entry for: isinrange
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 05:30
damn
bhartisachdeva
@bhartisachdeva
Jan 19 2016 05:30
i m geeting error for last NameLength

// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 8;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.length;

Adam Yuhasz
@jayuhasz
Jan 19 2016 05:31
@bhartisachdeva you changed the setup. you need the var lastNameLength = 0;
Kyle Roach
@iRoachie
Jan 19 2016 05:32

@jayuhasz Because myPlants is an ARRAY it’s not an OBJECT. Arrays have elements.

the first element in my plants is

 { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },

the second is

 {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
}
@jayuhasz these are elements inside the myPlants array. To get the second tree, we’ll have to get the list propery of that object

@jayuhasz

myPlants[1].list

this get’s us the list of trees

@jayuhasz To get the list of flowers we do
myPlants[0].list
Adam Yuhasz
@jayuhasz
Jan 19 2016 05:35
@iRoachie ahh, understood. I think I forgot about the .list property Thank you!
CamperBot
@camperbot
Jan 19 2016 05:35
jayuhasz sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 326 | @iroachie | http://www.freecodecamp.com/iroachie
aikatarine
@aikatarine
Jan 19 2016 05:36
@iRoachie Thanks. I think FCC was bugging out, cuz I tried that and it didn't work until I reset my code
CamperBot
@camperbot
Jan 19 2016 05:36
aikatarine sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 327 | @iroachie | http://www.freecodecamp.com/iroachie
Kyle Roach
@iRoachie
Jan 19 2016 05:38
@aikatarine Oh alright, well glad you got it :)
Adam Yuhasz
@jayuhasz
Jan 19 2016 05:42
@iRoachie seriously, thanks a lot that stuff wasn't clicking until you laid it out.
CamperBot
@camperbot
Jan 19 2016 05:42
jayuhasz sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:warning: jayuhasz already gave iroachie points
Kyle Roach
@iRoachie
Jan 19 2016 05:42
@jayuhasz Glad I could help mate!
Dylan Pagillo
@DylanNeil
Jan 19 2016 05:53
@camperbot testing objects for properties
@camperbot I feel sort of lost on the syntax of this one
Miguel
@Miguel12321
Jan 19 2016 06:00
can someone help me with Selecting from many options with Switch Statements
Pete Considine
@pjconsidine
Jan 19 2016 06:00
what's the problem @DylanNeil ?
Miguel
@Miguel12321
Jan 19 2016 06:02
  switch (val) {
  case===:
    statement "alpha";
    break;
  case value2:
    statement2;
    break;
case valueN:
    statementN;
    break;
}
Dylan Pagillo
@DylanNeil
Jan 19 2016 06:02
@pjconsidine I'm having trouble figuring out a way to return the properties of the values for myObj

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

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

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

@pjconsidine This is my solution so fat
far
@pjconsidine I'm not sure if an if statement was the way to go on this one
Eina
@thelittleblacksmith
Jan 19 2016 06:03
@Miguel12321 you need to assign 'alpha', and the other strings to 'answer' per case. And case operates on strict equality so you don't need the triple equals there.
NicholasDM
@NicholasDM
Jan 19 2016 06:03
// My question. What is the difference between how the variables are defined...

var car = { // here...
  "wheels":4,
  "engines":1,
  "seats":5
};

var motorBike = { // and here...
  wheels: 4,
  engines: 1,
  seats: 5
};

// With the quotation marks and then without.
?
Ankush Kalia
@ak274
Jan 19 2016 06:03
i'm not getting this instruction.Please help me to understand this one:-- Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Pete Considine
@pjconsidine
Jan 19 2016 06:04
@DylanNeil where are you passing in the property to check?
Eina
@thelittleblacksmith
Jan 19 2016 06:04
switch(val){
    case whatever:
        answer = 'a string';
        break;
}
@Miguel12321
NicholasDM
@NicholasDM
Jan 19 2016 06:05
ak274: 11 / 3 would be "eleven divided by 3". 11 % 3 would be "remainder of eleven divided by 3".
Pete Considine
@pjconsidine
Jan 19 2016 06:05
wouldn't you want to have myObj.hasOwnProperty("some property") ?
Dylan Pagillo
@DylanNeil
Jan 19 2016 06:05
yes
Pete Considine
@pjconsidine
Jan 19 2016 06:05
okay
TuanTM
@TuanTM93
Jan 19 2016 06:05
This message was deleted
Pete Considine
@pjconsidine
Jan 19 2016 06:05
I've been using Object.keys a lot, so I'm not sure how they'd want you to solve this one exectly
Dylan Pagillo
@DylanNeil
Jan 19 2016 06:06
I thought leaving it blank made more sense, since you are supposed to be able to call the property at the bottom
okay
Miguel
@Miguel12321
Jan 19 2016 06:06
@thelittleblacksmith like this?
Pete Considine
@pjconsidine
Jan 19 2016 06:06
oh, well you can use a placeholder in that case
Miguel
@Miguel12321
Jan 19 2016 06:06
  switch (val) {
    case whatever:
    answer= "alpha";
    break;
Dylan Pagillo
@DylanNeil
Jan 19 2016 06:06
could you give me an example?
Pete Considine
@pjconsidine
Jan 19 2016 06:06
I'll try
Eina
@thelittleblacksmith
Jan 19 2016 06:07
@Miguel12321 you need to change whatever into what you need valcompared to. it's numbers for that challenge, right?
NicholasDM
@NicholasDM
Jan 19 2016 06:07
var remainder;
remainder = 11 / 3; // 3.6, roughly. Also incorrect!
remainder = 11 % 3; // 2. 11 divided by 3, and remainder is what mains.
Pete Considine
@pjconsidine
Jan 19 2016 06:07
function foo(property) { if (myObj.hasOwnProperty(property) === true ) { do something; } else { so something else; }
NicholasDM
@NicholasDM
Jan 19 2016 06:07
@ak274
Pete Considine
@pjconsidine
Jan 19 2016 06:08
I think that's something like what I'm thinking
I don't guarantee it will work, though. :)
TuanTM
@TuanTM93
Jan 19 2016 06:08

i'm having a problem math.random, it not activity:
function myFunction() {

// Only change code below this line.
var num;
num = Math.random();
return num;
// Only change code above this line.
}

Miguel
@Miguel12321
Jan 19 2016 06:08
@thelittleblacksmith oh ok the numbers that are to the left of the word
Dylan Pagillo
@DylanNeil
Jan 19 2016 06:09
@pjconsidine thanks! either way, you have me thinking in a different direction
CamperBot
@camperbot
Jan 19 2016 06:09
dylanneil sends brownie points to @pjconsidine :sparkles: :thumbsup: :sparkles:
:star: 364 | @pjconsidine | http://www.freecodecamp.com/pjconsidine
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 06:10
function rot13(str) { // LBH QVQ VG!
  var newStr = '';
  for (var i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) == 32) {
      newStr += ' ';
      }
    if (str.charCodeAt(i) - 13 <= 100 && str.charCodeAt(i) - 13 >= 65) {
      newStr += String.fromCharCode(str.charCodeAt(i) - 13);
    }

  }
  return newStr;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");

Task:

One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount.

A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.

Write a function which takes a ROT13 encoded string as input and returns a decoded string.

All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.

The way I have it now, it converts only elements, that once converted, will be letters, and leaves spaces alone. First of all, how do I make the code 'loop around' for letters? It's pretty straightforward to include them in the final string, but they would look weird. Like if I wanted to use rot13('A'), it wouldn't turn into M like it's supposed to, it would turn into whatever is at the ASCII code 42, which is probably some obscure symbol. So how do I make it 'loop around'? And how do I make it leave punctuation alone?

Pete Considine
@pjconsidine
Jan 19 2016 06:11
I'm actually coming up to those challenges myself, so maybe I'll have a better idea in a little while.
Miguel
@Miguel12321
Jan 19 2016 06:11
@thelittleblacksmith thank you it worked.
CamperBot
@camperbot
Jan 19 2016 06:11
miguel12321 sends brownie points to @thelittleblacksmith :sparkles: :thumbsup: :sparkles:
:star: 308 | @thelittleblacksmith | http://www.freecodecamp.com/thelittleblacksmith
TuanTM
@TuanTM93
Jan 19 2016 06:12

i'm having a problem math.random, it not activity:
function myFunction() {

// Only change code below this line.
var num;
num = Math.random();
return num;
// Only change code above this line.
}
Who cant fix solve this problem help me.

Pete Considine
@pjconsidine
Jan 19 2016 06:12
@CodingDucky you could use modular numbers
num % 26
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 06:13
@pjconsidine good thing I have no idea what those are
Pete Considine
@pjconsidine
Jan 19 2016 06:13
it's like a 12 hour clock
there's no 13, it just goes back to 1
you can do the same with the 26 letters of the alphabet
there's no 27, it just goes back to 1
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 06:14
I've fixed the loopback issue
if (str.charCodeAt(i) - 13 > 100 || str.charCodeAt(i) - 13 < 65) {
      newStr += String.fromCharCode(str.charCodeAt(i) + 13);
    }
with this line of extra code
Pete Considine
@pjconsidine
Jan 19 2016 06:14
I think I just made an array of all the letters of the alphabet and looped around it
I'd have to check, though
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 06:14
my only problem, is how I get it to leave punctuation alone
Eina
@thelittleblacksmith
Jan 19 2016 06:15
@CodingDucky you can check if it's between 'A' and 'Z'
All the punctuation are before A/less than 65(A)
Pete Considine
@pjconsidine
Jan 19 2016 06:16
if you're using character codes, can't you limit the codes to particular range?
what are the character codes for punctuation?
I would think that they're outside the range of normal letters
Jose Dzireh Chong
@CodingDucky
Jan 19 2016 06:17
Yeah there is, just fixed that
thanks @pjconsidine
CamperBot
@camperbot
Jan 19 2016 06:17
codingducky sends brownie points to @pjconsidine :sparkles: :thumbsup: :sparkles:
:star: 366 | @pjconsidine | http://www.freecodecamp.com/pjconsidine
Pete Considine
@pjconsidine
Jan 19 2016 06:18
I went way low tech, so I didn't run into punctuation problems. ha
Ankush Kalia
@ak274
Jan 19 2016 06:22
In the code below i havn't declare fahrenheit as varible then why its still a valid code and no warnings?
function convert(celsius) {
  // Only change code below this line

  fahrenheit=celsius*9/5+32;

  // Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}

// Change the inputs below to test your code
convert(0);
Markus Kiili
@Masd925
Jan 19 2016 06:23
@ak274 Without var, you generate global variables.
fluffystub
@RakshithNM
Jan 19 2016 06:24
help Make Object Properties Private
CamperBot
@camperbot
Jan 19 2016 06:24

:point_right: waypoint make object properties private [wiki]

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

  this.getSpeed = function () {  // public
    return addUnit(speed);
  };

};

Another example:

:pencil: read more about waypoint make object properties private on the FCC Wiki

Mahendra Singh
@mahendra3006
Jan 19 2016 06:24
Hi folks!
fluffystub
@RakshithNM
Jan 19 2016 06:24
hi @mahendra3006
Mahendra Singh
@mahendra3006
Jan 19 2016 06:24
Can anyone help me with symmetric difference
Markus Kiili
@Masd925
Jan 19 2016 06:25
@mahendra3006 Yes.
Mahendra Singh
@mahendra3006
Jan 19 2016 06:26
function sym(args) {
  var res = {},diff = [];
  for(var arr in arguments){
    for(var el in arguments[arr]){
      if(!res[arguments[arr][el]]){
          res[arguments[arr][el]] = arguments[arr][el];  
        }else{
          delete res[arguments[arr][el]];
        }
    }    
  }
  for(var elm in res){
    diff.push(res[elm]);
  }
  console.log(res);
  return diff;
}
this is my code
i am not able to pass test cases 3 and 4
and 5
Markus Kiili
@Masd925
Jan 19 2016 06:26
I will take a look.
Mahendra Singh
@mahendra3006
Jan 19 2016 06:26
thanks
Nick Robson
@nickrobson
Jan 19 2016 06:29
bonfire symmetric difference
CamperBot
@camperbot
Jan 19 2016 06:29

:fire:Bonfire: Symmetric Difference :link:

function sym(args) {
  return arguments;
}

sym([1, 2, 3], [5, 2, 1, 4]);

Create a function that takes two or more arrays and returns an array of the symmetric difference of the provided arrays.

more info:  bf details | bf links | hint

Nick Robson
@nickrobson
Jan 19 2016 06:29
ah, that.
Markus Kiili
@Masd925
Jan 19 2016 06:29
@mahendra3006 It would be better to use only arrays in this problem. You are using an object too. for...in is not meant to be used on arrays.
Nick Robson
@nickrobson
Jan 19 2016 06:30
You need to remember that
symdiff(a, b) == a XOR b
symdiff(a, b, c) == (a XOR b) XOR c
Mahendra Singh
@mahendra3006
Jan 19 2016 06:30
@nickrobson ya i read that, but what about repeating elements?
Nick Robson
@nickrobson
Jan 19 2016 06:31
@mahendra3006 Do you, mean, say a == [1,1,2] ?