These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Jan 2016
Ashley Marie
@adesiongco
Jan 23 2016 00:02
js code function lookUp(firstName, prop){ for (var i=0; i<contacts.length; i++){ if (contacts[i].firstName === firstName){ if (contacts[i].hasOwnProperty(prop)){ return contacts[i][prop]; } else return "No such property"; } else return "No such contact"; } }js code
Gosh... I feel slow... let me try again - sorry guys!
rphares
@rphares
Jan 23 2016 00:03
no worries-- you are close-- that is with ONE `, you need three :)
Ashley Marie
@adesiongco
Jan 23 2016 00:04
function lookUp(firstName, prop){
  for (var i=0; i<contacts.length; i++){
    if (contacts[i].firstName === firstName){
      if (contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      }
      else return "No such property";
    }
    else return "No such contact";
  }
}
Woo! Success!
Ok, now that I'm over THAT hump... my function is still not returning the expected results...
Zoe
@roamroam
Jan 23 2016 00:05
@adesiongco the .hasOwnProperty should === true
Ashley Marie
@adesiongco
Jan 23 2016 00:06
I thought the hasOwnProperty would return a true or false? So wouldn't the inside of my IF statement already be true or false?
Zoe
@roamroam
Jan 23 2016 00:07
that's right
Michael Mazzone
@GitMazzone
Jan 23 2016 00:08
@ArielLeslie Welp... this is what I have now, and it's working for half of the test cases js // Only change code below this line function update(id, prop, value) { if(value !== "" && prop !== "tracks") { collection[id][prop] = value; } else if(prop === "tracks" && value !== "") { collection[id][prop].push(value); } else if(value === "") { delete(collection[id][prop]); } }
sorry, js function update(id, prop, value) { if(value !== "" && prop !== "tracks") { collection[id][prop] = value; } else if(prop === "tracks" && value !== "") { collection[id][prop].push(value); } else if(value === "") { delete(collection[id][prop]); } }
Zoe
@roamroam
Jan 23 2016 00:08
I'm not sure if you need to flip the argument in the first if , start it with
if (firstName === contacts[i].firstName){
It doesn't matter I just checked
Ashley Marie
@adesiongco
Jan 23 2016 00:10
@slowoddchild It didn't make a difference :( it's returning the correct results when I access the 1st name in the array, but it doesn't work for any name after the 1st
Zoe
@roamroam
Jan 23 2016 00:10
The last thing i can think of is, placing the return "no such contact" after the for loop without return
Ashley Marie
@adesiongco
Jan 23 2016 00:10
That's why I think I may have the FOR loop in the wrong place... I need to break out of it once I find a matching name... otherwise I think it will keep evaluating the other names even though it found the match?
Oh! @slowoddchild That worked!!
Thank you so much!! :)
Zoe
@roamroam
Jan 23 2016 00:12
Sweet!
rphares
@rphares
Jan 23 2016 00:12
thanks, @slowoddchild ~
CamperBot
@camperbot
Jan 23 2016 00:12
rphares sends brownie points to @slowoddchild :sparkles: :thumbsup: :sparkles:
:star: 252 | @slowoddchild | http://www.freecodecamp.com/slowoddchild
Ashley Marie
@adesiongco
Jan 23 2016 00:12
@slowoddchild Thanks!
CamperBot
@camperbot
Jan 23 2016 00:12
adesiongco sends brownie points to @slowoddchild :sparkles: :thumbsup: :sparkles:
:warning: adesiongco already gave slowoddchild points
rphares
@rphares
Jan 23 2016 00:13
( @slowoddchild deserved two, but you can only feed the same person once an hour :blush: )
Ashley Marie
@adesiongco
Jan 23 2016 00:13
Aw man, I can't give you double brownie points @slowoddchild ? lol
Ah, got it. I'm learning the rules of the room ;)
rphares
@rphares
Jan 23 2016 00:13
:)
Zoe
@roamroam
Jan 23 2016 00:14
@adesiongco @rphares I was stuck on that last line for 3+ hours and then i just moved it out of the for loop as a test and it worked.
Josue Escobar
@jees10
Jan 23 2016 00:16
I'm missing "\"I am a \"double quoted\" string inside \"double quotes";
Variable myStr should equal to ("I am a "double quoted" string inside "double quotes"").
Elizabeth Fine
@elizabethfinedev
Jan 23 2016 00:20
hey guys. happy fridayyy whoohoooo. can anyone tell me what charAt is and how to use it? :) :)
i looked it up but i think i need an actual person to explain it to me
oh wait nevermind i get it duh
too bad i cant give myself brownie points for that one! lol
Thequadehunter
@Thequadehunter
Jan 23 2016 00:24

Ok, so clearly I got the desired result from the challenge, but even after resetting the code and restarting my browser I can't move on, anyone know if there's anything wrong here?

Here's proof that it should be working, I tested this with all results: http://imgur.com/RHJoCmB

Here's my code just in case:

function titleCase(str) {
  str = str.split(" ");
  var i = 0;
  var newSentence = "";

  for (i in str){
    str[i] = str[i].toLowerCase();
    str[i] = str[i].charAt(0).toUpperCase() + str[i].substr(1);
    newSentence += str[i].concat(" ");
  }
  return newSentence;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Ulan
@ulans
Jan 23 2016 00:24
@adesiongco What was the problem with your code?
Elizabeth Fine
@elizabethfinedev
Jan 23 2016 00:29
um guys
does anyone know what this means: /\w\S*/g
rphares
@rphares
Jan 23 2016 00:30
@BananaHavana , thats a bit of regex
you may want to check out a few other resources, regex comes up a lot,
http://regexone.com and https://regex101.com are recommended resources in the wiki, and https://www.hackerrank.com/challenges/matching-word-non-word was recommended by a mod, @BananaHavana :)
hulk
@phillworden
Jan 23 2016 00:54

function queue(arr, item) {
// Your code here
arr.push(item);
a = arr(0);
arr.shift();
return a; // 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));

im wondering what is wrong here
Dusan Nikodijevic
@pika89
Jan 23 2016 00:54
hi guys, could someone explain this line of code to me
  return Math.floor(Math.random() * (myMax - myMin +1)) + myMin; // Change this line
Pandarati
@Pandarati
Jan 23 2016 00:55
@pika89 The line of code is used to generate a random number in a range. myMax is where you put the maximum number for your range, and myMin is where you put the minimum number for your range.
hulk
@phillworden
Jan 23 2016 00:56
the directions were kind of vague but i was supposed to create a function that added item to the end of arr and took off the first element of arr, and then returned the element that had been removed
Dusan Nikodijevic
@pika89
Jan 23 2016 00:57
@Pandarati but why couldnt we have used ">=" instead of myMax - myMin ?
that part is quite confusing
Pandarati
@Pandarati
Jan 23 2016 00:58
@pika89 The line is set up to act as an equation. You will use ">=" for checking conditions. You wouldn't be able to use ">=" in this case.
hulk
@phillworden
Jan 23 2016 00:59
also the error message i got was "maximum call stack size exceeded"... not sure what that means though
rphares
@rphares
Jan 23 2016 00:59
@phillworden , maximum call stack-- did you try refreshing?
Dusan Nikodijevic
@pika89
Jan 23 2016 00:59
@Pandarati ok thanks :)
CamperBot
@camperbot
Jan 23 2016 00:59
pika89 sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 327 | @pandarati | http://www.freecodecamp.com/pandarati
hulk
@phillworden
Jan 23 2016 01:00
no
rphares
@rphares
Jan 23 2016 01:00
try :)
hulk
@phillworden
Jan 23 2016 01:01
refreshed... ran tests again and it gave me the same error
rphares
@rphares
Jan 23 2016 01:01
(i didn't look at your code-- just letting you know maximum call stack can often be resolved by refreshing or closing and reopening the window :) )
ah, then i shall go away again ~ Sorry!
hulk
@phillworden
Jan 23 2016 01:02
could you check my code?
Pandarati
@Pandarati
Jan 23 2016 01:02
@phillworden Post the link to your challenge
Pandarati
@Pandarati
Jan 23 2016 01:03
@phillworden It's a range error :/
hulk
@phillworden
Jan 23 2016 01:03
which means...
Pandarati
@Pandarati
Jan 23 2016 01:04
I'm thinking. I'm thinking :P. I just saw it in the console
hulk
@phillworden
Jan 23 2016 01:04
sorry im really new to this. third day coding, asside from my experience on a calculator haha.
Redvibe
@Redvibe
Jan 23 2016 01:05

Counting Cards Help please. My Hold result works but none of the others do.

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

}

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

// Only change code above this line
}

Pandarati
@Pandarati
Jan 23 2016 01:07
@phillworden Try clearing your cache and cookies
titi207
@titi207
Jan 23 2016 01:07
Someone can explain me What should i do?
hulk
@phillworden
Jan 23 2016 01:07
k
Redvibe
@Redvibe
Jan 23 2016 01:10
nevermind about Counting Cards... I figured it out. I had to say count ++ and count --. I don't know why I couldn't use count + 1 though. I'd love to hear why if anyone knows.
rphares
@rphares
Jan 23 2016 01:11
@titi207 , you just need to declare a global var
Pandarati
@Pandarati
Jan 23 2016 01:11
@Redvibe You are never properly updating count
hulk
@phillworden
Jan 23 2016 01:11
alright i cleared everything. im gonna try again. if i run into issues ill come back @Pandarati
Pandarati
@Pandarati
Jan 23 2016 01:11
Yeah that was the problem @Redvibe. It was just remaining static before.
rphares
@rphares
Jan 23 2016 01:11
it needs to be outside of the functions, on the top line, for example :) @titi207
Pandarati
@Pandarati
Jan 23 2016 01:12
@phillworden It should work now :P
rphares
@rphares
Jan 23 2016 01:13
then, you want to assign 5 to oopsGlobal inside the function, @titi207
but you don't want to use var
Redvibe
@Redvibe
Jan 23 2016 01:13
@Pandarati thanks. I don't think that was explained in the lesson. Don't understand why you can't just do + 1
CamperBot
@camperbot
Jan 23 2016 01:13
redvibe sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 328 | @pandarati | http://www.freecodecamp.com/pandarati
rphares
@rphares
Jan 23 2016 01:13
so, just name = value @titi207
matthew3454
@matthew3454
Jan 23 2016 01:16
Can someone please help me on the waypoint: Golf Code?
rphares
@rphares
Jan 23 2016 01:17
hmm, not sure but paste away, @matthew3454 :blush:
matthew3454
@matthew3454
Jan 23 2016 01:17
These are the instructions: [golfScore(4, 1) should return "Hole-in-one!"
golfScore(4, 2) should return "Eagle"
golfScore(5, 2) should return "Eagle"
golfScore(4, 3) should return "Birdie"
golfScore(4, 4) should return "Par"
golfScore(1, 1) should return "Hole-in-one!"
golfScore(5, 5) should return "Par"
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"]
function golfScore(par, strokes3) {
  // Only change code below this line
  if (strokes = 1) {
  return "Hole-in-one!";
  }
  else if (strokes <= par-2){
    return "Eagle";
  }
  else if (strokes =par-1){
    return "Birdie";
      }
  else if (strokes = par) {
    return "Par";
  }
  else if (strokes = par + 2){
    return "Double Bogey";
  }
  else (strokes >= par +3){
    return "Go Home!";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
rphares
@rphares
Jan 23 2016 01:19
@matthew3454 , times when you are using =, try using ==,
you don't want to assign it, you want to compare :)
matthew3454
@matthew3454
Jan 23 2016 01:21
I did that and all the red x's to the left of all my "if" and "else" statement went away except for the last "else" statement.
@rphares
rphares
@rphares
Jan 23 2016 01:21
Woot, big step, let;s take a look at that bit, then :)
ah, try making that else an else if, @matthew3454
matthew3454
@matthew3454
Jan 23 2016 01:22
okay
@rphares it worked
rphares
@rphares
Jan 23 2016 01:23
:)
On that-- i don't want to have steered you wrong, so a quick point,
else, by itself, doesn't need the condition,
matthew3454
@matthew3454
Jan 23 2016 01:23
okay
rphares
@rphares
Jan 23 2016 01:23
its what you do when all the ifs aren't true,
so you could have used just else,
i think
matthew3454
@matthew3454
Jan 23 2016 01:24
okay. nice to know. thank you @rphares . I still have an error that says "strokes is not defined"
CamperBot
@camperbot
Jan 23 2016 01:24
matthew3454 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
rphares
@rphares
Jan 23 2016 01:24
BUT, not sure and knew my answer worked and you already had the condition there, so i took the lazy way :blush:
CamperBot
@camperbot
Jan 23 2016 01:24
:star: 1880 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 23 2016 01:24
you have a type in your first row,
i don't know why you have strokes3 in function golfScore(par, strokes3), should just be function golfScore(par, strokes) { i believe :)
matthew3454
@matthew3454
Jan 23 2016 01:25
okay I'll try it
Max Gudmundson
@maxgud
Jan 23 2016 01:26
Hey I feel really dumb about this but I am having problems with the switch syntax. Anyone able to help me out?
rphares
@rphares
Jan 23 2016 01:26
Umm, can you tell me the name and paste your code?
Max Gudmundson
@maxgud
Jan 23 2016 01:26

function myTest(val) {
var answer = "";
// Only change code below this line
switch (val) {
case value1:
return "alpha";
break;
case value2:
statement2;
break;

}

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

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

rphares
@rphares
Jan 23 2016 01:26
Full discloure-- not very good at JS yet, and haven't used those much, though I've passed the waypoints an MAY be able to help, not sure,
Max Gudmundson
@maxgud
Jan 23 2016 01:27
Np, any help is appreciated.
rphares
@rphares
Jan 23 2016 01:27
which one is that again, @maxgud ?
matthew3454
@matthew3454
Jan 23 2016 01:27
Thanks @rphares
CamperBot
@camperbot
Jan 23 2016 01:27
matthew3454 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: matthew3454 already gave rphares points
rphares
@rphares
Jan 23 2016 01:29
yay, congrats, @matthew3454 !
oooh, okay
to start out, we don't need to write case valueX:, we can just write case X : @maxgud
Max Gudmundson
@maxgud
Jan 23 2016 01:31
Something like this for the first case?
case a:
document.write("alpha");
break;
titi207
@titi207
Jan 23 2016 01:31
What's the problem
Enter to the second
Max Gudmundson
@maxgud
Jan 23 2016 01:33
Also for this first bit, does the string 'val' after switch need to be 'val' or 'answer' or does it need to be unique like 'num' ?
function myTest(val) {
var answer = "";
// Only change code below this line
switch (val)
rphares
@rphares
Jan 23 2016 01:34
oooh, sorry, my example was misleading-- case 1 : for example
hmm, okay, let me go at this another way
Josue Escobar
@jees10
Jan 23 2016 01:35
}
rphares
@rphares
Jan 23 2016 01:35
example:
Max Gudmundson
@maxgud
Jan 23 2016 01:35
This doesn't work
case 1:
1 == document.write("alpha");
break;
rphares
@rphares
Jan 23 2016 01:35
no, it doesn't, let me give you a fake example,
  case 13 :
  answer = "Bob";
   break;
@maxgud :point_up:
Max Gudmundson
@maxgud
Jan 23 2016 01:36
Wooo! that is it. Thx so much
titi207
@titi207
Jan 23 2016 01:36
rphares
@rphares
Jan 23 2016 01:37
sure thing! remember to return answer once your cases are finished, and happy coding! :) @maxgud
titi207
@titi207
Jan 23 2016 01:37
Ok it's good
Thank you @rphares
CamperBot
@camperbot
Jan 23 2016 01:37
titi207 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1882 | @rphares | http://www.freecodecamp.com/rphares
Max Gudmundson
@maxgud
Jan 23 2016 01:37
Hey how do you assign brownie points?
rphares
@rphares
Jan 23 2016 01:38
you just say thanks, @name
explain brownie
CamperBot
@camperbot
Jan 23 2016 01:38

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

Max Gudmundson
@maxgud
Jan 23 2016 01:38
thanks @rphares
CamperBot
@camperbot
Jan 23 2016 01:38
maxgud sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1883 | @rphares | http://www.freecodecamp.com/rphares
Max Gudmundson
@maxgud
Jan 23 2016 01:38
Huzzah
rphares
@rphares
Jan 23 2016 01:38
aw, thank you, @maxgud ! honored to be the first brownie recipient~
CamperBot
@camperbot
Jan 23 2016 01:38
rphares sends brownie points to @maxgud :sparkles: :thumbsup: :sparkles:
:star: 198 | @maxgud | http://www.freecodecamp.com/maxgud
rphares
@rphares
Jan 23 2016 01:41
@titi207 , you all good now? :)
h-fiona
@h-fiona
Jan 23 2016 01:58
Hey guys
Was hoping if someone could help me on this challenge re: Stand in Line
not sur what the instructions are asking for exactly

function queue(arr, item) {

return item; // Change this line
}

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

rphares
@rphares
Jan 23 2016 02:00
hmmm, have you checked out the wiki, @h-fiona ?
h-fiona
@h-fiona
Jan 23 2016 02:00
Do I need to use push() and shift() in the queue() function?
rphares
@rphares
Jan 23 2016 02:00
normally, i don't recommend that-- very easy to fall into temptation and read the soln,
h-fiona
@h-fiona
Jan 23 2016 02:00
Oh I do not know wher to find the solution
(can we find it somewhere in the page?)
rphares
@rphares
Jan 23 2016 02:01
yep, push and shift should sort it :)
@h-fiona , no its not in the page, but sample solutions can be found in the wikis,
that said, NOT generally advisable, better to try try try first :)
the only reason on this one i might say look, is it starts by clarifying the directions,
h-fiona
@h-fiona
Jan 23 2016 02:01
my quetion is, "arr" and 'item" are parameters (ie: dumy text?)
rphares
@rphares
Jan 23 2016 02:02
so if you can withstand the temptation to check out the answer...
h-fiona
@h-fiona
Jan 23 2016 02:02
so in the console, they are introducing var testArr
howeever, should I be using arr instead?
and why is the display code introducing
Micah Bales
@micahbales
Jan 23 2016 02:02
thanks @agbales
CamperBot
@camperbot
Jan 23 2016 02:02
micahbales sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 304 | @agbales | http://www.freecodecamp.com/agbales
h-fiona
@h-fiona
Jan 23 2016 02:02
JSON.stringify
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
rphares
@rphares
Jan 23 2016 02:02
should be using arr, yes, don't need testArr,
h-fiona
@h-fiona
Jan 23 2016 02:03
however, in the display code, it references testArr
and queu as well
i suppose testArr is the variable which contains the array
rphares
@rphares
Jan 23 2016 02:03
yes-- queue is your function,
h-fiona
@h-fiona
Jan 23 2016 02:04
and we create a function that consumes an array, as well as a number?
rphares
@rphares
Jan 23 2016 02:04
i don't have a testArr, my display code is myArr, but not too important for the part you are writing,
h-fiona
@h-fiona
Jan 23 2016 02:05
the reason why i am a bit confused regarding the instructions is
it asks for "The queue function should then return the element that was removed."

function queue(arr, item) {

return item; // Change this line
}

rphares
@rphares
Jan 23 2016 02:05
Write a function queue which takes an "array" and an "item" as arguments.
Add the item onto the end of the array, then remove the first element of the array.
The queue function should return the element that was removed.
h-fiona
@h-fiona
Jan 23 2016 02:06
so in the console, it says return item
Yam
@livefreensmart
Jan 23 2016 02:06
So, I'm in Record Collection Challenge and have this code.
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
update(1245, "tracks", "Addicted to Love");
It's failing at After update(1245, "tracks", "Addicted to Love"), tracks should have a length of 1
h-fiona
@h-fiona
Jan 23 2016 02:07
does item refer to the actual parameter from (arr, item) or does it refer to getting the element that was removed, in this case, wod it be the first element of the array?
ie arr[0].shift ??
Yam
@livefreensmart
Jan 23 2016 02:07
Is it a bug or something I'm doing wrong?
rphares
@rphares
Jan 23 2016 02:07
just need arr.shift(); @h-fiona
I'm sorry, I'm not your best source on this-- I'm really bad at talking about things in the right words,
h-fiona
@h-fiona
Jan 23 2016 02:08
oh, ok, ya that makes sense, because the shift() function takes the first element so we dont need to specify the position
@rphares thank you for your help ! i wil try that now
CamperBot
@camperbot
Jan 23 2016 02:09
h-fiona sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1884 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 23 2016 02:09
Anytime, sorry i can t be of more help!
@livefreensmart , not a bug, i think,
h-fiona
@h-fiona
Jan 23 2016 02:12
@rphares actually, let me khow where the wiki page is
rphares
@rphares
Jan 23 2016 02:12
hahaha, sure thing, you can generally get them by wiki + keyword from title
wiki stand in line
CamperBot
@camperbot
Jan 23 2016 02:12

:point_right: checkpoint stand in line [wiki]

Checkpoint: Stand In Line

About queues

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Instructions

Write a function queue which takes an "array" and an "item" as arguments.

Add the item onto the end of the array, then remove the first element of the array.

The queue function should return the element that was removed.

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

:pencil: read more about checkpoint stand in line on the FCC Wiki

h-fiona
@h-fiona
Jan 23 2016 02:13
tank ou!!
rphares
@rphares
Jan 23 2016 02:13
sure thing!
Abby
@s0uth
Jan 23 2016 02:14

Hey everyone, I'm stuck in this exercise on basic javascript 280: When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
console.log("Hello");
return "World";
console.log("byebye")
}
myFun();
The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement.

Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

// 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);
h-fiona
@h-fiona
Jan 23 2016 02:16
@rphares thanks so much
CamperBot
@camperbot
Jan 23 2016 02:16
h-fiona sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: h-fiona already gave rphares points
Abby
@s0uth
Jan 23 2016 02:17
what's wrong with my code? Thanks!
h-fiona
@h-fiona
Jan 23 2016 02:17
we needed to define another varaible
rphares
@rphares
Jan 23 2016 02:17
@s0uth , a few things :)
in your conditional you want it to say (if a is less than zero OR if b is less than zero) @s0uth
right now, you are saying (if a or b is equal to zero)
try switching what is in the brackets around :)
@h-fiona , curious to see your answer if you've solved it already! (I didn't define anything new in mine, i don't think...)
Abby
@s0uth
Jan 23 2016 02:19
right right...let me try that...
rphares
@rphares
Jan 23 2016 02:19
:)
Abby
@s0uth
Jan 23 2016 02:20
That worked @rphares Thank you!
CamperBot
@camperbot
Jan 23 2016 02:20
s0uth sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1885 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 23 2016 02:21
sure thing, @s0uth :)
h-fiona
@h-fiona
Jan 23 2016 02:22
@rphares actually no i didnt solve it yet
rphares
@rphares
Jan 23 2016 02:23
oooh, cool cool, lol, just thought you meant you'd solved it :) Back to work, then, and happy coding! :)
h-fiona
@h-fiona
Jan 23 2016 02:23

i guess my issue is the challenge asks for

queue([], 1) should return 1
queue([2], 1) should return 2
queue([5,6,7,8,9], 1) should return 5
After queue(testArr, 10), myArr[4] should be 10

so do i need to change the display code that is defauted
rphares
@rphares
Jan 23 2016 02:24
it's been a while, but i don't recall changing that,
but i never look at the tests, I'm sorry,
i find them to be misleading more often than not, heh
i find it easier to just focus on what it wants me to do-
h-fiona
@h-fiona
Jan 23 2016 02:25
my question is

function queue(arr, item) {
arr.push(item); // Change this line

return arr.shift();
}

so this was the solution
arr.push(item), represents an argument?
rphares
@rphares
Jan 23 2016 02:26
hahaha, thats exactly the type of answer i can't give, I'm terrible at the terminology,
h-fiona
@h-fiona
Jan 23 2016 02:26
nd return arr.shift() is the output / return?
rphares
@rphares
Jan 23 2016 02:26
i would ask that in the main room,
there are quite a few strong people in there at moment :)
h-fiona
@h-fiona
Jan 23 2016 02:26
how is it that the array becomes updated with the arr.shift() applied as well
Yasin Yusuf
@YasinYA
Jan 23 2016 02:27
hi guys
rphares
@rphares
Jan 23 2016 02:27
@sludge256
hi, @YasinYA ! :)
h-fiona
@h-fiona
Jan 23 2016 02:27
in the console.log() output
Yasin Yusuf
@YasinYA
Jan 23 2016 02:28
@rphares how are you
Brian
@sludge256
Jan 23 2016 02:28
Hi
rphares
@rphares
Jan 23 2016 02:28
Great, thanks! about to head out and enjoy the nice weather :) You?
YAY, thanks, @sludge256 -- can you answer @h-fiona ? questions about stand in line...
CamperBot
@camperbot
Jan 23 2016 02:28
rphares sends brownie points to @sludge256 and @h-fiona :sparkles: :thumbsup: :sparkles:
:star: 996 | @sludge256 | http://www.freecodecamp.com/sludge256
:star: 60 | @h-fiona | http://www.freecodecamp.com/h-fiona
h-fiona
@h-fiona
Jan 23 2016 02:30
in the solution
they define a variable returned first
Leonard Johnson
@Jarvis3000
Jan 23 2016 02:31

@neopoole // 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
I'm having a problem with two of my challenges playerNumber should be a numberYou should use bracket notation to access testObj

Yasin Yusuf
@YasinYA
Jan 23 2016 02:31
what am i doing wrongly
Brian
@sludge256
Jan 23 2016 02:33
I'm not sure I'm understanding what you mean by they define a variable returned first
Leonard Johnson
@Jarvis3000
Jan 23 2016 02:33

@Jarvis3000 @neopoole // 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
I'm having a problem with two of my challenges playerNumber should be a numberYou should use bracket notation to access testObj

BDMayhem
@BDMayhem
Jan 23 2016 02:35
This message was deleted
Yasin Yusuf
@YasinYA
Jan 23 2016 02:35
@sludge256 are you talkin to me
BDMayhem
@BDMayhem
Jan 23 2016 02:36
Any idea why this isn't joining?
Brian
@sludge256
Jan 23 2016 02:36
Nope
BDMayhem
@BDMayhem
Jan 23 2016 02:36
This message was deleted
function reverseString(str) {
  var a = str.split("");
  a.reverse();
  a.join("");
  str = a;
  return str;
}

reverseString("hello");
I got it to work with str = a.join(""); but I don't understand the problem with joining a, then assigning str.
Brian
@sludge256
Jan 23 2016 02:41
Maybe because it doesn't actually modify the array?
It just returns a string value
I could be wrong though
Being on mobile is hindering my code test abilities
BDMayhem
@BDMayhem
Jan 23 2016 02:44
I want a string. The function should take a string, split it into an array, reverse it, join it back into a string, and return that string.
Brian
@sludge256
Jan 23 2016 02:45
I'm saying that it's possible that the methods are working but they won't actually modify what they're being called on
Instead they return a new string
Which goes away if you don't assign it on the same line
d wilder
@alhazen1
Jan 23 2016 02:50
@BDMayhem str = a.join("");
BDMayhem
@BDMayhem
Jan 23 2016 02:50
Thanks. I got it to work with that. I just don't get why it wouldn't work on 2 lines.
d wilder
@alhazen1
Jan 23 2016 02:50
@BDMayhem join returns a string but does not alter string a
BDMayhem
@BDMayhem
Jan 23 2016 02:51
So join acts differently from, say, reverse.
Tarun
@tkc3vp
Jan 23 2016 02:52
@Jarvis3000 @neopoole
BDMayhem
@BDMayhem
Jan 23 2016 02:53
Does split do the same? Like if I say string.split()it won't actually do anything unless I assign it to a different array?
d wilder
@alhazen1
Jan 23 2016 02:53
@BDMayhem actually join takes an array and turns it in to a string
@BDMayhem split makes the string into an array so you can run array-type methods on it. Then you make it back into a string to return it. Most of those can be chained as well
Courtney Smith
@courtneylue
Jan 23 2016 02:58

function myTest(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "a":
answer = "apple";
break;

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

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

default:
answer = "stuff";
// Only change code above this line
return answer;
}
}

// Change this value to test
myTest("a");
Not sure what I'm missing... could anyone help out?

d wilder
@alhazen1
Jan 23 2016 02:59
@BDMayhem Yes, string will as it was before so you need to catch the output in a variable or as a return var temp = str.split();
@BDMayhem so if str is 'hello' after str.split() it is still 'hello' but a.reverse() actually manipulates that array. If you catch the output of your .join() then it should work
@BDMayhem but this one change should make your function work str = a.join("");
Tennile Edwards
@telaed
Jan 23 2016 03:05
Hey all! I've been working on the Waypoint: Profile Lookup and I am stumped!
I can get all of the tests to pass except "No such contact"
Here is my code:

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

else {return "No such property";}
}
// Only change code above this line
}
}

Alwan Mortada
@TheeGrassHopper
Jan 23 2016 03:10
I'm trying to get 10 random generated numbers
function random(){
  for(var i = 0; i <= 10; i++){
    var num = Math.floor(Math.random()* 11);
    console.log(num);

  }
}
HELP PLEASE
CamperBot
@camperbot
Jan 23 2016 03:11
no wiki entry for: please
Alwan Mortada
@TheeGrassHopper
Jan 23 2016 03:11
please
help please
CamperBot
@camperbot
Jan 23 2016 03:11

:point_right: bonfire no repeats please [wiki]

Problem Explanation:

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

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

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

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

d wilder
@alhazen1
Jan 23 2016 03:14
@telaed hmmmm... Your code worked for me. Maybe you need to reload your browser page
Tennile Edwards
@telaed
Jan 23 2016 03:15
Thanks. I'll try it.
d wilder
@alhazen1
Jan 23 2016 03:17
@telaed ...but it did not work in some of the other cases
Tennile Edwards
@telaed
Jan 23 2016 03:18
yes. that is why I am experiencing. When I read it, the logic seems sound.
Something is wrong though
Alwan Mortada
@TheeGrassHopper
Jan 23 2016 03:21
how can i get 10 random generated numbers function random(){ for(var i = 0; i <= 10; i++){ var num = Math.floor(Math.random()* 11); return num.[i]; } }
function random(){
  for(var i = 0; i <= 10; i++){
    var num = Math.floor(Math.random()* 11);
    return num.[i];
  }
}
how can i get 10 random generated numbers
anyone??????
d wilder
@alhazen1
Jan 23 2016 03:22
@telaed if (contacts[i].firstName !== firstName) returns if the first in array is not a match. Probably better to change logic to if it DOES match and then act accordingly
matthew3454
@matthew3454
Jan 23 2016 03:37
I have a question on the Waypoint: Selecting from many options with Switch Statements. Can someone help me?
d wilder
@alhazen1
Jan 23 2016 03:37
@TheeGrassHopper Your loop only runs once because return exits your function. I'm assuming you get one random number. You could call your random function 10 times or have your random function save 10 numbers into an array
@matthew3454 probably, what are you stuck on?
matthew3454
@matthew3454
Jan 23 2016 03:38
Instructions
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta" This is what I have left to do: myTest(2) should have a value of "beta"
myTest(3) should have a value of "gamma"
myTest(4) should have a value of "delta"
THis is my code:
function myTest(val) {
  var answer = "alpha";
  // Only change code below this line
  switch (val) {
    case val:"beta";
    answer;
    break;
  case val: "gamma";
    answer;
    break;

  case val:"delta";
    answer;
    break;
  }


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

// Change this value to test
myTest(1);
eeflores
@eeflores
Jan 23 2016 03:39
@matthew3454 you'll want to assign the string to answer
d wilder
@alhazen1
Jan 23 2016 03:39
@matthew3454 your syntax is off a bit
case 1:
    answer = "beta";
matthew3454
@matthew3454
Jan 23 2016 03:40
ohkay dokay
It @alhazen1 @eeflores Thank you
CamperBot
@camperbot
Jan 23 2016 03:43
matthew3454 sends brownie points to @alhazen1 and @eeflores :sparkles: :thumbsup: :sparkles:
:star: 290 | @alhazen1 | http://www.freecodecamp.com/alhazen1
:star: 473 | @eeflores | http://www.freecodecamp.com/eeflores
d wilder
@alhazen1
Jan 23 2016 03:44
@matthew3454 you're welcome
Alwan Mortada
@TheeGrassHopper
Jan 23 2016 03:45
@alhazen1 function random(){ for(var i = 0; i <= 10; i++){ var num = Math.floor(Math.random()* 10); return random([i]); } }
or function random(){ for(var i = 0; i <= 10; i++){ var num = Math.floor(Math.random()* 10); return [i].random(); } }
jwang687
@jwang687
Jan 23 2016 03:46
Hi. I feel lost by reading the Stand in Line description
Not sure what to do with this: Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.
d wilder
@alhazen1
Jan 23 2016 03:48
@jwang687 imagine a paper towel tube full of ping pong balls. if you push one in one end then another ball will fall out the other
jwang687
@jwang687
Jan 23 2016 03:51
@alhazen1 Thanks! That makes sense, but what should I write to continue? Where did I do wrong? function queue(arr, item) {
// Your code here
queue([1,2,3,4,5], 6);
return item; // Change this line
}
CamperBot
@camperbot
Jan 23 2016 03:51
jwang687 sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 291 | @alhazen1 | http://www.freecodecamp.com/alhazen1
d wilder
@alhazen1
Jan 23 2016 03:52
@jwang687 if I remember correctly the instructions had methods push and shift.
push(val) will put val at the end of an array and shift() will take one element off the front of an array
function queue(arr, item) {
// Your code here
queue([1,2,3,4,5], 6); //<- don't move that here
return item; // Change this line
}
matthew3454
@matthew3454
Jan 23 2016 03:54
I have a new question on the Waypoint: Adding a default option in Switch statements. Can Someone help me with this one?
Joshua McKenzie
@mckenzieja
Jan 23 2016 03:55
@jwang687 make a line that adds to the end of your arr, and then return with the one that removes.
d wilder
@alhazen1
Jan 23 2016 03:56
@jwang687 when your program calls queue([1,2,3,4,5],6) it sends an array and a number to your function. You are to push the 6 onto the array and pull the first element off the array. The return value is to be the element your removed
Alex Rose
@thelyricalrose
Jan 23 2016 03:56
@matthew3454 Sure what problem are you having?
matthew3454
@matthew3454
Jan 23 2016 03:56
These are the instructions: myTest("a") should have a value of "apple"
myTest("b") should have a value of "bird"
myTest("c") should have a value of "cat"
myTest("d") should have a value of "stuff"
myTest(4) should have a value of "stuff"
You should not use any if or else statements
You should have at least 3 break statements
And Here is my code:
function myTest(val) {
  var answer = "a";
  // Only change code below this line
  switch (val){
    case 2:
      answer = "b";
      break;
    case 3:
      answer = "c";
      break;
    default:
     "stuff";
  }


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

// Change this value to test
myTest(1);
here's an update:
function myTest(val) {
  var answer = "apple";
  // Only change code below this line
  switch (val){
    case 2:
      answer = "bird";
      break;
    case 3:
      answer = "cat";
      break;
    default:
     "stuff";
  }


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

// Change this value to test
myTest(1);
myTest("b") should have a value of "bird"
myTest("c") should have a value of "cat"
myTest("d") should have a value of "stuff"
myTest(4) should have a value of "stuff"
You should have at least 3 break statements
jwang687
@jwang687
Jan 23 2016 03:57
@alhazen1 Right. But it didn't return 1, what does this mean...
matthew3454
@matthew3454
Jan 23 2016 03:57
Those are what I have left to do
Joshua McKenzie
@mckenzieja
Jan 23 2016 03:58
@matthew3454 your "var answer = "a"; " should be var answer =""
matthew3454
@matthew3454
Jan 23 2016 03:58
mk
Joshua McKenzie
@mckenzieja
Jan 23 2016 03:58
and just add "case a" to your switch along with the var assignment.
@jwang687 can you copy/paste the code you have?
Alex Rose
@thelyricalrose
Jan 23 2016 03:59
@matthew3454 your case values should be the letters you are looking for so if you wanted to have "d" = delta you would havejs case "d": return "delta"; break;
case "d":
  return "delta";
  break;
d wilder
@alhazen1
Jan 23 2016 04:01

@jwang687

```
function queue(arr, item) {
// Your code here
//use push to put item into array
//use shift to take first element off array - save into variable 
return whateveryorvariableisnamed; // Change this line
}

queue([1,2,3,4,5], 6); //leave this here

```

matthew3454
@matthew3454
Jan 23 2016 04:01
oh! okay I'll try that @thelyricalrose
Alex Rose
@thelyricalrose
Jan 23 2016 04:03
Happy to help! Ask if you have any more problems @matthew3454
Joshua McKenzie
@mckenzieja
Jan 23 2016 04:03
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([2], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
CamperBot
@camperbot
Jan 23 2016 04:03
:bulb: to format code use backticks! ``` more info
Tal Abziz
@TalAbziz
Jan 23 2016 04:04
" palindrome("0_0 (: /-\ :) 0-0") should return true." guys wth?
oh damn emote
matthew3454
@matthew3454
Jan 23 2016 04:04
@thelyricalrose You almost got me through it. Now I just need to make myTest(4) have a value of "stuff"
Tal Abziz
@TalAbziz
Jan 23 2016 04:05
palindrome("0_0 (: /-\ :) 0-0") should return true.
matthew3454
@matthew3454
Jan 23 2016 04:05
here is my updated code:
function myTest(val) {
  var answer = "apple";
  // Only change code below this line
  switch (val){
    case "b":
      answer = "bird";
      break;
    case "c":
      answer = "cat";
      break;
    case "d":
    answer = "stuff";
      break;
  }


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

// Change this value to test
myTest(1);
Ttvi
@XeCtvi
Jan 23 2016 04:06
Dear all . why str.split('').reverse().join(''). didn't work in str ? cause the memory for the str can not be changed ? thanks for help ~
Tal Abziz
@TalAbziz
Jan 23 2016 04:07
var rev = str.split("").reverse().join("");
Alex Rose
@thelyricalrose
Jan 23 2016 04:07
@matthew3454 While that will return the value "Stuff" the challenge in question wants you to use default
Tal Abziz
@TalAbziz
Jan 23 2016 04:07
should work
matthew3454
@matthew3454
Jan 23 2016 04:08
oaky
Alex Rose
@thelyricalrose
Jan 23 2016 04:08
@matthew3454 default functions like a catch all for test cases, so that if a value you didnt specify specific result for is put in it execute the default course of action
Ttvi
@XeCtvi
Jan 23 2016 04:09
I know that after var a variable. I just gonna ask why can't alter the value of str ... = =
Alex Rose
@thelyricalrose
Jan 23 2016 04:09
@matthew3454 so instead of case "d":
return "stuff";
break;
case "d":
  return "stuff";
  break; 
You have default:
return "what you want";
break;
default:
  return "what you want";
  break;
Ttvi
@XeCtvi
Jan 23 2016 04:10
@TalAbziz I know that after var a variable. I just gonna ask why can't alter the value of str ... = =
Alex Rose
@thelyricalrose
Jan 23 2016 04:10
One of these days I'll copy code properly the first time :P
Joshua McKenzie
@mckenzieja
Jan 23 2016 04:10
@matthew3454
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {

    case "a":
      answer = "apple";
      break;
    case "b":
      answer = "bird";
      break;
    case "c":
      answer = "cat";
      break;
    default:
      answer = "stuff";
  }


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

// Change this value to test
myTest("a");
@matthew3454 you modified your variable above the comment line //only change code below
Tal Abziz
@TalAbziz
Jan 23 2016 04:12
@XeCtvi its immutable . im not sure why , but i think this is a convention, i know its like that in java too, so i guess javascript works tha same
matthew3454
@matthew3454
Jan 23 2016 04:12
@thelyricalrose @metaljacke1 Thank You very much
CamperBot
@camperbot
Jan 23 2016 04:12
matthew3454 sends brownie points to @thelyricalrose and @metaljacke1 :sparkles: :thumbsup: :sparkles:
:star: 224 | @thelyricalrose | http://www.freecodecamp.com/thelyricalrose
:star: 209 | @metaljacke1 | http://www.freecodecamp.com/metaljacke1
Alex Rose
@thelyricalrose
Jan 23 2016 04:14
@matthew3454 No Problem! Keep on Keeping on
Ttvi
@XeCtvi
Jan 23 2016 04:15
@TalAbziz I guess so . Thanks a lot ~
CamperBot
@camperbot
Jan 23 2016 04:15
xectvi sends brownie points to @talabziz :sparkles: :thumbsup: :sparkles:
:star: 249 | @talabziz | http://www.freecodecamp.com/talabziz
Tal Abziz
@TalAbziz
Jan 23 2016 04:16
guys is there a way to find punctuations using regexp ?
i mean a short way or something
Nick Robson
@nickrobson
Jan 23 2016 04:19
@TalAbziz Do you just mean anything but letters, numbers, and whitespace? or do you mean only a specific set of characters?
Tal Abziz
@TalAbziz
Jan 23 2016 04:21
im in the palindrome challange, and apparantly js "0_0 (: /-\ :) 0-0" is a palindrome
so the underscore or dash probably should be ignored
ok I found this "[^\w]|_" and it worked.
d wilder
@alhazen1
Jan 23 2016 04:32
@TalAbziz I find this super helpful with regular expressions
REgExr
Aaron Graves
@gravesmeister
Jan 23 2016 04:37
Can someone help me understand this?
var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
var citrus = fruits.slice(1, 3)
Apparently the 3 element represents Lemon. Logic tells me that it would actually be Apple since Javascript starts counting at 0
Tal Abziz
@TalAbziz
Jan 23 2016 04:39
I guess it works like iterator, where the start is included but the end is not included.
@alhazen1 thanks ill look at it when in need.
CamperBot
@camperbot
Jan 23 2016 04:40
talabziz sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 292 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Michael Mazzone
@GitMazzone
Jan 23 2016 04:42
I'm confused about what the requirements are for the Profile Lookup waypoint in JS. What does it mean when it wants me to check if a property is an actual property...?
Josh Lumley
@JWLumley
Jan 23 2016 04:45
Seems like this should be super simple. Can't see what I'm missing.
// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line

testObj.hat;      // Change this line
testObj.shirt;    // Change this line
Chris Burros
@cburros
Jan 23 2016 04:47
@JWLumley need to set testObj.hat and testObj.shirt as values to variables
@JWLumley The expected results at the bottom of the left sidebar serve as a hint on this one
Josh Lumley
@JWLumley
Jan 23 2016 04:48
@cburros Thanks, for the help!
CamperBot
@camperbot
Jan 23 2016 04:48
jwlumley sends brownie points to @cburros :sparkles: :thumbsup: :sparkles:
:star: 237 | @cburros | http://www.freecodecamp.com/cburros
Chris Burros
@cburros
Jan 23 2016 04:50
@GitMazzone the parameters of the function are firstName and prop. So it wants you to see if the prop parameter is equal to the property named in the function call at the bottom of the script.
sean9
@sean9
Jan 23 2016 04:53
hey people
as laymen as you can
could someone explain this
  return arr.filter(function(element) {
    return args.indexOf(element) === -1;
  } );
step by step
Chris Burros
@cburros
Jan 23 2016 04:56
@gravesmeister the slice method starts with the first specified element but ends with the element before the one named. So the method only returns positions 1 and 2. You are slicing up to but not including the last specified element. Not for sure why this method does this, but that is how that method works
Tal Abziz
@TalAbziz
Jan 23 2016 04:57
ok so you return a filtered array,
now to filter it you need a boolean function which returns true or false.
so theres a nested function which returns true if the index of (element) equals to -1 (strict equal).
so you kick out all the elements that return "true" in this function.
i
keep in mind the variable element is just a name, it will actually hold each element in the array.
sean9
@sean9
Jan 23 2016 04:59
so the nested function takes element filters
then spits them into element of the first function?
Rex Schrader
@SaintPeter
Jan 23 2016 05:01
@sean9 The inner funciton is called once for each element in arr. If that function returns true, then the element is kept. If it returns false, that element is not kept. The elements are put into a new array which is then returned from filter. In the above code, that new array is being returned from the calling function.
@sean9 So all that you need to know is if element is present in the array args. If it is present, it gets a value that is not -1. If it is NOT present, indexOf returns -1
@sean9 So It's really only keeping elements of arr which are NOT present in array args
@sean9 Ya dig?
Fidel Severino
@fidelscodes
Jan 23 2016 05:03
arr.filter() will go through each element in the array arr and only keep those that return true after being evaluated by the function you give it. In this case, the function uses indexOf() to determine whether the element being passed is found in args array or not. If it's not found it will return false, thus that element will be filtered out.
Josh Lumley
@JWLumley
Jan 23 2016 05:04
I just can't seem to get the playerNumber to work
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16[testObj];    // Change this Line
var player = testObj[16];   // Change this Line
Rex Schrader
@SaintPeter
Jan 23 2016 05:04
@JWLumley playerNumber is just 16. It's literally the number of the player.
@JWLumley You can then put playerNumber in the brackets of testObj, to extract the corasponding value.
Josh Lumley
@JWLumley
Jan 23 2016 05:05
@SaintPeter It's not passing because it says I should use bracket notation to access testObj
Rex Schrader
@SaintPeter
Jan 23 2016 05:05
@JWLumley e.g. someObject[someVariableWhichContainsAPropertyName]
Josh Lumley
@JWLumley
Jan 23 2016 05:06
@SaintPeter Thanks. I feel a little slow after re-reading the variable.
CamperBot
@camperbot
Jan 23 2016 05:06
jwlumley sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2356 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Jan 23 2016 05:06
@JWLumley :D Happens to the best of us
Aaron Graves
@gravesmeister
Jan 23 2016 05:07
Does anyone notice what I'm doing wrong here?
function convert(celsius) {
  // Only change code below this line
  var fahranheit = (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(30);
Rex Schrader
@SaintPeter
Jan 23 2016 05:07
@gravesmeister You did not spell fahrenheit correctly ;)
Aaron Graves
@gravesmeister
Jan 23 2016 05:07
are you cereal?
Muhammed Nuhman
@nuhman
Jan 23 2016 05:07
Hey any help with 'mutations' challenge ?
function mutation(arr) {
 for(var i=0;i<arr[1].length;i++){
   x = arr[0].indexOf(arr[1][i]);
   if(x === -1){
     return false;
   }
 }
  return true;
}

mutation(["hello", "he"]);
Rex Schrader
@SaintPeter
Jan 23 2016 05:08
@gravesmeister If it's any consolation, I wrote the bloody thing and I can't figure out how to spell it either.
Aaron Graves
@gravesmeister
Jan 23 2016 05:08
@SaintPeter Thanks. Don't I feel like a noob
CamperBot
@camperbot
Jan 23 2016 05:08
gravesmeister sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2357 | @saintpeter | http://www.freecodecamp.com/saintpeter
Aaron Graves
@gravesmeister
Jan 23 2016 05:08
Ok , on with the learning. Thanks dude.
Muhammed Nuhman
@nuhman
Jan 23 2016 05:08
I got it right except for the 'Case Insensitive ' Part
Can anyone help , please ?
Rex Schrader
@SaintPeter
Jan 23 2016 05:09
@nuhman I think you may need to convert your strings to lowercase
Muhammed Nuhman
@nuhman
Jan 23 2016 05:10
@SaintPeter yea but how
Rex Schrader
@SaintPeter
Jan 23 2016 05:10
@nuhman Some of them are capital which is going to fail the .indexOf
Muhammed Nuhman
@nuhman
Jan 23 2016 05:10
i mean in arrays
Rex Schrader
@SaintPeter
Jan 23 2016 05:10
@nuhman Those arrays contain strings.
Muhammed Nuhman
@nuhman
Jan 23 2016 05:10
when I try to do the compiler doesn't respond and I had to hard reload the page
sean9
@sean9
Jan 23 2016 05:10
i think i get it
Rex Schrader
@SaintPeter
Jan 23 2016 05:10
@nuhman arr[0] is a string, as is arr[1]
sean9
@sean9
Jan 23 2016 05:11
thanks! @fidelscodes @SaintPeter
CamperBot
@camperbot
Jan 23 2016 05:11
sean9 sends brownie points to @fidelscodes and @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 405 | @fidelscodes | http://www.freecodecamp.com/fidelscodes
:star: 2358 | @saintpeter | http://www.freecodecamp.com/saintpeter
Muhammed Nuhman
@nuhman
Jan 23 2016 05:11
arr[0].toLowerCase, yiou mean ?
Rex Schrader
@SaintPeter
Jan 23 2016 05:11
@nuhman Yes, except it's toLowerCase() - the parentheses are required because it's a function call.
@nuhman Remember that strings are immutable, though, so if you want to change arr[0] you'll need to assign the result back to it.
IE: someStr = someStr.toLowerCase();
Muhammed Nuhman
@nuhman
Jan 23 2016 05:12
@SaintPeter Thanks a Lot !
CamperBot
@camperbot
Jan 23 2016 05:12
nuhman sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2359 | @saintpeter | http://www.freecodecamp.com/saintpeter
Muhammed Nuhman
@nuhman
Jan 23 2016 05:12
Was missing the para , Silly though :)
Rex Schrader
@SaintPeter
Jan 23 2016 05:13
:D :D
Muhammed Nuhman
@nuhman
Jan 23 2016 05:13
How should I do that, I am new here
Rex Schrader
@SaintPeter
Jan 23 2016 05:13
Do what?
Muhammed Nuhman
@nuhman
Jan 23 2016 05:13
send Brownie Points
Rex Schrader
@SaintPeter
Jan 23 2016 05:14
You just did.
Muhammed Nuhman
@nuhman
Jan 23 2016 05:14
Ok cool :+1:
Rex Schrader
@SaintPeter
Jan 23 2016 05:14
All you have to do is @mention someone and say thanks (or some variation of thanks)
CamperBot
@camperbot
Jan 23 2016 05:14
saintpeter sends brownie points to @mention :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for mention
sean9
@sean9
Jan 23 2016 05:15
where can someone check their brownie points
Rex Schrader
@SaintPeter
Jan 23 2016 05:15
about sean9
CamperBot
@camperbot
Jan 23 2016 05:15
you need to ask about @someone!
Rex Schrader
@SaintPeter
Jan 23 2016 05:15
about @sean9
CamperBot
@camperbot
Jan 23 2016 05:15
:star: 261 | @sean9 | http://www.freecodecamp.com/sean9
Rex Schrader
@SaintPeter
Jan 23 2016 05:16
Also, the upper right corner of your screen on Free Code Camp shows your current brownie points
You get one point for each challenge you complete
and one for each thank you you get
and one for each upvote an article you submit gets
Aaron Graves
@gravesmeister
Jan 23 2016 05:19
Escape Sequences in Strings. I have no clue what it's wanting me to put after myStr; Am I supposed to put each code in there or? I've tried that and just totally lost on what it's wanting me to do
Anyone?
Chris Crook
@chrisisacrook
Jan 23 2016 05:24
@gravesmeister you are trying to return a string that will start with \ and include two tabs, a carriage return, and a new line.
Aaron Graves
@gravesmeister
Jan 23 2016 05:25
So I create a string with those codes in it?
Chris Crook
@chrisisacrook
Jan 23 2016 05:25
If I understood your original post correctly I think you're on the right track. Do you have sample code you've already tried?
Aaron Graves
@gravesmeister
Jan 23 2016 05:26
var myStr' \\ \t \t \r \n'; // Change this line
I added the equals to
Something so simple seems so complicated on FCC sometimes
Chris Crook
@chrisisacrook
Jan 23 2016 05:28
you have a space at the beginning of the string that's not needed. I'm not sure if that would prevent it from working.
Aaron Graves
@gravesmeister
Jan 23 2016 05:30
Ok I got rid of that
Chris Crook
@chrisisacrook
Jan 23 2016 05:31
still no luck? your code looks the same as mine as long as you did put in the assignment operator
Aaron Graves
@gravesmeister
Jan 23 2016 05:31
I had to refresh lol @chrisisacrook thanks
CamperBot
@camperbot
Jan 23 2016 05:31
gravesmeister sends brownie points to @chrisisacrook :sparkles: :thumbsup: :sparkles:
:star: 246 | @chrisisacrook | http://www.freecodecamp.com/chrisisacrook
Aaron Graves
@gravesmeister
Jan 23 2016 05:32
Ok. I have a long way to go but I'm sure I'll be back. Thanks chris
shadowx1224
@shadowx1224
Jan 23 2016 05:32
I'm currently on Counting Cards. Can someone point me in the right direction, because I currently have no idea where to start.
Chris Crook
@chrisisacrook
Jan 23 2016 05:32
No problem. It's those little things that cause the most frustration.
Joshua McKenzie
@mckenzieja
Jan 23 2016 05:34
@shadowx1224 use a switch to group which cards will increase by 1 or decrease by 1.
shadowx1224
@shadowx1224
Jan 23 2016 05:34
thanks.
Joshua McKenzie
@mckenzieja
Jan 23 2016 05:35
Im here for some help myself. On waypoint "Using Objects for Lookups" I know Im missing a variable but not sure how I should configure the function to pass the 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");
Chris Crook
@chrisisacrook
Jan 23 2016 05:38
I was about to ask the same question. I added this below the var lookup codeblock on mine:
lookup[val];
Joshua McKenzie
@mckenzieja
Jan 23 2016 05:39
wow
Just found the answer
and the code check was throwing me a warning which made me hesitate
change that line @chrisisacrook to var result = lookup[val];
Chris Crook
@chrisisacrook
Jan 23 2016 05:41
oh man. those little things like I said before.
thanks @metaljacke1
CamperBot
@camperbot
Jan 23 2016 05:42
chrisisacrook sends brownie points to @metaljacke1 :sparkles: :thumbsup: :sparkles:
:star: 217 | @metaljacke1 | http://www.freecodecamp.com/metaljacke1
Joshua McKenzie
@mckenzieja
Jan 23 2016 05:42
thanks @chrisisacrook
CamperBot
@camperbot
Jan 23 2016 05:42
metaljacke1 sends brownie points to @chrisisacrook :sparkles: :thumbsup: :sparkles:
:star: 248 | @chrisisacrook | http://www.freecodecamp.com/chrisisacrook
Chris Crook
@chrisisacrook
Jan 23 2016 05:42
this is why pair programming would be really useful
Joshua McKenzie
@mckenzieja
Jan 23 2016 05:42
brackets not curly braces my bad...
I agree
If only there was a way to "buddy up"
Joshua McKenzie
@mckenzieja
Jan 23 2016 05:48
there we go.
shovopoddar
@shovopoddar
Jan 23 2016 05:53

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

abTest(-2,2) should return undefined
anyone help ?
NainaPS
@Navyya
Jan 23 2016 05:55
waypoint name?
shovopoddar
@shovopoddar
Jan 23 2016 05:57
Return Early Pattern for Functions
Richard O'Brien
@exarp1
Jan 23 2016 05:57
Hey folks. Got a real frustrating issue getting "Profile Lookup" challenge completed
Anyone remember that one?
NainaPS
@Navyya
Jan 23 2016 06:00
pls read the instruction of the statement...is it and?? or "or"?
@shovopoddar it should satisfy both or one of them
@shovopoddar hint if(a<0 && b<0){ check ur this condition
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:03

@shovopoddar
|| means OR in JS .

No one told you to return a string ;)

Aung Myo Kyaw
@AungMyoKyaw
Jan 23 2016 06:04
array.sort(function(a,b){
  return b-a;
});
i pass this test
but i don't understand the concept
of compare function
NainaPS
@Navyya
Jan 23 2016 06:04
and the value of (a,b) should be (2,2)
Rumen1982
@Rumen1982
Jan 23 2016 06:04
Hey guys i need help on WordBlanks
NainaPS
@Navyya
Jan 23 2016 06:05
what help?
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:05
@AungMyoKyaw ?
What about it?
Aung Myo Kyaw
@AungMyoKyaw
Jan 23 2016 06:05
function(a,b){
  return b-a;
}
Yasin Yusuf
@YasinYA
Jan 23 2016 06:05
hi guys i need help
Chris Crook
@chrisisacrook
Jan 23 2016 06:06
@YasinYA what waypoint are you on?
Aung Myo Kyaw
@AungMyoKyaw
Jan 23 2016 06:06
var array = [1, 12, 21, 2];

// Only change code below this line.

array.sort(function(a,b){
  return b>a;
});
it also work
Rumen1982
@Rumen1982
Jan 23 2016 06:07
wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
@Navyya
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:07
NainaPS
@Navyya
Jan 23 2016 06:07
@shovopoddar are u still working or u got ur error?
Aung Myo Kyaw
@AungMyoKyaw
Jan 23 2016 06:07
@brainyfarm thanks bro
CamperBot
@camperbot
Jan 23 2016 06:07
aungmyokyaw sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1141 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
NainaPS
@Navyya
Jan 23 2016 06:08
@Rumen1982 what u wrote for it? did u try some thing?
Rumen1982
@Rumen1982
Jan 23 2016 06:08
i dont understand what to do in word blanks
NainaPS
@Navyya
Jan 23 2016 06:08
its like fill in the blanks
Rumen1982
@Rumen1982
Jan 23 2016 06:08
i dont know wat to do
NainaPS
@Navyya
Jan 23 2016 06:08
where it should be giving a string with the value of given objs
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:09
@Rumen1982
Join the whole arguments concatenating them with a white space as separator and return them.
NainaPS
@Navyya
Jan 23 2016 06:09
u have to print like this big dog ran quickly
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:09
You are almost there @YasinYA :)
Yasin Yusuf
@YasinYA
Jan 23 2016 06:10
@brainyfarm but what is the thing that am missing
NainaPS
@Navyya
Jan 23 2016 06:10
obj1 + "" + obj2 + " " and so on .....
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:11
You should join the two arrays to make a new one and then filter out items that are not present in arr1 and arr2 @YasinYA :)
So I suggest joining before filtering.
Rumen1982
@Rumen1982
Jan 23 2016 06:12

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

please show me where to put
NainaPS
@Navyya
Jan 23 2016 06:13
below //Your code below this line ... :)
Rumen1982
@Rumen1982
Jan 23 2016 06:14
what to put
NainaPS
@Navyya
Jan 23 2016 06:14
var result = myNoun  +  " "  + myAdjective +  " "  + myVerb + " " + myAdverb;
Maxwell Nare
@maxinare
Jan 23 2016 06:14
@Rumen1982 arrange them the way you like and add some of your words inbetween but your sentence should make sence
Eg the big black dog ran ahead quickly ....
Aaron Graves
@gravesmeister
Jan 23 2016 06:17
I don't think I'm getting it either
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = "My" + "myAdjective" + "myNoun" + "myVerb" + "myAdverb";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
NainaPS
@Navyya
Jan 23 2016 06:19
@gravesmeister var result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;
Chris Crook
@chrisisacrook
Jan 23 2016 06:19
myNoun, myAdjective etc are variables. putting them in quotes turns them into strings instead of using the value stored as the variable
NainaPS
@Navyya
Jan 23 2016 06:19
check it
Aaron Graves
@gravesmeister
Jan 23 2016 06:19
oh ok. Gotchta
I'll try again and be back
@chrisisacrook thanks
CamperBot
@camperbot
Jan 23 2016 06:21
gravesmeister sends brownie points to @chrisisacrook :sparkles: :thumbsup: :sparkles:
:warning: gravesmeister already gave chrisisacrook points
Aaron Graves
@gravesmeister
Jan 23 2016 06:21
thanks @Navyya
CamperBot
@camperbot
Jan 23 2016 06:21
gravesmeister sends brownie points to @navyya :sparkles: :thumbsup: :sparkles:
Maxwell Nare
@maxinare
Jan 23 2016 06:21
@gravesmeister , put your own words in between, "my" should be ur own words that you come up with and concatenate with the given strings
CamperBot
@camperbot
Jan 23 2016 06:21
:star: 24 | @navyya | http://www.freecodecamp.com/navyya
Aaron Graves
@gravesmeister
Jan 23 2016 06:21
ok
Maxwell Nare
@maxinare
Jan 23 2016 06:23
@gravesmeister result= "my" + myNoun + "lazy" + dog ....
Aaron Graves
@gravesmeister
Jan 23 2016 06:25
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = "My" + myAdjective + myNoun + myVerb + "very" + myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Is that at least closer?
Maxwell Nare
@maxinare
Jan 23 2016 06:27
@gravesmeister but for every given word put your own in between
Aaron Graves
@gravesmeister
Jan 23 2016 06:27
Oh ok. I'll try again. Thanks @maxinare
CamperBot
@camperbot
Jan 23 2016 06:27
gravesmeister sends brownie points to @maxinare :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for maxinare
Maxwell Nare
@maxinare
Jan 23 2016 06:28
@gravesmeister treat the given words as bread, just bond them together with peanut butter lol
Richard O'Brien
@exarp1
Jan 23 2016 06:30
Ok - Profile Lookup is kicking my butt: Here's what I tried - I think this should have worked!function lookUp(firstName, prop){
// Only change code below this line
contacts.map(function(obj){
console.log(obj.firstName === firstName);
if(obj.firstName === firstName) {
if(obj.hasOwnProperty[prop]){
return obj.prop;
} else {
return "No such property";
}
} else {
return "No such contact";
}
});
// Only change code above this line
}
Aaron Graves
@gravesmeister
Jan 23 2016 06:31
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = "My" + myAdjective + "black" + myNoun + "freaking" + myVerb + "very" + myAdverb;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Maxwell Nare
@maxinare
Jan 23 2016 06:32
@gravesmeister yes it should go through
Still getting problems?
Aaron Graves
@gravesmeister
Jan 23 2016 06:34
I realized that I didn't have the spacing right by looking at the little black box on the left. I fixed that and it went through. Thanks again Max
Miguel
@Miguel12321
Jan 23 2016 06:34
can someone help me with Introducing JavaScript Object Notation JSON
Aaron Graves
@gravesmeister
Jan 23 2016 06:34
Back to learning. Take care
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:35
Go on @Miguel12321 :D
NainaPS
@Navyya
Jan 23 2016 06:35
@Miguel12321 yes
Miguel
@Miguel12321
Jan 23 2016 06:35
I don't understand what I have to do
Tal Abziz
@TalAbziz
Jan 23 2016 06:36
something specific that you don't understand?
is it the notation itself or the idea?
Miguel
@Miguel12321
Jan 23 2016 06:37
the instruction
NainaPS
@Navyya
Jan 23 2016 06:37
@Miguel12321 u have to create one more obj in the array myMusic with different name of artists and so on
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:37
@Miguel12321
Here is one of the sample object
{
    "artist":"Nicki Minaj",
    "title":"Fly",
    "release_year": 2011,
    "formats": [
      "MP3",
      "MP4",
      "AAC"
    ]
  }
NainaPS
@Navyya
Jan 23 2016 06:38
the same way above it is created
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:38
So basically, what you do is create a similar object and push it into the myMusic array @Miguel12321
To add new item into an array, remember you use array.push(item).
myMusic is an array of objects.
Miguel
@Miguel12321
Jan 23 2016 06:43
@brainyfarm I did the same code that you did but it gives me errors
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:44
You should not do the same code I gave you @Miguel12321 .
Can you copy your whole code as pretty code and paste here @Miguel12321 ?
Miguel
@Miguel12321
Jan 23 2016 06:45
{ 
  "artist": "Nicki Manaj"
  "title":"Fly",
    "release_year":2011,
      "formats":[
"MP3",
        "MP4",
        "AAC",
        ]


}

array.push(item)
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:46
@Miguel12321
That is not all.
Miguel
@Miguel12321
Jan 23 2016 06:46
@brainyfarm that's all I have
Chris Moore
@dooglus
Jan 23 2016 06:47
@brainyfarm I don't think it wants you to use push(). it says "add record here" inside the initialisation. I think it wants you to edit the literal value itself, not push onto the end of it
NainaPS
@Navyya
Jan 23 2016 06:48
Make Object Properties Private????
var Bike = function() {
 var gear= 2;
  // Only change code below this line.
this.getGear= function (){
 return gear+=2;
};
  this.setGear= function (){
  return gear;
};
};

var myCar = new Car();

var myBike = new Bike();
whats wrong here?
myBoke.getGear() should return 4
Chris Moore
@dooglus
Jan 23 2016 06:50
@Navyya setGear() is meant to take a parameter and not return anything isn't it?
NainaPS
@Navyya
Jan 23 2016 06:50
myBike()
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:50
Oh! That is true @dooglus
I am wanting to do it dynamically @dooglus :)
Here is an example @Miguel12321
var myAnimals = [
  {
    "name":"cow",
    "legs":4,
    "goods":"milk"
  },

  {
    "name":"dog",
    "legs":4,
    "goods":"security"
  }

  ]

// Now I want to add new animal to the myAnimal array.

var newAnimal = { 
    "name":"cat",
    "legs":4,
    "goods":"pet"
}

// Ass newAnimal to the array myAnimals
myAnimals.push(newAnimal)
NainaPS
@Navyya
Jan 23 2016 06:51
@dooglus so do i need to give it parameteres?
Chris Moore
@dooglus
Jan 23 2016 06:52
@brainyfarm why did you write about ass in your code?
NainaPS
@Navyya
Jan 23 2016 06:52
say (1,2)
Miguel
@Miguel12321
Jan 23 2016 06:52
@brainyfarm do I have to use the push()?
NainaPS
@Navyya
Jan 23 2016 06:52
no @Miguel12321
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:52
Not necessary @Miguel12321
I did it that way though.
NainaPS
@Navyya
Jan 23 2016 06:52
jus add a record
Chris Moore
@dooglus
Jan 23 2016 06:52
@Miguel12321 I didn't. I just edited the array, adding a new {object} inside the [brackets]
NainaPS
@Navyya
Jan 23 2016 06:53
exactly i did the same
Chris Moore
@dooglus
Jan 23 2016 06:53
@Navyya I don't remember - let me check it. what's the exercise called?
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:53

I could have just copied this:

{ 
    "name":"cat",
    "legs":4,
    "goods":"pet"
}

And add it to the myAnimals array @Miguel12321 which is the approach I now recommend.

Thanks @dooglus :)
CamperBot
@camperbot
Jan 23 2016 06:54
brainyfarm sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 319 | @dooglus | http://www.freecodecamp.com/dooglus
NainaPS
@Navyya
Jan 23 2016 06:54
@dooglus make object properties private
mkumar07
@mkumar07
Jan 23 2016 06:55
Hi, this is regarding JSON part off javascript
here is what i wrote. I think i couldn't understood the whole thing well, can anyone help me out please ?
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here

  {
    "artist" : "A.R.Rahman";
    "title" : "Jai Ho";
    "release_year": 2008;
    "formats": [
    "mp3";
    "mp4";
    "mpeg4";
    ]
  }

];
NainaPS
@Navyya
Jan 23 2016 06:55
@dooglus pls check ur n mine code and lemme know
Chris Moore
@dooglus
Jan 23 2016 06:55
@Navyya ok. so getGear() should just return the current gear, and setGear(x) should set the current gear to x
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:55
@Miguel12321
var myAnimals = [
  {
    "name":"cow",
    "legs":4,
    "goods":"milk"
  },

  {
    "name":"dog",
    "legs":4,
    "goods":"security"
  },


// A new animal is added here
{ 
    "name":"cat",
    "legs":4,
    "goods":"pet"
}

  ]
NainaPS
@Navyya
Jan 23 2016 06:55
@mkumar07 yes we just have to add a record same as above
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:55
@mkumar07
You omitted a comma. (,).
Miguel
@Miguel12321
Jan 23 2016 06:56
{ 
"artist": "Nicki Manaj"
"title":"Fly",
"release_year":2011,
"formats":[
"MP3",
"MP4",
"AAC",
]    
}
];
NainaPS
@Navyya
Jan 23 2016 06:56
@dooglus u set a variable for getting a value??
Miguel
@Miguel12321
Jan 23 2016 06:57
this is what I have but it gives me a semicolon error
Chris Moore
@dooglus
Jan 23 2016 06:57
@Navyya no, getGear takes no arguments and returns the gear, and setGear takes one argument and sets the gear to that value, returning nothing
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:58
What is the comma after AAC for @Miguel12321 ?
Chris Moore
@dooglus
Jan 23 2016 06:58
@Miguel12321 you need to separate each key:value pair with a comma
NainaPS
@Navyya
Jan 23 2016 06:58
lemme try once @dooglus
mkumar07
@mkumar07
Jan 23 2016 06:58
@dooglus Hey, can you help me out with JSON thing.. @Navyya Can you please explain, I don't think I understood it well
Olawale Akinseye
@brainyfarm
Jan 23 2016 06:59
You are missing a comma @mkumar07
NainaPS
@Navyya
Jan 23 2016 07:00
can u give ur solution @dooglus ?
Chris Moore
@dooglus
Jan 23 2016 07:00
@mkumar07 when you are making an array by listing things inside square backets, you have to put a command between each thing. like: var myArray = [1, 2, 3];-- see how there's a comma between them all? you don't have any comma between the two things in your array
@Navyya I think it's better if you do it. can you paste just your two functions?
Miguel
@Miguel12321
Jan 23 2016 07:01
@dooglus I did
NainaPS
@Navyya
Jan 23 2016 07:01
@dooglus i tried this once again lemme give u
mkumar07
@mkumar07
Jan 23 2016 07:01
@dooglus I modified the code . here is what it look right now. However, error are still same
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
  {
    "artist" : "A.R.Rahman";
    "title" : "Jai Ho";
    "release_year": 2008;
    "formats": [
    "mp3",
    "mp4",
    "mpeg4"],
  }

];
Chris Moore
@dooglus
Jan 23 2016 07:01
@Miguel12321 last I saw you didn't have a comma after the artist:NM pair
NainaPS
@Navyya
Jan 23 2016 07:01
var Bike = function() {
 var gear= 2;
  // Only change code below this line.
this.getGear= function (){
 return gear+=2;
};
  this.setGear= function (val){
  return gear== val;
};
};
Chris Moore
@dooglus
Jan 23 2016 07:02
@Navyya you have a += in your getGear() function. it's not meant to change the gear, just 'get' (ie. return) it
Miguel
@Miguel12321
Jan 23 2016 07:02
@dooglus a finally it worked thank you
CamperBot
@camperbot
Jan 23 2016 07:02
miguel12321 sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 320 | @dooglus | http://www.freecodecamp.com/dooglus
Olawale Akinseye
@brainyfarm
Jan 23 2016 07:02
@mkumar07
A comma before add record here.
Miguel
@Miguel12321
Jan 23 2016 07:02
@Navyya @brainyfarm thank you I worked
CamperBot
@camperbot
Jan 23 2016 07:02
miguel12321 sends brownie points to @navyya and @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 25 | @navyya | http://www.freecodecamp.com/navyya
:star: 1142 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
NainaPS
@Navyya
Jan 23 2016 07:03
@dooglus when i return gear for getGear it still has same error
mkumar07
@mkumar07
Jan 23 2016 07:03
@brainyfarm Hey, it worked. Thank you
CamperBot
@camperbot
Jan 23 2016 07:03
mkumar07 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
Chris Moore
@dooglus
Jan 23 2016 07:03
@Navyya maybe a different error?
CamperBot
@camperbot
Jan 23 2016 07:03
:star: 1143 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
mkumar07
@mkumar07
Jan 23 2016 07:04
@dooglus Thanks
CamperBot
@camperbot
Jan 23 2016 07:04
mkumar07 sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 321 | @dooglus | http://www.freecodecamp.com/dooglus
Chris Moore
@dooglus
Jan 23 2016 07:04
@Navyya remember the difference between = and ==?
@mkumar07 you're welcome
NainaPS
@Navyya
Jan 23 2016 07:04
getGear should return 4 and setGear should set 4
is the error
Chris Moore
@dooglus
Jan 23 2016 07:05
@Navyya ok, so there's only one test for both functions... I think you fixed one but not the other, so the test still fails
previously they were both broken
NainaPS
@Navyya
Jan 23 2016 07:06
:(
Chris Moore
@dooglus
Jan 23 2016 07:06
@Navyya we're getting there. the remaining problem is with the ==
NainaPS
@Navyya
Jan 23 2016 07:07
yeah i did it
but pls check my code again
this is correct one
var Bike = function() {
 var gear= 4;
  // Only change code below this line.
this.getGear= function (){
 return gear;
};
  this.setGear= function (val){
  return gear== val;
};
};

var myCar = new Car();

var myBike = new Bike();
@dooglus pls check it with urs if u have some other login can u share?
Chris Moore
@dooglus
Jan 23 2016 07:08
@Navyya setGear is meant to set the gear...
@Navyya ie. assign to it
NainaPS
@Navyya
Jan 23 2016 07:08
can u share ur? becz this is correct one
and it had no error
Chris Moore
@dooglus
Jan 23 2016 07:09
@Navyya I'm not sure I understand you. Are you saying your code has no error?
Olawale Akinseye
@brainyfarm
Jan 23 2016 07:09
Hey @dooglus :+1:
Nice work with https://just-dice.com/
NainaPS
@Navyya
Jan 23 2016 07:09
yup my above code has no error
Chris Moore
@dooglus
Jan 23 2016 07:10
your gear == val is comparing gear with val, and evaluates to true if they are the same. it doesn't change the value of gear
@brainyfarm thanks. it was a site I made to try out node.js on the backend
CamperBot
@camperbot
Jan 23 2016 07:10
dooglus sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1144 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Chris Moore
@dooglus
Jan 23 2016 07:10
@brainyfarm now I feel like you tricked me into giving you a brownie point ;)
NainaPS
@Navyya
Jan 23 2016 07:10
what was ur solution for it @dooglus ???
Chris Moore
@dooglus
Jan 23 2016 07:11
@Navyya it's better if you find it for yourself. I'm happy to help you, but telling you the answer doesn't help you
Olawale Akinseye
@brainyfarm
Jan 23 2016 07:11
Not really @dooglus
I was in the chatroom there and asked who own it.
It seems very active in there too so I meant it :)
Chris Moore
@dooglus
Jan 23 2016 07:12
@brainyfarm I replied to you :)
NainaPS
@Navyya
Jan 23 2016 07:12
yeah sure but i m exactly not getting if my code is not having error what m i missing?
or where m i wrong?
Chris Moore
@dooglus
Jan 23 2016 07:13
@Navyya your setGear() function isn't setting the gear
NainaPS
@Navyya
Jan 23 2016 07:13
ok .... so what is it ? its just returning value?
Chris Moore
@dooglus
Jan 23 2016 07:13
@Navyya and you shouldn't be hardcoding the gear to 4 in your function - the gear should be undefined until setGear() is called
Mohi Mirza
@mohimirza
Jan 23 2016 07:13
Please someone review my Ceasars Cipher code, oi think the logic is correct but the terminal is showing a red dot.

function rot13(str) {
var arr1 = [];
for (i = 0; i <= str.length-1; i++){
var temp = str.charCodeAt(i);
if (temp >= 65 && temp <= 77){
arr1.push(temp+13);
}
else if (temp >77 && temp <= 90){
arr1.push(temp-13);
}

else {
arr1.push(temp);
}
}
return String.fromCharCode(arr1.toString());
}
rot13("SERR PBQR PNZC");

NainaPS
@Navyya
Jan 23 2016 07:14
ohhhhh now i got what exactly went wrong
Chris Moore
@dooglus
Jan 23 2016 07:15
@mohimirza you have an array of character codes, which you convert to a string
that gives you a string like "[65, 66, 67]"
@mohimirza then you're calling a single fromCharCode() on that big long string
@mohimirza you need to fromCharCode() on each character separately, and then join the resulting characters into a string
[65, 66, 67].toString() ==> '65,66,67'
then: String.fromCharCode([65, 66, 67].toString()) ==> '\u0000'
Mohi Mirza
@mohimirza
Jan 23 2016 07:18
so how do i convert [65, 66,67] to '65,66,67' ?
actually in terminal when i was returning the arr1 it was showing the string without brackets so i thought it would work
Olawale Akinseye
@brainyfarm
Jan 23 2016 07:20
This message was deleted
Chris Moore
@dooglus
Jan 23 2016 07:21
@mohimirza I don't think that's what you want to do. you want to convert [65, 66, 67] to "ABC"
Olawale Akinseye
@brainyfarm
Jan 23 2016 07:21

@mohimirza :point_down:

[65, 66, 67].toString() ==> '65,66,67'

@dooglus already answered.

Chris Moore
@dooglus
Jan 23 2016 07:21
ie. an array of charCodes to a string
Mohi Mirza
@mohimirza
Jan 23 2016 07:22
so arr1.toString() != [65, 66, 67].toString() ?
Chris Moore
@dooglus
Jan 23 2016 07:22
I have a question... why does this work:
[65, 66, 67].map(function(x) { return String.fromCharCode(x); }).join('') => 'ABC'
but this doesn't:
[65, 66, 67].map(String.fromCharCode).join('') ==> 'A\u0000\u0000B\u0001\u0000C\u0002\u0000'
mkumar07
@mkumar07
Jan 23 2016 07:23
@brainyfarm For a minute, i thought why u tagged me, then i remembered @dooglus words, you know...."tricked into to give browny point"
Chris Moore
@dooglus
Jan 23 2016 07:23
ie. what is the difference between function(x) { return String.fromCharCode(x); } and just String.fromCharCode?
@mohimirza they are the same - but neither does what you want...
Mohi Mirza
@mohimirza
Jan 23 2016 07:26
okay lets say
var decrypt = arr1.toString();
now decrypt contains 65,66,67
Olawale Akinseye
@brainyfarm
Jan 23 2016 07:27
Lol @mkumar07
I tagged you wrongly and not for the brownies.
Mohi Mirza
@mohimirza
Jan 23 2016 07:27
inow if i return String.fromCharCode(decrypt);
it should work, right?
I am missing something very obvious here, please guide me through .
Chris Moore
@dooglus
Jan 23 2016 07:30
@mohimirza String.fromCharCode() will happily take multiple numbers, and convert them to characters:
String.fromCharCode(65, 66, 67) ==> 'ABC'
but you aren't giving it a bunch of numbers, you are giving it a single string:
String.fromCharCode("65,66,67") ==> '\u0000'
@mohimirza see the difference?
(and to answer my own question, Array.map(fn) calls fn with 3 parameters: value, index, array
Mohi Mirza
@mohimirza
Jan 23 2016 07:31
got it, I'm passing string as parameter instead of numbers.
thanks @dooglus
CamperBot
@camperbot
Jan 23 2016 07:31
mohimirza sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 322 | @dooglus | http://www.freecodecamp.com/dooglus
Chris Moore
@dooglus
Jan 23 2016 07:31
and so fromCharCode was seeing those as 3 characters to convert - hence all the zeroes
@mohimirza this may be interesting for you: String.fromCharCode.apply(null, [65, 66, 67]); ==> 'ABC'
@mohimirza apply(this, args) lets you call a function as if it was called with the elements of an array as its parameters
Mohi Mirza
@mohimirza
Jan 23 2016 07:34
I'll look into it. Thanks again :)
Chris Moore
@dooglus
Jan 23 2016 07:37
anyone else?
Leonard Johnson
@Jarvis3000
Jan 23 2016 07:39

@dooglus I'm having trouble with using Objects for Lookups. This is my code. Kind of lost.function phoneticLookup(val) {
var result = "";

// Only change code below this line

var lookup;
(val) = {
1: "Adams",

2: "Boston", 

3: "Chicago",

4:  "Denver",

5: "Easy",

6: "Frank",

};

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

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

Chris Moore
@dooglus
Jan 23 2016 07:40
@Jarvis3000 can you use the 'pretty' copy/paste?
@Jarvis3000 select it, then click 'copy as pretty code', then paste here
Leonard Johnson
@Jarvis3000
Jan 23 2016 07:41

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

// Only change code below this line

var lookup;
(val) = {
1: "Adams",

2: "Boston", 

3: "Chicago",

4:  "Denver",

5: "Easy",

6: "Frank",

};

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

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

```

Chris Moore
@dooglus
Jan 23 2016 07:42
@Jarvis3000 I think you have to hit return before you paste it...
Leonard Johnson
@Jarvis3000
Jan 23 2016 07:42
@dooglus I'll try again.
@dooglus
mkumar07
@mkumar07
Jan 23 2016 07:44
Hey, this is regarding access of nested object in JSON. this is what I wrote, and i am not getting desired output, can anyone help me out?
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = "myStorage[car].inside[glove box]";
Mohit Garg
@mohitgarg
Jan 23 2016 07:44
// 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);
Can someone tell me what is wrong with this code?? it is returning undefined for negative values but the test won't pass...
Leonard Johnson
@Jarvis3000
Jan 23 2016 07:44

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

// Only change code below this line

var lookup;
(val) = {
1: "Adams",

2: "Boston", 

3: "Chicago",

4:  "Denver",

5: "Easy",

6: "Frank",

};

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

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

```

NainaPS
@Navyya
Jan 23 2016 07:45
@4mohit check ur if condition
Fidel Severino
@fidelscodes
Jan 23 2016 07:45
@mkumar07 you are assigning a string to the variable
Mohit Garg
@mohitgarg
Jan 23 2016 07:45
i used the OR statement too but the result is the same
NainaPS
@Navyya
Jan 23 2016 07:45
@mkumar07 ["glove box"]
it should be in ""
Fredd
@daqoo
Jan 23 2016 07:46
anyone can help converting celcius to F?

function convert(celsius) {
// Only change code below this line

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

have no idea where to start
NainaPS
@Navyya
Jan 23 2016 07:46
@4mohit re read the condition do they need and or "or"??
Chris Moore
@dooglus
Jan 23 2016 07:46
@Jarvis3000 your function is going to be called with one of 'alpha', 'bravo', 'charlie', etc. as its parameter
mkumar07
@mkumar07
Jan 23 2016 07:46
Modified code
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = "myStorage["car"].inside["glove box"]";
still shows unexpected identifier
NainaPS
@Navyya
Jan 23 2016 07:46
@daqoo pls add the equation for farehnheit
Chris Moore
@dooglus
Jan 23 2016 07:46
@Jarvis3000 so those are going to have to be the keys of your object
NainaPS
@Navyya
Jan 23 2016 07:47
.ustorage.car.inside["glovebox"]
Mohit Garg
@mohitgarg
Jan 23 2016 07:47
I used the || pipe symbol for OR condition @Navyya
mkumar07
@mkumar07
Jan 23 2016 07:47
@daqoo there will be an equation to it, something like 9/5 C + 32
Chris Moore
@dooglus
Jan 23 2016 07:47
@mkumar07 you don't want double quotes around the whole last expression
NainaPS
@Navyya
Jan 23 2016 07:47
han
waypoint name?
not c but celsius
Nick Robson
@nickrobson
Jan 23 2016 07:48
help fahrenheit
CamperBot
@camperbot
Jan 23 2016 07:48

:point_right: checkpoint convert celsius to fahrenheit [wiki]

Details

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

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

:pencil: read more about checkpoint convert celsius to fahrenheit on the FCC Wiki

NainaPS
@Navyya
Jan 23 2016 07:48
@daqoo
mkumar07
@mkumar07
Jan 23 2016 07:48
@dooglus so i removed quote, and it started showing correct one, what was i doing wrong?
Leonard Johnson
@Jarvis3000
Jan 23 2016 07:48
@dooglus Is 1: the key to my object Adam
Richard O'Brien
@exarp1
Jan 23 2016 07:48
Hey guys, I'm looking for a tip on the 'Profile Lookup' Challenge. I can get my lookup function to pass either the test where the firstName && prop match an existing object, or I can get my code to pass the test where either firstName or prop do not match any object in the array, (but not both, lol!)
Mohit Garg
@mohitgarg
Jan 23 2016 07:48
@Navyya still the result is the same
NainaPS
@Navyya
Jan 23 2016 07:49
waypoint name??? @4mohit
Mohit Garg
@mohitgarg
Jan 23 2016 07:49
Return Early Pattern for Functions
Nick Robson
@nickrobson
Jan 23 2016 07:49
@4mohit You need to use
if (a < 0 || b < 0)
NainaPS
@Navyya
Jan 23 2016 07:50
@4mohit gimme ur solution
Nick Robson
@nickrobson
Jan 23 2016 07:50
THIS IS NOT A VALID SOLUTION:
if (a || b < 0)
Chris Moore
@dooglus
Jan 23 2016 07:50
@4mohit it just wants you to put something like "if either parameter is bad then return" at the top
Nick Robson
@nickrobson
Jan 23 2016 07:50
That just tests the same as
if (a != 0 || b < 0)
Fredd
@daqoo
Jan 23 2016 07:50
@camperbot :+1:
Chris Moore
@dooglus
Jan 23 2016 07:50
@nickrobson it is valid syntax - but it doesn't mean what he thinks it means
Mohit Garg
@mohitgarg
Jan 23 2016 07:51
// 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);
mkumar07
@mkumar07
Jan 23 2016 07:51

@4mohit

if (a<=0 || b<=0)
    return "undefined";

It will be something like this

Nick Robson
@nickrobson
Jan 23 2016 07:51
@dooglus I edited my message to avoid confusion. I know it's valid syntax.
Chris Moore
@dooglus
Jan 23 2016 07:51
@4mohit you are meant to return undefined, not the string "undefined"
Nick Robson
@nickrobson
Jan 23 2016 07:51
@4mohit You need to be returning undefined, not "undefined"
lol
Chris Moore
@dooglus
Jan 23 2016 07:51
stop copying me! ;)
Nick Robson
@nickrobson
Jan 23 2016 07:52
@dooglus :high_heel::five:
Mohit Garg
@mohitgarg
Jan 23 2016 07:52
thanks guys
silly mistake :P
Nick Robson
@nickrobson
Jan 23 2016 07:52
:up::five:
idk
NainaPS
@Navyya
Jan 23 2016 07:52
@4mohit it worked?
Mohit Garg
@mohitgarg
Jan 23 2016 07:52
@dooglus @nickrobson Thanks
CamperBot
@camperbot
Jan 23 2016 07:52
4mohit sends brownie points to @dooglus and @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 323 | @dooglus | http://www.freecodecamp.com/dooglus
:star: 351 | @nickrobson | http://www.freecodecamp.com/nickrobson
Mohit Garg
@mohitgarg
Jan 23 2016 07:52
@Navyya yes it worked. Thanks
CamperBot
@camperbot
Jan 23 2016 07:52
4mohit sends brownie points to @navyya :sparkles: :thumbsup: :sparkles:
:star: 26 | @navyya | http://www.freecodecamp.com/navyya
Brian
@sludge256
Jan 23 2016 07:53
@nickrobson :hand:
Nick Robson
@nickrobson
Jan 23 2016 07:53
that's a better symbol fo sho
Brian
@sludge256
Jan 23 2016 07:53
still fairly ambiguous though
could be construed as stop
Derrick
@clickspiker23
Jan 23 2016 07:54
@exarp1 post what you have so far
Richard O'Brien
@exarp1
Jan 23 2016 07:54
kk

function lookUp(firstName, prop){
// Only change code below this line
//Locate the object the caller is targeting
contacts.map(function(obj){
if (obj.firstName === firstName && obj.hasOwnProperty(prop)) {
console.log(obj[prop]);
return obj[prop];
}

});
// Only change code above this line
}

Nick Robson
@nickrobson
Jan 23 2016 07:54
:arrow_up::five:
there we go
lol
:arrow_up::five::hand:
Derrick
@clickspiker23
Jan 23 2016 07:55
@exarp1 use mark up like this
unction lookUp(firstName, prop){
// Only change code below this line
//Locate the object the caller is targeting
contacts.map(function(obj){
if (obj.firstName === firstName && obj.hasOwnProperty(prop)) {
console.log(obj[prop]);
return obj[prop];
}
});
// Only change code above this line
}
Richard O'Brien
@exarp1
Jan 23 2016 07:55
um.. love to. How?
Derrick
@clickspiker23
Jan 23 2016 07:56
three tick marks like thisthen hit shift+enter then paste code then shift+enter then
well crap it converted my example to actual markup up
Brian
@sludge256
Jan 23 2016 07:56
you can use the copy pretty pop up
when you highlight code
it auto formats and copies
Derrick
@clickspiker23
Jan 23 2016 07:56
@sludge256 forgot that. that is way easier
Richard O'Brien
@exarp1
Jan 23 2016 07:57

''''function lookUp(firstName, prop){
// Only change code below this line
//Locate the object the caller is targeting
contacts.map(function(obj){
if (obj.firstName === firstName && obj.hasOwnProperty(prop)) {
console.log(obj[prop]);
return obj[prop];
}

});
// Only change code above this line
}''''

CamperBot
@camperbot
Jan 23 2016 07:57
:bulb: to format code use backticks! ``` more info
Richard O'Brien
@exarp1
Jan 23 2016 07:57
lolz
function lookUp(firstName, prop){
// Only change code below this line
//Locate the object the caller is targeting
  contacts.map(function(obj){
    if (obj.firstName === firstName && obj.hasOwnProperty(prop)) {
      console.log(obj[prop]);
      return obj[prop];
    }



  });
// Only change code above this line
}
so sorry omfg
I'll get it
Brian
@sludge256
Jan 23 2016 07:58
you can edit your previous messages too
you did it :clap:
Derrick
@clickspiker23
Jan 23 2016 07:59
it looks like you are trying to do something object oriented. i think??? i am new also so i dont know but i completed this task using for loops
@exarp1
i have noe covered any object oriented stuff so if that is then case then i probably will not be much help
well besides what is on FCC
Nick Robson
@nickrobson
Jan 23 2016 08:00
@exarp1 That won't work.
Richard O'Brien
@exarp1
Jan 23 2016 08:00
yeah i thought a functional approach was asked for with this one
Brian
@sludge256
Jan 23 2016 08:00
You can do it however you want
Nick Robson
@nickrobson
Jan 23 2016 08:00
@exarp1 You need to use one if-statement that covers obj.firstName === firstName, and then another that does obj.hasOwnProperty(prop)
The second has an else-statement which returns "No such property"
Derrick
@clickspiker23
Jan 23 2016 08:02
I think i will let @sludge256 and @nickrobson help with this. i did it using a for loop that had a nested if statement inside
Richard O'Brien
@exarp1
Jan 23 2016 08:02
```
  contacts.map(function(obj){
    if (obj.firstName === firstName) {
      if(obj.hasOwnProperty(prop)){
        return obj[prop];
      }
    } else if( !obj.hasOwnProperty(prop)) {
Brian
@sludge256
Jan 23 2016 08:02
@clickspiker23 I just got home so I'm too lazy
just doing low effort help :D
Derrick
@clickspiker23
Jan 23 2016 08:03
lol im pretty new to coding so i might be of some help but also dont want to be a hinderance
but it is looking closer to what i did
Richard O'Brien
@exarp1
Jan 23 2016 08:03
argh
Brian
@sludge256
Jan 23 2016 08:03
It'll be a learning experience for both you and the person you're helping then :D
Derrick
@clickspiker23
Jan 23 2016 08:04
what exactly doees this line do
contacts.map(function(obj)
Brian
@sludge256
Jan 23 2016 08:05
it loops through each element of the array
and performs the function on each element
Richard O'Brien
@exarp1
Jan 23 2016 08:05
function lookUp(firstName, prop){
// Only change code below this line
//Locate the object the caller is targeting
  contacts.map(function(obj){
    if (obj.firstName === firstName) {
      if(obj.hasOwnProperty(prop)){
        return obj[prop];
      } else {
        return "No such property";
      }
    } else {
      return "No such contact";
    }



  });
// Only change code above this line
}
like so?
Derrick
@clickspiker23
Jan 23 2016 08:05
so recursion?
Richard O'Brien
@exarp1
Jan 23 2016 08:05
no pe
Derrick
@clickspiker23
Jan 23 2016 08:06
ive never messed with that but i have heard about it
Richard O'Brien
@exarp1
Jan 23 2016 08:06
like it applies the function to each element of the array, in order
Brian
@sludge256
Jan 23 2016 08:06
it's bascially the same as doing it with a for loop
Richard O'Brien
@exarp1
Jan 23 2016 08:06
it's sweet, and easier to reason about than for loops ( it lacks the side-effects and potential bugs of for loops)
Brian
@sludge256
Jan 23 2016 08:06
you only want to return no contact after you've searched the entire array
otherwise your function ends early
Richard O'Brien
@exarp1
Jan 23 2016 08:07
hmm ok that makes sense
give me a minute to reason this out
Brandon
@Intendant-
Jan 23 2016 08:07
Ay need a bit of advice on the return largest numbers in arrays

function largestOfFour(arr) {
// You can do this!
var ray = arr;
var set = [];
var arrLength = arr.length;
for(var i = 0; i < arrLength; i++) {

var subLength = arr[i].length;
for(var x = 0; x < subLength; x++) {
  if(arr[i][x] > set[i]) {
    set[i] = arr[i][x];
    ray[i] = arr[i][x]; 
  }
}

}
return ray;
}

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

function largestOfFour(arr) {
// You can do this!
var ray = arr;
var set = [];
var arrLength = arr.length;
for(var i = 0; i < arrLength; i++) {

  var subLength = arr[i].length;
  for(var x = 0; x < subLength; x++) {
    if(arr[i][x] > set[i]) {
      set[i] = arr[i][x];
      ray[i] = arr[i][x]; 
    }
  }
}
return ray;

}

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

dammit lol, hope someone can read this. New to using the chat.
Leonard Johnson
@Jarvis3000
Jan 23 2016 08:10
@dooglus Am I supposed to take out the switch statement in Using Objects for Lookups?
Chris Moore
@dooglus
Jan 23 2016 08:10
@Jarvis3000 yes, you're replacing the switch statement by an object {key1:val1, key2:val2, ...}, and looking up the key in it
Leonard Johnson
@Jarvis3000
Jan 23 2016 08:11
@dooglus Do I replace it with lookup(val)?
Chris Moore
@dooglus
Jan 23 2016 08:11
@Intendant- select all your code, and click the 'pretty' option, then paste that here
Leonard Johnson
@Jarvis3000
Jan 23 2016 08:12
@dooglus Do I replace it with lookup(val)?
Brian
@sludge256
Jan 23 2016 08:12
good luck guys off to sleep
Richard O'Brien
@exarp1
Jan 23 2016 08:13
@sludge256 I'm having trouble finding a way to do this with only one iteration thru the array of objects - do I have to reprocess the contacts array again for the (firstName === bob) condition?
Chris Moore
@dooglus
Jan 23 2016 08:13
@Jarvis3000 something like var ret = {'alpha':'archie', ...}[val];
Richard O'Brien
@exarp1
Jan 23 2016 08:13
argh
Chris Moore
@dooglus
Jan 23 2016 08:13
@Jarvis3000 I forgot the name of the exercise, so I don't have the real variable names to hand
Vladimr Morev
@vladimirmorev
Jan 23 2016 08:14

Hello! Can someone help me with palindrome?
This expression

"0_0 (: /-\ :) 0-0".toLowerCase().replace(/[ .,]/g,"")

got this result

"0_0(:/-:)0-0"

so "\" replaced. Why?

Brandon
@Intendant-
Jan 23 2016 08:16
@dooglus ahh thanks man
CamperBot
@camperbot
Jan 23 2016 08:16
intendant- sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 326 | @dooglus | http://www.freecodecamp.com/dooglus
Brandon
@Intendant-
Jan 23 2016 08:16
function largestOfFour(arr) {
  // You can do this!
  var ray = arr;
  var set = [];
  var arrLength = arr.length;
  for(var i = 0; i < arrLength; i++) {

    var subLength = arr[i].length;
    for(var x = 0; x < subLength; x++) {
      if(arr[i][x] > set[i]) {
        set[i] = arr[i][x];
        ray[i] = arr[i][x]; 
      }
    }
  }
  return ray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], "");
Chris Moore
@dooglus
Jan 23 2016 08:16
@Intendant- what's the exercise called?
Brandon
@Intendant-
Jan 23 2016 08:16
@dooglus Return Largest Numbers in Arrays
NainaPS
@Navyya
Jan 23 2016 08:17
@Intendant- u need two if condtns