These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Feb 2016
Guzman Monne
@guzmonne
Feb 09 2016 00:00 UTC
@chris1819 You have wrong tests on the switch statement
Ariel
@ArielLeslie
Feb 09 2016 00:00 UTC
@chris1819 But none of those will happen the only thing that will return "apple" is myTest(1)
because you have
case 1:
      answer = "apple";
      break;
Guzman Monne
@guzmonne
Feb 09 2016 00:00 UTC
@chris1819 You are checking for numbers instead of strings. Change your numbers for "a", "b" and "c"
Ali Musa
@AliMusa8790
Feb 09 2016 00:01 UTC
@blueExcess so would it be result = lookup[val]?
Nate Petersen
@blueExcess
Feb 09 2016 00:01 UTC
@blueExcess bracket notation should be used when you're using a variable or if there's a space in the name of the property (lookup[variable] or lookup["variable one"])
Ali Musa
@AliMusa8790
Feb 09 2016 00:01 UTC
with a semicolon
Nate Petersen
@blueExcess
Feb 09 2016 00:01 UTC
@AliMusa8790 You've got it :)
chris1819
@chris1819
Feb 09 2016 00:01 UTC
thats what i thought but the red X's tell me it should say. the checks that it is doing to advance to the next lesson
Ali Musa
@AliMusa8790
Feb 09 2016 00:02 UTC
Hooray! I'm having some difficulty understanding when and when not to use quotations
Ariel
@ArielLeslie
Feb 09 2016 00:02 UTC
@chris1819 Why are you doing a switch block looking for numbers?
@AliMusa8790 How so?
chris1819
@chris1819
Feb 09 2016 00:03 UTC
Got it. Silly (confusing) directions. Thats why IKEA is so popular.Thanks a lot.
Norman Dela Cruz
@dcnr
Feb 09 2016 00:04 UTC

@AliMusa8790 eh don't call yourself stupid
Objects have key(or property)/value pairs

var myObj = {
  property : "value"
}

And you can access them with . or with []
If you use the . notation, you should specify the literal name of the property

var person = {
  name: "Ali"
}

With the . you will look it up as

result = person.name;

and result will be "Ali"

With the [] notation, you can use it two ways. The first one is like the . and it would look like

result = person["name"]; // result is "Ali"

note the ""

The other way of using the [] is with variables.

var propertyWanted = "name";
result = person[propertyWanted]; // result is "Ali"

note that there are no ""

And that's just about it. Sorry took too long to type.

Ali Musa
@AliMusa8790
Feb 09 2016 00:05 UTC
@ArielLeslie I don't know, honestly. Most of the time I understand what FCC is asking me to do at that very moment but sometimes even on the next step, I completely forget what I just learned in the previous step. I don't know if I'm just not understanding it, or my memory is shot or what.
penzinho
@penzinho
Feb 09 2016 00:05 UTC
Could someone please help me with Adding a default option in Switch statements
Nate Petersen
@blueExcess
Feb 09 2016 00:05 UTC
@AliMusa8790 @dcnr just explained it better than I ever could have haha
penzinho
@penzinho
Feb 09 2016 00:05 UTC
I'm stuck :smile:
http://bit.ly/1KBIKeL is the problem
my code is:

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

and I get ReferenceError: a is not defined
Nate Petersen
@blueExcess
Feb 09 2016 00:07 UTC
@penzinho you need to put quotations around the a I think
Ariel
@ArielLeslie
Feb 09 2016 00:07 UTC
@AliMusa8790 For one thing, you're probably cramming a lot into your head at a fast pace. That might mean you're retaining less and it would be a good idea to slow it down and really play with each new thing you learn to help it sink in before moving on. Another thing is just that a huge part of learning to program is just repetition. Using tools and skills over and over in slightly different ways until they become second nature
penzinho
@penzinho
Feb 09 2016 00:07 UTC
I've tried and I get the same error
I've tried with and without quotations in all case
cases
Ariel
@ArielLeslie
Feb 09 2016 00:07 UTC
@penzinho when you don't put a in quotes, it thinks it's a variable name
chris1819
@chris1819
Feb 09 2016 00:07 UTC
thats it. just got it myself. the myTest function at bottom needs " "
your firs case a need quate marks
Ali Musa
@AliMusa8790
Feb 09 2016 00:08 UTC
@ArielLeslie you're probably right about the cramming. But I was under the impression that you continue doing the steps every day for as long as possible, step by step until you reach the end? Am I just approaching this all wrong?
penzinho
@penzinho
Feb 09 2016 00:08 UTC
@chris1819 thank you very much mate, that was it!
CamperBot
@camperbot
Feb 09 2016 00:08 UTC
penzinho sends brownie points to @chris1819 :sparkles: :thumbsup: :sparkles:
:star: 202 | @chris1819 | http://www.freecodecamp.com/chris1819
penzinho
@penzinho
Feb 09 2016 00:09 UTC
stupid me, I've been focusing on code itself instead of mytest
chris1819
@chris1819
Feb 09 2016 00:09 UTC
two silly questions here. How do you address replys to someones screenname and what are brownie points?
Sergey
@SZharkov
Feb 09 2016 00:09 UTC
// 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 (prop !== "tracks") {
  if (value !== ""){
    return collection[id].prop.value;
  } else {
    delete collection[id].prop;
  }
}

}

// Alter values below to test your code
update(5439, "artist", "ABBA");

Task : For the given id in collection:

If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.
If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.
If value is blank, delete that prop.
What's wrong?

Ariel
@ArielLeslie
Feb 09 2016 00:10 UTC
@AliMusa8790 It's not wrong per se. The important thing is not to move forward until you really "get" what you just did, even if that makes you slower. This isn't like school where you just want to pass everything and call it done. You're here because you want to learn and understand, so you're only shortchanging yourself by rushing. Sometimes you just need to give your brain time to absorb too. After something particularly tricky: have a snack, go for a walk, try for a good poop, play with a dog.
greg
@wearenotgroot
Feb 09 2016 00:10 UTC
@SZharkov use bracket notation
Sergey
@SZharkov
Feb 09 2016 00:10 UTC
@chris1819 just click on nickname. They add points at freecodecamp
Ariel
@ArielLeslie
Feb 09 2016 00:10 UTC
explain brownie
CamperBot
@camperbot
Feb 09 2016 00:10 UTC

: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

greg
@wearenotgroot
Feb 09 2016 00:10 UTC
@SZharkov because there is no property named prop in the collections----->this wouldnt work--------->collection[id].prop.
no property named prop
2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
Ariel
@ArielLeslie
Feb 09 2016 00:11 UTC
@chris1819 :point_up:
@chris1819 To reference someone by name type their username with an @ or click on their username on a message they sent
chris1819
@chris1819
Feb 09 2016 00:12 UTC
awesome, I really appreciate it. thanks @ArielLeslie
CamperBot
@camperbot
Feb 09 2016 00:12 UTC
chris1819 sends brownie points to @arielleslie :sparkles: :thumbsup: :sparkles:
:star: 1073 | @arielleslie | http://www.freecodecamp.com/arielleslie
Ariel
@ArielLeslie
Feb 09 2016 00:12 UTC
@chris1819 :+1: you bet
greg
@wearenotgroot
Feb 09 2016 00:14 UTC
@SZharkov if you use bracket notation on the other hand -------> collection[id][prop]<------------------will work beacause prop is a variable/parameter containing the property name
Sergey
@SZharkov
Feb 09 2016 00:15 UTC
@wearenotgroot collection[id][prop] it doesn't work
greg
@wearenotgroot
Feb 09 2016 00:16 UTC
@SZharkov you sure you are doing it right?
@SZharkov collection[id][prop] = value<--------------------for example
Sergey
@SZharkov
Feb 09 2016 00:18 UTC
@wearenotgroot can we speak in private?
greg
@wearenotgroot
Feb 09 2016 00:18 UTC
@SZharkov sure
Nate Petersen
@blueExcess
Feb 09 2016 00:22 UTC
Question: I'm on bonfire 'Repeat a string repeat a string' - you're given a string and a number of times you're supposed to repeat said string. Is it best to make the string into an array or is it better to simply manipulate the string w/o converting it?
Brian
@sludge256
Feb 09 2016 00:23 UTC
Don't convert it to an array if it's not necessary.
Norman Dela Cruz
@dcnr
Feb 09 2016 00:23 UTC
@blueExcess you can just append the string to itself or use one of the new string function that deals specifically with repetition
Nate Petersen
@blueExcess
Feb 09 2016 00:24 UTC
@dcnr I'm guessing I can find the string function you're referring to on MDK or some such reference?
Haha, sorry, MDN
thanks @sludge256 @dcnr
CamperBot
@camperbot
Feb 09 2016 00:26 UTC
blueexcess sends brownie points to @sludge256 and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 1366 | @sludge256 | http://www.freecodecamp.com/sludge256
:star: 544 | @dcnr | http://www.freecodecamp.com/dcnr
Brian
@sludge256
Feb 09 2016 00:26 UTC
Yep, that challenge can be quite simple if you find the right function.
Nate Petersen
@blueExcess
Feb 09 2016 00:27 UTC
@sludge256 Yeah, I'm probably overthinking it haha
Toine
@Aeon777
Feb 09 2016 00:28 UTC
Hi, I need some help. I don't quite understand the error message I'm getting: InternalError: too much recursion -
My Code:
function lookUp(firstName, prop) {
// Only change code below this line

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

  if (contacts.firstName === firstName && contacts.prop) {
  return lookUp("");
} else {
  return lookUp("no such contact");
}

}
Nate Petersen
@blueExcess
Feb 09 2016 00:28 UTC
@sludge256 lemme ask this - you prefer MDN or DevDocs? (or another site)
bitgrower
@bitgrower
Feb 09 2016 00:28 UTC
@Aeon777 -- you keep calling lookUp with no way to exit the recursion ...
it will keep calling lookup until it runs out of stack space ...
Brian
@sludge256
Feb 09 2016 00:30 UTC
Well DevDocs pulls from MDN
bitgrower
@bitgrower
Feb 09 2016 00:31 UTC
...and @Aeon -- you can do this challenge easily without doing recursion ...
Brian
@sludge256
Feb 09 2016 00:31 UTC
I guess DevDocs if you're looking for more than MDN provides
or if you prefer the DevDocs navigation
Nate Petersen
@blueExcess
Feb 09 2016 00:32 UTC
@sludge256 Ahh, I see. Thanks again :smile:
CamperBot
@camperbot
Feb 09 2016 00:32 UTC
blueexcess sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:warning: blueexcess already gave sludge256 points
Jon
@jcmockbee
Feb 09 2016 00:38 UTC
Hi All I am doing the card counting and I am stuck on coding this one

var count = 0;

function cc(card) {
// Only change code below this line
while(card !== ""){
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
{ return ++count “bet”;}

case 7:
case 8:
case 9:
  {return count “Hold”;}
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
 { return --count “Hold;}

}
return count;

// Only change code above this line
}

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

Ivan Perez
@joannesalfa
Feb 09 2016 00:44 UTC
@jcmockbee you need to correct this syntax, to increment variable, it should be count++;
bitgrower
@bitgrower
Feb 09 2016 00:44 UTC
@jcmockbee -- the editor indicates some of the problems you have in your code ... fix those ...
Jon
@jcmockbee
Feb 09 2016 00:45 UTC
ok ill do both and be back thx
bitgrower
@bitgrower
Feb 09 2016 00:45 UTC
you have a number of just plain syntax errors ... the editor error messages are your friend!!!
RickWisneske
@rwisneske
Feb 09 2016 00:48 UTC
Lesson: "Return Early Pattern for Functions". Help...
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a, b < 0);

  // 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);
Ivan Perez
@joannesalfa
Feb 09 2016 00:49 UTC
@rwisneske your if statement is wrong
if (a, b < 0);
you need to use OR operators to separate each variable
for example
if(a < 0 || b < 0 ) since || acts as OR operator
RickWisneske
@rwisneske
Feb 09 2016 00:54 UTC
@joannesalfa thank you. Got it!
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0 || b < 0){
    return undefined;
  }

  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
CamperBot
@camperbot
Feb 09 2016 00:54 UTC
rwisneske sends brownie points to @joannesalfa :sparkles: :thumbsup: :sparkles:
:star: 375 | @joannesalfa | http://www.freecodecamp.com/joannesalfa
Sergey
@SZharkov
Feb 09 2016 01:05 UTC
@wearenotgroot thanks
Jason Ulaner
@julaner
Feb 09 2016 01:08 UTC
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

 if (firstName === "" && prop === "") {
   return contacts[firstName][prop];
 }

  else if (firstName !== "") {
    return ("No such contact");
  }

  else if (prop !== "") {
    return ("No such property");
  }
// Only change code above this line

}
// Change these values to test your function
lookUp("Akira", "likes");
Good evening guys, im a bit stuck on this one.
greg
@wearenotgroot
Feb 09 2016 01:09 UTC
@julaner what do we usually do if we have an array`? in this case an array of objects
Purna Kanneganti
@purnakanneganti
Feb 09 2016 01:09 UTC
for (i = 0; i < contacts.length; i++) {
if (contacts[i][firstName] === firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
else if (contacts[i].firstName !== firstName) {
return "No such contact";
}
else if (contacts[i].prop !== prop) {
return "No such property";
}
}
did any one get his prob
same thing
Jason Ulaner
@julaner
Feb 09 2016 01:10 UTC
@wearenotgroot we normally look them up and in this case compare with if/else statements and returns
greg
@wearenotgroot
Feb 09 2016 01:10 UTC
@purnakanneganti remember there is no property inside those elements in the contacts that has the name prop so the .prop will not work
@julaner yes but how can we access them? iterate through each element?
@julaner what is the mechanism we can use ? :smile:
@julaner something that loops through thing?
Jason Ulaner
@julaner
Feb 09 2016 01:12 UTC
@wearenotgroot I understand the previous lesson of iterating through loops Im just not sure how we apply it to the real world stuff like this
lemme go back and read through some older lessons
using a For Loop?
greg
@wearenotgroot
Feb 09 2016 01:13 UTC
@purnakanneganti you already use the .hasOwnProperty(prop) correctly in the first if statement why did you do this in the last else if contacts[i].prop !== prop
@julaner yes!
Norman Dela Cruz
@dcnr
Feb 09 2016 01:13 UTC
Or get fancy and use .find() :fire:
greg
@wearenotgroot
Feb 09 2016 01:14 UTC
@dcnr :smile:
Jason Ulaner
@julaner
Feb 09 2016 01:15 UTC
@wearenotgroot I understood it in the previous lesson when we were cycling through the numbers. Is it the same concept for this lesson? Im having a hard time transferring that knowledge to this
greg
@wearenotgroot
Feb 09 2016 01:15 UTC
@julaner yes
@julaner so create a for loop iterate through the elements then perform if tests
Jason Ulaner
@julaner
Feb 09 2016 01:16 UTC
@wearenotgroot ok, are the if and else if statements ok?
greg
@wearenotgroot
Feb 09 2016 01:16 UTC
@julaner not quite
@julaner you need to compare each contacts firstName with the firstName parameter
@julaner you also have to test if the prop given in the parameter exist in those contacts--------> use .hasOwnProperty(arg); to test for it.
Brandon Powell
@brandonpowell
Feb 09 2016 01:18 UTC
I'm trying figure out this last problem that has red X I cannot find it https://gyazo.com/78093e47182c12db00207e0afe9c30fe
Jason Ulaner
@julaner
Feb 09 2016 01:18 UTC
@wearenotgroot does that require an additional var to compare the parameters of firstName to firstName param
greg
@wearenotgroot
Feb 09 2016 01:19 UTC
@julaner nope
Jason Ulaner
@julaner
Feb 09 2016 01:20 UTC
@wearenotgroot are there other good resources for "for loops" and iterating. Im just still co confused with it:-(
so'
greg
@wearenotgroot
Feb 09 2016 01:20 UTC
@brandonpowell you are missing a semicolon (;)
Brandon Powell
@brandonpowell
Feb 09 2016 01:21 UTC
ok
@wearenotgroot Thank you
CamperBot
@camperbot
Feb 09 2016 01:21 UTC
brandonpowell sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 691 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Ivan Perez
@joannesalfa
Feb 09 2016 01:22 UTC
Anyone can help me this challenge Where art thou ?
Brandon Powell
@brandonpowell
Feb 09 2016 01:22 UTC
@wearenotgroot I added the semicolon but still not working
greg
@wearenotgroot
Feb 09 2016 01:23 UTC
@brandonpowell try refreshing the page
Ivan Perez
@joannesalfa
Feb 09 2016 01:23 UTC
function where(collection, source) {
  var arr = [];
  var keys = [];
  // What's in a name?

  arr = new Object(collection);

  return arr;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Since I really forgot how object works, I think i'm stuck
Jason Ulaner
@julaner
Feb 09 2016 01:23 UTC
@wearenotgroot thank you!
CamperBot
@camperbot
Feb 09 2016 01:23 UTC
julaner sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
greg
@wearenotgroot
Feb 09 2016 01:24 UTC
@julaner YW
CamperBot
@camperbot
Feb 09 2016 01:24 UTC
:star: 692 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Norman Dela Cruz
@dcnr
Feb 09 2016 01:24 UTC

@julaner here's the "standard" for loop for iterating through an array

for (var i = 0; i < array.length; i++) {
  array[i]
}

Since arrays values are accessed through the indices, by doing this loop we can loop go through each of the array index as i goes up.

Yeah the docs can probably clear that up better though.
greg
@wearenotgroot
Feb 09 2016 01:24 UTC
@julaner also just search in youtube about for loop, most other programming language will have similar concepts with js about for loop
Norman Dela Cruz
@dcnr
Feb 09 2016 01:25 UTC
@joannesalfa collection is already an array of objects, you don't have to create anything from it. You'll just have to inspect their properties for source.
@joannesalfa collection[0].first; // "Romeo" and stuff
Rusty Hutchison
@rustyhutchison
Feb 09 2016 01:27 UTC
on "Golf Code", even though my code is passing all the tests when I run it says, it says it isn't passing the tests, any advice
rphares
@rphares
Feb 09 2016 01:27 UTC
can you paste your code please, @rustyhutchison ?
This message was deleted
Rusty Hutchison
@rustyhutchison
Feb 09 2016 01:27 UTC

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

return "Change Me";

rphares
@rphares
Feb 09 2016 01:28 UTC
you dont need "return change me)
and,
watch the punctuation in all those returns
Jason Ulaner
@julaner
Feb 09 2016 01:28 UTC
@dcnr thanks!
rphares
@rphares
Feb 09 2016 01:28 UTC
it has to be exact, so a lot of them dont need the ! at the end... @rustyhutchison
(eagle, birdie)
Kelsey
@kcdilla
Feb 09 2016 01:29 UTC
I'm having trouble with the Record Collection challenge - I feel like I'm nearly there but can't add a property.
Norman Dela Cruz
@dcnr
Feb 09 2016 01:29 UTC
@rustyhutchison I tried running your code and it's actually failing 3 tests hmm
rphares
@rphares
Feb 09 2016 01:29 UTC
And... the ifs for `Bogey, double bogey" dont look quite right... @rustyhutchison ,
Kelsey
@kcdilla
Feb 09 2016 01:30 UTC
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

// Alter values below to test your code
update(5439, "artist", "ABBA");
Wes
@weslez
Feb 09 2016 01:30 UTC
This message was deleted
greg
@wearenotgroot
Feb 09 2016 01:30 UTC
@rustyhutchison should be --------->strokes <= par -2
Norman Dela Cruz
@dcnr
Feb 09 2016 01:30 UTC
@kcdilla you forgot the collection part :P
rphares
@rphares
Feb 09 2016 01:30 UTC
example: (strokes == (par + 1)){ @rustyhutchison
Rusty Hutchison
@rustyhutchison
Feb 09 2016 01:30 UTC
It was the "!" in the strings. Thanks!
Kelsey
@kcdilla
Feb 09 2016 01:30 UTC
oh wow
I knew it was something dumb
Norman Dela Cruz
@dcnr
Feb 09 2016 01:31 UTC
@kcdilla you access your object via object[property]
Wes
@weslez
Feb 09 2016 01:31 UTC
Hi friends, got stuck on challenge "Using Objects for Lookups" today. Eventually google'd my way into this solution which worked. Can anyone confirm whether I got the correct solution or just an inelegant workaround. In particular my result = lookup[val]; part. Was there a better way to return the correct thing?
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    "alpha": 
      "Adams",

    "bravo": 
      "Boston",

    "charlie": 
     "Chicago",

    "delta": 
      "Denver",

    "echo": 
     "Easy",

    "foxtrot": 
      "Frank",

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

// Change this value to test
phoneticLookup("delta");
Norman Dela Cruz
@dcnr
Feb 09 2016 01:31 UTC
@kcdilla collection is your object so you should work on it and not just id
rphares
@rphares
Feb 09 2016 01:31 UTC
sure thing, @rustyhutchison ~ happy coding
Kelsey
@kcdilla
Feb 09 2016 01:31 UTC
@dcnr ok I updated it but it's still wrong
rphares
@rphares
Feb 09 2016 01:32 UTC
@weslez , thats good
Ivan Perez
@joannesalfa
Feb 09 2016 01:32 UTC
@dcnr
function where(collection, source) {
  var arr = [];
  var keys = Object.keys(source);
  // What's in a name?

  for(var i = 0; i <= collection.length; i++){
    if(collection[i].hasOwnProperty(source)){
        return collection;
    }
  }
}
Kelsey
@kcdilla
Feb 09 2016 01:32 UTC
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

// Alter values below to test your code
update(5439, "artist", "ABBA");
Ivan Perez
@joannesalfa
Feb 09 2016 01:32 UTC
I guess im confused about objects
rphares
@rphares
Feb 09 2016 01:32 UTC
in real life, we might just return lookup[val] @weslez . But, since we were given return result, that is great, exactly what we needed to do to make it return what we needed using result :)
bitgrower
@bitgrower
Feb 09 2016 01:33 UTC
you do need to read the problem carefullly @joannesalfa
Jason Ulaner
@julaner
Feb 09 2016 01:33 UTC
@wearenotgroot
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop) {
// Only change code below this line
 var ourContacts = 0;

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

  else if (firstName !== "") {
    return ("No such contact");
  }

  else if (prop !== "") {
    return ("No such property");
  }
// Only change code above this line

}
// Change these values to test your function
lookUp("Akira", "likes");
Norman Dela Cruz
@dcnr
Feb 09 2016 01:33 UTC
@joannesalfa You're supposed to return only the objects that has source. You're on it though!
Jason Ulaner
@julaner
Feb 09 2016 01:33 UTC
hows this looking?
greg
@wearenotgroot
Feb 09 2016 01:34 UTC
@julaner the if test was supposed to be inside the for loop:)
bitgrower
@bitgrower
Feb 09 2016 01:34 UTC
I don't understand teh purpose of the first loop ?
lol,, kinda what @wearenotgroot said
Wes
@weslez
Feb 09 2016 01:34 UTC
Thank @rphares . Thanks for the feedback. I'll keep on keeping on then.
CamperBot
@camperbot
Feb 09 2016 01:34 UTC
weslez sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2564 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 09 2016 01:34 UTC
Happy coding~
Jason Ulaner
@julaner
Feb 09 2016 01:34 UTC
@bitgrower Yeah IM totally confused lol
I feel like we work through these lessons and then when it comes to the check points its like I know nothing!
bitgrower
@bitgrower
Feb 09 2016 01:35 UTC
try to analogize it to a real world situation ...
Norman Dela Cruz
@dcnr
Feb 09 2016 01:35 UTC
@weslez I guess you can shorten it to
function phoneticLookup(val) {
  // Only change code below this line
  return {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank",
  }[val];
}

// Change this value to test
phoneticLookup("delta");
greg
@wearenotgroot
Feb 09 2016 01:35 UTC
@julaner ---------> contacts[i]<-----------------gives you access to element
Ivan Perez
@joannesalfa
Feb 09 2016 01:36 UTC
TypeError: Cannot read property 'hasOwnProperty' of undefined
It's giving me nuts
@dcnr
bitgrower
@bitgrower
Feb 09 2016 01:36 UTC
@julaner -- not to worry ... it will get easier with time ... (but then the challenges get harder, too) ... you'll look back and wonder why you thought something was so hard previously ...
Jason Ulaner
@julaner
Feb 09 2016 01:36 UTC
@bitgrower LOL thanks for the encouragement
CamperBot
@camperbot
Feb 09 2016 01:36 UTC
julaner sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 414 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 09 2016 01:37 UTC
@kcdilla it should be collection[id] etc because id is a variable so you can't use . notation
bitgrower
@bitgrower
Feb 09 2016 01:37 UTC
in fact...you may even go back and improve on your previous solutions ...
Norman Dela Cruz
@dcnr
Feb 09 2016 01:37 UTC
@joannesalfa will you post your current code?
greg
@wearenotgroot
Feb 09 2016 01:37 UTC
@joannesalfa source is an object
Ivan Perez
@joannesalfa
Feb 09 2016 01:38 UTC
@dcnr
function where(collection, source) {
  var arr = [];
  var keys = Object.keys(source);
  // What's in a name?

  for(var i = 0; i <= collection.length; i++){
    if(collection[i].hasOwnProperty(source)){
        //return;
    }
  }


}
Norman Dela Cruz
@dcnr
Feb 09 2016 01:38 UTC
@joannesalfa i < collection.length
It's going overbounds
greg
@wearenotgroot
Feb 09 2016 01:39 UTC
@joannesalfa .hasOwnProperty(arg)<------------will try to find the a property with a given name, and you put source which is an object that is why you get an error
Brandon Powell
@brandonpowell
Feb 09 2016 01:39 UTC
#123
Norman Dela Cruz
@dcnr
Feb 09 2016 01:39 UTC
oh yeah that too @wearenotgroot nice catch
greg
@wearenotgroot
Feb 09 2016 01:40 UTC
@dcnr i do what i can :smile:
Jon
@jcmockbee
Feb 09 2016 01:40 UTC

Hi all working on card challenge I am not getting output I should be
http://www.freecodecamp.com/challenges/counting-cards#?solution=var%20count%20%3D%200%3B%0A%0Afunction%20cc(card)%20%7B%0A%20%20%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20%20%20%20%20while(card%20!%3D%3D%20%22%22)%7B%0A%20%20switch(card)%7B%0A%20%20%20%20case%202%3A%0A%20%20%20%20case%203%3A%0A%20%20%20%20case%204%3A%0A%20%20%20%20case%205%3A%0A%20%20%20%20case%206%3A%0A%20%20%20%20%0A%20%20%20%20%20%20result%20%3D%22Bet%22%3B%7Breturn%20count%2B%2B%3B%7D%0A%0A%20%20break%3B%0A%0A%20%20%20%20case%207%3A%0A%20%20%20%20case%208%3A%0A%20%20%20%20case%209%3A%0A%20%20%20%20%20%0A%20%20%20%20%20%20result%20%3D%22Hold%22%3B%7Breturn%20count%3B%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20case%2010%3A%0A%20%20%20%20case%20'J'%3A%0A%20%20%20%20case%20'Q'%3A%0A%20%20%20%20case%20'K'%3A%0A%20%20%20%20case%20'A'%3A%0A%20%20%20%20%20result%20%3D%22Hold%22%3B%7Breturn%20count--%3B%7D%0A%20%20%20%20%20%20%0A%20%20%20%7D%0A%20%20return%20count%3B%0A%0A%20%20%0A%0A%20%20%20%20%20%20%7D%0A%20%20%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Add%2Fremove%20calls%20to%20test%20your%20function.%0A%2F%2F%20Note%3A%20Only%20the%20last%20will%20display%0Acc(2)%3B%20cc(3)%3B%20cc(7)%3B%20cc('K')%3B%20cc('A')%3B%0A

var count = 0;

function cc(card) {
// Only change code below this line
while(card !== ""){
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:

  result ="Bet";{return count++;}

break;

case 7:
case 8:
case 9:

  result ="Hold";{return count;}

  break;


case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
 result ="Hold";{return count--;}

}
return count;

greg
@wearenotgroot
Feb 09 2016 01:40 UTC
@joannesalfa you already have collected the keys on source try and use it instead
@joannesalfa ------>var keys = Object.keys(source);
@jcmockbee you are returning too early!
@jcmockbee remember you have to test if count is greater than 0, then you can return the appropriate value
Ivan Perez
@joannesalfa
Feb 09 2016 01:44 UTC

@wearenotgroot

function where(collection, source) {
  var arr = [];
  var keys = Object.keys(source);
  // What's in a name?

  for(var i = 0; i < collection.length; i++){
    if (collection[i].hasOwnProperty(Object.keys(source))){
        var prop = Object.keys(source);
        if (collection[i][prop]===source[prop]){
        arr.push(collection[i]);}
   }
  }

  return arr;
}

I just got 2 of 4 results, I still dont understand at all

Jon
@jcmockbee
Feb 09 2016 01:45 UTC
@wearenotgroot sorry I am not understanding
Norman Dela Cruz
@dcnr
Feb 09 2016 01:46 UTC
@jcmockbee Object.keys() returns an array so your prop would be an array
greg
@wearenotgroot
Feb 09 2016 01:48 UTC
@jcmockbee instead of ---->result ="Hold";{return count--;}----------------------> do this count --; aswell as the other one count++
DJ Nixon
@tGxcoder
Feb 09 2016 01:48 UTC
// 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("alpha");
greg
@wearenotgroot
Feb 09 2016 01:48 UTC
@jcmockbee then outside the switch make an if statement
rphares
@rphares
Feb 09 2016 01:49 UTC
@tGxcoder , good start,
DJ Nixon
@tGxcoder
Feb 09 2016 01:49 UTC
what am i doing wrong . that is the correct format right
rphares
@rphares
Feb 09 2016 01:49 UTC
the table is fine, but--
Ivan Perez
@joannesalfa
Feb 09 2016 01:49 UTC
Anyone can help me to explain what I made mistake
function where(collection, source) {
  var arr = [];
  var keys = Object.keys(source);
  // What's in a name?

  for(var i = 0; i < collection.length; i++){
    if (collection[i].hasOwnProperty(Object.keys(source))){
        var prop = Object.keys(source);
        if (collection[i][prop]===source[prop]){
        arr.push(collection[i]);}
   }
  }

  return arr;
}
Norman Dela Cruz
@dcnr
Feb 09 2016 01:49 UTC
@joannesalfa alternatively you can use .filter() on collection instead, so you don't have to do nested loops. Inside the filter, you can test for all of source
rphares
@rphares
Feb 09 2016 01:49 UTC
we need to use it to get what we want.right now, its just a table, @tGxcoder :)
there are two steps-- building the lookup part, and thinking about the return,
bitgrower
@bitgrower
Feb 09 2016 01:50 UTC
@tGxcoder -- look at the example on the left side of your screen ...
rphares
@rphares
Feb 09 2016 01:50 UTC
lets start with the lookup :)
the example:
Their table is named var alpha and they want 2, so they write alpha[2]
Ivan Perez
@joannesalfa
Feb 09 2016 01:50 UTC
@dcnr hmmm... let me re-write with filter function
rphares
@rphares
Feb 09 2016 01:50 UTC
your table is named var lookup and you want val, so you can write...? @tGxcoder
Jon
@jcmockbee
Feb 09 2016 01:51 UTC
@wearenotgroot ok got rid of brackets
greg
@wearenotgroot
Feb 09 2016 01:51 UTC
@jcmockbee let's see the update code
Ivan Perez
@joannesalfa
Feb 09 2016 01:52 UTC
@dcnr thanks
CamperBot
@camperbot
Feb 09 2016 01:52 UTC
joannesalfa sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 545 | @dcnr | http://www.freecodecamp.com/dcnr
DJ Nixon
@tGxcoder
Feb 09 2016 01:53 UTC
i had it as val .
greg
@wearenotgroot
Feb 09 2016 01:54 UTC
@joannesalfa here is another array function/method you can use -----> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
rphares
@rphares
Feb 09 2016 01:54 UTC
@tGxcoder , sorry, i dont understand what you mean-- can you show me how to write the alpha[2] part for your table?
DJ Nixon
@tGxcoder
Feb 09 2016 01:54 UTC
i tried plain val. val phoneticLookup....
Jon
@jcmockbee
Feb 09 2016 01:54 UTC

@wearenotgroot var count = 0;

function cc(card) {
// Only change code below this line
while(card !== ""){
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:

  result ="Bet"; count++;

break;

case 7:
case 8:
case 9:

  result ="Hold"; return count;

  break;


case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
 result ="Hold";return count--;

}
return count;

  }

// Only change code above this line
} @wearenotgroot oopps revised

outspc
@outspc
Feb 09 2016 01:56 UTC
hi
im get stucked
greg
@wearenotgroot
Feb 09 2016 01:56 UTC
@jcmockbee i just notice why do you have a while loop?
outspc
@outspc
Feb 09 2016 01:56 UTC
need some help with js challenge 203
DJ Nixon
@tGxcoder
Feb 09 2016 01:56 UTC
@rphares would it be bravo[2];
rphares
@rphares
Feb 09 2016 01:57 UTC
no, not quite, @tGxcoder
your table is called var lookup and you aren't looking for 2, you are looking for val
tableName[thingYouWant]
how do we use that format to get what we want from your table?
greg
@wearenotgroot
Feb 09 2016 01:58 UTC

@jcmockbee remove unneccessary while loop

switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
  result ="Bet"; count++;//<--------------------------------------remove everything except count++;
break;
case 7:
case 8:
case 9:

  result ="Hold"; return count;//<-----------------------------remove everything

  break;


case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
 result ="Hold";return count--;//<------------------------remove everything except count--;
}

after the switch statement create an if statement below--->from instruction-.---------->The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

DJ Nixon
@tGxcoder
Feb 09 2016 01:59 UTC
val[phoneticLookup]; ?
Lloyd Consolacion
@cowboybebot
Feb 09 2016 01:59 UTC
@jcmockbee case 7-9 can be safely omitted , too
DJ Nixon
@tGxcoder
Feb 09 2016 01:59 UTC
@rphares
rphares
@rphares
Feb 09 2016 02:00 UTC
@tGxcoder no phonetic lookup, we aren't doing anything with the function,
and what we want goes in the []
Norman Dela Cruz
@dcnr
Feb 09 2016 02:00 UTC
@joannesalfa sorry I had to step out, have you solved it? :D
DJ Nixon
@tGxcoder
Feb 09 2016 02:00 UTC
alpha bravo....? so then val[alpha];
rphares
@rphares
Feb 09 2016 02:00 UTC
var alpha and we want 2 is alpha[2]. (tableName[thingWeWant])
var lookup and we want val is...?
the table name goes on the outside, @tGxcoder . you table is named lookup
DJ Nixon
@tGxcoder
Feb 09 2016 02:02 UTC
lookup[2].(val[bravo]; ?
rphares
@rphares
Feb 09 2016 02:02 UTC
okay, now lookup is right :)
but, we dont want 2, they wanted 2
and we dont want bravo, thats a specific example from the the tests,
we only need to use val in the brackets
DJ Nixon
@tGxcoder
Feb 09 2016 02:04 UTC
lookup[val] so just that? because im still a little confused to be honest
rphares
@rphares
Feb 09 2016 02:04 UTC
yep-- thats all you need for this part!
DJ Nixon
@tGxcoder
Feb 09 2016 02:05 UTC
@rphares thanks man
CamperBot
@camperbot
Feb 09 2016 02:05 UTC
tgxcoder sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2566 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 09 2016 02:05 UTC
wel--- there is one step left! @tGxcoder
that is how you tell it to get val from lookup,
but... if you just tell it that, just like that, and then return result... you haven't used that line,
Jenn Hardy
@smokeyLilac
Feb 09 2016 02:06 UTC
This message was deleted
rphares
@rphares
Feb 09 2016 02:06 UTC
if you are going to return result (and you are, its below the 'do not change line', @tGxcoder )
then you need to put your lookup[val] in result, before you return result
earlier, at the top, you set result = " ", so now, after the table, you need to set result = again, so it will give you what you want :) @tGxcoder
DJ Nixon
@tGxcoder
Feb 09 2016 02:08 UTC
ok let see if i can get it brb
Norman Dela Cruz
@dcnr
Feb 09 2016 02:08 UTC
@tGxcoder hi I wrote this earlier about object lookups, maybe it can help you understand a little better :point_up: Explanation
rphares
@rphares
Feb 09 2016 02:10 UTC
oooh, @dcnr , can i save that for others?
Jon
@jcmockbee
Feb 09 2016 02:10 UTC
blob
Norman Dela Cruz
@dcnr
Feb 09 2016 02:10 UTC
sure, maybe I should format that, or put it in the wiki!
rphares
@rphares
Feb 09 2016 02:10 UTC
(im not good at using words like key/value pairs yet...)
Norman Dela Cruz
@dcnr
Feb 09 2016 02:11 UTC
@rphares meh technobabblebuzwords :P
@jcmockbee hi what challenge name is that again?
Jon
@jcmockbee
Feb 09 2016 02:12 UTC
@wearenotgroot I think I cleaned it up
Norman Dela Cruz
@dcnr
Feb 09 2016 02:12 UTC
Man I should update my repo for these new stuffs
rphares
@rphares
Feb 09 2016 02:12 UTC
lol- but important ones! can't explain for those who need more specifics than "the thing in the place" :wink2:
@dcnr , hes on counting cards
Norman Dela Cruz
@dcnr
Feb 09 2016 02:12 UTC
aah thanks! @rphares
CamperBot
@camperbot
Feb 09 2016 02:12 UTC
dcnr sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2568 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 09 2016 02:13 UTC
(and-- tis looking much better, @jcmockbee , you are getting closer! Keep it up :) )
Keith Adams
@unclwilli
Feb 09 2016 02:14 UTC
Where can I find other examples and exercises for each waypoint? (Just finished the Basic Javascript and OOP segments)It would be good to practice on some of the functiions and methods.
Jon
@jcmockbee
Feb 09 2016 02:14 UTC
@rphares thanks still trying to get ouput
CamperBot
@camperbot
Feb 09 2016 02:14 UTC
jcmockbee sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
Norman Dela Cruz
@dcnr
Feb 09 2016 02:14 UTC
@jcmockbee I think you have one extra }
rphares
@rphares
Feb 09 2016 02:14 UTC
@jcmockbee , you may want to think about your return next... you willed an if/else, based on count.
CamperBot
@camperbot
Feb 09 2016 02:14 UTC
:star: 2569 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 09 2016 02:15 UTC
you just updated count in all of those-- thats exactly what we wanted, well done~
but when you return, you want to return more than just count,
you want to return count and the correct string ( " Hold" or " Bet")
so you will need to tell it what to do if count is above zero or not...
Jon
@jcmockbee
Feb 09 2016 02:16 UTC
ok will work in if/else hold bet
Norman Dela Cruz
@dcnr
Feb 09 2016 02:17 UTC
@jcmockbee I think your switch case is ok, you just have to return the proper string after your count--/++
@jcmockbee you also need cases for 7, 8, 9
rphares
@rphares
Feb 09 2016 02:18 UTC
:) (hint-- notice exactly what i typed for the string parts... because you want the count in front of the string, and you dont want it to say -4Hold, you would want -4 Hold) @jcmockbee ;)
Jon
@jcmockbee
Feb 09 2016 02:20 UTC
will do just in thought process now
Nikki
@nikkiLuan
Feb 09 2016 02:22 UTC
blob
bitgrower
@bitgrower
Feb 09 2016 02:22 UTC

okay ... I guess I understand what happens if I return arr.reduce(...

...but what if I were to use

return arr.splice(0,1); -- what gets returned ? The removed items? Or the arr without the removed items ...

Nikki
@nikkiLuan
Feb 09 2016 02:22 UTC
hey, guys, can anyone help me to solve this plz?
bitgrower
@bitgrower
Feb 09 2016 02:23 UTC
well, can't see your entire code, @nikkiLuan
explain format
CamperBot
@camperbot
Feb 09 2016 02:23 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

rphares
@rphares
Feb 09 2016 02:24 UTC
make objects private? can you just paste the formatted code, not send a screenshot, please? @nikkiLuan
explain format
CamperBot
@camperbot
Feb 09 2016 02:24 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Norman Dela Cruz
@dcnr
Feb 09 2016 02:25 UTC
@nikkiLuan .setGear should be gear = (whatever gear), you also have typo geat
Nikki
@nikkiLuan
Feb 09 2016 02:25 UTC
well, let me see how to paste code
chris1819
@chris1819
Feb 09 2016 02:26 UTC
type three back ticks(```) then press enter, paste your code between the 2 sets of back ticks then post
DJ Nixon
@tGxcoder
Feb 09 2016 02:29 UTC
@dcnr thanks it helped a little bit. @rphares i think i got what you said. but its havving a issue with val its saying it expected an expression but instead for a assiment or something like that
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

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

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

// Change this value to test
phoneticLookup("alpha");
CamperBot
@camperbot
Feb 09 2016 02:29 UTC
tgxcoder sends brownie points to @dcnr and @rphares :sparkles: :thumbsup: :sparkles:
:warning: tgxcoder already gave rphares points
:star: 546 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 09 2016 02:30 UTC
@tGxcoder I think you meant var lookupand not val lookup :P
rphares
@rphares
Feb 09 2016 02:31 UTC
@tGxcoder , yay!so close, but
your table name--
yeah
:)
Calvoxel
@Calvoxel
Feb 09 2016 02:31 UTC
I'm working on "Where do I belong" which is an algorithm. Here is my code. It doesn't seem to be working though..... :3
function where(arr, num) {
  var holdPlace = 0;
  // Find my place in this sorted array.
  for (i = 0; i < arr.length; i++) {
    if (num >= arr[i]) {
      if (num <= arr[i+1]) {
        holdPlace += 1;
      }
    }
  }
  return holdPlace;
}

where([10, 20, 30, 40, 50, 60], 35);
DJ Nixon
@tGxcoder
Feb 09 2016 02:32 UTC
ps i hate this challenge. i have been messing with for for a few days now......
Nikki
@nikkiLuan
Feb 09 2016 02:33 UTC
@chris1819 i typed three (), then paste my code, n then closed with, its not working when i press enter, i mean, i can't post
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

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

var Bike = function() {

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

  this.getGear = function(change){
    gear += change;    
  };

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

};

var myCar = new Car();

var myBike = new Bike();
nice!
I'm confusing with the question: myBike.getGear() should return 4 after calling myBike.setGear(4).
Calvoxel
@Calvoxel
Feb 09 2016 02:34 UTC
@nikkiLuan I think you need to give setGear a parameter to call.
@nikkiLuan give setGear a parameter that should be added to gear
chris1819
@chris1819
Feb 09 2016 02:35 UTC

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

switch(val) {
case "bob":
answer = "Marley";
break;
case 42:
answer = "The Answer";
break;
case 1:
answer = "There is no #1";
break;
case 99:
answer = "Missed me by this much!";
break;
case 7:
answer = "Ate Nine";
break;
}
}

// Change this value to test
myTest(7);
```
switches are kicking my butt. I dont understand what is wrong

DJ Nixon
@tGxcoder
Feb 09 2016 02:35 UTC
@dcnr thanks that got it to work.
CamperBot
@camperbot
Feb 09 2016 02:35 UTC
tgxcoder sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: tgxcoder already gave dcnr points
chris1819
@chris1819
Feb 09 2016 02:35 UTC
function myTest(val) {
  var answer = "";
  // Only change code below this line


switch(val) {
    case "bob":
      answer = "Marley";
      break;
    case 42:
      answer = "The Answer";
      break;
    case 1:
      answer = "There is no #1";
      break;
    case 99:
      answer = "Missed me by this much!";
      break;
    case 7:
      answer = "Ate Nine";
      break;
  }
}

// Change this value to test
myTest(7);
DJ Nixon
@tGxcoder
Feb 09 2016 02:36 UTC
@rphares thanks for helping me with the walk through
CamperBot
@camperbot
Feb 09 2016 02:36 UTC
tgxcoder sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: tgxcoder already gave rphares points
chris1819
@chris1819
Feb 09 2016 02:36 UTC
can someone tell me how to make switches understand strings and numbers at the same time
rphares
@rphares
Feb 09 2016 02:36 UTC
@chris1819 whats the name of that guy again? sorry, he's so weird, i wanna look at mine, but... off the top of my head, are you returning anything??
anytime, @tGxcoder ~
Jason
@jpr00
Feb 09 2016 02:37 UTC
@chris1819 you need a statement to return answer
chris1819
@chris1819
Feb 09 2016 02:37 UTC
@rphares Replacing If Else Chains with Switch
Calvoxel
@Calvoxel
Feb 09 2016 02:37 UTC
Can someone help me out with "Where do I belong"? The following code is returning the number 1 instead of 3.
function where(arr, num) {
  var holdPlace = 0;
  // Find my place in this sorted array.
  for (i = 0; i < arr.length; i++) {
    if (num >= arr[i]) {
      if (num <= arr[i+1]) {
        holdPlace += 1;
      }
    }
  }
  return holdPlace;
}

where([10, 20, 30, 40, 50, 60], 35);
Jason
@jpr00
Feb 09 2016 02:37 UTC
@chris1819 your switch is good, just missing the return statement
rphares
@rphares
Feb 09 2016 02:38 UTC
@chris1819 , there was a line in below the do not change line
line 22 and beyond was
  // Only change code above this line  
  return answer;  
}

// Change this value to test
myTest(7);
chris1819
@chris1819
Feb 09 2016 02:40 UTC
itried a return answer; but it says that myTest(7) is unreachable
rphares
@rphares
Feb 09 2016 02:40 UTC
can you paste what you tried now?
(also, you dont need that last break, i dont think...)
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 02:41 UTC
Has someone done the "Caesars Cipher" challenge?
chris1819
@chris1819
Feb 09 2016 02:41 UTC
nevermind I hd bracket in wrong place.
rphares
@rphares
Feb 09 2016 02:42 UTC
awesome! congrats and happy doing, @chris1819 ~
chris1819
@chris1819
Feb 09 2016 02:43 UTC
@rphares thanks
CamperBot
@camperbot
Feb 09 2016 02:43 UTC
chris1819 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 2572 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Feb 09 2016 02:43 UTC
anytime~
Norman Dela Cruz
@dcnr
Feb 09 2016 02:43 UTC
@Calvoxel It's not adding up because if your second if statement
@Calvoxel for example at first iteration arr[i] is 10
@Calvoxel 35 is greater than 10 so it goes into the inner if
and you check the next element with arr[i + 1] which is 20
but 35 is not less than 20
so holdPlace += 1 does not happen
Calvoxel
@Calvoxel
Feb 09 2016 02:45 UTC
@dcnr Oh, I see. How do I fix this though?
Norman Dela Cruz
@dcnr
Feb 09 2016 02:45 UTC
@Calvoxel hmm lemme think, I haven't even thought of doing it this way though
Calvoxel
@Calvoxel
Feb 09 2016 02:46 UTC
@dcnr take your time, I'll be okay
(No sarcasm intended)
Taysha
@taariya
Feb 09 2016 02:46 UTC
can someone help me with spinal tap case
Norman Dela Cruz
@dcnr
Feb 09 2016 02:46 UTC
@Calvoxel ah and the array isn't even sorted
Calvoxel
@Calvoxel
Feb 09 2016 02:46 UTC
@dcnr oh, right, forgot about that D:
Norman Dela Cruz
@dcnr
Feb 09 2016 02:47 UTC
@Calvoxel actually if you notice the test cases
10, 20, 30, 35; // answer should be 3
10, 20, 30; // answer should be 2
Calvoxel
@Calvoxel
Feb 09 2016 02:47 UTC
@dcnr what about that?
Norman Dela Cruz
@dcnr
Feb 09 2016 02:48 UTC
@Calvoxel the answer is the number of numbers before your target
so for 35 it's 3, and for 30 it's 2
@Calvoxel that means you can just keep count of how many numbers lower than your target is
@Calvoxel and return that
@Calvoxel there are many ways of doing this really :P
Calvoxel
@Calvoxel
Feb 09 2016 02:49 UTC
@dcnr Oh, I see! Thanks!
CamperBot
@camperbot
Feb 09 2016 02:49 UTC
calvoxel sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 547 | @dcnr | http://www.freecodecamp.com/dcnr
Peter Elbaum
@elbaumpj
Feb 09 2016 02:49 UTC
Can anyone speak to what I'm doing wrong in the card counting function? How do you get the count to appear with "Bet" or "Hold"? if (count > 0) {
return "Bet";
}
if (count <= 0 ) {
return "count Hold";
}
Norman Dela Cruz
@dcnr
Feb 09 2016 02:50 UTC
@elbaumpj you can do something like return count + " Word";
@Pilotwing hi, you still on Caesar's?
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 02:51 UTC
@dcnr yes!
Norman Dela Cruz
@dcnr
Feb 09 2016 02:51 UTC
@Pilotwing what you got so far?
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 02:53 UTC
ok so first I am trying to identify non-alphanumeric and also I need to understand if I substract 13 or add 13 to the code. My guess by reading the wiki link is that I have to add when the unicode is below 13
@dcnr do you want me to show you the code so far?
Nikki
@nikkiLuan
Feb 09 2016 02:53 UTC
var Bike = function() {

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

  this.setGear = function(change)
  {
    gear = change;
  };

  this.getGear= function()
  {
    return Bike.setGear;
  };

};

var myCar = new Car();

var myBike = new Bike();
  myBike.setGear(4);
i'm still not able to solve this
azat55
@azat55
Feb 09 2016 02:54 UTC
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  switch(val) {
    case "alpha": 
      result = "Adams";
      break;
    case "bravo": 
      result = "Boston";
      break;
    case "charlie": 
      result = "Chicago";
      break;
    case "delta": 
      result = "Denver";
      break;
    case "echo": 
      result = "Easy";
      break;
    case "foxtrot": 
      result = "Frank";
  }

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

// Change this value to test
phoneticLookup("charlie");
Guys here I need to convert switch into so called lookup, I didn't understand about lookup clearly, can someone advice me on how to solve it
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 02:54 UTC
@dcnr
function rot13(str) { // LBH QVQ VG!
  var unicodeVal = 0;
  var newStr = "";
  for(var i = 0; i < str.length; i++) {
    unicodeVal = str.charCodeAt(i);
    newStr = newStr.concat(String.fromCharCode(str[i] != /\W/ ? unicodeVal - 13 : unicodeVal));
  }
  return newStr;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Nikki
@nikkiLuan
Feb 09 2016 02:55 UTC
can anyone help me?
Norman Dela Cruz
@dcnr
Feb 09 2016 02:56 UTC
@Pilotwing oh nice conditional use, but you don't just subtract, you also have to add, because you have a certain treshold
@Pilotwing for example, "A" is char code 65, if you subtract 13, then it won't be in the alphabet range of 65 to 90 anymore!
Jon
@jcmockbee
Feb 09 2016 02:57 UTC
I am doing the card counting challenge too
Frank
@fctromba66
Feb 09 2016 02:57 UTC
I am stuck on the make object properties private I cannot figure out where to put the myBike.getGear()

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

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

var Bike = function() {

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

this.getGear = function(change){
gear += change;
};

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

var myCar = new Car();

var myBike = new Bike();

Norman Dela Cruz
@dcnr
Feb 09 2016 02:58 UTC
@azat55 read the description at the side carefully, it shows an example of a "lookup table"
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 02:58 UTC
@dcnr ok that part i got it clear know. So my next thing to fix will be the expression
Nikki
@nikkiLuan
Feb 09 2016 02:58 UTC
@fctromba66 we are same, i'm working on it now
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 02:59 UTC
@dcnr mI am getting red dots in the spaces so I guess my code is adding to the unicode values of the white spaces
Norman Dela Cruz
@dcnr
Feb 09 2016 02:59 UTC
@Pilotwing also I just noticed that your ternary operator isn't probably working
Frank
@fctromba66
Feb 09 2016 02:59 UTC
@nikkiLuan I think it goes underneath the var myBike = new Bike(); but I am stuck
matthew3454
@matthew3454
Feb 09 2016 02:59 UTC
Can someone help me with the exercise Make Object Properties Private. пожалуйста?
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:00 UTC
@dcnr what is my temproal operator? and sorry to ask
Nikki
@nikkiLuan
Feb 09 2016 03:00 UTC
var Bike = function() {

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

  this.setGear = function(change)
  {
    gear = change;
  };

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

};

var myCar = new Car();

var myBike = new Bike();
  myBike.setGear(4);
  myBike.getGear();
Norman Dela Cruz
@dcnr
Feb 09 2016 03:00 UTC
@Pilotwing I think you should probably use /\W/.test(str[i]) instead of str[i] != /\W/
Nikki
@nikkiLuan
Feb 09 2016 03:00 UTC
Finally
Norman Dela Cruz
@dcnr
Feb 09 2016 03:00 UTC
coz regex doesn't work that way
Frank
@fctromba66
Feb 09 2016 03:00 UTC
@nikkiLuan Nice I was just writing that!!!!
Nikki
@nikkiLuan
Feb 09 2016 03:01 UTC
@fctromba66 lol
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:01 UTC
@dcnr oo ok let me try that and also fix the adding and substracting and 'll let you know if I pass the challenge
Norman Dela Cruz
@dcnr
Feb 09 2016 03:02 UTC
@Pilotwing the conditional operator aka ternary is that ? : part you're using, how come you don't know the name :P
bitgrower
@bitgrower
Feb 09 2016 03:04 UTC

well ... I just ran the solution of symmetric difference provided in the wiki ... and it doesn't work!
(it seems to leave duplicated numbers in the answer, as well as having the order of the numbers in the last test case different, and so doesn't pass ... )

leaves me with a few questions about the meaning of symmetric difference !!!

Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:05 UTC
@dcnr Thanks for reminding me the name XD
CamperBot
@camperbot
Feb 09 2016 03:05 UTC
pilotwing sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 548 | @dcnr | http://www.freecodecamp.com/dcnr
Jon
@jcmockbee
Feb 09 2016 03:05 UTC
I would like to post my code how to please
bitgrower
@bitgrower
Feb 09 2016 03:05 UTC
explain format
CamperBot
@camperbot
Feb 09 2016 03:05 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Jon
@jcmockbee
Feb 09 2016 03:05 UTC
using snipping tool
Norman Dela Cruz
@dcnr
Feb 09 2016 03:05 UTC
@bitgrower I think some of the wiki answers are outdated because the exercises are changing too
rphares
@rphares
Feb 09 2016 03:06 UTC
@jcmockbee , pasting is far preferable than images,
we can't copy and run your code if its a screen shot,
bitgrower
@bitgrower
Feb 09 2016 03:07 UTC
okay ... it seems to get really close to the answers except for the instances I've noted ... and, uh, I ran your solution and it passes ... :)
rphares
@rphares
Feb 09 2016 03:07 UTC
nor comment to help
Jon
@jcmockbee
Feb 09 2016 03:07 UTC
ok will paste then
bitgrower
@bitgrower
Feb 09 2016 03:07 UTC
so ... my scalp is getting sore from scratching my head ... LOL ...
rphares
@rphares
Feb 09 2016 03:07 UTC
:point_up: February 9, 2016 10:05 AM @jcmockbee :)
Norman Dela Cruz
@dcnr
Feb 09 2016 03:08 UTC
@bitgrower you ran mine? :P my solutions aren't exactly friendly because I use newly implemented stuffs and try to shorthand a lot
bitgrower
@bitgrower
Feb 09 2016 03:09 UTC
yeah, I didn't understand your solution, for sure ...
but it passed!
Norman Dela Cruz
@dcnr
Feb 09 2016 03:09 UTC
course it does! :D
bitgrower
@bitgrower
Feb 09 2016 03:09 UTC
I was just trying to figure out what is going on, in terms of answers, solutions, wiki, problem, etc ...
but I was not ready to go digging into fat arrows (I think you used?) thankyouverymuch ... :)
Norman Dela Cruz
@dcnr
Feb 09 2016 03:11 UTC
oh arrow functions, they're awesome!
@bitgrower I think you just have to hmm write down first what you understood of the description
and what's needed
bitgrower
@bitgrower
Feb 09 2016 03:11 UTC
tryin' to figure out where the discrepancy is ... the different solutions on stackexchange also seem to not be completely consistent with the solutions in the test cases (they seem to be okay with dup numbers...) ... and finding a good def of sym difference (like, does the order the numbers are returned matter ?)
Yeah, I wrote some code which worked for the first test case ... then couldn't figure out how to pull .reduce into the problem ...
Norman Dela Cruz
@dcnr
Feb 09 2016 03:12 UTC
ah yeah there's that too, though I remember some exercises where you need to keep the position
bitgrower
@bitgrower
Feb 09 2016 03:13 UTC
...the solution def had some new syntaxes for me to explore ... like just .concat -- without the arr in front of it ...
kinda making my brain go wonky ...
LOL ... I'll get to arrow functions when I'm ready, right now that would be a bit of overwhelm, I'm afraid ...
Norman Dela Cruz
@dcnr
Feb 09 2016 03:14 UTC
@bitgrower sorry I lost my original repo, I kept my 'noobie' solutions then, and I think it would have been much better help than the current ones
bitgrower
@bitgrower
Feb 09 2016 03:14 UTC
ah well ... such is life, eh ?
Norman Dela Cruz
@dcnr
Feb 09 2016 03:14 UTC
@bitgrower ah but the arr is there! [].concat()
why don't you show your current code, maybe we can bang it up
bitgrower
@bitgrower
Feb 09 2016 03:15 UTC
so saying .concat() ... is the same as [].concat() ?
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:15 UTC
@dcnr
function rot13(str) { // LBH QVQ VG!
  var unicodeVal = 0;
  var newStr = "";
  for(var i = 0; i < str.length; i++) {
    unicodeVal = str.charCodeAt(i);
    newStr = newStr.concat(String.fromCharCode(/\w/.test(str[i]) ? unicodeVal < 77.5 ? unicodeVal + 13 : unicodeVal - 13 : unicodeVal));
  }
  return newStr;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
@dcnr it work Thanks! I wonder if how I do it is bad or good practice XD
CamperBot
@camperbot
Feb 09 2016 03:16 UTC
pilotwing sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: pilotwing already gave dcnr points
Norman Dela Cruz
@dcnr
Feb 09 2016 03:16 UTC
@bitgrower oh no .concat is an array function so it needs to be called with an array. so usually myArray.concat but [] is just an empty array so you can do [].concat too
bitgrower
@bitgrower
Feb 09 2016 03:16 UTC
that's very tempting, @dcnr ... maybe later this week ... I've been looking at symmetric difference for too long atm ... need to hit my head up against something a bit fresher ... I think that section of my brain needs a bit of vacation ...
hmm ... okay ... hang on ...
Norman Dela Cruz
@dcnr
Feb 09 2016 03:17 UTC
@Pilotwing I guess it's arguable? I love conditional use and I use it quite a lot but some people think they're hard to read. And I agree if they're not formatted properly
@bitgrower try the problems at Project Euler, they're refreshing
bitgrower
@bitgrower
Feb 09 2016 03:18 UTC
function sym(args) {

  var arg = Array.prototype.slice.call(arguments);

  // Return the symmetric difference of 2 arrays
  var getDiff = function(arr1, arr2) {

    // Returns items in arr1 that don't exist in arr2
    function filterFunction(arr1, arr2) {
      return arr1.filter(function(item) {
        return arr2.indexOf(item) === -1;
      });
    }

    // Run filter function on each array against the other
    return filterFunction(arr1, arr2)
      .concat(filterFunction(arr2, arr1));
  };

  return arg.reduce(getDiff,[]);
}
@dcnr -- that's the wiki soln ... ... see that .concat down there ?
what does that mean ?
(that's also a bit too much recursion for my little brain ... LOL.)
Norman Dela Cruz
@dcnr
Feb 09 2016 03:20 UTC
@bitgrower it's just placed on the next line, I do it a lot too when chaining stuff. here filterFunction returns an array
bitgrower
@bitgrower
Feb 09 2016 03:20 UTC
ahhhhhhhhh ... okay ...
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:20 UTC
@dcnr well bad or good it is defently uglier but I am too lazy to write if statements XD
bitgrower
@bitgrower
Feb 09 2016 03:20 UTC
yeah, that's another one of my js puzzlements ... wrapping code over multiple lines ...
Norman Dela Cruz
@dcnr
Feb 09 2016 03:21 UTC
@Pilotwing it's not that ugly if you break em down :P
@bitgrower here example
function reverseString(str) {
  'use strict';

  return str
    .split('')
    .reverse()
    .join('');
}
they're just put on the next line
so they stand out on their own
and you know you're chaining them
Peter Elbaum
@elbaumpj
Feb 09 2016 03:22 UTC
Stuck on the Card Counting exercise. What is needed in order to add the card's value to the universal count variable?
bitgrower
@bitgrower
Feb 09 2016 03:22 UTC
ooooh ... I like that ... that's about as cool as I've seen since I saw regexes commented over multiple lines in perl ...
EHunt13
@EHunt13
Feb 09 2016 03:23 UTC
function chunk(arr, size) {
  var finalArray = [];

  for (var i=0; i<arr.length; i+=size){
    finalArray.push(arr.slice(0,size));

  }
  return finalArray;
}

chunk(["a", "b", "c", "d"], 2);
can someone give me a hint on this?
i imagine i'm pretty close
bitgrower
@bitgrower
Feb 09 2016 03:23 UTC
@EHunt13 ... you are ...
here's how I think you'll figure out the answer quickly ....
Norman Dela Cruz
@dcnr
Feb 09 2016 03:24 UTC

@Pilotwing see my record collection

function update(id, prop, value) {
  return value
    ? prop === 'tracks'
        ? (collection[id].tracks.push(value), collection)
        : (collection[id][prop] = value, collection)
    : (delete collection[id][prop], collection);
}

not that hard to read even though they're nested!

bitgrower
@bitgrower
Feb 09 2016 03:24 UTC
put a console.lot(finalArray) into your loop ...
EHunt13
@EHunt13
Feb 09 2016 03:24 UTC
i guess I just want to know why the loop doesnt slice off the part of the array each time
k
bitgrower
@bitgrower
Feb 09 2016 03:24 UTC
^^^^ try what I just suggested, @EHunt13 -- how long have you been staring at this ...
EHunt13
@EHunt13
Feb 09 2016 03:24 UTC
thanks @bitgrower
CamperBot
@camperbot
Feb 09 2016 03:24 UTC
ehunt13 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 415 | @bitgrower | http://www.freecodecamp.com/bitgrower
EHunt13
@EHunt13
Feb 09 2016 03:25 UTC
maybe 10 minutes
bitgrower
@bitgrower
Feb 09 2016 03:25 UTC
it's one of those things, that when you see it ... it may be time to get up and walk around and re-oxygenated your brain cells ... they get oxygen depleted if you sit around too much ... :)
EHunt13
@EHunt13
Feb 09 2016 03:26 UTC
haha ok thanks...will do
Moisés Man
@moigithub
Feb 09 2016 03:26 UTC
@EHunt13 if slice modify the original array.. ur code will work.. but it doesnt modify, so u keep pushing the same data over n over again...
so instead of 0. u should use a changing"index"
bitgrower
@bitgrower
Feb 09 2016 03:26 UTC
not too bad ... but getting up, taking bathroom, water, snack, vitamin D breaks do help ...
EHunt13
@EHunt13
Feb 09 2016 03:27 UTC
haha thanks @moigithub
CamperBot
@camperbot
Feb 09 2016 03:27 UTC
ehunt13 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 09 2016 03:27 UTC
yeah, @moigithub -- I was hoping he would see that for himself ...
CamperBot
@camperbot
Feb 09 2016 03:27 UTC
:star: 527 | @moigithub | http://www.freecodecamp.com/moigithub
EHunt13
@EHunt13
Feb 09 2016 03:27 UTC
that is simple....how do i view the console to solve it? @bitgrower
bitgrower
@bitgrower
Feb 09 2016 03:28 UTC
There is a whole new set of hikes (I guess they are called) ... at the bottom of your map ... under Video Challenges ... one of them covers chrome developer tools ...
EHunt13
@EHunt13
Feb 09 2016 03:28 UTC
ok
faintlywonky
@faintlywonky
Feb 09 2016 03:28 UTC
Is there a way to search for specific FCC rooms without having to manually scroll through all 514 of them?
bitgrower
@bitgrower
Feb 09 2016 03:28 UTC
you can (I'm told) even use the dev tools to set breakpoints ... but they didn't cover that in the tools, just gave an awesome intro to the various tools available ...
help rooms
CamperBot
@camperbot
Feb 09 2016 03:29 UTC

:point_right: help rooms [wiki]

Help Rooms

Choose the right room for your question!

:pencil: read more about help rooms on the FCC Wiki

EHunt13
@EHunt13
Feb 09 2016 03:29 UTC
im looking at the console, I understand how to get into it, i just dont understand the output
bitgrower
@bitgrower
Feb 09 2016 03:29 UTC
many of the 514 are probably for individual algorithm challenges ...
EHunt13
@EHunt13
Feb 09 2016 03:29 UTC
i will learn this later?
bitgrower
@bitgrower
Feb 09 2016 03:29 UTC
I don't understand all of it ...
Norman Dela Cruz
@dcnr
Feb 09 2016 03:30 UTC
@EHunt13 oh you're using slice(0, size) so you're just slicing from index 0 to size
bitgrower
@bitgrower
Feb 09 2016 03:30 UTC
but, while Google may or may not be your friend (privacy speaking) ... they do put out good info ...
Norman Dela Cruz
@dcnr
Feb 09 2016 03:30 UTC
@EHunt13 you should move your index up to cut the next elements
bitgrower
@bitgrower
Feb 09 2016 03:30 UTC
so you can use google to google for some of their training ... their dev tools are quite sophisticated ... they even have a chrome developer tools conference ...
EHunt13
@EHunt13
Feb 09 2016 03:30 UTC
thanks @dcnr
CamperBot
@camperbot
Feb 09 2016 03:30 UTC
ehunt13 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:30 UTC
@dcnr wow I read it a few times it still looks confusing
CamperBot
@camperbot
Feb 09 2016 03:30 UTC
:star: 549 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 09 2016 03:31 UTC
which, @Pilotwing
EHunt13
@EHunt13
Feb 09 2016 03:31 UTC
lots to learn
bitgrower @bitgrower wants to see if she's confused, too ...
bitgrower
@bitgrower
Feb 09 2016 03:32 UTC
yeah ... but also lots of cool stuff, too ... I use evernote and I have tons of notes on different software stuff & resources :)
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:32 UTC
function update(id, prop, value) {
  return value
    ? prop === 'tracks'
        ? (collection[id].tracks.push(value), collection)
        : (collection[id][prop] = value, collection)
    : (delete collection[id][prop], collection);
}
@dcnr code
EHunt13
@EHunt13
Feb 09 2016 03:33 UTC
I use evernote too, but haven't for coding yet
I'll start getting organized on there
bitgrower
@bitgrower
Feb 09 2016 03:33 UTC
hahahahaha ... yeah ... that is a bit complex ...

@EHunt -- I stick nearly everything in there .. but I don't use copy & paste web pages much, since I have the free version ... and I figure if I primarily just use text, I can use it forever ... LOL ...

exceptions are fb chats ... because copying fb chats into text is NOT useful at all ... can't even tell who is talking ...

Also, have been interested in looking at OneNote ... especially since microsoft made it free ..
Norman Dela Cruz
@dcnr
Feb 09 2016 03:35 UTC
@Pilotwing Here's the alternative one
function update(id, prop, value) {
  value
    ? prop === 'tracks'  // value is not empty, check if prop is tracks                 
        ? collection[id].tracks.push(value) // prop is tracks, update tracks
        : collection[id][prop] = value // prop is not tracks, update/make new prop
    : delete collection[id][prop]; // value is empty, delete prop

  return collection;
}
EHunt13
@EHunt13
Feb 09 2016 03:35 UTC
yea i just downgraded to the freeversion....I'll check out onenote too
bitgrower
@bitgrower
Feb 09 2016 03:35 UTC
I suspect once I fall into OneNote, I may give up on EN ...
EHunt13
@EHunt13
Feb 09 2016 03:36 UTC
ok since im starting over i'll def give OneNote a shot
used evernote a ton for my old work and just cleared it all out to use for coding
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:37 UTC
@dcnr After reading it a few times (1000) I am starting to undestand it. Basically the \t help you understand what goes with what condition
well I am out for today. Now some gaming and sleep XD
Norman Dela Cruz
@dcnr
Feb 09 2016 03:39 UTC
@Pilotwing lol goodnight! :sleeping:
Franco Zapata
@Francozt01
Feb 09 2016 03:39 UTC
@Pilotwing de donde eres?
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:40 UTC
@Francozt01 Puerto Rico
Matt Gilbert
@Alquh
Feb 09 2016 03:40 UTC
how do i post code here and make it look nice? i forget the command
Franco Zapata
@Francozt01
Feb 09 2016 03:40 UTC
@Pilotwing que bien :+1: yo soy de Venezuela :D
bitgrower
@bitgrower
Feb 09 2016 03:41 UTC
explain format
CamperBot
@camperbot
Feb 09 2016 03:41 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Franco Zapata
@Francozt01
Feb 09 2016 03:41 UTC
JS code
Matt Gilbert
@Alquh
Feb 09 2016 03:42 UTC

'''
function queue(arr, item) {
item.push();
arr.shift();

return item; // Change this line
}

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

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

CamperBot
@camperbot
Feb 09 2016 03:42 UTC
:bulb: to format code use backticks! ``` more info
Franco Zapata
@Francozt01
Feb 09 2016 03:42 UTC
js code
Norman Dela Cruz
@dcnr
Feb 09 2016 03:43 UTC
@Alquh backticks ``` the key usually above tab, below esc, and left of 1
Iván Muñiz Rivera
@Pilotwing
Feb 09 2016 03:43 UTC
@Francozt01 nice si me vez por ahi no dudes en preguntar cualquier duda de lo basico XD buenas noches
Norman Dela Cruz
@dcnr
Feb 09 2016 03:43 UTC
@Alquh
```js
<code here>
```
Franco Zapata
@Francozt01
Feb 09 2016 03:44 UTC
@Pilotwing estoy pasando ingresando a JS intermediate xd buenas noches
Dan
@dee-one
Feb 09 2016 03:45 UTC
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++ ) {
    product = product * arr[i];
  }


  // Only change code above this line
  return product;
Matt Gilbert
@Alquh
Feb 09 2016 03:46 UTC

```jsfunction queue(arr, item) {
item.push();
arr.shift();

return item; // Change this line
}

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

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

ugh. wow forget it
Norman Dela Cruz
@dcnr
Feb 09 2016 03:46 UTC
@Alquh almost! The backticks should be their own line
@Alquh SHIFT+ENTER to newline
anyway you need to push item into arr
Dan
@dee-one
Feb 09 2016 03:47 UTC
@Alquh @Alquh
function queue(arr, item) {
  item.push();
  arr.shift();

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Matt Gilbert
@Alquh
Feb 09 2016 03:47 UTC
Thanks. I have push(); but it is saying item.push is not a function
Norman Dela Cruz
@dcnr
Feb 09 2016 03:48 UTC
@Alquh you use push on an a array and item is a number
@Alquh
var myArr = [1, 2];
myArr.push(100);
console.log(myArr); // [1, 2, 100]
Matt Gilbert
@Alquh
Feb 09 2016 03:52 UTC
thanks @dcnr i'll mess around with it
CamperBot
@camperbot
Feb 09 2016 03:52 UTC
alquh sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 550 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 09 2016 03:53 UTC
@Alquh you got this!
vin4oo
@vin4oo
Feb 09 2016 03:54 UTC

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

Dan
@dee-one
Feb 09 2016 03:54 UTC
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++ ) {
    product = product * arr[i];
  }


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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
greg
@wearenotgroot
Feb 09 2016 03:55 UTC
@dee-one arr is a multi-dimensional array<-----------------need 2 for loops nested
Rex Schrader
@SaintPeter
Feb 09 2016 03:57 UTC
@vin4oo Do you have a question?
Dan
@dee-one
Feb 09 2016 04:03 UTC
@wearenotgroot
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 1; i < arr.length; i++ ) {
    for (var j=0; j< arr[i].length;j++);

      }

  // Only change code above this line
  return product;
greg
@wearenotgroot
Feb 09 2016 04:03 UTC
@dee-one :+1:
Dan
@dee-one
Feb 09 2016 04:03 UTC
@wearenotgroot my answer isn't correct though
greg
@wearenotgroot
Feb 09 2016 04:03 UTC
@dee-one remember arr[i][j]<-----------to get the value of the inner array element
Rex Schrader
@SaintPeter
Feb 09 2016 04:04 UTC
@dee-one Your loops are correct, but you need to do something with product and the elements of the array.
Dan
@dee-one
Feb 09 2016 04:06 UTC
@SaintPeter product=[i]*[j]
?
greg
@wearenotgroot
Feb 09 2016 04:06 UTC
@dee-one look at my comment!^
Franco Zapata
@Francozt01
Feb 09 2016 04:06 UTC
@dee-one the same u did before asking but with 2 for loops
bitgrower
@bitgrower
Feb 09 2016 04:06 UTC
arr[i][j] <-- what does this point to ?
greg
@wearenotgroot
Feb 09 2016 04:08 UTC
@dee-one you know this :+1:
Rex Schrader
@SaintPeter
Feb 09 2016 04:08 UTC
@dee-one There are two thing you need to think about: How are you going to multiply product by something and update the value of product - there is an operator that does that for you. The second thing is what is it that you're multiplying by? You need to access the array arr using bracket notation to view the ith jth value
Dan
@dee-one
Feb 09 2016 04:09 UTC
@SaintPeter brain is spiining
Rex Schrader
@SaintPeter
Feb 09 2016 04:09 UTC
@dee-one If you look above, @wearenotgroot actually told you how to access arr :D
greg
@wearenotgroot
Feb 09 2016 04:10 UTC
@dee-one you almost had it with your original code, just need to add a secondary for loop to access the inner array
Rex Schrader
@SaintPeter
Feb 09 2016 04:10 UTC
@dee-one Then you need to look up the times equals operator
greg
@wearenotgroot
Feb 09 2016 04:12 UTC
@dee-one
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++ ) {
                        //<-------------------------add secondary for loop to loop through the inner
    product = product * arr[i]; //<------------------almost had it, now to access the inner array just add [j]
  }


  // Only change code above this line
  return product;
}
Franco Zapata
@Francozt01
Feb 09 2016 04:13 UTC
@wearenotgroot lol best way to explain
Ivan Perez
@joannesalfa
Feb 09 2016 04:13 UTC
Hi all, anyone can help me about Where art thou challenge?
greg
@wearenotgroot
Feb 09 2016 04:14 UTC
@Francozt01 some people needs visuals :smile:
@joannesalfa still stuck huh?
@joannesalfa did you read through what we link you?
Franco Zapata
@Francozt01
Feb 09 2016 04:14 UTC
@wearenotgroot sometimes we all need it :D
Ivan Perez
@joannesalfa
Feb 09 2016 04:14 UTC
@wearenotgroot Yes, there a difference between string and object, prop with strings that didn't solve
function where(collection, source) {
  var arr = [];
  var key = Object.keys(source);

  function whereIs(prop){
    if(prop[key] === source[key]){
      return prop[key];
    }
    return false;
  }

  return collection.filter(whereIs); 


}

where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
greg
@wearenotgroot
Feb 09 2016 04:16 UTC
@joannesalfa you can make a for loop inside the whereIS function
Nate Petersen
@blueExcess
Feb 09 2016 04:16 UTC
Does anyone know what the difference is between String.prototype.split() and String.prototype.substr()?
Ivan Perez
@joannesalfa
Feb 09 2016 04:17 UTC
@wearenotgroot what does make difference with loop?
greg
@wearenotgroot
Feb 09 2016 04:17 UTC
@joannesalfa
function where(collection, source) {
  var arr = [];
  var key = Object.keys(source);

  function whereIs(prop){
    if(prop[key] === source[key]){ //<----------------make a for loop to loop through the key array then compare prop and the element in key
      return prop[key];
    }
    return false;
  }

  return collection.filter(whereIs); 


}
Gordon Davidescu
@gordondavidescu
Feb 09 2016 04:17 UTC
no idea why but for some reason string.split isn't working on friendly date ranges
Rex Schrader
@SaintPeter
Feb 09 2016 04:18 UTC
@joannesalfa Source may have more than one key . . . and ALL of the keys must exist and match for an object to be kept. Right now you return the new object a soon as a key is found. I think you need to return true
Gordon Davidescu
@gordondavidescu
Feb 09 2016 04:18 UTC
at all
greg
@wearenotgroot
Feb 09 2016 04:18 UTC
@joannesalfa if you dont want for loop, i link you this earlier-------->https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
Ivan Perez
@joannesalfa
Feb 09 2016 04:18 UTC
@SaintPeter ok, let me try
@wearenotgroot I dont think I have received your link earlier, let me see
greg
@wearenotgroot
Feb 09 2016 04:20 UTC
@joannesalfa you missed it i guess
Ivan Perez
@joannesalfa
Feb 09 2016 04:24 UTC
@SaintPeter @wearenotgroot :worried: returned []
Rex Schrader
@SaintPeter
Feb 09 2016 04:25 UTC
@joannesalfa Share your updated code?
Ivan Perez
@joannesalfa
Feb 09 2016 04:25 UTC
function where(collection, source) {
  var arr = [];
  var key = Object.keys(source);

  function whereIs(prop){
    for(var i = 0; i < collection.length; i++){

      if(collection[i]==source[i]){
        return true;
      }
      return false;
    }

  }

  return collection.filter(whereIs); 

}
greg
@wearenotgroot
Feb 09 2016 04:25 UTC
@joannesalfa use prop
@joannesalfa prop is the element in the collection
Ivan Perez
@joannesalfa
Feb 09 2016 04:26 UTC
@wearenotgroot pls
greg
@wearenotgroot
Feb 09 2016 04:26 UTC
@joannesalfa ok so to not get confuse
@joannesalfa rename prop as element instead
Ivan Perez
@joannesalfa
Feb 09 2016 04:27 UTC
@wearenotgroot same result
greg
@wearenotgroot
Feb 09 2016 04:27 UTC
@joannesalfa
function whereIs(element){
    for(var i = 0; i < collection.length; i++){

      if(collection[i]==source[i]){
        return true;
      }
      return false;
    }

  }
Gordon Davidescu
@gordondavidescu
Feb 09 2016 04:27 UTC
it says TypeError: str.split is not a function
greg
@wearenotgroot
Feb 09 2016 04:27 UTC
@joannesalfa well not done yet
Gordon Davidescu
@gordondavidescu
Feb 09 2016 04:27 UTC
but it totally is
greg
@wearenotgroot
Feb 09 2016 04:27 UTC
@joannesalfa you have to check if the key[i] is a property in element
@joannesalfa use .hasOwnProperty(key[i]); like so
Ivan Perez
@joannesalfa
Feb 09 2016 04:28 UTC
Ok, gotcha
Rex Schrader
@SaintPeter
Feb 09 2016 04:28 UTC
@gordondavidescu Got code?
greg
@wearenotgroot
Feb 09 2016 04:28 UTC
@joannesalfa then you also have to compare values
Gordon Davidescu
@gordondavidescu
Feb 09 2016 04:28 UTC
function friendly(str) {
  var tempDate = str.split('-');

  return tempDate;
}
it almost looks like a face, lol
Rex Schrader
@SaintPeter
Feb 09 2016 04:29 UTC
@gordondavidescu I thought that the input was an array with two dates?
greg
@wearenotgroot
Feb 09 2016 04:29 UTC
@joannesalfa if both are true then return true if not return false
Gordon Davidescu
@gordondavidescu
Feb 09 2016 04:29 UTC
I just started on this
I mean I just re-started on this
I'm positive I started out this way last time
Rex Schrader
@SaintPeter
Feb 09 2016 04:30 UTC
@gordondavidescu Yeah, the input may be labeled str, but it's actually an array with two strings in it.
Ivan Perez
@joannesalfa
Feb 09 2016 04:30 UTC

@wearenotgroot

function where(collection, source) {
  var arr = [];
  var key = Object.keys(source);

  function whereIs(prop){
    for(var i = 0; i < prop.length; i++){

      if(prop[i].hasOwnProperty(key[i]) === true){
        return true;
      }
      return false;
    }

  }

  return collection.filter(whereIs); 

}

is that?

greg
@wearenotgroot
Feb 09 2016 04:31 UTC
@joannesalfa yep, also no need for === true
@joannesalfa as .hasOwnProperty returns boolean values
Rex Schrader
@SaintPeter
Feb 09 2016 04:31 UTC
@gordondavidescu Look at the example:
friendly(['2016-07-01', '2016-07-04']);
greg
@wearenotgroot
Feb 09 2016 04:31 UTC
@joannesalfa now you have to compare the values you get by using the key[i] as keys in the element and in the source(aka look up values)
Ivan Perez
@joannesalfa
Feb 09 2016 04:32 UTC
@wearenotgroot more details since I'm really confused about "where art thou" where they give me chaos between strings and objects
greg
@wearenotgroot
Feb 09 2016 04:34 UTC
@joannesalfa what they are asking in this challenge is to check if the property exist and if the values you get from using the property as a key in both collection and source are the same
Gordon Davidescu
@gordondavidescu
Feb 09 2016 04:34 UTC
true @SaintPeter thanks
CamperBot
@camperbot
Feb 09 2016 04:34 UTC
gordondavidescu sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2460 | @saintpeter | http://www.freecodecamp.com/saintpeter
Dan
@dee-one
Feb 09 2016 04:35 UTC
@wearenotgroot product = arr[i][j]
greg
@wearenotgroot
Feb 09 2016 04:35 UTC
@dee-one you have to multiply it and accumulate the result
@dee-one just like this---------->product = product * arr[i] only missing is [j]
Dan
@dee-one
Feb 09 2016 04:37 UTC
product = product * arr[i][j]
greg
@wearenotgroot
Feb 09 2016 04:37 UTC
@dee-on yep!
Dan
@dee-one
Feb 09 2016 04:37 UTC
yeah but that isn't correct
greg
@wearenotgroot
Feb 09 2016 04:37 UTC
@dee-one you sure
Dan
@dee-one
Feb 09 2016 04:37 UTC
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++ ) {
    for (var j=0; j< arr[i].length;j++);
     product = product * arr[i][j];
      }

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Ivan Perez
@joannesalfa
Feb 09 2016 04:38 UTC
@wearenotgroot it's not helping me after all, I have to reset and stratch from zero again, yhanks
greg
@wearenotgroot
Feb 09 2016 04:38 UTC
@dee-one try and refresh
Dan
@dee-one
Feb 09 2016 04:38 UTC
did tht
that
keeps saying "null"
narkeeta
@narkeeta
Feb 09 2016 04:38 UTC

function every(collection, pre) {
if (typeof pre === 'string') {
for (var i = 0; i < collection.length; i++) {
if (!collection[i].hasOwnProperty(pre)) {
return false;
}
if (collection[i] !== true) {
return false;
}
}
}
return true;
}

every([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");

greg
@wearenotgroot
Feb 09 2016 04:38 UTC
@dee-one close the for loop
@dee-one missing{ and }
narkeeta
@narkeeta
Feb 09 2016 04:39 UTC
can anyone help me and tell me what is wrong with my code for the Everything true bonfire
CamperBot
@camperbot
Feb 09 2016 04:39 UTC
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
greg
@wearenotgroot
Feb 09 2016 04:40 UTC
@dee-one
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++ ) {
    for (var j=0; j< arr[i].length;j++){
     product = product * arr[i][j];
      }
   }

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Rex Schrader
@SaintPeter
Feb 09 2016 04:41 UTC
@narkeeta Share what you've got?
greg
@wearenotgroot
Feb 09 2016 04:41 UTC
@joannesalfa you dont have to
@joannesalfa you were almost on the home stretch
Dan
@dee-one
Feb 09 2016 04:41 UTC
@wearenotgroot yeah i got it thanks
CamperBot
@camperbot
Feb 09 2016 04:41 UTC
dee-one sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
narkeeta
@narkeeta
Feb 09 2016 04:41 UTC
@SaintPeter how do i copy in nice code?
CamperBot
@camperbot
Feb 09 2016 04:41 UTC
:star: 696 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 09 2016 04:41 UTC
@dee-one np
Rex Schrader
@SaintPeter
Feb 09 2016 04:41 UTC
wiki format
CamperBot
@camperbot
Feb 09 2016 04:41 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Dan
@dee-one
Feb 09 2016 04:41 UTC
i get what the first loop means, but the second loop means what exactly?
Ivan Perez
@joannesalfa
Feb 09 2016 04:41 UTC
@wearenotgroot it's useless
Dan
@dee-one
Feb 09 2016 04:42 UTC
is the first loop creating the overall array, and the second loop creates the values for each slot?
greg
@wearenotgroot
Feb 09 2016 04:42 UTC
@joannesalfa well if you dont want for loop read about the .every method i linked you
Rex Schrader
@SaintPeter
Feb 09 2016 04:42 UTC
@narkeeta Three backticks, shift-enter, code, shift-enter, three more backticks
greg
@wearenotgroot
Feb 09 2016 04:43 UTC
@dee-one arr[i]<----------------------gives you [1,2]<---------------------------arr[i][j]<----------------gives you 1 and 2 as it iterates
Ivan Perez
@joannesalfa
Feb 09 2016 04:43 UTC
@wearenotgroot im still reading this doc, I have never used this before
greg
@wearenotgroot
Feb 09 2016 04:43 UTC
@joannesalfa it is just like a filter
Dan
@dee-one
Feb 09 2016 04:44 UTC
@wearenotgroot whats the differeance between "giving it you" and " giving it to you as it itterates" ?
narkeeta
@narkeeta
Feb 09 2016 04:44 UTC
function every(collection, pre) {
  if (typeof pre === 'string') {
    for (var i = 0; i < collection.length; i++) {
      if (!collection[i].hasOwnProperty(pre)) {
        return false;
      }
      if (collection[i] !== true) {
        return false;
      }
    }
  }
  return true;
}
greg
@wearenotgroot
Feb 09 2016 04:44 UTC
@dee-one the first one gives you an array the second one give you the value
narkeeta
@narkeeta
Feb 09 2016 04:45 UTC
anyone know how to make this code return cases where the collection has the property and has a string as the property return true
Dan
@dee-one
Feb 09 2016 04:45 UTC
@wearenotgroot so the first one gives you a calendar, and the second loop fills in the dates?
greg
@wearenotgroot
Feb 09 2016 04:46 UTC
@dee-one yep if you put it that way
[[1,2],[3,4],[5,6,7]]<------------------------first loop step 1 will give you --------i = 0-------element-------->[1,2]------second loop-----------j = 0 ----------> 1
Rex Schrader
@SaintPeter
Feb 09 2016 04:47 UTC
@narkeeta You need to check if both the property exists and that it evaluates truthy. You're just checking to see if it exists.
narkeeta
@narkeeta
Feb 09 2016 04:48 UTC
@SaintPeter I thought I was doing that with the final if statement...how would I make that if statement?
This message was deleted
Josiah Anderson
@Josiahdanderson
Feb 09 2016 04:50 UTC
Hi all, I'm stuck on the "Using Objects for Lookups" waypoint. Here is my code thus far:
// 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");
narkeeta
@narkeeta
Feb 09 2016 04:50 UTC
function every(collection, pre) {
  if (typeof pre === 'string') {
    for (var i = 0; i < collection.length; i++) {
      if (!collection[i].hasOwnProperty(pre)) {
        return false;
      }
      if (collection[i][pre] !== true) {
        return false;
      }
    }
  }
  return true;
}
There is a revised code but I still get a few cases failed when I run it
Rex Schrader
@SaintPeter
Feb 09 2016 04:51 UTC
@narkeeta Well, you need to figure out if the element is truthy or not. You can add || !collection[i][pre] to your if statement
Rather
Just remove the !== true
gvik02
@gvik02
Feb 09 2016 04:51 UTC
hello ! need help with "Profile Lookup"
Rex Schrader
@SaintPeter
Feb 09 2016 04:52 UTC
And just test the element: if(!collection[i][pre])
narkeeta
@narkeeta
Feb 09 2016 04:52 UTC
@SaintPeter Thanks!
CamperBot
@camperbot
Feb 09 2016 04:52 UTC
narkeeta sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2462 | @saintpeter | http://www.freecodecamp.com/saintpeter
gvik02
@gvik02
Feb 09 2016 04:53 UTC
Is anybody there?
Josiah Anderson
@Josiahdanderson
Feb 09 2016 04:53 UTC
I don't know where to go from there.
Rex Schrader
@SaintPeter
Feb 09 2016 04:54 UTC
@gvik02 Nobody here but us chickens
Brock
@brockwei
Feb 09 2016 04:54 UTC
@gvik02 what do u need help with
Norman Dela Cruz
@dcnr
Feb 09 2016 04:54 UTC

@joannesalfa Hi I've been typing this so I don't know the current developments but maybe you can get something out of it:

  1. collection is an array of objects
  2. source is an object containing the properties we need to find in the objects in collection
  3. We must return only the objects that has all the properties of source

One approach is to filter collection using Array.filter() and we are to keep the items that has all of source's properties.

That would mean that in our .filter() function:

  1. We need to get all the properties (aka keys) of source
  2. We need to test our collection's object against all of sources properties to make sure that the object has the property, and that their values match.

Some pseudocode:

filtered = collection.filter(function(object_being_tested) {
  for each property in source
    check object_being_tested if has property
      if false return false
      if true check if same value
        if false return false
  end for

  return true // object_being_tested has all property and equivalent values
});

return filtered;
gvik02
@gvik02
Feb 09 2016 04:54 UTC
I need help with " profile Lookup"
contacts[i].firstName === firstName

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

function lookUp(firstName, prop){
// Only change code below this line
var finalResult=[];
for (var i = 0;i< contacts.length;i++){
if(contacts[i].firstName === firstName && contacts[i].prop===undefined){
finalResult= "No such property";
break;
}
else if (contacts[i].firstName === firstName){
console.log('control is in if statement');
finalResult=contacts[i][prop];
break;
}
else if(contacts[i].firstName!=firstName){
finalResult= "No such contact";
}
}
console.log("finalResult",finalResult);
return finalResult;
// Only change code above this line
}

// Change these values to test your function

lookUp("Akira", "address");

Rex Schrader
@SaintPeter
Feb 09 2016 04:54 UTC
@Josiahdanderson You need to use bracket notation with lookup and val and assign the result to result
gvik02
@gvik02
Feb 09 2016 04:54 UTC
this is what I tried
can you help me with this @brockwei
Rex Schrader
@SaintPeter
Feb 09 2016 04:55 UTC
@gvik02 In order to see if a property exists in an object, you have to use hasOwnProperty. Also, you can't use dot notation with a variable, because there is no property named .prop
Brock
@brockwei
Feb 09 2016 04:56 UTC
you need to use .hasOwnProperty(prop) which returns true/false
Neil Ganotisi
@neilUnreal
Feb 09 2016 04:57 UTC
I could use some help with "Stand In Line"

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

var old = testArr.shift();
testArr.push(item);
console.log(old);
return old; // Change this line
}

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

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

gvik02
@gvik02
Feb 09 2016 04:57 UTC
thanks @brockwei @SaintPeter
CamperBot
@camperbot
Feb 09 2016 04:57 UTC
gvik02 sends brownie points to @brockwei and @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2464 | @saintpeter | http://www.freecodecamp.com/saintpeter
:star: 267 | @brockwei | http://www.freecodecamp.com/brockwei
gvik02
@gvik02
Feb 09 2016 04:57 UTC
whats your issue @neilUnreal
ehekatlOf
@ehekatlOf
Feb 09 2016 04:57 UTC
hey can someone read my arguments optional?
everything returns properly for me
but I can't get completion
Neil Ganotisi
@neilUnreal
Feb 09 2016 04:59 UTC
@gvik02 http://i.imgur.com/OTS0xdR.png For some reason the code fails at the third test case, although it appears to be passing correctly when ran through the console?
gvik02
@gvik02
Feb 09 2016 04:59 UTC
ok try to refresh it and do it again @neilUnreal
DJ
@qualitymanifest
Feb 09 2016 05:00 UTC
@neilUnreal don't use testArr that's not your function parameter. use arr
Josiah Anderson
@Josiahdanderson
Feb 09 2016 05:00 UTC
thanks @SaintPeter I figured it out. I just don't really understand what i did.
CamperBot
@camperbot
Feb 09 2016 05:00 UTC
josiahdanderson sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2465 | @saintpeter | http://www.freecodecamp.com/saintpeter
greg
@wearenotgroot
Feb 09 2016 05:01 UTC
@neilUnreal use the parameters that was given ---------> arr
DJ
@qualitymanifest
Feb 09 2016 05:01 UTC
@neilUnreal but yes, your results are correct. the tests are just looking for you to do it in a specific way
Rex Schrader
@SaintPeter
Feb 09 2016 05:01 UTC
@Josiahdanderson Don't worry, you'll get more practice in later exercises :D
Josiah Anderson
@Josiahdanderson
Feb 09 2016 05:02 UTC
@SaintPeter alright great!
ehekatlOf
@ehekatlOf
Feb 09 2016 05:02 UTC
@neilUnreal can't you just do unshift item then shift arr?
can I get someone to look at the arguments optional bonfire though?
everything in my code is correct and returns properly
DJ
@qualitymanifest
Feb 09 2016 05:05 UTC
@ehekatlOf post your code
ehekatlOf
@ehekatlOf
Feb 09 2016 05:05 UTC
but it's making red x's on the last 3
thanks!
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:05 UTC
@gvik02 @qualitymanifest @wearenotgroot @qualitymanifest Whoops. What happens when I over analyze it. Thanks!
CamperBot
@camperbot
Feb 09 2016 05:05 UTC
neilunreal sends brownie points to @gvik02 and @qualitymanifest and @wearenotgroot and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 932 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 932 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 698 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
:star: 226 | @gvik02 | http://www.freecodecamp.com/gvik02
ehekatlOf
@ehekatlOf
Feb 09 2016 05:05 UTC
function add() {

    function testMe (tested) {
        if (typeof tested == 'number') {
            return tested;
        }

        else {
            return 'undefined';
        }
    }

    if (arguments.length > 1) {

        var a = testMe(arguments[0]);
        var b = testMe(arguments[1]);

        if (a == 'undefined') {
            return 'undefined';
        }

        else if (b == 'undefined') {
            return 'undefined';
        }

        else {
            return a + b;
        }
    }

    else {

        var c = testMe(arguments[0]);

        if (c == 'undefined') {
            return 'undefined';
        }

        else {
            return function(argument2) {

                if (c == 'undefined') {
                    return 'undefined';
                }

                else if (testMe(argument2) == 'undefined') {
                    return 'undefined';
                }

                else {
                    return c + testMe(argument2);
                }
            };
        }
    }

}

add("http://bit.ly/IqT6zt");
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:06 UTC
@ehekatlOf As far as I know, shift removes the first item in the array, and push adds to the end of an array
greg
@wearenotgroot
Feb 09 2016 05:06 UTC
@ehekatlOf woah
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:06 UTC
Unshift would be adding to the start of the array, which is not what is asking.
ehekatlOf
@ehekatlOf
Feb 09 2016 05:06 UTC
oh right, push adds to the end
my apologies
DJ
@qualitymanifest
Feb 09 2016 05:07 UTC
@ehekatlOf undefined should be returned without quotation marks
ehekatlOf
@ehekatlOf
Feb 09 2016 05:07 UTC
oooh, let me try that
Rex Schrader
@SaintPeter
Feb 09 2016 05:07 UTC
@ehekatlOf undefined is a keyword, not a string
ehekatlOf
@ehekatlOf
Feb 09 2016 05:07 UTC
thanks @qualitymanifest
CamperBot
@camperbot
Feb 09 2016 05:07 UTC
ehekatlof sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 933 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Feb 09 2016 05:07 UTC
@ehekatlOf it's not a string, it's a primitive value. you only use it in quotation marks when using typeof
ehekatlOf
@ehekatlOf
Feb 09 2016 05:07 UTC
@SaintPeter thanks
CamperBot
@camperbot
Feb 09 2016 05:07 UTC
ehekatlof sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2466 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Feb 09 2016 05:07 UTC
Hah, Jinx @qualitymanifest
ehekatlOf
@ehekatlOf
Feb 09 2016 05:07 UTC
yeah, what do you call those types of primitives by the way
undefined, null, ''
DJ
@qualitymanifest
Feb 09 2016 05:07 UTC
@SaintPeter haha
ehekatlOf
@ehekatlOf
Feb 09 2016 05:08 UTC
false, and zero are in there too right
DJ
@qualitymanifest
Feb 09 2016 05:08 UTC
@ehekatlOf falsy values
ehekatlOf
@ehekatlOf
Feb 09 2016 05:08 UTC
haha :D
ok, I can stop sounding dumb when I need a definition for those now
thanks dude!
DJ
@qualitymanifest
Feb 09 2016 05:08 UTC
np :+1:
greg
@wearenotgroot
Feb 09 2016 05:10 UTC
@ehekatlOf also use strict ===
ehekatlOf
@ehekatlOf
Feb 09 2016 05:10 UTC
oh right, in case of 0 returns
greg
@wearenotgroot
Feb 09 2016 05:12 UTC
@ehekatlOf also you can make this shorter by using ||
ehekatlOf
@ehekatlOf
Feb 09 2016 05:12 UTC
yeah
all the else if can be condensed with ||
good suggestion
thanks @wearenotgroot
CamperBot
@camperbot
Feb 09 2016 05:12 UTC
ehekatlof sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 699 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Feb 09 2016 05:13 UTC
@ehekatlOf well as long as the code work, you can always refractor and clean up later
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:17 UTC
Alright all of my checks passed, but is there a cleaner way about doing this? http://i.imgur.com/lmpQRxJ.png
greg
@wearenotgroot
Feb 09 2016 05:17 UTC
@neilUnreal can be done in two lines
Norman Dela Cruz
@dcnr
Feb 09 2016 05:18 UTC
@neilUnreal you don't have to do the checks :P
greg
@wearenotgroot
Feb 09 2016 05:18 UTC
@dcnr just being thourough :+1:
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:18 UTC
I'm all ears, I was stumped because of the queue([], 1) test case
Figured a conditional check would do it, but I'm missing something
greg
@wearenotgroot
Feb 09 2016 05:19 UTC
@neilUnreal
arr.push(item);
return arr.shift();
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:19 UTC
Of course.
Norman Dela Cruz
@dcnr
Feb 09 2016 05:19 UTC
or return (arr.push(item), arr.shift());
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:20 UTC
Welp. Thanks @wearenotgroot @dcnr!
CamperBot
@camperbot
Feb 09 2016 05:20 UTC
neilunreal sends brownie points to @wearenotgroot and @dcnr :sparkles: :thumbsup: :sparkles:
:warning: neilunreal already gave wearenotgroot points
:star: 551 | @dcnr | http://www.freecodecamp.com/dcnr
greg
@wearenotgroot
Feb 09 2016 05:20 UTC
@neilUnreal :smile:
Neil Ganotisi
@neilUnreal
Feb 09 2016 05:21 UTC
Also TIL, I never knew we could do return like that, thought it always had to be a variable.
or boolean, etc.
greg
@wearenotgroot
Feb 09 2016 05:22 UTC
you can also do return; the function just return undefined
Norman Dela Cruz
@dcnr
Feb 09 2016 05:23 UTC

@neilUnreal each function/expression returns something and you don't have to assign it. In this case, return just takes it as is. return arr.shift() takes the returned value of shift().

Or if you don't do any returns, it's immediately undefined

greg
@wearenotgroot
Feb 09 2016 05:24 UTC
alright, G2G
GL and Happy Coding EVeryone! :smile:
Norman Dela Cruz
@dcnr
Feb 09 2016 05:25 UTC
@wearenotgroot good day/night! :D
greg
@wearenotgroot
Feb 09 2016 05:25 UTC
@dcnr O/
Irina Sokolovskaja
@ierhyna
Feb 09 2016 05:25 UTC
help where art thou
CamperBot
@camperbot
Feb 09 2016 05:25 UTC

:point_right: bonfire where art thou [wiki]

Problem Explanation

Write an algorithm that will take an array for the first argument and return an array with all the objects that matches all the properties and values in the Object passed as second parameter.

:pencil: read more about bonfire where art thou on the FCC Wiki

vantrav This message was deleted
YeahICodeSorta
@YeahICodeSorta
Feb 09 2016 05:35 UTC
help chunky monkey
CamperBot
@camperbot
Feb 09 2016 05:35 UTC

:point_right: bonfire chunky monkey [wiki]

Explanation

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

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

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

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

YeahICodeSorta
@YeahICodeSorta
Feb 09 2016 05:38 UTC
Hey guys, I'm working through the chunky monkey challenge, and I feel like my code is so close to working. Someone pls take a look if u can!
Lallo Vigil
@lalov1
Feb 09 2016 05:39 UTC

```function lookUp(firstName, prop){

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

YeahICodeSorta
@YeahICodeSorta
Feb 09 2016 05:39 UTC
function chunk(arr, size) {
  // Break it up.
 var amnt = arr.length / size; 
 var pieces = [];
  var test = [1,2,3];

  for (var i = 0; i < amnt - 1; i++) {

   if (i === 0) {
      pieces[0] = arr.slice(0, size);
     }

   else if (i > 1)  {  
      pieces[i] = arr.slice(size, (size * i + size));
     }

  }
  // pieces[0] returns as desired, but pieces[1] = nothing
  return pieces;
}

chunk([0, 1, 2, 3, 4, 5], 3); // [[0,1,2], [3,4,5]]
Lallo Vigil
@lalov1
Feb 09 2016 05:44 UTC
Trying to get the Profile Lookup working, but it isn't going over each item in the object.
function lookUp(firstName, prop){


// Only change code below this line
  for (i = 0; i < contacts.length; i++){
    console.log(i);
    console.log(contacts[i].firstName);
    console.log(contacts[i][prop]);  
    if (firstName === contacts[i].firstName && contacts[i][prop]===prop){
      return contacts[i][prop];
    }else if (firstName !== contacts[i].firstName){
      return "No such contact";
    }
    else {
      return "No such property";
    }
  }
// Only change code above this line
}
arjunpunnam
@arjunpunnam
Feb 09 2016 05:52 UTC
Change the provided string from double to single quotes and remove the escaping.
i accidentally deleted the string and now im left with blank screen
help please
CamperBot
@camperbot
Feb 09 2016 05:53 UTC

: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

Norman Dela Cruz
@dcnr
Feb 09 2016 05:57 UTC
@arjunpunnam have you tried the reset button?

@lalov1 hi you're getting the no contact because if your firstName isn't the first object, it would immediately go into the else if part

else if (firstName !== contacts[i].firstName)

and ends your loop and function

@lalov1 for example, "Kristian" is in the last object, but it will check "Akira" first, and since the firstNames don't match, it goes to the else if and ends
@lalov1 you will have to make it so that the loop goes through all the object first before declaring that there is no contact like that
arjunpunnam
@arjunpunnam
Feb 09 2016 06:11 UTC
@dcnr tried now.worked.Thanks.
CamperBot
@camperbot
Feb 09 2016 06:11 UTC
arjunpunnam sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 552 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 09 2016 06:14 UTC
@arjunpunnam nice :D
JackeL
@jackel27
Feb 09 2016 06:33 UTC
helllo
Jason
@carpediem1213
Feb 09 2016 06:34 UTC
Hello all - for exercise #210, Accessing Nested Arrays, is there another way to complete the problem besides "var secondTree = myPlants[1].list[1];"? This gives me the thumbs up, but I figured there'd be a myPlants.trees.list way that also works somehow.
Markus Kiili
@Masd925
Feb 09 2016 06:38 UTC
@carpediem1213 myPlants is an array, so it must start with myPlants[i]. There is no other way.
Matt
@mattbag
Feb 09 2016 06:41 UTC
hey good people, I need help with the nesting for loops chapter :) I can't figure where to elaborate the product var
Jason
@carpediem1213
Feb 09 2016 06:41 UTC
@Masd925 The reason I ask is because the example shows: ourPets.cats[1]; // "Fluffy". And the previous exercise shows ourStorage.cabinet["top drawer"].folder2; I feel like I'm cheating when I do MyPlants[1].list[1]
Matt
@mattbag
Feb 09 2016 06:41 UTC
Those where different structured arrays I think
earlcuritana
@earlcuritana
Feb 09 2016 06:43 UTC
need help on wordblanks
Matt
@mattbag
Feb 09 2016 06:45 UTC
@camperbot nesting for loops
Markus Kiili
@Masd925
Feb 09 2016 06:45 UTC
@carpediem1213 You are doing it just right.
Jason
@carpediem1213
Feb 09 2016 06:46 UTC
@Masd925 Thanks, Masd. I have been having issues with Record Collection so I thought maybe I did the previous problem wrong.
CamperBot
@camperbot
Feb 09 2016 06:46 UTC
carpediem1213 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 952 | @masd925 | http://www.freecodecamp.com/masd925
Matt
@mattbag
Feb 09 2016 06:47 UTC
help nesting for loops
CamperBot
@camperbot
Feb 09 2016 06:47 UTC

find nesting for loops

:zero: waypoint nesting for loops

Matt
@mattbag
Feb 09 2016 06:47 UTC
help nesting for loops
CamperBot
@camperbot
Feb 09 2016 06:47 UTC

:point_right: waypoint nesting for loops [wiki]

Waypoint: Nesting For Loops

If you have a multi-dimensional array, you can use the same logic as the prior waypoint to loop through both the array and any sub-arrays. Here is an example:

    var arr = [
      [1,2], [3,4], [5,6]
    ];
    for (var i=0; i < arr.length; i++) {
      for (var j=0; j < arr[i].length; j++) {
        console.log(arr[i][j]);
      }
    }

This outputs each sub-element in arr one at a time. Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array.
:pencil: read more about waypoint nesting for loops on the FCC Wiki

Matt
@mattbag
Feb 09 2016 06:48 UTC
guess I'm stuck
Norman Dela Cruz
@dcnr
Feb 09 2016 06:50 UTC
@mattbag hi, what about it you don't quite get?
Matt
@mattbag
Feb 09 2016 06:50 UTC
nesting for loops chapter, I think I'm not getting the instructions right
Norman Dela Cruz
@dcnr
Feb 09 2016 06:52 UTC
@mattbag ah but you know how nested loops work? and how to access arrays properly?
@mattbag the exercise wants you to get each element inside the array of arrays, and multiply them all together, and then return the product
Matt
@mattbag
Feb 09 2016 06:54 UTC
yes, so the last result would be just a number, right?
Norman Dela Cruz
@dcnr
Feb 09 2016 06:55 UTC
@mattbag yes, the total product of all the numbers
Matt
@mattbag
Feb 09 2016 06:55 UTC
i am accessing as the example says, but I think I'm making a mistake in the console.log line
console.log(product[i][j]); that's it
Norman Dela Cruz
@dcnr
Feb 09 2016 06:57 UTC
@mattbag oh the array name is arr, so to get the values you need to do arr[i][j]
Matt
@mattbag
Feb 09 2016 06:58 UTC
ok, I thought that was one, now I'm missing something else, to reach the finals result
Is there a command to past here the block of code?
Norman Dela Cruz
@dcnr
Feb 09 2016 06:59 UTC

@mattbag yeah just do
```js

<past code here>
```

Those are 3 backticks, the key is above the Tab, left of 1, and below the Esc, usually. To go to the next line to paste your code you hit SHIFT+ENTER

@mattbag so you type ```js SHIFT+ENTER, then paste your code, SHIFT+ENTER, then ``` then submit
earlcuritana
@earlcuritana
Feb 09 2016 07:00 UTC
anyone know wordblanks in Javascript?
Matt
@mattbag
Feb 09 2016 07:00 UTC
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
    console.log(arr[i]);
}
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Norman Dela Cruz
@dcnr
Feb 09 2016 07:00 UTC
@earlcuritana hi, what about it? the exercise wants you to make a sentence out of the given variables
Matt
@mattbag
Feb 09 2016 07:01 UTC
oh i was trying the second console.log, but that's not solving anything
Norman Dela Cruz
@dcnr
Feb 09 2016 07:01 UTC
@mattbag nice, one try paste :D
Instead of console.log you need to multiply the values
and return product
earlcuritana
@earlcuritana
Feb 09 2016 07:02 UTC
+dcnr my brain is fried and i've been trying to figure it out
Norman Dela Cruz
@dcnr
Feb 09 2016 07:02 UTC
so in your first console.log(arr[i][j]) rather than logging it out, multiply the array values with product
@earlcuritana what you got so far?
earlcuritana
@earlcuritana
Feb 09 2016 07:05 UTC

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"); i don't even know what to put on there do i put variables?

Norman Dela Cruz
@dcnr
Feb 09 2016 07:06 UTC

@earlcuritana
You can build (or concatenate) strings by using the + operator

var myStr = "Hello" + "World";

Here myStr will equal to "HelloWorld" because I didn't put a space.
you can also use variables to create your string

var myName = "Norman";
var adjective="AWESOME";

var myStr = myName + " is " + adjective;

Here note that I "added" (or concatenated) myName to " is " and the variable adjective to produce "Norman is AWESOME"

@earlcuritana this is the principle behind Word Blanks
@earlcuritana the function gives you your "variables" myNoun, myAdjective, etc. And you are to assign them to result to create your own sentence.
Matt
@mattbag
Feb 09 2016 07:10 UTC
ehy I still don't get how to output the product times the array values
Norman Dela Cruz
@dcnr
Feb 09 2016 07:11 UTC
@mattbag you already got the values with arr[i][j] right? so you can do something * arr[i][j] and it will multiply something with the value of arr[i][j]
Matt
@mattbag
Feb 09 2016 07:14 UTC
exactly... should I return that at the same time?
Jason
@carpediem1213
Feb 09 2016 07:16 UTC
@earlcuritana You'd change the words if you wanted, but the wordBlanks function takes string arguments not variables.
Norman Dela Cruz
@dcnr
Feb 09 2016 07:16 UTC
@mattbag not until the loop is finished, there's already a predefined return product in the code too
sarea
@sarea
Feb 09 2016 07:16 UTC
hello ...can i ask
Jason
@carpediem1213
Feb 09 2016 07:16 UTC
Where am I going wrong here on Record Collection? function update(id, prop, value) {
//collection[id].album = "1999";
if ((value !== "") & (prop != "tracks"))
{
value = collection[id].prop; }
else if ((value !== "") & (prop == "tracks")) {
value = collection[id].prop.push(); }
else if (value === "") {
delete collection[id].prop; }
return collection;
}
(also) is there a better way to cut and paste here?
Markus Kiili
@Masd925
Feb 09 2016 07:17 UTC
wiki format
CamperBot
@camperbot
Feb 09 2016 07:17 UTC

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Matt
@mattbag
Feb 09 2016 07:17 UTC
This message was deleted
This message was deleted
Markus Kiili
@Masd925
Feb 09 2016 07:19 UTC
@carpediem1213 Use logical operator &&. Also use strict equality === and !==.
Matt
@mattbag
Feb 09 2016 07:20 UTC
This message was deleted
Markus Kiili
@Masd925
Feb 09 2016 07:20 UTC
@carpediem1213 Assigning to value does nothing useful. You should change the property on the object with the id.
Matt
@mattbag
Feb 09 2016 07:20 UTC
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    product* arr[i][j];
  }

}
  // Only change code above this line
  return product;
}
sarea
@sarea
Feb 09 2016 07:21 UTC
no ? :D
Matt
@mattbag
Feb 09 2016 07:21 UTC
of course you can mate
Jason
@carpediem1213
Feb 09 2016 07:21 UTC
@Masd925 I don't think I'm getting this part of the instruction "if, (true), then update or set the value for the prop"
Markus Kiili
@Masd925
Feb 09 2016 07:23 UTC
@carpediem1213 You have the correct if condition there. if ((value !== "") & (prop !== "tracks")). Just find the object with the id and assign value to correct property (prop).
Jason
@carpediem1213
Feb 09 2016 07:24 UTC
@Masd925 the reason I was assigning to value was because this test line worked in the output - collection[id].album = "1999";
Markus Kiili
@Masd925
Feb 09 2016 07:24 UTC
@carpediem1213 Remember that you cannot use dot notation if the property key is in a variable, like .prop.
@carpediem1213 Don't look too much at the tests. Most of the tests can be green with totally wrong code.
Norman Dela Cruz
@dcnr
Feb 09 2016 07:25 UTC
@mattbag almost! but you have to save the product to somewhere! and since you need to multiply them all, you can use product itself
sarea
@sarea
Feb 09 2016 07:26 UTC

why this code work on text editor (offline) and not work on free code camp

function smallestCommons(arr) {
  var  count = 0 , SmallestCommons = 2 ;
  arr.sort(function(a,b){return a - b ;});
  var arrNumbers = (arr[1]-arr[0])+1;

   do 
  {
     SmallestCommons ++ ;
     for ( var k = arr[0] ; k <= arr[1] ; k ++)
      {
        if ( SmallestCommons % k === 0)
            count++ ;
          else {count = 0 ; break ;}
      }

  }
  while (count !== arrNumbers);
  return SmallestCommons;



}

smallestCommons([1,5]);

it give me syntaxerror unexpected token ;

Matt
@mattbag
Feb 09 2016 07:26 UTC
ok I forgot the *=
Norman Dela Cruz
@dcnr
Feb 09 2016 07:26 UTC
@Masd925 sorry wrong autocomplete
Matt
@mattbag
Feb 09 2016 07:26 UTC
thanks dcnr
Norman Dela Cruz
@dcnr
Feb 09 2016 07:27 UTC
@mattbag no probs, you already got it in the first place! :D
Jason
@carpediem1213
Feb 09 2016 07:28 UTC
@Masd925 I think that's my problem. I understand what the program is trying to do, but I don't know how to update or set the value without dot notation
@Masd925 value = collection[id][prop] ?
Matt
@mattbag
Feb 09 2016 07:29 UTC
square brackets it's right if I recall, otherwise I should review that chapter
Markus Kiili
@Masd925
Feb 09 2016 07:29 UTC
@carpediem1213 Bracket notation works with strings, variables, or expressions as the property key. Dot notation with only strings that are valid JS identifiers.
This message was deleted
@carpediem1213 No, the other way around.
Assign to the property.
Daniel Candido De Alcantara
@danielca31
Feb 09 2016 07:35 UTC

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

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

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

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

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

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

function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
if(firstName == contacts[i].firstName && prop ==){

}
}

// Only change code above this line
}

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

Markus Kiili
@Masd925
Feb 09 2016 07:36 UTC
@sarea I don't see any misplaced ; there.
Jason
@carpediem1213
Feb 09 2016 07:37 UTC
@Masd925 Ah, still nothing. So if I am looking at the JSON, it seems collection[id].album = "Album title" works to set the value, where album is the prop and the album title is the value. My problem is that I can't seem to set it in the function update(id,prop,value)
sarea
@sarea
Feb 09 2016 07:37 UTC
@Masd925 me to :D and that's why i am asking
i've tried on many browsers
Nevermind. Didn't work
Markus Kiili
@Masd925
Feb 09 2016 07:42 UTC
@carpediem1213 It should be collection[id][prop]=value; after the first if.
You assign the given value to the property on the object if the property is not tracks and value is not an empty string.
Jason
@carpediem1213
Feb 09 2016 07:45 UTC
@Masd925 Interesting. Why value on the right side?
Markus Kiili
@Masd925
Feb 09 2016 07:48 UTC
@carpediem1213 The assignment operator = evaluates the right side (the value inside value parameter) and assigns it to the variable on the left side (property prop of the object with the given id).
Jason
@carpediem1213
Feb 09 2016 07:50 UTC
@Masd925 I have 3 out of 4 green tests. There must be a problem with value = collection[id][prop].push();
same issue with value on the right side
Markus Kiili
@Masd925
Feb 09 2016 07:51 UTC
@carpediem1213 Post the code again.
Jason
@carpediem1213
Feb 09 2016 07:52 UTC
```js
if ((value !== "") && (prop != "tracks"))
{
collection[id][prop] = value; }
else if ((value !== "") && (prop == "tracks")) {
collection[id][prop].push() = value; }
else if (value === "") {
delete collection[id][prop]; }
return collection;
Markus Kiili
@Masd925
Feb 09 2016 07:53 UTC
@carpediem1213 There is no assignment if you push.
value goes inside the parens.
Jason
@carpediem1213
Feb 09 2016 07:55 UTC
@Masd925 Thanks! Everything works. I'm going to have to review "push" and JSON some more.
CamperBot
@camperbot
Feb 09 2016 07:55 UTC
carpediem1213 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 953 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Feb 09 2016 07:56 UTC
@carpediem1213 You're wellcome.
Jason
@carpediem1213
Feb 09 2016 07:56 UTC
the only way to get to prop is the multi-dimensional array with the [][], right?
no other notation?
Markus Kiili
@Masd925
Feb 09 2016 07:57 UTC
@carpediem1213 They are objects inside objects.
And you access objects with syntax obj[key].
Arrays are actually objects too. That is why you access array elements with the same [] syntax.
Matt
@mattbag
Feb 09 2016 08:05 UTC
This message was deleted
what am i missing here...
Markus Kiili
@Masd925
Feb 09 2016 08:07 UTC
@mattbag Loop through the contacts.
Matt
@mattbag
Feb 09 2016 08:08 UTC
oh sure thanks
something else, everything i wrapped n the for loop now
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 08:21 UTC
Could someone help me I am stuck at the card counting assignment this is what my code looks like:
var count = 0;

function cc(card) {
  // Only change code below this line
  if(card < 1){
    return card + " Hold";
  } else if(card >= 1){
    return card + " Bet";
  }


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
Aleksander Gębicki
@Takumar
Feb 09 2016 08:28 UTC
@ArnoMauriceLieshout "Bet" if the count is positive, or "Hold" if the count is zero or negative.
Put the border of your condition on 0 not 1
if (card <= 0) {
  return count + " Hold";
}

@ArnoMauriceLieshout now you have to first create another checking to set count variable depending on given card:

+1 for cards 2, 3, 4, 5, 6
0 for cards 7, 8, 9
-1 for cards 10, 'J', 'Q', 'K','A'

dvoci
@dvoci
Feb 09 2016 08:32 UTC
This message was deleted
CamperBot
@camperbot
Feb 09 2016 08:32 UTC
no wiki entry for: with this returning blank
dvoci
@dvoci
Feb 09 2016 08:32 UTC
This message was deleted
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 08:44 UTC
@Takumar I got that part but count is not a global variable so I can't call it inside my function
Aleksander Gębicki
@Takumar
Feb 09 2016 08:45 UTC
@ArnoMauriceLieshout var count = 0; you have it declared before your function, it is global. It is visible in your function.
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 08:47 UTC
Hello
I am getting expected output
but, it's not accepting
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 08:47 UTC
to add to the count is it better to use a switch or a if else
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 08:48 UTC

```var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

var newArray = oldArray.filter(function(val){return val >5;});
```

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

var newArray = oldArray.filter(function(val){return val >5;});
Markus Kiili
@Masd925
Feb 09 2016 08:51 UTC
@venkateshprabhu2 Your code is keeping all the elements that are greater than 5.
Filter keeps the elements for which the callback function returns true (or truthy) value.
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 08:52 UTC
@Masd925 oops! I misunderstood
I misunderstood the question. Thanks @Masd925
CamperBot
@camperbot
Feb 09 2016 08:52 UTC
venkateshprabhu2 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 954 | @masd925 | http://www.freecodecamp.com/masd925
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 08:53 UTC
I don't understand what I am doing wrong could someone help me
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(count){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = count+1;
      break;

    case 7:
    case 8:
    case 9:
      count = count;
      break;

    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count = count-1;
}



  if(card < 1){
    return count + " Hold";
  } else if(card >= 1){
    return count + " Bet";
  }


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 08:54 UTC
@ArnoMauriceLieshout switch(count)??
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 08:55 UTC
that should be card right
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 08:56 UTC
yes
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 08:56 UTC
I changed that but it still doesn't work
Aleksander Gębicki
@Takumar
Feb 09 2016 08:58 UTC
@ArnoMauriceLieshout you have to check count variable if it is positive or negative not card
if(count <= 0 ){
@ArnoMauriceLieshout I have told you about it half and hour ago :point_up: 9 lutego 2016 09:28
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 09:00 UTC
@ArnoMauriceLieshout You get the value 'card' from function call, you change the value of 'count' based on that, you test 'count' for positivity and display output
As @Takumar has mentioned.
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 09:01 UTC
so like this
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = count+1;
      break;

    case 7:
    case 8:
    case 9:
      count = count;
      break;

    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count = count-1;
}



  if(count < 1){
    return count + " Hold";
  } else if(count >= 1){
    return count + " Bet";
  }


  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
nevermind got it
thanks for the help guys
Aleksander Gębicki
@Takumar
Feb 09 2016 09:03 UTC
@ArnoMauriceLieshout you still haven't got this, because you still have wrong conditions:
 if(count < 1){
    return count + " Hold";
  } else if(count >= 1){
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 09:03 UTC
to improve, you don't really have to test for cases 7, 8, 9
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 09:03 UTC
I got it working now
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 09:04 UTC
and you don't have to use 'if' after else. The rest all falls into same category of 'else' in this case
ArnoMauriceLieshout
@ArnoMauriceLieshout
Feb 09 2016 09:05 UTC
you'r right it shortens the code by quite a bit
venkatesh prabhu
@venkateshprabhu2
Feb 09 2016 09:06 UTC
It's more about eliminating unnecessary conditions and checking than just 'shortening'. That's what I believe.
Aleksander Gębicki
@Takumar
Feb 09 2016 09:06 UTC
@venkateshprabhu2 less code, less possibilites for errors :-)