16th
Jan 2016
Gristel Periwinkle
@gristel
Jan 16 2016 00:01
I notice quite a few people wanting to go too fast and forget golden rule #1: read carefully what info you are given and figure out exactly what is being asked. Then build your solution step by step.
John Cerpa
@johncerpa
Jan 16 2016 00:01
ohh okay i'm sorry
Gristel Periwinkle
@gristel
Jan 16 2016 00:01
No no don’t be :)
You’re being kind and helpful and all
John Cerpa
@johncerpa
Jan 16 2016 00:02
:) :+1:
Gristel Periwinkle
@gristel
Jan 16 2016 00:02
We each have our own way of ‘helping’ :)
John Cerpa
@johncerpa
Jan 16 2016 00:02
gonna keep that in mind
Gristel Periwinkle
@gristel
Jan 16 2016 00:02
So in this case, I would ask: What is the first thing you have to figure out?
Which would be: is value empty or not
so write that first and test it
then the 2nd thing
and so on...
Not everybody appreciates my way of helping, but hey, in the end, I’m doing them a favor :)
Because
learning to think analytical > learning to code
In my opinion
:)
John Cerpa
@johncerpa
Jan 16 2016 00:05
hmmn
right
there's no point
if you pass the exercise and that's it
you need to analyze the whole thing
Gristel Periwinkle
@gristel
Jan 16 2016 00:05
That’s how I feel yes
It’s really the same thing everywhere: give a man a fish and he will eat 1 day. Teach a man how to fish and he will eat the rest of his life
Philip Bowles
@pabowles
Jan 16 2016 00:07

ok so i'm confused with Profile Lookup challenge
What is the difference in the following code?

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

and

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

The second block of code is the correct one and I understand that the difference between if(contacts[i][prop]) and if(contacts[i][prop] === prop) is that the first one is just checking to see if it exists..But using the strict equals operator should still return true in this case, right?

Robbie
@centraleft
Jan 16 2016 00:09
the difference is that contacts[i][prop] will never return false, but contacts[i][prop] === prop will return false if the current object in your iteration doesn't match
so you'll get no such property, even if an object in your array does in fact have that property, simply because it checked an object that didn't have it before it checked an object that did
I hope that makes sense
Philip Bowles
@pabowles
Jan 16 2016 00:11
so you're saying it won't check through every part of the object? once it hits one and returns false then it stops?
i thought it would keep going through each part of the array because of the counter and the for loop
Robbie
@centraleft
Jan 16 2016 00:11
yep once a function hits return it ends immediately
Philip Bowles
@pabowles
Jan 16 2016 00:12
ah so it's stopping the for loop in the middle and not even finishing it?
Robbie
@centraleft
Jan 16 2016 00:12
thats correct
Philip Bowles
@pabowles
Jan 16 2016 00:12
ok i knew return would stop but i didn't think of it in the context of a for loop like that and stopping the counter mid track
Robbie
@centraleft
Jan 16 2016 00:13
yeah I actually had the same problem earlier today with that challenge
Philip Bowles
@pabowles
Jan 16 2016 00:13
i understand it now but i'm struggling to understand when i would apply the logic in other situaitons
my brain automatically wants to use an operator with conditionals...i'm not used to just checking to see if something exists like that
Gristel Periwinkle
@gristel
Jan 16 2016 00:16
In many cases it will be required
Robbie
@centraleft
Jan 16 2016 00:16
you can still use the conditionals if you don't throw a return in your first if, there are always multiple ways to solve a problem
Philip Bowles
@pabowles
Jan 16 2016 00:17
how would you solve that one without returning the value of prop in the if statement?
Gristel Periwinkle
@gristel
Jan 16 2016 00:17
It really depends on what’s being asked.
How do you mean, without returning the value of prop?
Philip Bowles
@pabowles
Jan 16 2016 00:18
well without using the return statement, as @centraleft said
Gristel Periwinkle
@gristel
Jan 16 2016 00:19
Well, you always need to return something, no?
Philip Bowles
@pabowles
Jan 16 2016 00:19
that's what i thought, yes
so now i'm confused lol
Robbie
@centraleft
Jan 16 2016 00:20
@gristel you don't have to in a conditional
Gristel Periwinkle
@gristel
Jan 16 2016 00:20
you mean you want to use if(contacts[i][prop] === prop) ?
Philip Bowles
@pabowles
Jan 16 2016 00:20
@gristel exactly
Gristel Periwinkle
@gristel
Jan 16 2016 00:21
@centraleft no, but in this case, you do.
Robbie
@centraleft
Jan 16 2016 00:21
I solved it without so
Gristel Periwinkle
@gristel
Jan 16 2016 00:21
or you could work with a global variable etc..
Pandarati
@Pandarati
Jan 16 2016 00:21
wiki Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
Jan 16 2016 00:21

# Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

Philip Bowles
@pabowles
Jan 16 2016 00:21
ah so set a variable outside of the function and then in the if statement just set that variable rather than using a return statement?
Robbie
@centraleft
Jan 16 2016 00:21
it doesn't have to be global if you keep track of the scope
@pabowles that is what I did
Gristel Periwinkle
@gristel
Jan 16 2016 00:22
@pabowles exactly
Elizabeth Fine
@elizabethfinedev
Jan 16 2016 00:22
hey guys, does anyone know what this means
[\W_]+/g
Robbie
@centraleft
Jan 16 2016 00:22
its regex
Philip Bowles
@pabowles
Jan 16 2016 00:22
gotcha...makes sense
Elizabeth Fine
@elizabethfinedev
Jan 16 2016 00:22
like which characters does that select
Robbie
@centraleft
Jan 16 2016 00:22
Gristel Periwinkle
@gristel
Jan 16 2016 00:22
@centraleft no it doesn’t have to be global, but it’s easiest to avoid mistakes I think
mmacedo
@mmacedoeu
Jan 16 2016 00:22
@nitiblack try here
Robbie
@centraleft
Jan 16 2016 00:23
@gristel it's better to use var and initialize at the start of the function, global variables can get dangerous
mmacedo
@mmacedoeu
Jan 16 2016 00:23
@BananaHavana looks like WordWar
Gristel Periwinkle
@gristel
Jan 16 2016 00:23
@centraleft hmm, good point
Robbie
@centraleft
Jan 16 2016 00:23
in this case it wouldn't make a difference because this is one function, but if you had other functions you could run into naming conflicts
mmacedo
@mmacedoeu
Jan 16 2016 00:23
*WorldWar
Gristel Periwinkle
@gristel
Jan 16 2016 00:23
exactly
I was too focussed on this 1 function
mmacedo
@mmacedoeu
Jan 16 2016 00:24
@gristel relax and procastinate a little bit
Gristel Periwinkle
@gristel
Jan 16 2016 00:24
@mmacedoeu meaning?
Robbie
@centraleft
Jan 16 2016 00:25
@mmacedoeu lol what
mmacedo
@mmacedoeu
Jan 16 2016 00:25
@gristel you can do it
Robbie
@centraleft
Jan 16 2016 00:25
maybe this person thinks you need to take a break? sort of insulting xD
Gristel Periwinkle
@gristel
Jan 16 2016 00:25
@mmacedoeu I have no clue what you’re trying to say ...
@centraleft That’s what I thought yes :)
mmacedo
@mmacedoeu
Jan 16 2016 00:26
@gristel sometimes the brain needs to chance focus so it can reinflux new ideas
@gristel you are toooo focused toooo much
:smile:
Gristel Periwinkle
@gristel
Jan 16 2016 00:27
@mmacedoeu What I was trying to say is that I was talking from the perspective of the specific question of that purpose, and not in general
*of that person
See! Not focussed enough :P
mmacedo
@mmacedoeu
Jan 16 2016 00:28
@gristel ahah, you are a cool guy
Gristel Periwinkle
@gristel
Jan 16 2016 00:28
Uhm, thanks I guess :)
Andrew
@SuperHedgehog
Jan 16 2016 00:30
So I got this to finally work but really I guess at the line for result = lookup[val]
Elizabeth Fine
@elizabethfinedev
Jan 16 2016 00:32
function palindrome(str) {
var newArray = str.replace(/[^A-Za-z0-9_]/g, '');
var newString = newArray.split("").reverse().join("").toLowerCase();

if  (newArray === newString) {
return true;
}
else  {
return false;
}
}

palindrome("A man, a plan, a canal. Panama");
Andrew
@SuperHedgehog
Jan 16 2016 00:32

sorry ignore last.
function phoneticLookup(val) {
var result = "";

// Only change code below this line

var lookup = {

"bravo": "Boston",

"charlie": "Chicago",

"delta": "Denver",

"echo": "Easy",

"foxtrot": "Frank"

};
result = lookup[val];

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

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

So I got this to finally work but really I guess at the line for result = lookup[val]. What I am struggling to understand is why that line does require a var or something in
front.

Elizabeth Fine
@elizabethfinedev
Jan 16 2016 00:32
grrr dont know whats wrong. three palindromes are not returning correctly
Kevin
@KAlanHicks
Jan 16 2016 00:35
Hey guys, how do I run my code and see the actual results I am getting in the browser? When I program in VS, for example, I can run the debugger in console mode and just return my results there to see what I might be getting wrong. Is there an equivalent to this that I can do while coding on freecodecamp's website?
wushupork
@wushupork
Jan 16 2016 00:39
@BananaHavana put your toLowerCase() in the newArray instead of in the newString. str.toLowerCase().replace(...)
newArray still has the uppercase letters in it
Pablo K
@pablok47
Jan 16 2016 00:45
still working on the JSON checkpoint...can someone help me fix this code...collection[id][prop].push(value);
error is that "collection[id][prop].push(value);" is not a function
wushupork
@wushupork
Jan 16 2016 00:47
@pablok47 it is if "tracks" is the prop, because "tracks" is an array. that's why that statement goes in the section where it checks for prop === "tracks"
Pablo K
@pablok47
Jan 16 2016 00:49
so its correct?
gravesr1993
@gravesr1993
Jan 16 2016 00:50
got a question about Increment a Number with Javascript in Basic Javascript , it seems like it doesn't accept myVar=myVar++; because it's post increment, but it doesn't accept myVar=++myVar; because it expects ++ as post
wushupork
@wushupork
Jan 16 2016 00:50
@pablok47 Yes, in the section where it checks for prop === "tracks". in the other section it won't work, you'll have to go about it another way.
@gravesr1993 you don't need to use myVar= when incrementing, myVar++ is all you need.
Pablo K
@pablok47
Jan 16 2016 00:52
@wushupork if have it in that section but i still getting error
gravesr1993
@gravesr1993
Jan 16 2016 00:52
yeah, I just didn't want to change a lot of code and just added that in real fast, but was wondering if it was intentional or not
Pablo K
@pablok47
Jan 16 2016 00:53
this is my code...

function update(id, prop, value) {

if (value !== "" && collection[id][prop] !== "tracks"){
collection[id][prop] = value;

} if (prop === "tracks" && value !== ""){
collection[id][prop].push(value);

} else if (value === ""){
delete collection[id][prop];

}
return collection;
}

wushupork
@wushupork
Jan 16 2016 00:54
the first if should be prop !== "tracks" not collection[id][prop] !== "tracks"
Pablo K
@pablok47
Jan 16 2016 00:55
got it
thanks @wushupork
CamperBot
@camperbot
Jan 16 2016 00:55
pablok47 sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 279 | @wushupork | http://www.freecodecamp.com/wushupork
wushupork
@wushupork
Jan 16 2016 00:55
Glad to help, @pablok47
Kevin
@KAlanHicks
Jan 16 2016 00:58
Has anyone done what I'm after? It's just a pain to have to code in the browser and not be able to see my results.
wushupork
@wushupork
Jan 16 2016 01:01
@KAlanHicks open up developer mode (ctrl-shift-i in firefox and chrome), select the console tab
then use console.log() to test your results
console.log() is your friend
Kevin
@KAlanHicks
Jan 16 2016 01:03
Thanks!
wushupork
@wushupork
Jan 16 2016 01:04
No problem, good coding :)
Kevin
@KAlanHicks
Jan 16 2016 01:04
How do you do that send brownie points thing? xD
wushupork
@wushupork
Jan 16 2016 01:04
@KAlanHicks thanks
CamperBot
@camperbot
Jan 16 2016 01:04
wushupork sends brownie points to @kalanhicks :sparkles: :thumbsup: :sparkles:
:star: 207 | @kalanhicks | http://www.freecodecamp.com/kalanhicks
John Cerpa
@johncerpa
Jan 16 2016 01:04
CamperBot
@camperbot
Jan 16 2016 01:04
johncerpa sends brownie points to @username :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for username
Kevin
@KAlanHicks
Jan 16 2016 01:04
@wushupork thanks
CamperBot
@camperbot
Jan 16 2016 01:04
kalanhicks sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 280 | @wushupork | http://www.freecodecamp.com/wushupork
Kevin
@KAlanHicks
Jan 16 2016 01:04
aha! thanks!
Gregory Bilecki
@gbilecki
Jan 16 2016 01:19
thank you @pablok47 @wushupork
CamperBot
@camperbot
Jan 16 2016 01:19
gbilecki sends brownie points to @pablok47 and @wushupork :sparkles: :thumbsup: :sparkles:
:star: 281 | @wushupork | http://www.freecodecamp.com/wushupork
:star: 120 | @pablok47 | http://www.freecodecamp.com/pablok47
Juan Ocasio
@juanocasio
Jan 16 2016 01:36
Hello all: Having some trouble with Profile lookup
here is my code:
function lookUp (firstName, prop) {
// Only change code below this line
var contactsLength = contacts.length;
for (var i = 0;i < contactsLength; i++) {
if (contacts[i].firstName === firstName) {
if (contacts[i][prop]) {
return console.log(contacts[i][prop]);
} else {
return console.log('No such property');
}
}

}
return console.log('No such contact');
// Only change code above this line
}
It works in my editor, but I'm not passing. Can someone direct me?
oh, wait...Think I know...
matthew3454
@matthew3454
Jan 16 2016 01:38
I have a question on the Escaping Literal Quotes in Strings:
var myStr=\\I am a "double quoted" string insid
Juan Ocasio
@juanocasio
Jan 16 2016 01:38
Yep, I'm an idoit! forgot to remove the console.log. duh!
matthew3454
@matthew3454
Jan 16 2016 01:39
var myStr=\\I am a "double quoted" string inside "double quotes"\\;
Juan Ocasio
@juanocasio
Jan 16 2016 01:39
@matthew3454 You escape the quotes within the string
matthew3454
@matthew3454
Jan 16 2016 01:39
These are the instructions:You should use two double quotes (") and four escaped double quotes (\")
Variable myStr should equal to ("I am a "double quoted" string inside "double quotes"").
Juan Ocasio
@juanocasio
Jan 16 2016 01:39
\"
Brandon John-Baptiste
@Kizzeh
Jan 16 2016 01:40

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

// Only change code below this line.
var oldArray = oldArray.filter(function(val){
return val < 5;
});
newArray = oldArray;

can someone help me this won't work
Juan Ocasio
@juanocasio
Jan 16 2016 01:41
@Kizzeh Which one it that?
Brandon John-Baptiste
@Kizzeh
Jan 16 2016 01:41
Filter arrays with filters
brl1906
@brl1906
Jan 16 2016 01:42
weird question. but, has anyone had an issue with the site in which a large white column blocks a third of the page from the right? if so how did you resolve?
Robbie
@centraleft
Jan 16 2016 01:42
@kizzeh I think you need to set return val < 5 equal to a variable
or push val < 5 to newArray
I could be totally wrong though, not 100% sure how filter works
Brandon John-Baptiste
@Kizzeh
Jan 16 2016 01:43
When I run the test it gives the right output it just won't continue to the next one
Juan Ocasio
@juanocasio
Jan 16 2016 01:44
@Kizzeh Alomst there.
right now you have would have anything greater that 6
wushupork
@wushupork
Jan 16 2016 01:44
^
matthew3454
@matthew3454
Jan 16 2016 01:45
var myStr=\"I am a double quoted string inside double quotes\"; I can't get it to work still. @juanocasio
Juan Ocasio
@juanocasio
Jan 16 2016 01:45
@matthew3454 can't escape the first and last quote
wushupork
@wushupork
Jan 16 2016 01:45
@kizzeh what conditional works with five or greater?
Brandon John-Baptiste
@Kizzeh
Jan 16 2016 01:46
@wushupork <== 5
Juan Ocasio
@juanocasio
Jan 16 2016 01:46
@Kizzeh remove one =
matthew3454
@matthew3454
Jan 16 2016 01:46
var myStr=\""I am a double quoted string inside double quotes"\"; Like this? @juanocasio
Juan Ocasio
@juanocasio
Jan 16 2016 01:47
@matthew3454 not quite. You have a beginning quote and and ending quote to denote the string. You escape any quotes inside the string
Brandon John-Baptiste
@Kizzeh
Jan 16 2016 01:47
@juanocasio Thanks
CamperBot
@camperbot
Jan 16 2016 01:47
kizzeh sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:star: 284 | @juanocasio | http://www.freecodecamp.com/juanocasio
Juan Ocasio
@juanocasio
Jan 16 2016 01:48
@matthew3454 example: "I and escaping the \n new line character"
the and should've been am
matthew3454
@matthew3454
Jan 16 2016 01:50
var myStr="\I am a double quoted string inside double quotes\";
@juanocasio
Juan Ocasio
@juanocasio
Jan 16 2016 01:51
Here is another example" 'I have to escape this: don\'t because it's a tick inside of single tick marks'
so for this string -> "I am a "double quoted" string inside "double quotes"", the first and last quote stays because they signify the string, the rest of them have to be escaped
matthew3454
@matthew3454
Jan 16 2016 01:53
so do I get rid of the backslashes as well?
Juan Ocasio
@juanocasio
Jan 16 2016 01:53
no, the backlash is the escape character, you add it to the string to escape the quotes within the quotes
matthew3454
@matthew3454
Jan 16 2016 01:54
i see
var myStr="I am a \double quoted\ string inside \double quotes\";
Juan Ocasio
@juanocasio
Jan 16 2016 01:55
very, very close, but you removed the quotes
you need those
matthew3454
@matthew3454
Jan 16 2016 01:56

var myStr="I am a \"double quoted"\ string inside \"double quotes"\";



Juan Ocasio
@juanocasio
Jan 16 2016 01:56
close. look at how you escaped the first quote. That is how you escape the rest
the escape character always come before the character it is escaping
\n, \t, etc
matthew3454
@matthew3454
Jan 16 2016 01:57
var myStr="I am a \"double quoted\" string inside \"double quotes\"";
Juan Ocasio
@juanocasio
Jan 16 2016 01:57
bingo!
matthew3454
@matthew3454
Jan 16 2016 01:58
Nice!! @juanocasio
@juanocasio Thank you!
CamperBot
@camperbot
Jan 16 2016 01:58
matthew3454 sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:star: 285 | @juanocasio | http://www.freecodecamp.com/juanocasio
Nick Hester
@nickhstr
Jan 16 2016 01:58

Palindromes are killing me! Can anyone help?

function palindrome(str) {
str = str.toLowerCase();
var noPunc = str.replace(/[\W]/g, "");
var strArr = noPunc.split("");
var reversal = strArr.reverse().join("");
return reversal === noPunc;
}

palindrome("eye");

This is the only test not passing: palindrome("0_0 (: /-\ :) 0-0") should return true.

Robbie
@centraleft
Jan 16 2016 01:59
@nickhstr I might be remembering incorrectly but I'm pretty the underscore is what's causing your issue
wushupork
@wushupork
Jan 16 2016 01:59
the regex is keeping too many special characters
Robbie
@centraleft
Jan 16 2016 02:01
if you need an extra hint let me know but I'm almost certain it's the underscore
Juan Ocasio
@juanocasio
Jan 16 2016 02:01
@nickhstr you should also make sure Eye returns true
Nick Hester
@nickhstr
Jan 16 2016 02:02
I'm still new, so let me see if I understand correctly. I thought the regex used only kept alphanumeric characters, right?
And thank you, @juanocasio, that has been returning true.
CamperBot
@camperbot
Jan 16 2016 02:02
nickhstr sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:star: 286 | @juanocasio | http://www.freecodecamp.com/juanocasio
Nick Hester
@nickhstr
Jan 16 2016 02:03
Should I split the string before replacing?
Helio Ha
@helioha
Jan 16 2016 02:03
I'm doing the symetric difference algorithm coding challenge and would like to ask if there is a bug on the answer
Robbie
@centraleft
Jan 16 2016 02:04
no but you may want to split it afterwards
Helio Ha
@helioha
Jan 16 2016 02:04
it says: sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) should return [1, 4, 5]
but mine is returning [1,4]
isn't my answer right?
Juan Ocasio
@juanocasio
Jan 16 2016 02:04
@nickhstr You need to modify your regex a bit
Nick Hester
@nickhstr
Jan 16 2016 02:05
Ok, thanks @centraleft. How do I isolate, for example, the underscore in "0_0"?
CamperBot
@camperbot
Jan 16 2016 02:05
nickhstr sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
:star: 280 | @centraleft | http://www.freecodecamp.com/centraleft
Robbie
@centraleft
Jan 16 2016 02:05
@nickhstr
regexone.com
does a pretty good job at introducing you to regex
Dave
@dloyst
Jan 16 2016 02:06
what's the difference between a JSON object that opens with a { as opposed to a [ ??
Robbie
@centraleft
Jan 16 2016 02:06
@helioha post your code
Nick Hester
@nickhstr
Jan 16 2016 02:06
Thanks, I'll be spending quite some time in there then, haha.
Robbie
@centraleft
Jan 16 2016 02:06
@dloyst if something is contained in [] brackets it is an array
Helio Ha
@helioha
Jan 16 2016 02:06

function sym(args) {

var result = [];

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

// loop trhough the arguments to find result
for(var i = 0; i < argumentsArray.length; i++) {
// check singularity of each element of an argument
for(var j = 0; j < argumentsArray[i].length; j++) {
var isSingular = true; // assume that arg[i][j] is singular
// check singularity against elements of other arguments
for(var k = 0; k < argumentsArray.length; k++) {
// skip singularity check against an argument itself
if(i === k) {
continue;
}// end if
// check singularity against every element of an argument
for(var l = 0; l < argumentsArray[k].length; l++) {
// true if element is not singular
if(argumentsArray[i][j] === argumentsArray[k][l]) {
isSingular = false;
break;
} // end if
}// end for
// stop looping through arguments if singularity is false
if(isSingular === false) {
break;
} // end if
} // end for
// if arg[i][j] is singular, add to result
if(isSingular === true) {
result.push(argumentsArray[i][j]);
} // end if
} // end for
} // end for

return result;

}

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

Robbie
@centraleft
Jan 16 2016 02:06
@dloyst if something is contained in {} curly braces it is an object
@dloyst JSON is essentially just a formatting guideline for objects and groups of objects
@helioha put your code in backticks 
one on top and one on bottom, each in their own line
Dave
@dloyst
Jan 16 2016 02:07
So, in the JSON waypoint with the trees, it creates the JSON object:
var myObject = [
but in the next exercise it's describing a JSON object starting with var collection = {
Helio Ha
@helioha
Jan 16 2016 02:09

 function sym(args) {

  var result = [];

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

  // loop trhough the arguments to find result
  for(var i = 0; i < argumentsArray.length; i++) {
    // check singularity of each element of an argument
    for(var j = 0; j < argumentsArray[i].length; j++) {
      var isSingular = true;  // assume that arg[i][j] is singular
      // check singularity against elements of other arguments
      for(var k = 0; k < argumentsArray.length; k++) {
        // skip singularity check against an argument itself
        if(i === k) {
          continue;
        }// end if
        // check singularity against every element of an argument
        for(var l = 0; l < argumentsArray[k].length; l++) {
          // true if element is not singular
          if(argumentsArray[i][j] === argumentsArray[k][l]) {
            isSingular = false;
            break;
          } // end if
        }// end for
        // stop looping through arguments if singularity is false
        if(isSingular === false) {
          break;
        } // end if
      } // end for
      // if arg[i][j] is singular, add to result
      if(isSingular === true) {
        result.push(argumentsArray[i][j]);
      } // end if
    } // end for
  } // end for

 return result;

}

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

sorry, I don't know how the back ticks works exactly
Dave
@dloyst
Jan 16 2016 02:09
@centraleft I just got what you're saying
Robbie
@centraleft
Jan 16 2016 02:09
@dloyst JSON stands for JavaScript Object Notation. It really is just like MLA for JavaScript objects. The interpreter isn't gonna freak out if you don't format them properly, but it is best to follow it
the brackets are an array of objects, its an easy way to group individual objects together so you can parse it
I hope that makes sense lol
Dave
@dloyst
Jan 16 2016 02:10
definitely, thanks!!
Robbie
@centraleft
Jan 16 2016 02:10
@helioha thats okay helioha for future reference it is just two sets of backticks
Helio Ha
@helioha
Jan 16 2016 02:11
did anyone went through the Symmetric Difference challenge yet?
I cannot help to think that the exercise is wrong
it says that sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) should return [1, 4, 5]
but i think the correct answer is [1,4]
because the number 5 is in all of the elements
Robbie
@centraleft
Jan 16 2016 02:12
I think the continue might be your issue?
Helio Ha
@helioha
Jan 16 2016 02:13
my doubt is not about the code, but about the exercise
I guess I didn't understand it well, or it is wrong
Robbie
@centraleft
Jan 16 2016 02:13
I'm having trouble reading it there are so many things popping up right now, but it looks like whether or not i === k your code is going to continue to the next for loop
maybe add an else { break;}?
Helio Ha
@helioha
Jan 16 2016 02:14
the code is working as I expect, the output is coming out like I want
Robbie
@centraleft
Jan 16 2016 02:14
there is also a chance it could be bugged, wish I could help more
Helio Ha
@helioha
Jan 16 2016 02:14
okay, no problem
Robbie
@centraleft
Jan 16 2016 02:14
wiki Symmetric Difference
CamperBot
@camperbot
Jan 16 2016 02:14
no wiki entry for: symmetric difference
Robbie
@centraleft
Jan 16 2016 02:14
hm
Nick Hester
@nickhstr
Jan 16 2016 02:17
Thank you! @centraleft
CamperBot
@camperbot
Jan 16 2016 02:17
nickhstr sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
:warning: nickhstr already gave centraleft points
Nick Hester
@nickhstr
Jan 16 2016 02:17
regexone.com is fantastic
Robbie
@centraleft
Jan 16 2016 02:17
no problem! it helped me a lot as well
Helio Ha
@helioha
Jan 16 2016 02:18
just testing if I learned how to post code on chat, please ignore my next message

function sym(args) {

var result = [];

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

// loop trhough the arguments to find result
for(var i = 0; i < argumentsArray.length; i++) {
// check singularity of each element of an argument
for(var j = 0; j < argumentsArray[i].length; j++) {
var isSingular = true; // assume that arg[i][j] is singular
// check singularity against elements of other arguments
for(var k = 0; k < argumentsArray.length; k++) {
// skip singularity check against an argument itself
if(i === k) {
continue;
}// end if
// check singularity against every element of an argument
for(var l = 0; l < argumentsArray[k].length; l++) {
// true if element is not singular
if(argumentsArray[i][j] === argumentsArray[k][l]) {
isSingular = false;
break;
} // end if
}// end for
// stop looping through arguments if singularity is false
if(isSingular === false) {
break;
} // end if
} // end for
// if arg[i][j] is singular, add to result
if(isSingular === true) {
result.push(argumentsArray[i][j]);
} // end if
} // end for
} // end for

return result;

}

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

wushupork
@wushupork
Jan 16 2016 02:18
single backtick only works on a single line like so: here's some code
you have to use triple backticks for a multi-line paste
Helio Ha
@helioha
Jan 16 2016 02:19

function sym(args) {

var result = [];

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

// loop trhough the arguments to find result
for(var i = 0; i < argumentsArray.length; i++) {
// check singularity of each element of an argument
for(var j = 0; j < argumentsArray[i].length; j++) {
var isSingular = true; // assume that arg[i][j] is singular
// check singularity against elements of other arguments
for(var k = 0; k < argumentsArray.length; k++) {
// skip singularity check against an argument itself
if(i === k) {
continue;
}// end if
// check singularity against every element of an argument
for(var l = 0; l < argumentsArray[k].length; l++) {
// true if element is not singular
if(argumentsArray[i][j] === argumentsArray[k][l]) {
isSingular = false;
break;
} // end if
}// end for
// stop looping through arguments if singularity is false
if(isSingular === false) {
break;
} // end if
} // end for
// if arg[i][j] is singular, add to result
if(isSingular === true) {
result.push(argumentsArray[i][j]);
} // end if
} // end for
} // end for

return result;

}

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

triple backticks on every line?
wushupork
@wushupork
Jan 16 2016 02:19
help formatting
CamperBot
@camperbot
Jan 16 2016 02:19

## :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

Helio Ha
@helioha
Jan 16 2016 02:20
function sym(args) {

var result = [];

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

// loop trhough the arguments to find result
for(var i = 0; i < argumentsArray.length; i++) {
// check singularity of each element of an argument
for(var j = 0; j < argumentsArray[i].length; j++) {
var isSingular = true;  // assume that arg[i][j] is singular
// check singularity against elements of other arguments
for(var k = 0; k < argumentsArray.length; k++) {
// skip singularity check against an argument itself
if(i === k) {
continue;
}// end if
// check singularity against every element of an argument
for(var l = 0; l < argumentsArray[k].length; l++) {
// true if element is not singular
if(argumentsArray[i][j] === argumentsArray[k][l]) {
isSingular = false;
break;
} // end if
}// end for
// stop looping through arguments if singularity is false
if(isSingular === false) {
break;
} // end if
} // end for
// if arg[i][j] is singular, add to result
if(isSingular === true) {
result.push(argumentsArray[i][j]);
} // end if
} // end for
} // end for

return result;

}

sym([1, 2, 5], [2, 3, 5], [3, 4, 5]);
OKay!
yay
thank you @wushupork
CamperBot
@camperbot
Jan 16 2016 02:20
helioha sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 282 | @wushupork | http://www.freecodecamp.com/wushupork
Dave
@dloyst
Jan 16 2016 02:38

In the JSON waypoint with updating the music collection, can anyone tell me why this code works: function update(id, prop, value) {
if (prop !== "tracks" && value !== "") {
collection[id][prop] = value;
} else if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
} else if (value === "") {
delete collection[id][prop];
}

return collection;
} instead of: function update(id, prop, value) {
if (prop !== "tracks" && value !== "") {
collection.id[prop] = value;
} else if (prop === "tracks" && value !== "") {
collection.id[prop].push(value);
} else if (value === "") {
delete collection.id[prop];
}

return collection;
}

when I say in the update function : collection.id[prop], I get an error saying: Cannot set property 'artist' of undefined
But when I use : collection[id][prop], it works
Brian
@sludge256
Jan 16 2016 02:48
@dloyst if you want to access object properties with a variable you must use bracket notation
Juan Ocasio
@juanocasio
Jan 16 2016 02:49
@dloyst can't do collection.id because id is a variable when you use dot notiation, you are trying to locate the id property of the object
Brian
@sludge256
Jan 16 2016 02:49
if you use dot notation such as obj.item it will look for a property named item
wushupork
@wushupork
Jan 16 2016 02:49
@dloyst when you use collection.id it's looking for literally a section in collection called "id". when you use collection[id] it's passing the value of id to it.
Brian
@sludge256
Jan 16 2016 02:49
but if you use obj[item] it will use the value of the variable called item
wushupork
@wushupork
Jan 16 2016 02:49
^
Brian
@sludge256
Jan 16 2016 02:50
teamwork :clap:
Dom
@zocke1r
Jan 16 2016 02:51
why does JS create a global Variable if i try to assign a value to it instead of just failing to do so and returning an error ?
Juan Ocasio
@juanocasio
Jan 16 2016 02:52
@zocke1r: what do you mean? If you don't use the keyword var?
Dave
@dloyst
Jan 16 2016 02:52
omg, thank you so much @sludge256 and @wushupork !!!!! That seriously helps so so much!!
CamperBot
@camperbot
Jan 16 2016 02:52
dloyst sends brownie points to @sludge256 and @wushupork :sparkles: :thumbsup: :sparkles:
:star: 850 | @sludge256 | http://www.freecodecamp.com/sludge256
:star: 284 | @wushupork | http://www.freecodecamp.com/wushupork
Dom
@zocke1r
Jan 16 2016 02:53
@juanocasio yes
Brian
@sludge256
Jan 16 2016 02:53
@juanocasio brownies for you too thanks
CamperBot
@camperbot
Jan 16 2016 02:53
sludge256 sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:star: 287 | @juanocasio | http://www.freecodecamp.com/juanocasio
Juan Ocasio
@juanocasio
Jan 16 2016 02:55
@zocke1r when you use a variable without the var, js automatically puts it into the global context, it's just the nature of the language. You should always declare with the keyword var to keep it in the current context
@sludge, that's too kind :)
Robbie
@centraleft
Jan 16 2016 02:57
@zocke1r if you're really curious this is worth the read:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var
Dom
@zocke1r
Jan 16 2016 02:59
@centraleft thank you going to read it
CamperBot
@camperbot
Jan 16 2016 02:59
zocke1r sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
:star: 284 | @centraleft | http://www.freecodecamp.com/centraleft
Dom
@zocke1r
Jan 16 2016 03:01
@juanocasio but why does JS behave like that and does not simply crash instead of trying to fix it? Is there any scenario in which this behaviour would ever be helpfull?
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:03
guys, I need to beat the last Bonfire
Totally lost on this one, just don't get it.
Juan Ocasio
@juanocasio
Jan 16 2016 03:05
@zocke1r: this is how the language was designed. If you want it to throw an error, you can use 'strict mode', however you have to be careful using this in the global context, especially when using other libraries
@Varulvsnatt: what is the issue?
Dom
@zocke1r
Jan 16 2016 03:06
@juanocasio okay thank you
CamperBot
@camperbot
Jan 16 2016 03:06
zocke1r sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:star: 288 | @juanocasio | http://www.freecodecamp.com/juanocasio
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:06
I just don't get the thing about Arguments.
Juan Ocasio
@juanocasio
Jan 16 2016 03:08
@Varulvsnatt arguments is a special keyword that is similar to an array. it will display all of the arguments passed to a function
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:08
I don't even know how to start this one.
Juan Ocasio
@juanocasio
Jan 16 2016 03:10
so for example:
var myFunc = function(myParameter){
return arguments.length; // will return 3
}

myFunc("one", "two", "three");
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:10

In

var singleVal = array.reduce(function(previousVal, currentVal) {

return previousVal - currentVal;

}, 0);

what is the , 0 doing?

Juan Ocasio
@juanocasio
Jan 16 2016 03:11
arguments.length will return 3 because the length of arguments is three (three arguments were passed)
@CodingDucky 0 starts it at the begining
or at the 0 element in the array
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:13
Thanks
var oldArray = [1,2,3,4,5,6,7,8,9,10];
var newArray = [];

// Only change code below this line.

newArray = oldArray.filter(function(val){
return val <= 5;
});
So why isn't it needed here?
Juan Ocasio
@juanocasio
Jan 16 2016 03:15
@CodingDucky That's a different function
and it is not needed for the reduce function either, it is totally optional
Dom
@zocke1r
Jan 16 2016 03:16
i have a question if i declare a local variable inside a loop will this variable persist over multiple loop runs or be destroyed and recreated?
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:17
thanks @juanocasio
CamperBot
@camperbot
Jan 16 2016 03:17
codingducky sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:star: 289 | @juanocasio | http://www.freecodecamp.com/juanocasio
Juan Ocasio
@juanocasio
Jan 16 2016 03:17
@zocke1r if you declare inside the loop it will be recreated each time. Declare it just outside of the loop if you want the value to persist
Dom
@zocke1r
Jan 16 2016 03:18
@juanocasio okay thank you, that was the thing i did not want it to persist
CamperBot
@camperbot
Jan 16 2016 03:18
zocke1r sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:warning: zocke1r already gave juanocasio points
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:19
so Arguments is a special keyword. good.
but how it can be used in this exercise?
Seems like I'm missing a lot of javascript in this one, haha, the other ones were far more easier!
Juan Ocasio
@juanocasio
Jan 16 2016 03:20
@Varulvsnatt: what you want to do it use the arguments to check what's inside of it.
You should have 2 for loops
one to loop through the arr array, and one to loop through the arguments 'array'. I put the quotes around array, because aguments ins't really an array, but you can use an index like an array (and use the length prop)
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:22
destroyer([1, 2, 3, 1, 2, 3], 2, 3)
but how many arguments are there?
3?
Juan Ocasio
@juanocasio
Jan 16 2016 03:23
yep. First one is an array, then 2, then 3
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:24
Ohhhh, now I'm getting it, great.
Juan Ocasio
@juanocasio
Jan 16 2016 03:24
so you already know that arguments[0] == [1,2,3,2,3]
hint: you'll use arguments.length as well as arr.length to set up your two for loops
CamperBot
@camperbot
Jan 16 2016 03:25
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:25
and I need to compare arguments[0] with both arguments1 and arguments[2]
Juan Ocasio
@juanocasio
Jan 16 2016 03:26
@Varulvsnatt: nope you have to compare all arguments greater than arguments[0] with all of the elements in arr
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:26
var array = [1, 12, 21, 2];

array.sort(function(a, b) {

return a - b;

});

How is this sorting the array from smallest to largest?

From what I can see it's returning a - b

Not sorting anything
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:26
// 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"){
tracks.push(value);
}
else if (value=== "") {
delete prop;
}
else {

}
return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
So, I'm running into an issue in that I have an error that says I shouldn't delete variables in the middle of solving this problem. But the instructions say "If value is blank, delete that prop."
CamperBot
@camperbot
Jan 16 2016 03:26
:bulb: to format code use backticks!  more info
Juan Ocasio
@juanocasio
Jan 16 2016 03:27
@CodingDucky a and b are the first and second elements in the array
that's because that is how they're passed in the function declaration
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:27
Oh, is that like a predefined thing?
Juan Ocasio
@juanocasio
Jan 16 2016 03:28
not really. Using it in conjuction with the sort basically makes the function iterate through the arr return the smaller of the two values
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:29
So it's not actually returning a - b
Juan Ocasio
@juanocasio
Jan 16 2016 03:29
if you do b-a it will return a sort from largest to smallest
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:29
Just did that about thirty seconds ago
thanks @juanocasio
CamperBot
@camperbot
Jan 16 2016 03:29
codingducky sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:warning: codingducky already gave juanocasio points
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 03:29
what
not fair
Juan Ocasio
@juanocasio
Jan 16 2016 03:29
no worries, @CodingDucky
that's how it works here :)
Mattie
@matsieftw
Jan 16 2016 03:32
This message was deleted
Varulvsnatt
@Varulvsnatt
Jan 16 2016 03:34
thanks @juanocasio a lot! :D
CamperBot
@camperbot
Jan 16 2016 03:34
varulvsnatt sends brownie points to @juanocasio :sparkles: :thumbsup: :sparkles:
:star: 290 | @juanocasio | http://www.freecodecamp.com/juanocasio
Juan Ocasio
@juanocasio
Jan 16 2016 03:34
you're welcome. Did you get it?
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:34
I think JSON objects may give me an aneurysm.
Kevin
@KAlanHicks
Jan 16 2016 03:36
Ha! I think everyone seems to be struggling with JSON objects. Me too. I am stuck on Record Collection. Should I just paste the code here?
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:37
Haha, it might help the both of us get through it. I'm stuck on it, too.
Kevin
@KAlanHicks
Jan 16 2016 03:38
Javascripts syntax just feels so weird for me when it comes to objects. I'll have a peak at your code
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:39
I'm pretty sure I had the wrong idea in reversing the "If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop." and going with (value==="" || prop == "tracks") route. Do you want me to paste it here again? Not sure if you saw the first instance of it I posted.
Kevin
@KAlanHicks
Jan 16 2016 03:39
One thing I already noticed is that you have an if statement that uses a blank value. if (value === "" || prop == "tracks")
You want to make sure it does not use a blank value
Here's where my solution is at, it isn't right either though. "Cannot assign to read only property 'prop'
function update(id, prop, value) {
if (prop !== "tracks" && value !== ""){
return id.prop.value;
}
else if (prop === "tracks" && value !== ""){
id.prop.push(value);
}
else
delete id.prop;
return collection;
}
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:40
WELP. I feel dumb. I misread "non-blank" in the second condition.
Kevin
@KAlanHicks
Jan 16 2016 03:41
haha! It happens to everyone man
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:42
Well, that's a strange error. Where is it being applied?
Kevin
@KAlanHicks
Jan 16 2016 03:42
What do you mean?
wushupork
@wushupork
Jan 16 2016 03:42
@KAlanHicks the only "return" should be the one at the end
Kevin
@KAlanHicks
Jan 16 2016 03:42
oh, okay
wushupork
@wushupork
Jan 16 2016 03:43
and the id is part of collection, so how would you reference that?
Kevin
@KAlanHicks
Jan 16 2016 03:43
collection.id, right?
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:44
I think we can use indexing for the solution. collection[id][prop] is what I'm going to try.
For the first condition at least.
wushupork
@wushupork
Jan 16 2016 03:44
@keccakec correct
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 03:45
Now to figure out how exactly to format it all, haha.
Sami Zaman
@sydszaman
Jan 16 2016 03:48
Modify the welcomeToBooleans function so that it returns true instead of false when the run button is clicked.
Kevin
@KAlanHicks
Jan 16 2016 03:49
Could you show us the code? It's been a bit since I saw that one, but I'm pretty sure it's one I did already
Sami Zaman
@sydszaman
Jan 16 2016 03:49

function welcomeToBooleans() {

// Only change code below this line.

return false; // Change this line

// Only change code above this line.
}

wushupork
@wushupork
Jan 16 2016 03:49
see the line where it says "return false"? what would you have to do to make it return true?
Sami Zaman
@sydszaman
Jan 16 2016 03:50
i serioulsy cant figure it out
its been over 12 hours the i've beeen coding
Kevin
@KAlanHicks
Jan 16 2016 03:50
There is one line to change and it currently says false, try changing that one. Just one word
Sami Zaman
@sydszaman
Jan 16 2016 03:50
im sorry man heads not working at full capacity
japugliese
@japugliese
Jan 16 2016 03:51
I'm having trouble with "Accessing Nested Arrays" can anyone tell me what I'm doing wrong???
Sami Zaman
@sydszaman
Jan 16 2016 03:51
you mean just remove the word "false"?
japugliese
@japugliese
Jan 16 2016 03:51

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

// Only change code below this line

var secondTree = myPlants1.list1; // Change this line

Kevin
@KAlanHicks
Jan 16 2016 03:52
yes, the instructions say to make it return true. That's literally all you have to do. It's just an introduction to a boolean
Stephen Antony
@Stephen-antony
Jan 16 2016 03:52
hello
Sami Zaman
@sydszaman
Jan 16 2016 03:52
thanks man
Stephen Antony
@Stephen-antony
Jan 16 2016 03:52

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

if(a<2 || b<2)
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);

Sami Zaman
@sydszaman
Jan 16 2016 03:53
sorry for wasting your time with such idiotic questions
Stephen Antony
@Stephen-antony
Jan 16 2016 03:53
is something wrong with the if statement here
Sami Zaman
@sydszaman
Jan 16 2016 03:53
and seriouslly thank you soooo much for the help
wushupork
@wushupork
Jan 16 2016 03:53
@Stephen-antony the instructions say what you should be testing for I believe
Kevin
@KAlanHicks
Jan 16 2016 03:54
Never apologize man, most of us are starting out and silly things will get you sometimes
Stephen Antony
@Stephen-antony
Jan 16 2016 03:54
i am doing this "Return Early Pattern for Functions"
wushupork
@wushupork
Jan 16 2016 03:54
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Stephen Antony
@Stephen-antony
Jan 16 2016 03:55
tried that
the negative values output arent coming
wushupork
@wushupork
Jan 16 2016 03:56
undefined is a value, not a string: it's not "undefined", it's just undefined
also your tests are looking for less than 2 in your code, not less than 0
Stephen Antony
@Stephen-antony
Jan 16 2016 03:56
ohh LOL great
@wushupork Thanks lot :)
CamperBot
@camperbot
Jan 16 2016 03:57
stephen-antony sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 286 | @wushupork | http://www.freecodecamp.com/wushupork
Kevin
@KAlanHicks
Jan 16 2016 03:57
Is this idea getting me any closer @wushupork
if (prop !== "tracks" && value !== ""){
collection.id.prop = value;
wushupork
@wushupork
Jan 16 2016 03:59
@KAlanHicks you're closer, but @keccakec had the correct syntax for getting collection[id][prop] above
Kevin
@KAlanHicks
Jan 16 2016 04:00
So it needs brackets? I thought periods were supposed to work too
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:01
You're using a variable
so it should be collection[id][prop]
I think
wushupork
@wushupork
Jan 16 2016 04:01
@KAlanHicks the problem is dot notation is looking for a value of literally "id" and "prop". bracket notation substitutes the proper values e.g. collection[5439]["tracks"]
Nolan A Eliason
@Naeliason
Jan 16 2016 04:03

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

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

how do your code to make it look like it does in the waypoints?
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:04
I'm running into issues with only the "addicted to love" part now. I have no idea what's wrong with my push value : collection[id][prop].push(value);
@Naeliason add  before and after.
Nolan A Eliason
@Naeliason
Jan 16 2016 04:04

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


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


Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:05
Shift enter at the top. I think that's messing with it.
wushupork
@wushupork
Jan 16 2016 04:05
@keccakec that looks right, try refreshing the page and running it again
Stephen Antony
@Stephen-antony
Jan 16 2016 04:05
@Naeliason multidimenstional array should be in the format arr[i][j]
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:05
After the 
Nolan A Eliason
@Naeliason
Jan 16 2016 04:05
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]]);
ahhh gotcha thanks @keccakec
CamperBot
@camperbot
Jan 16 2016 04:06
naeliason sends brownie points to @keccakec :sparkles: :thumbsup: :sparkles:
:star: 219 | @keccakec | http://www.freecodecamp.com/keccakec
Nolan A Eliason
@Naeliason
Jan 16 2016 04:06
and thanks @Stephen-antony for answering before I even asked
CamperBot
@camperbot
Jan 16 2016 04:06
naeliason sends brownie points to @stephen-antony :sparkles: :thumbsup: :sparkles:
:star: 203 | @stephen-antony | http://www.freecodecamp.com/stephen-antony
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:06
No problem, @Naeliason
And @wushupork refreshing didn't seem to work. It is still adding the track to the array correct?
wushupork
@wushupork
Jan 16 2016 04:07
@keccakec what's your code?
Stephen Antony
@Stephen-antony
Jan 16 2016 04:07
@Naeliason Happy to Help :)
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:08
// 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!== "" && collection[id][prop] !=="tracks"){
collection[id][prop] = value;
}
else if (collection[id][prop] === "tracks" && value !== "") {
collection[id][prop].push(value);
}
else if (value==="") {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
@wushupork
wushupork
@wushupork
Jan 16 2016 04:08
@keccakec it should check prop vs. tracks, not collection[id][prop] vs tracks
Kevin
@KAlanHicks
Jan 16 2016 04:10
finally got through it! Thanks @wushupork
CamperBot
@camperbot
Jan 16 2016 04:10
kalanhicks sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 287 | @wushupork | http://www.freecodecamp.com/wushupork
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:10
CamperBot
@camperbot
Jan 16 2016 04:10
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:10
wiki for loop
CamperBot
@camperbot
Jan 16 2016 04:10

## For Loops

The for statement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement or a set of statements executed in the loop.

The for loop has the following syntax:

for ([initialization]; [condition]; [final-expression]) {
code block to be executed
}

[initialization] is executed before the loop (the code block) starts.

[condition] defines the condition for running the loop (the code block).

[final-expression] is executed each time after the loop (the code block) has been executed.

Example in Javascript:


var ourArray = [];
:pencil: read more about for loops explained on the FCC Wiki

Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:11
@wushupork This is making me feel like I should have gone to bed already, but do you mean making it prop === "tracks"?
wushupork
@wushupork
Jan 16 2016 04:11
@keccakec yes
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:13
function factorialize(num) {
var fact = 1;
for (i = num; i == 1; i--){
fact *= i;
}
return fact;
}

That's supposed to factorialize a given 'num'

It does not. Why?

Stephen Antony
@Stephen-antony
Jan 16 2016 04:16
@CodingDucky you didnt close }
Dom
@zocke1r
Jan 16 2016 04:17
@CodingDucky would the condition need to be >0 or >= 1?
wouldn't
Stephen Antony
@Stephen-antony
Jan 16 2016 04:18
@CodingDucky for for loop the second iteration cant be ==
Kevin
@KAlanHicks
Jan 16 2016 04:18
Are you still working on that one we were talking about @keccakec ?
Dom
@zocke1r
Jan 16 2016 04:19
@Stephen-antony it can be if you wan it to run once and only in the case that the iterator is equal to the condition value
in which case an if would be more advisable
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:20
Got it done
How do I remove all the spaces out of a given string?
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:20
@KAlanHicks Yeah, I changed the collection[id][prop] to just prop and it gave the same results.
Stephen Antony
@Stephen-antony
Jan 16 2016 04:20
think it should for(i=1;i<=num;i++)
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:21
yeah i fixed it
wushupork
@wushupork
Jan 16 2016 04:21
@keccakec in both locations? prop === "tracks" and prop !== "tracks" ?
Stephen Antony
@Stephen-antony
Jan 16 2016 04:22
@CodingDucky what changes did you make?
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:22
@wushupork Yeah, I feel like it has to be my push(), but I don't see what I did wrong with it.
wushupork
@wushupork
Jan 16 2016 04:22
did you refresh again?
Kevin
@KAlanHicks
Jan 16 2016 04:22
@keccakec I had the same thing happen to me. I just cleared my code and started fresh and that's what helped me.
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:22
I did the opposite of what you dd
Kevin
@KAlanHicks
Jan 16 2016 04:23
Show us your push @keccakec
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:23
I did i <= 1; i--
I think that's what i did
wushupork
@wushupork
Jan 16 2016 04:23
oh i see it @keccakec
Dom
@zocke1r
Jan 16 2016 04:24
@CodingDucky that wouldnt work you most likely used >=1;i--
Stephen Antony
@Stephen-antony
Jan 16 2016 04:24
@CodingDucky nice
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:24
@wushupork Yeah, at first I thought it was an issue with the ordering of statements, but I guess I'm just getting desperate to see what's wrong, because that did nothing.
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:24
yeah I think that's what I did
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:24
@KAlanHicks @wushupork function update(id, prop, value) { if (collection[id][prop] === "tracks" && value !== "") { collection[id][prop].push(value); } else if (value!== "" && collection[id][prop] !=="tracks"){ collection[id][prop] = value; } else if (value==="") { delete collection[id][prop]; } return collection; }
Well, I guess you can't select portions.
wushupork
@wushupork
Jan 16 2016 04:24
@keccakec try removing the two "else"
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:25
@wushupork Just tried it. Still getting the "After update(1245, "tracks", "Addicted to Love"), tracks should have a length of 1"
wushupork
@wushupork
Jan 16 2016 04:25
wait
you're still using collection[id][prop] === "tracks" in your last paste
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:26
Yeah, I ended up having to copy paste my code from earlier trying something.
@wushupork WAIT ARE YOU SERIOUS
wushupork
@wushupork
Jan 16 2016 04:26
it should be prop === "tracks" and if prop !== "tracks"
Dom
@zocke1r
Jan 16 2016 04:27
wait you are still stuck on the music collection?
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:27
@wushupork So, reordering worked. I just forget to redo it as "prop" and not the full index. Why would the order make that big a difference? Regardless, thanks.
CamperBot
@camperbot
Jan 16 2016 04:27
keccakec sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 288 | @wushupork | http://www.freecodecamp.com/wushupork
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:27
Also, thanks, @KAlanHicks for getting me to think about it a bit more seeing yours.
CamperBot
@camperbot
Jan 16 2016 04:27
keccakec sends brownie points to @kalanhicks :sparkles: :thumbsup: :sparkles:
:star: 224 | @kalanhicks | http://www.freecodecamp.com/kalanhicks
wushupork
@wushupork
Jan 16 2016 04:28
@keccakec I didn't use any elses in mine, just 3 if statements. not sure if that makes a difference or not
Kevin Elser
@CoffeeCodeKevin
Jan 16 2016 04:29
@wushupork Weird. I went back and tested again in the alternate order with the same statements and it failed. Either way, I'm glad to have that done.
Kevin
@KAlanHicks
Jan 16 2016 04:33
Of course @keccakec Thanks for sharing your code, it helped me as well
CamperBot
@camperbot
Jan 16 2016 04:33
kalanhicks sends brownie points to @keccakec :sparkles: :thumbsup: :sparkles:
:star: 221 | @keccakec | http://www.freecodecamp.com/keccakec
Andrew Charlebois
@andrewchar
Jan 16 2016 04:34
stuck on Assignment with Plus Equals for javascript

var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

var a +=12;
var b +=9;
var c +=7;
wushupork
@wushupork
Jan 16 2016 04:36
the variables are already declared above, so you don't need "var " again
Andrew Charlebois
@andrewchar
Jan 16 2016 04:37
@wushupork thanks!
CamperBot
@camperbot
Jan 16 2016 04:37
andrewchar sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 289 | @wushupork | http://www.freecodecamp.com/wushupork
Dom
@zocke1r
Jan 16 2016 04:37
great i just got stuck on a mission for 10mins because of a spelling mistake
Andrew Charlebois
@andrewchar
Jan 16 2016 04:37
i did not know that. i was sure my addition math was not failing me lol
Dom
@zocke1r
Jan 16 2016 04:37
in the return value
@andrewchar well it was not failing you only your knowledge of JS was
and to fix that is the whole point of this thing
Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:44
How do I remove all punctuation marks from a given string?
str = str.replace(/ /g, ''); removes all spaces, what do I add to make it remove punctuation?
wushupork
@wushupork
Jan 16 2016 04:53
@CodingDucky if you're converting to lowercase beforehand, you can just use /[^a-z0-9]/g and it'll replace all but lowercase alpha and numbers
Steven Czechowski
@sczechowski
Jan 16 2016 04:53

Can anyone give me a hand with the Accessing Nested Arrays in JSON waypoint? Code looks like this: // Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line


Jose Dzireh Chong
@CodingDucky
Jan 16 2016 04:53
thanks @wushupork
CamperBot
@camperbot
Jan 16 2016 04:53
codingducky sends brownie points to @wushupork :sparkles: :thumbsup: :sparkles:
:star: 290 | @wushupork | http://www.freecodecamp.com/wushupork
wushupork
@wushupork
Jan 16 2016 04:54
Happy to help
mmacedo
@mmacedoeu
Jan 16 2016 04:54
CamperBot
@camperbot
Jan 16 2016 04:54
:star: 250 | @codingducky | http://www.freecodecamp.com/codingducky
Steven Czechowski
@sczechowski
Jan 16 2016 04:59

Can anyone give me a hand with the Accessing Nested Arrays in JSON waypoint? Code looks like this:


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

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line



hernc
@hernc
Jan 16 2016 05:20
@sczechowski you have to first access the [1] object in myPlants
Marco A.
@Macranius
Jan 16 2016 05:21
Good night everybody
hernc
@hernc
Jan 16 2016 05:22
@sczechowski myPlants[object you want].list[object you want]
Devyn Hedin
@djhedin
Jan 16 2016 05:24
Can anyone help me? I'm on "Introducing JavaScript Object Notation JSON" and I am completely 100% lost on what I'm supposed to do.
Marco A.
@Macranius
Jan 16 2016 05:28
I've been trying to solve Record Collection waypoint, and after some time of frustration, I'm still unable of getting a solution, I'm not sure if is it a problem with my browser or am I really still feeling a bit reluctant about asking for help... Every time i run the test for my code, it's the same every time, I get the full content of "collection", i even tried reseting the code and changed the return for this: return collection[id]; expecting to receive at least one part of the full content, but it's no use, I'm still receiving all the content or no content at all... Is it only me who gets this error? Thank you for anyone who takes the time on reading this.

@djhedin you just need to add another album using the notation for the object:

{
"artist": " ",
"title": " ",
"release_year": ,
"formats": [
" ",
" ",
" " ],
"gold":
}

Devyn Hedin
@djhedin
Jan 16 2016 05:33
What I'm confused on his how I do that. I can create another object with that format but I have no clue how to add it. I tried pushing it like an array and that didn't work.
Marco A.
@Macranius
Jan 16 2016 05:34
just add a comma
between the braces
Devyn Hedin
@djhedin
Jan 16 2016 05:34
I honestly can't believe I didn't think of that...
Marco A.
@Macranius
Jan 16 2016 05:34
for instance

var myObject = [

{
properties....
},
{
properties....
},
{
properties....
},

]

;
jdubdigi
@jdubdigi
Jan 16 2016 05:36

@Youakeem Hi, as an addition to your code I included the .hasOwnProperty(propname) method of objects to find out if that objects (gift, pet, or bed) have the given property names ("pony", "kitten", or "sleigh"). The solution is below: // Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty("pet");
myObj.hasOwnProperty("bed");

if(myObj.hasOwnProperty(checkProp)) {
result = myObj[checkProp];

} else {
}
return result;
}

// Test your code by modifying these values

Devyn Hedin
@djhedin
Jan 16 2016 05:39
@Macranius Thanks man, I can't believe I complicated it so much. A lot easier than I thought.
CamperBot
@camperbot
Jan 16 2016 05:39
djhedin sends brownie points to @macranius :sparkles: :thumbsup: :sparkles:
:star: 257 | @macranius | http://www.freecodecamp.com/macranius
Marco A.
@Macranius
Jan 16 2016 05:39
@djhedin you're wellcome
Marco A.
@Macranius
Jan 16 2016 06:06

I've been trying to solve Record Collection waypoint, and after some time of frustration, I'm still unable of getting a solution, I'm not sure if is it a problem with my browser or am I really still feeling a bit reluctant about asking for help... Every time i run the test for my code, it's the same every time, I get the full content of "collection", i even tried reseting the code and changed the return for this: return collection[id]; expecting to receive at least one part of the full content, but it's no use, I'm still receiving all the content or no content at all... Is it only me who gets this error? Thank you for anyone who takes the time on reading this.

By the way... I already solved this, so thanks anyway. To whoever tries to help me on that, it's not needed anymore.

Dom
@zocke1r
Jan 16 2016 06:22
anyone else trying to squeeze the solutions for the basic algorithms challenges all in one line?
or is that just me?
Kevin Voshell
@kvoshell
Jan 16 2016 06:28
Ok, so...'Nesting For Loops'...am I on the right track here? Having trouble getting this to go
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (i = [0]; i < multiplyAll.length; i++)
for (j = 0; j < [i].length; j++)
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]]);
Should mention I removed the [] in 'i=[0], was a typo
Marco A.
@Macranius
Jan 16 2016 06:32
@Payne1006 In both for loops, you should be comparing to "arr" length properties, arr.length and arr[i].length. It is also necesary that you make the product, not just to asign different values to your product variable
@Payne1006 try: product= (arr[i][j]); or product = product (arr[i][j]);
I can't type the star...
/*
Kevin Voshell
@kvoshell
Jan 16 2016 06:34
 product=(arr[i]*[j]);
?
@Macranius
Marco A.
@Macranius
Jan 16 2016 06:34
no, before the assignation
product STAR= (arr[i]*[j]);
...
again
product STAR= (arr[i][j]);
Kevin Voshell
@kvoshell
Jan 16 2016 06:35
AH!
Yes, this works. I need to dig into some more information so I can fully understand (not sure why it works :smile: ), but thank you! @Macranius
CamperBot
@camperbot
Jan 16 2016 06:36
payne1006 sends brownie points to @macranius :sparkles: :thumbsup: :sparkles:
:star: 260 | @macranius | http://www.freecodecamp.com/macranius
Marco A.
@Macranius
Jan 16 2016 06:38
@Payne1006 nesting for loops is like reading the hour in an analog clock, the innermost of the cycles goes faster than the outermost
the "product" variable stores the multiplication of every single element, once on each iteration of every loop
Kevin Voshell
@kvoshell
Jan 16 2016 06:44
I appreciate the comparison @Macranius , visualizing it this way does help to understand the concept
Marco A.
@Macranius
Jan 16 2016 06:45
Beau
@Beauvelop
Jan 16 2016 06:47
Hello campers. Brownie for your thoughts...(?). (I've got a quick Q. about a single line of .js)
(it's from "record collection")

function update(id, prop, value) {
if (value !== "" && prop != "tracks") {

//update or set the value for the prop.
collection.id[prop].push(value);
Anyone able to gimme a hand?
I just want to know whether it will do what is instructed...
Marco A.
@Macranius
Jan 16 2016 06:49
I had exactly the same problem...
Beau
@Beauvelop
Jan 16 2016 06:49
(which is "update or set the value for the prop")
hmm.
Marco A.
@Macranius
Jan 16 2016 06:49
its just an assignation
Beau
@Beauvelop
Jan 16 2016 06:49
so... did you solve it?
Dave
@dloyst
Jan 16 2016 06:50

Trying to figure out why this won't work on the lookup exercise:

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

Beau
@Beauvelop
Jan 16 2016 06:50
That last line of code, you mean? @Macranius
Marco A.
@Macranius
Jan 16 2016 06:51
if (value!== "" && prop !=="tracks")
collection[id][prop] = value;
Beau
@Beauvelop
Jan 16 2016 06:51
collection.id[prop].push(value);
This is an assignment statement?
right.
yet push, it would seem...
right?
--so I would be on the right track?
Ah... I see [ ] hmm.
@Macranius --You around?
Marco A.
@Macranius
Jan 16 2016 06:54
It's just a sequence of if statements, something more less like this
if (value!== "" && prop !=="tracks")
collection[id][prop] = value;
if (prop === "tracks" && value !== "")
collection[id][prop].push(value);
if (value==="")
delete collection;
return collection;
}
Beau
@Beauvelop
Jan 16 2016 06:54
hm...
Marco A.
@Macranius
Jan 16 2016 06:55
sorry for the last }
it's the end of the function
Beau
@Beauvelop
Jan 16 2016 06:55
thanks @Macranius that is a huge help... I wish I understood it more.
CamperBot
@camperbot
Jan 16 2016 06:55
leofib sends brownie points to @macranius :sparkles: :thumbsup: :sparkles:
:star: 261 | @macranius | http://www.freecodecamp.com/macranius
Beau
@Beauvelop
Jan 16 2016 06:55
right :)
I'll have to study it more carefully.
Marco A.
@Macranius
Jan 16 2016 06:55
i had a long fight with that one
Beau
@Beauvelop
Jan 16 2016 06:56
Ugh... well you won! :)
Have you ever been to san miguel?
I've never been to mexico, but I've heard its gorgeous.
It's freezing up here.
Dom
@zocke1r
Jan 16 2016 06:56
are the time estimates totally off? or am i doing way to easy stuff for my knowledge lvl considering i'm on the second last basic algorithm after like 2hours on and off?
Marco A.
@Macranius
Jan 16 2016 06:56
In fact I was there about half year ago
Dave
@dloyst
Jan 16 2016 06:56
Trying to figure out why this first code won't run, but the second one will:
Beau
@Beauvelop
Jan 16 2016 06:57
Wish I were coding in some warmth.... well thanks very much again!
Muchas Gracias!
Marco A.
@Macranius
Jan 16 2016 06:57
San Miguel de Allende Guanajuato?
Beau
@Beauvelop
Jan 16 2016 06:58
Yo no say (?) Ugh.. my Javascript is better than my spanish...
(actually they both suck)...
anyway...
Marco A.
@Macranius
Jan 16 2016 06:58
hehe, I guess is just about commitment
Beau
@Beauvelop
Jan 16 2016 06:58
I think that is the place. yes.
Marco A.
@Macranius
Jan 16 2016 06:58
I'm still learning too
Beau
@Beauvelop
Jan 16 2016 06:58
Right.
Marco A.
@Macranius
Jan 16 2016 06:58
(spanish too sometimes...)
Beau
@Beauvelop
Jan 16 2016 06:59
:D
Okay.. I'm going to put my eyeballs on your code.
thanks again!
Take care... I've got studying to do.
:D
Marco A.
@Macranius
Jan 16 2016 06:59
Same to you
Beau
@Beauvelop
Jan 16 2016 06:59
Jon Grant
@jong649
Jan 16 2016 07:07
Profile Lookup
hint
CamperBot
@camperbot
Jan 16 2016 07:07
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Dom
@zocke1r
Jan 16 2016 07:10
great i just had a moment where my debug logging actually caused the bug
is was trying to solve
Jon Grant
@jong649
Jan 16 2016 07:23
Has anyone done Profile Lookup yet?
I'm wondering what I'm doing wrong here?
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++){
console.log(contacts[i][prop]);
if(contacts[i].firstName !== firstName){
return "No such contact";
}
if(contacts[i][prop] === undefined){
return "No such property";
}
else if(contacts[i].firstName === firstName && contacts[i][prop] === prop){
return contacts[i][prop];
}
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Jan 16 2016 07:30
Hi budies, am having difficulty solving this:
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Jon Grant
@jong649
Jan 16 2016 07:30
@Saladg can you show us your code?
Jan 16 2016 07:32
var myStr; // Change this line
This is what i tried:
var myStr="\\ \t\t\ \r\ \n\ "; // Change this line
Jon Grant
@jong649
Jan 16 2016 07:33
@Saladg if I remember correctly, you need to use \ as an escape character to do all that
@Saladg did you put a space between the \t \t
Jan 16 2016 07:34
@jong649 , no
Jon Grant
@jong649
Jan 16 2016 07:34
@Saladg i think it wants a space between each character
Jan 16 2016 07:35
ok let me try
Jon Grant
@jong649
Jan 16 2016 07:35
@Saladg so like "\ \t \t \r \n
@Saladg What's the name of that one? I can look at my code
Jan 16 2016 07:36
@jong649 "Escape Sequences in Strings" JS section
Jon Grant
@jong649
Jan 16 2016 07:38
@Saladg ok, so you almost have it, you only need the backslashes before, not after
var myStr="\ \t \t \r \n ";
@Saladg for some reason it's removing the double backslash on first one, but that's it; you just had a few too many backslashes
var myStr="\\ \t \t \r \n";
Jan 16 2016 07:41
@jong649 , Thanks bro.
It worked
CamperBot
@camperbot
Jan 16 2016 07:41
saladg sends brownie points to @jong649 :sparkles: :thumbsup: :sparkles:
:star: 310 | @jong649 | http://www.freecodecamp.com/jong649
Jon Grant
@jong649
Jan 16 2016 07:41
@Saladg no problem, you almost had it :)
LYF
@pod4g
Jan 16 2016 07:54
hello world!
CamperBot
@camperbot
Jan 16 2016 07:54

## welcome to FreeCodeCamp @pod4g!

LYF
@pod4g
Jan 16 2016 07:55
hello everyone
Is there someone here?
tamnil
@tamnil
Jan 16 2016 08:04
bonfire pair
CamperBot
@camperbot
Jan 16 2016 08:04

## :fire:Waypoint: Pair Program on Bonfires :link:

119657641

Please note that the video for this challenge is a little outdated, and doesn't perfectly match these steps. We plan to record a new video soon.

more info:  bf details | bf links | hint

tamnil
@tamnil
Jan 16 2016 08:04
help bonfire pair
CamperBot
@camperbot
Jan 16 2016 08:04

# Explanation:

The program should look for the numbers in the array which would add to make the number from the arg. Then instead of adding those numbers up, you will add their indices which is the reason why you get 11 on the example from detail.

Remember that arrays start at index 0 and go from there so from [1,4,2,3,0,5] if we switch to their indices it would be [0,1,2,3,4,5] then we add indices 1 + 2 + 3 + 5 and we get 11. That is what we need to return.

tamnil
@tamnil
Jan 16 2016 08:05
@pod4g hi!
bf details
CamperBot
@camperbot
Jan 16 2016 08:06

## :fire:Waypoint: Pair Program on Bonfires :link:

119657641
Please note that the video for this challenge is a little outdated, and doesn't perfectly match these steps. We plan to record a new video soon.
OK, we're finally ready to start pair programming!
Pair Programming is where two people code together on the same computer. It is an efficient way to collaborate, and widely practiced at software companies. Pair Programming is one of the core concepts of "Agile" Software Development, which you will hear more about later.
Many people use Skype or Google Hangouts to pair program, but if you talk with professional software engineers, they will tell you that it's not really pair programming unless both people have the ability to use the keyboard and mouse.
The most popular tool for pair programming is Screenhero. You can download Screenhero for <a href='http://links.screenhero.com/e/c/eyJlbWFpbF9pZCI6Ik1qQTNNem9XQkNJQ1pBQUNjd0FYQVZrVEdnRkxNamtfX0JWZEdGVEpSZkVCWlRwbFpXRTBNamM0WVMxaE56SmlMVEV4WlRRdE9HUXpZUzFpWXpVNE1HRTJNalkxTldNNk1UUTJNVEEyQUE9PSIsInBvc2l0aW9uIjowLCJocmVmIjoiaHR0cDovL2RsLnNjcmVlbmhlcm8uY29tL3NtYXJ0ZG93bmxvYWQvZklYQU1UUUJBTEtQQkhQTC9TY3JlZW5oZXJvLnppcD9zb3VyY2U9d2ViIn0=' target='_blank'>Mac</a> or <a href='http://links.screenhero.com/e/c/eyJlbWFpbF9pZCI6Ik1qQTNNem9XQkNJQ1pBQUNjd0FYQVZrVEdnRkxNamtfX0JWZEdGVEpSZkVCWlRwbFpXRTBNamM0WVMxaE56SmlMVEV4WlRRdE9HUXpZUzFpWXpVNE1HRTJNalkxTldNNk1UUTJNVEEyQUE9PSIsInBvc2l0aW9uIjoxLCJocmVmIjoiaHR0cDovL2RsLnNjcmVlbmhlcm8uY29tL3NtYXJ0ZG93bmxvYWQvZklYQU1UUUJBTEtQQkhQTC9TY3JlZW5oZXJvLXNldHVwLmV4ZSJ9' target='_blank'>Windows</a>. Create your new user account from within the app.
We have a special chat room for people ready to pair program. Go to our <a href='//gitter.im/FreeCodeCamp/LetsPair' target='_blank'>LetsPair chatroom on Gitter</a> and type "Hello Pair Programmers!"
If someone is available, they will be your "pair" - the person you pair programming with.
If no one gets back to you in the first few minutes, don't worry. There will be lots of opportunities to pair program in the future.
If someone does get back to you, private message them and ask for the email address they used to register Screenhero.
Add them as a new contact in Screenhero, then click the monitor-looking button to attempt to share your screen with them.
Once the Screenhero session starts, your screen's margins will glow orange. You are now sharing your screen.
Your pair will have their own cursor, and will be able to type text on his or her keyboard.
Now it's time to tackle our Bonfires. You can begin them by advancing to the next challenge.
Once you you finish pair programming, end the session in Screenhero session.
Congratulations! You have completed your first pair programming session.
Pair program as much as possible with different campers until you've completed all the Bonfire challenges. This is a big time investment, but the JavaScript practice you get will be well worth it!
Mark this Waypoint complete and move on.
hernc
@hernc
Jan 16 2016 08:06
@jong649 any luck with the profile lookup?
tamnil
@tamnil
Jan 16 2016 08:07
bonfire pairwise
CamperBot
@camperbot
Jan 16 2016 08:07

## :fire:Bonfire: Pairwise :link:

function pairwise(arr, arg) {
return arg;
}

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

Return the sum of all indices of elements of 'arr' that can be paired with one other element to form a sum that equals the value in the second argument 'arg'. If multiple sums are possible, return the smallest sum. Once an element has been used, it cannot be reused to pair with another.

more info:  bf details | bf links | hint

tamnil
@tamnil
Jan 16 2016 08:07
bf details
CamperBot
@camperbot
Jan 16 2016 08:07

## :fire:Bonfire: Pairwise :link:

function pairwise(arr, arg) {
return arg;
}

pairwise([1,4,2,3,0,5], 7);
Return the sum of all indices of elements of 'arr' that can be paired with one other element to form a sum that equals the value in the second argument 'arg'. If multiple sums are possible, return the smallest sum. Once an element has been used, it cannot be reused to pair with another.
For example, pairwise([1, 4, 2, 3, 0, 5], 7) should return 11 because 4, 2, 3 and 5 can be paired with each other to equal 7.
pairwise([1, 3, 2, 4], 4) would only equal 1, because only the first two elements can be paired to equal 4, and the first element has an index of 0!
Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>RSAP</a> if you get stuck. Try to pair program. Write your own code.
tamnil
@tamnil
Jan 16 2016 08:09
hint
CamperBot
@camperbot
Jan 16 2016 08:09
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Deekshit.B.N
@deek28
Jan 16 2016 08:10
how do i do the Waypoint:Record Collection ,under the Javascript heading/
?
hernc
@hernc
Jan 16 2016 08:11
@deek28 wiki record collection
use a for loop with nested if statements
CamperBot
@camperbot
Jan 16 2016 08:12

# Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), 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.

Always return the entire collection object.

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

Deekshit.B.N
@deek28
Jan 16 2016 08:15
thanks @hernc
CamperBot
@camperbot
Jan 16 2016 08:15
deek28 sends brownie points to @hernc :sparkles: :thumbsup: :sparkles:
:star: 225 | @hernc | http://www.freecodecamp.com/hernc
Deekshit.B.N
@deek28
Jan 16 2016 08:17
wiki Profile Lookup
CamperBot
@camperbot
Jan 16 2016 08:17

# Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

fluffystub
@RakshithNM
Jan 16 2016 08:32
Accessing Nested Arrays in JSON
hernc
@hernc
Jan 16 2016 08:33
@deek28 did it work?
fluffystub
@RakshithNM
Jan 16 2016 08:33

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

// Only change code below this line

var secondTree = "myPlants.type.list[2]";

how is this done?
hernc
@hernc
Jan 16 2016 08:35
@RakshithNM you should access trees the same way you are accessing list but your index is wrong also
myPlants[]list[]
Arpit Agarwal
@arpit016
Jan 16 2016 08:45
@jong649 did your profile lookup code worked?
Your code has problem in the return statement
@jong649 return "No such contact" after for loop ends
Ashraf Ali
@ashrafmscs
Jan 16 2016 08:50
@RakshithNM check it as myPlants[].list[]; give index also
fluffystub
@RakshithNM
Jan 16 2016 08:57
@hernc @ashrafmscs thanks guys
CamperBot
@camperbot
Jan 16 2016 08:57
rakshithnm sends brownie points to @hernc and @ashrafmscs :sparkles: :thumbsup: :sparkles:
:star: 236 | @ashrafmscs | http://www.freecodecamp.com/ashrafmscs
:star: 226 | @hernc | http://www.freecodecamp.com/hernc
hernc
@hernc
Jan 16 2016 09:01
no problem. @RakshithNM
Ashraf Ali
@ashrafmscs
Jan 16 2016 09:03
you are welcome @RakshithNM
Jan 16 2016 09:05

Hello guys,
having problem solving this:
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");

wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
kanwerjeet singh virk
@rockye22
Jan 16 2016 09:09
the challange is =(Stand in Line) function queue(arr, item) {
// Your code here
arr.push(item);
return arr.shift(); // Change this line
}
what is wrong
?
Deekshit.B.N
@deek28
Jan 16 2016 09:14
wiki reverse a string
CamperBot
@camperbot
Jan 16 2016 09:14

# Problem Explanation:

You need to take the string and reverse it so if you had originally 'hello', it will turn into 'olleh'. Because you will need to split it, you will be working with Arrays too.

Deekshit.B.N
@deek28
Jan 16 2016 09:14
yes @hernc
Brian
@sludge256
Jan 16 2016 09:18
@rockye22 try refreshing the page
or restarting your browser
fluffystub
@RakshithNM
Jan 16 2016 09:19
Record Collection

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

}
else if(prop==tracks && value!==""){
tracks.push(value);
}
else if(value ==="")
delete prop[""] ;

return collection;
}

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

Deekshit.B.N
@deek28
Jan 16 2016 09:21
@RakshithNM , u have to specify the object name
like
instead of delete prop
it shouldbe delete collection[id[prop]
getit?
fluffystub
@RakshithNM
Jan 16 2016 09:23
@deek28 thank you
CamperBot
@camperbot
Jan 16 2016 09:23
rakshithnm sends brownie points to @deek28 :sparkles: :thumbsup: :sparkles:
:star: 248 | @deek28 | http://www.freecodecamp.com/deek28
fluffystub
@RakshithNM
Jan 16 2016 09:24
@deek28 can you tell me how to do this?
If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop
collection[id[prop]] = value ;
this way?'
Deekshit.B.N
@deek28
Jan 16 2016 09:25
collection[id][prop] = value;
fluffystub
@RakshithNM
Jan 16 2016 09:27
update(2548, "artist", ""); for this test i get Reference error
why?
@deek28
tamnil
@tamnil
Jan 16 2016 09:29
help pairwise
CamperBot
@camperbot
Jan 16 2016 09:29

# Explanation:

The program should look for the numbers in the array which would add to make the number from the arg. Then instead of adding those numbers up, you will add their indices which is the reason why you get 11 on the example from detail.

Remember that arrays start at index 0 and go from there so from [1,4,2,3,0,5] if we switch to their indices it would be [0,1,2,3,4,5] then we add indices 1 + 2 + 3 + 5 and we get 11. That is what we need to return.

tamnil
@tamnil
Jan 16 2016 09:30
elp pairise
hernc
@hernc
Jan 16 2016 09:31
thanks @leftynaut for your help with Checkpoint: Profile Lookup
CamperBot
@camperbot
Jan 16 2016 09:31
hernc sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 385 | @leftynaut | http://www.freecodecamp.com/leftynaut
fluffystub
@RakshithNM
Jan 16 2016 09:35
help record collection
CamperBot
@camperbot
Jan 16 2016 09:35

# Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), 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.

Always return the entire collection object.

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

Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:35
help profile lookup
CamperBot
@camperbot
Jan 16 2016 09:35

# Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

fluffystub
@RakshithNM
Jan 16 2016 09:37

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop==tracks && value!==""){
tracks.push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

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

Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:38
@RakshithNM what's your problem?
@RakshithNM you push the value onto the end of the tracks array incorrectly, the tracks are in the collection, so you should firstly address to a collection
fluffystub
@RakshithNM
Jan 16 2016 09:43

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop===tracks && value!==""){
collection[id][prop].push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

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

@ierhyna i did that
it doesnt work
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:43
what is the error?
fluffystub
@RakshithNM
Jan 16 2016 09:43
reference error
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:43
try: collection[id].tracks.push(value);
fluffystub
@RakshithNM
Jan 16 2016 09:43

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop===tracks && value!==""){
collection[id][prop].push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

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

update(2548, "artist", "")
this is the test value
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:44
@RakshithNM could you please use  to format the code? it's unreadable now
fluffystub
@RakshithNM
Jan 16 2016 09:45
@ierhyna i dont know how to
use ''' where?
CamperBot
@camperbot
Jan 16 2016 09:45
:bulb: to format code use backticks!  more info
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:46
@RakshithNM look at M button at the right
fluffystub
@RakshithNM
Jan 16 2016 09:46


// Alter values below to test your code
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop===tracks && value!==""){
collection[id].tracks.push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

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

Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:47
@RakshithNM put  at the end of the code too :)
fluffystub
@RakshithNM
Jan 16 2016 09:47
// Alter values below to test your code
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop===tracks && value!==""){
collection[id].tracks.push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

// Alter values below to test your code
update(2548, "artist", "");
@ierhyna thanks for your patience to teach :+1:
CamperBot
@camperbot
Jan 16 2016 09:48
rakshithnm sends brownie points to @ierhyna :sparkles: :thumbsup: :sparkles:
:star: 261 | @ierhyna | http://www.freecodecamp.com/ierhyna
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:48
@RakshithNM now I see ) You've missed the curly brackets at the last else if
fluffystub
@RakshithNM
Jan 16 2016 09:49
it doesnt work even now
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:51
@RakshithNM also, at the first else if you should write prop=== "tracks" - with quotes, because it is a string
leorczhu
@leorczhu
Jan 16 2016 09:51
hi Urobert, i got it figured out now, its the -13 and + 13 part that caused the error in output, my failure to understand the task properly. thank you for your assistance and the other gentleman too! jez these chats going down fast i cant even find the names in chat history
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:53
@RakshithNM and I think it would be better to use == instead of === everywhere, because you dont need to check the type of variables
zyggymaroo
@zyggymaroo
Jan 16 2016 09:53

the task "use conditional logic with if statements" the following is code: // Setup
function myFunction(testMe) {

// Only change code below this line.

if (wasThatTrue<10){
return "That was true";
}
return "That was false";
// Only change code above this line.

}

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

fluffystub
@RakshithNM
Jan 16 2016 09:53
== gives me error
@ierhyna
zyggymaroo
@zyggymaroo
Jan 16 2016 09:54
myFunction(false) is not returning "That was false" but everything else is working
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:54
@RakshithNM which one?
hernc
@hernc
Jan 16 2016 09:54
@RakshithNM are you not missing a for loop to wrap those if & elseif? thats how I solved it but then again there are many ways to skin this cat!
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:55
@hernc @RakshithNM no need to use for loop here
fluffystub
@RakshithNM
Jan 16 2016 09:56
@ierhyna @hernc it looks fine with my knowledge until now
i feel the code satisfies it
hernc
@hernc
Jan 16 2016 09:56
@RakshithNM did it pass?
fluffystub
@RakshithNM
Jan 16 2016 09:56
no
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:56
@hernc @RakshithNM I could share my solution, but I don't know if it is not cheating?
fluffystub
@RakshithNM
Jan 16 2016 09:57
@ierhyna dont share
teach me
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:57
@RakshithNM ok
fluffystub
@RakshithNM
Jan 16 2016 09:57
itll stay with me then
guys i got it
Irina Sokolovskaja
@ierhyna
Jan 16 2016 09:58
@RakshithNM congrats ))
CatNipples98
@CatNipples98
Jan 16 2016 09:59

can someone help me here?

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

i really don't understand what the instruction is telling me to do

fluffystub
@RakshithNM
Jan 16 2016 09:59

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop=="tracks" && value!==""){
collection[id][prop].push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

// Alter values below to test your code
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(value!==""){
collection[id].tracks.push(value);
}
else if(value ==="") {
delete collection[id][prop] ;
}

return collection;
}

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



hernc
@hernc
Jan 16 2016 09:59
oh ok sorry i just refrenced back and realized no loop necessary
fluffystub
@RakshithNM
Jan 16 2016 09:59
its else if
why didnt the formatting work?

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop=="tracks" && value!==""){
collection[id][prop].push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

// Alter values below to test your code
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(value!==""){
collection[id].tracks.push(value);
}
else if(value ==="") {
delete collection[id][prop] ;
}

return collection;
}

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



Irina Sokolovskaja
@ierhyna
Jan 16 2016 10:00
@RakshithNM to make formatting work, write the code from the new line after the 
Zina Astafyeva
@tragetraje
Jan 16 2016 10:01
@ierhyna @RakshithNM I'm looking for help with the same exercise...
fluffystub
@RakshithNM
Jan 16 2016 10:02
@tragetraje yes post your code
hernc
@hernc
Jan 16 2016 10:02
@RakshithNM ok how about hints? it takes 2 nested if statements. I don't know how to explain the logic behind the layout of the arguments
Zina Astafyeva
@tragetraje
Jan 16 2016 10:02
don't understand why should i have  at the end...
Aaron Osteraas
@aosteraas
Jan 16 2016 10:02
help Generate Random Whole Numbers within a Range
CamperBot
@camperbot
Jan 16 2016 10:02

# Generate Random Whole Numbers within a Range

We can use a certain mathematical expression to get a random number between two numbers.

Math.floor(Math.random() * (max - min + 1)) + min

See Also: :scroll: Explanation | Explanation in SO

hernc
@hernc
Jan 16 2016 10:03
@tragetraje its required for syntax coloring and formatting
fluffystub
@RakshithNM
Jan 16 2016 10:03
@hernc the hints are for?
Zina Astafyeva
@tragetraje
Jan 16 2016 10:03
hm...was it stated in one of the classes before?
Irina Sokolovskaja
@ierhyna
Jan 16 2016 10:03
@RakshithNM hints are the solutions
hernc
@hernc
Jan 16 2016 10:04
jaja
Zina Astafyeva
@tragetraje
Jan 16 2016 10:04
hm...i was wondering if a new variable should be introduced iin the beginning...like var collection_id = collection.id[value];
fluffystub
@RakshithNM
Jan 16 2016 10:05
@ierhyna @hernc thanks alot...i almost forgot
CamperBot
@camperbot
Jan 16 2016 10:05
rakshithnm sends brownie points to @ierhyna and @hernc :sparkles: :thumbsup: :sparkles:
:warning: rakshithnm already gave ierhyna points
:star: 228 | @hernc | http://www.freecodecamp.com/hernc
hernc
@hernc
Jan 16 2016 10:05
@RakshithNM did it work?
fluffystub
@RakshithNM
Jan 16 2016 10:05
@hernc it worked bro
hernc
@hernc
Jan 16 2016 10:06
@camperbot is there a way to forward brownie points!!
these belong to the person that helped me!!
rphares
@rphares
Jan 16 2016 10:06
What do you mean, @hernc ?
You can thank them with @name, and they'll get brownies...
CamperBot
@camperbot
Jan 16 2016 10:07
rphares sends brownie points to @name :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for name
fluffystub
@RakshithNM
Jan 16 2016 10:07
@hernc i am trying to paste the code here but unable!!!
hey @rphares
hernc
@hernc
Jan 16 2016 10:08
jus kidding but it would be cool to be able to tag the original person that helped me with a problem that I am getting thanks for
rphares
@rphares
Jan 16 2016 10:08
Are you trying to format, @RakshithNM ?
fluffystub
@RakshithNM
Jan 16 2016 10:08
yes @rphares
it worked once
rphares
@rphares
Jan 16 2016 10:08
Okay, let's practice with something small so it doesn't spam the chat :)
you found  , right?
fluffystub
@RakshithNM
Jan 16 2016 10:09
:smile: yes i did that
now the code it large and i am unable to send
rphares
@rphares
Jan 16 2016 10:09
okay-- then shift and enter at the same time, and a sec d row should come up,
fluffystub
@RakshithNM
Jan 16 2016 10:09
*is
rphares
@rphares
Jan 16 2016 10:09
one issue that often causes problems if that the  need one line,
you cannot type Code here other stuff
you must have 
code here
other stuff
fluffystub
@RakshithNM
Jan 16 2016 10:10
@rphares i did not understand
ill try once
rphares
@rphares
Jan 16 2016 10:10
Try using just online of fake code,
fluffystub
@RakshithNM
Jan 16 2016 10:10

 // Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop=="tracks" && value!==""){
collection[id][prop].push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

// Alter values below to test your code
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(value!==""){
collection[id].tracks.push(value);
}
else if(value ==="") {
delete collection[id][prop] ;
}

return collection;
}

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



rphares
@rphares
Jan 16 2016 10:11
@RakshithNM --the problem is the first line
fluffystub
@RakshithNM
Jan 16 2016 10:11
"online of fake code" what does that mean?
first line?
hernc
@hernc
Jan 16 2016 10:11
one way its simpler to understand if you look at the js as tags. anything in between these tags gets formatted
rphares
@rphares
Jan 16 2016 10:11
see how  // Setup
you must have
hernc
@hernc
Jan 16 2016 10:11
sorry
rphares
@rphares
Jan 16 2016 10:11
This message was deleted
hernc
@hernc
Jan 16 2016 10:11
my  didn't come out
rphares
@rphares
Jan 16 2016 10:12
you must have

// Setup
the  and the first line of code (///Setup) cannot be in one row
after  you Must press shift enter and paste the code in a new line
fluffystub
@RakshithNM
Jan 16 2016 10:13
k once i do that i am unable to send
hernc
@hernc
Jan 16 2016 10:13
@RakshithNM your missing the js after the first three 
rphares
@rphares
Jan 16 2016 10:13
then, you are in code mode, not convo mode,
so to send, try command and enter at once,
not just enter , @RakshithNM
fluffystub
@RakshithNM
Jan 16 2016 10:14
are u on ios?
rphares
@rphares
Jan 16 2016 10:14
yep :)
fluffystub
@RakshithNM
Jan 16 2016 10:15
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(prop=="tracks" && value!==""){
collection[id][prop].push(value);
}
else if(value ==="")
delete collection[id][prop] ;

return collection;
}

// Alter values below to test your code
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}
else if(value!==""){
collection[id].tracks.push(value);
}
else if(value ==="") {
delete collection[id][prop] ;
}

return collection;
}

// Alter values below to test your code
update(2548, "artist", "");
rphares
@rphares
Jan 16 2016 10:15
That's why, its a Mac thing i believe :)
fluffystub
@RakshithNM
Jan 16 2016 10:15
yessssssssssss
rphares
@rphares
Jan 16 2016 10:15
Tada! You got it! Great job, @RakshithNM :)
fluffystub
@RakshithNM
Jan 16 2016 10:15
there you go
its ctrl +enter
rphares
@rphares
Jan 16 2016 10:15
ah, oops :blush:
fluffystub
@RakshithNM
Jan 16 2016 10:15
:smile: thanks a lot
rphares
@rphares
Jan 16 2016 10:15
well, you got it either way-- kudos :)
fluffystub
@RakshithNM
Jan 16 2016 10:15
thanks man
hernc
@hernc
Jan 16 2016 10:15
shift enter works on my mac also
rphares
@rphares
Jan 16 2016 10:16
Anytime~
fluffystub
@RakshithNM
Jan 16 2016 10:16
@hernc thanks, you tried as well :smile:
CamperBot
@camperbot
Jan 16 2016 10:16
rakshithnm sends brownie points to @hernc :sparkles: :thumbsup: :sparkles:
:warning: rakshithnm already gave hernc points
hernc
@hernc
Jan 16 2016 10:18
@RakshithNM jaja what finally worked for you i know for me i put my code between  js 
Brian
@sludge256
Jan 16 2016 10:18
@rphares tanks for branching out
CamperBot
@camperbot
Jan 16 2016 10:18
sludge256 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1531 | @rphares | http://www.freecodecamp.com/rphares
hernc
@hernc
Jan 16 2016 10:19


rphares
@rphares
Jan 16 2016 10:19
This message was deleted
This message was deleted
Brian
@sludge256
Jan 16 2016 10:20
I've actually been busy ish at work recently :P
less time for typing out explanations
rphares
@rphares
Jan 16 2016 10:21
hahaha, you should have seen the start with no bot here... and new people sent directly when they press help :wink2:
Thank @brainyfarm and @bkinahan for responding when i begged for others to join trying to field all the qs in this room i didn't belong in when there were no brownies... i met three amazing campers who were already here and pitched in all day as well. :)
CamperBot
@camperbot
Jan 16 2016 10:23
rphares sends brownie points to @brainyfarm and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 631 | @bkinahan | http://www.freecodecamp.com/bkinahan
:star: 1074 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
fluffystub
@RakshithNM
Jan 16 2016 10:32
help Nesting For Loops
CamperBot
@camperbot
Jan 16 2016 10:32

# 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

Olawale Akinseye
@brainyfarm
Jan 16 2016 10:33
Awesome @rphares
We are at the meetup now :)
fluffystub
@RakshithNM
Jan 16 2016 10:33
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(i=0;i<arr.length;i++){
for(j=0;j<arr[i].length;j++){
arr[i] = arr[j]* arr[j+1];
}
product= arr[i]* product;
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
how is it done?
@hernc
Olawale Akinseye
@brainyfarm
Jan 16 2016 10:34
@RakshithNM
You could access items in your multi-dimensional array like this arr[i][j]
fluffystub
@RakshithNM
Jan 16 2016 10:34
anyone?
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr @brainyfarm
that is what is asked
Olawale Akinseye
@brainyfarm
Jan 16 2016 10:36
And remember the multiplication would be done inside your second for loop @RakshithNM
fluffystub
@RakshithNM
Jan 16 2016 10:36
got it bro...
@brainyfarm thanks
CamperBot
@camperbot
Jan 16 2016 10:36
rakshithnm sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1075 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
hernc
@hernc
Jan 16 2016 10:37
@RakshithNM check your logic in your second for loop you should be setting product
Yasin Yusuf
@YasinYA
Jan 16 2016 10:43
Hi everyone
can anyone help me with this waypiont http://www.freecodecamp.com/challenges/record-collection
just explian for me and give me a head up
Dave
@silv3rsc0rpion
Jan 16 2016 10:45

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;

How do i assign a to b with = ? :)
Yasin Yusuf
@YasinYA
Jan 16 2016 10:46
@silv3rsc0rpion js var a = 7; var b = a;
that is it
Dave
@silv3rsc0rpion
Jan 16 2016 10:47
Ahh thanks YasinYa
Yasin Yusuf
@YasinYA
Jan 16 2016 10:47
NP @silv3rsc0rpion
Aaron Osteraas
@aosteraas
Jan 16 2016 10:54
help iterate over arrays with map
CamperBot
@camperbot
Jan 16 2016 10:54

## :point_right: waypoint iterate over arrays with map [wiki]

Using map is the best way to iterate through an array or object. Map uses a function to pretty much do whatever you want it to do. It will pass each value to the callback function.

//Use map to add three to each value in the array
var array = [1,2,3,4,5];

array = array.map(function(val){
return val + 3;
});
bstrzelczyk
@bstrzelczyk
Jan 16 2016 11:10
help dna pairing
CamperBot
@camperbot
Jan 16 2016 11:10

# Problem Explanation:

• You will get a DNA strand sequence and you need to get the pair and return it as a 2D array of the base pairs. Keep in mind that the provided strand should be first always.
fluffystub
@RakshithNM
Jan 16 2016 11:14


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

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

if(contacts[i].firstName===firstName)
{
if(contacts[i][prop])
{
return contacts[i][prop];
}
else
{
return "No such prop" ;
}
}
return "No such contact";
}
}

// Change these values to test your function
lookUp("Harry", "likes");
JeppeV
@JeppeV
Jan 16 2016 11:15
I'm also struggling with that one
Aaron Osteraas
@aosteraas
Jan 16 2016 11:16
help filter arrays with filter
CamperBot
@camperbot
Jan 16 2016 11:16

## :point_right: waypoint filter arrays with filter [wiki]

Filter is a useful method that can filter out values that don't match a certain criteria.

var array = [1,2,3,4,5,6,7,8,9,10];
// Only change code below this line.
array = array.filter(function(val) {
return val <= 5;
});
JeppeV
@JeppeV
Jan 16 2016 11:18
Rakshith, i got it - try using to contacts[i].hasOwnPropery(prop) in your second if-statement, and also, try with only 2 == in the first if-statement
that worked for me
codingHahn
@codingHahn
Jan 16 2016 11:21
'''
CamperBot
@camperbot
Jan 16 2016 11:21
:bulb: to format code use backticks!  more info
fluffystub
@RakshithNM
Jan 16 2016 11:21
@JeppeV it doesnt
codingHahn
@codingHahn
Jan 16 2016 11:21
This message was deleted
fluffystub
@RakshithNM
Jan 16 2016 11:21
im going thanks
will try monday
codingHahn
@codingHahn
Jan 16 2016 11:22
sorry trying to chat.
I'm new
// 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") {
console.log(value + " if ");
collection[id][prop] = value;
return collection;
} else if (prop === "tracks" && value !== "") {
console.log(value + "else if 1");
collection[id][tracks].push(value);
return collection;
} else if (value === "") {
console.log(value + "else if 2");

collection[id][prop] = "";
return collection;

}

}

// Alter values below to test your code
// update(2548, "artist", "");
if have a proplem, I don't know how to end the challenge "Record Collection" in "Basic Java" script
rphares
@rphares
Jan 16 2016 11:26
Hmm, could be wrong, @codingHahn ,
but i don't think you want so many returns...
hernc
@hernc
Jan 16 2016 11:27
@codingHahn nest the if statements don't use && use the 2else statements hope that helps, That is only one way of doing it, it worked for me
codingHahn
@codingHahn
Jan 16 2016 11:27
@rphares should I only return at the end once?
rphares
@rphares
Jan 16 2016 11:28
that's the one i would suggest keeping, yep :)
codingHahn
@codingHahn
Jan 16 2016 11:28
@hernc Does nesting if-Statements really help that muuch?
AFK now
hernc
@hernc
Jan 16 2016 11:30
@codingHahn it just clarified it for me. and it solved it jaja most importantly
Gristel Periwinkle
@gristel
Jan 16 2016 11:30
@codingHahn nesting if statements usually helps to get a better view on what’s happening and on what needs to be done
Well, for me it does
rphares
@rphares
Jan 16 2016 11:31
(WB, @gristel ~ :) )
(Im just getting to my coffee and reading :blush: )
Gristel Periwinkle
@gristel
Jan 16 2016 11:32
And it helps you think more analytical. Which is my main goal here: not give people the solution but help them figure it out themselves :)
Hey @rphares !! Just getting to my coffee myself :)
@rphares I’m replacing the examples by the exercises on each topic. I think that will be better
rphares
@rphares
Jan 16 2016 11:34
Ah, cool--
if doing that, can i make a small two cents suggestion?
Gristel Periwinkle
@gristel
Jan 16 2016 11:34
of course
rphares
@rphares
Jan 16 2016 11:35
It'll be harder and more work.... but maybe two exercises rather than one? One thing i know is on a lot of resources, it is easy to catch specific things rather than the big ideas
(speaking from very personal experience)
Gristel Periwinkle
@gristel
Jan 16 2016 11:35
So you’re implying I need to invent exercises myself? :D
rphares
@rphares
Jan 16 2016 11:35
Heheh, not implying-- I'm just starting it, haven't looked much at what you have done yet, but
if i were looking for a dream resource,
that would be the biggest different in between what i see out there so far and what i would want,
Gristel Periwinkle
@gristel
Jan 16 2016 11:36
I’ll start by doing that for the checkpoints only for now
rphares
@rphares
Jan 16 2016 11:36
Sweet!
Thanks, @gristel ~
CamperBot
@camperbot
Jan 16 2016 11:37
rphares sends brownie points to @gristel :sparkles: :thumbsup: :sparkles:
:star: 242 | @gristel | http://www.freecodecamp.com/gristel
Gristel Periwinkle
@gristel
Jan 16 2016 11:37
:)
rphares
@rphares
Jan 16 2016 11:37
(and again, just my two cents)
Gristel Periwinkle
@gristel
Jan 16 2016 11:37
I like input like that, so keep going ;)
But first: more coffee :D
rphares
@rphares
Jan 16 2016 11:37
Agreed!
Gristel Periwinkle
@gristel
Jan 16 2016 11:38
👍
codingHahn
@codingHahn
Jan 16 2016 11:44
Here again!
@gristel I'll try
Abhisek Pattnaik
@abhisekp
Jan 16 2016 11:47
I feel trapped again!
codingHahn
@codingHahn
Jan 16 2016 11:54

I changed

if (value !== "" &&  prop !==  tracks) {
// some code
}

to:

if (value !== "") {
if (prop !== tracks) {
}
}

Did you mean that @hernc and @gristel ?

codingHahn
@codingHahn
Jan 16 2016 12:05
Got it. only had to change one line.
Gristel Periwinkle
@gristel
Jan 16 2016 12:09
@codingHahn Yes exactly. That’s the ‘cleanest’ approach
Arseny
@arsenykonohovwork
Jan 16 2016 12:10
Oh! nice! Are javascript ninjas here?) I started FCC)
Gristel Periwinkle
@gristel
Jan 16 2016 12:10
@abhisekp I always feel trapped :D
Arseny
@arsenykonohovwork
Jan 16 2016 12:10
Hi there!)
Gristel Periwinkle
@gristel
Jan 16 2016 12:10
@arsenykonohovwork We’ll see what we can do :)
rphares
@rphares
Jan 16 2016 12:10
There are indeed.... sometimes :wink2:
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:10
@arsenykonohovwork Ninjas have gone to fight
$\Huge\dagger$
MonsterRabbit
@MonsterRabbit
Jan 16 2016 12:11
T T i can't not finsh Counting cards..
codingHahn
@codingHahn
Jan 16 2016 12:11
@gristel You're right, thats a whole lot cleaner, but i derped up the deleting of the prop if
value === ""
Arseny
@arsenykonohovwork
Jan 16 2016 12:11
@abhisekp well we'll going to fight too) With php-developers)
Jan 16 2016 12:12
Hi
Anyone help me with this? http://www.freecodecamp.com/challenges/quoting-strings-with-single-quotes#?solution=var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";
Gristel Periwinkle
@gristel
Jan 16 2016 12:12
@codingHahn It takes some practice but it helps you figure out exactly what you need to do
B Manoj Kumar
@bmkmanoj
Jan 16 2016 12:12
Hello All. We have started a GitHub repo recently for learning JavaScript by examples. Do look at the content and let me know your thoughts. And, if you like it, do star it :smile: . Link: https://github.com/bmkmanoj/js-by-examples
codingHahn
@codingHahn
Jan 16 2016 12:14
@SarthakAdhikari You have to make the outer quotes to single quotes, not the inner ones.
Jan 16 2016 12:14

Can anyone help me with this? http://www.freecodecamp.com/challenges/quoting-strings-with-single-quotes#?solution=var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";

:D

@codingHahn okay
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:14

@arsenykonohovwork well, we can't socially connect w/o PHP devs.

Jan 16 2016 12:15
@codingHahn Thanks :D
CamperBot
@camperbot
Jan 16 2016 12:15
sarthakadhikari sends brownie points to @codinghahn :sparkles: :thumbsup: :sparkles:
:star: 221 | @codinghahn | http://www.freecodecamp.com/codinghahn
codingHahn
@codingHahn
Jan 16 2016 12:15
@SarthakAdhikari no problem. Thanks ;)
CamperBot
@camperbot
Jan 16 2016 12:15
codinghahn sends brownie points to @sarthakadhikari :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for sarthakadhikari
Gristel Periwinkle
@gristel
Jan 16 2016 12:15
@bmkmanoj I have a look now
codingHahn
@codingHahn
Jan 16 2016 12:16
@rphares Thanks
CamperBot
@camperbot
Jan 16 2016 12:16
codinghahn sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1536 | @rphares | http://www.freecodecamp.com/rphares
codingHahn
@codingHahn
Jan 16 2016 12:17
@gristel Thanks
CamperBot
@camperbot
Jan 16 2016 12:17
codinghahn sends brownie points to @gristel :sparkles: :thumbsup: :sparkles:
:star: 243 | @gristel | http://www.freecodecamp.com/gristel
Gristel Periwinkle
@gristel
Jan 16 2016 12:17
@bmkmanoj I looks very promising! Although at this moment I think it will scare off ‘new’ JS codes
rphares
@rphares
Jan 16 2016 12:17
Hahaha, didnt do anything!
But glad you got it~ Keep it up :)
B Manoj Kumar
@bmkmanoj
Jan 16 2016 12:19
@gristel thanks, we wish to include the not so obvious nature of the language features or behaviour in this repo. The basic language constructs are mostly covered in some popular books
CamperBot
@camperbot
Jan 16 2016 12:19
bmkmanoj sends brownie points to @gristel :sparkles: :thumbsup: :sparkles:
:star: 244 | @gristel | http://www.freecodecamp.com/gristel
Arseny
@arsenykonohovwork
Jan 16 2016 12:20
@abhisekp Oh! You right! It was a joke)
Arjun
@Ajju-Rocks
Jan 16 2016 12:20
Hi does anyone how to do the word blank exercise?
Gristel Periwinkle
@gristel
Jan 16 2016 12:20
@Ajju-Rocks yes
Arjun
@Ajju-Rocks
Jan 16 2016 12:20
I have no idea how to do it or what to do
Can you help @gristel
Gristel Periwinkle
@gristel
Jan 16 2016 12:20
@Ajju-Rocks well, that’s the first problem
Before you even start to think of code, you must figure out what exactly you need to do
What is being asked of you?
Arjun
@Ajju-Rocks
Jan 16 2016 12:21
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
B Manoj Kumar
@bmkmanoj
Jan 16 2016 12:21
What have you tried @Ajju-Rocks ?
Arjun
@Ajju-Rocks
Jan 16 2016 12:22
Nothing
Gristel Periwinkle
@gristel
Jan 16 2016 12:22
Yes, that’s given in the exercise, but translate it into something you understand
So you get the ‘Aha! This is what I need to do’ experience
Only then can you start coding
Arjun
@Ajju-Rocks
Jan 16 2016 12:22
hmmmmmm...................................
B Manoj Kumar
@bmkmanoj
Jan 16 2016 12:22
@Ajju-Rocks
Arjun
@Ajju-Rocks
Jan 16 2016 12:23
so am i creating like a hangman thing @gristel
Gristel Periwinkle
@gristel
Jan 16 2016 12:24
Start like this:
B Manoj Kumar
@bmkmanoj
Jan 16 2016 12:24
Don't get me wrong. @Ajju-Rocks but you should read the article (every developer should read this)
Arjun
@Ajju-Rocks
Jan 16 2016 12:24
yeah @bmkmanoj
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:24
@bmkmanoj TL;DR; :P
Summary plz :D
Arjun
@Ajju-Rocks
Jan 16 2016 12:24
its true but im not asking for solution @bmkmanoj
Gristel Periwinkle
@gristel
Jan 16 2016 12:25
I get a function that has 4 parameters.
Question 1: what do I have to return?
Question 2: what do I need to do in order to achieve that
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:25
@bmkmanoj there is dedicated domain which redirects to this article http://whathaveyoutried.com/
B Manoj Kumar
@bmkmanoj
Jan 16 2016 12:25
@abhisekp its supposed to be Too long for a reason, I would not do justice to the article even if I try summarizing
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:25
@bmkmanoj :/
Gristel Periwinkle
@gristel
Jan 16 2016 12:26
The summary is: don’t ask for solutions, ask for help to make you understand what you need to do
:D
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:26
@gristel you read the article so fast? :zap:
Gristel Periwinkle
@gristel
Jan 16 2016 12:26
@abhisekp I know the article
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:26
@gristel nice :D
abhisekp @abhisekp goes to read it
Gristel Periwinkle
@gristel
Jan 16 2016 12:27
So that’s why I’m using this approach here to ‘help’ people
I will never give solutions, because that’s not helping
Arjun
@Ajju-Rocks
Jan 16 2016 12:27
@gristel yes i understand but i didnt ask for solution
i asked for help because i didnt understand question
Gristel Periwinkle
@gristel
Jan 16 2016 12:27
@Ajju-Rocks I’m speaking in general. I know you didn’t :)
Arjun
@Ajju-Rocks
Jan 16 2016 12:28
;)
Abhisek Pattnaik
@abhisekp
Jan 16 2016 12:28
@Ajju-Rocks Alright, here is the soln...
Gristel Periwinkle
@gristel
Jan 16 2016 12:29
@Ajju-Rocks follow me here… you get 4 words, right?
Arjun
@Ajju-Rocks
Jan 16 2016 12:29
Yeah
Gristel Periwinkle
@gristel
Jan 16 2016 12:29
So, what do you need to do with those 4 words?
Arjun
@Ajju-Rocks
Jan 16 2016 12:29
make like a fill in the blank game?
Gristel Periwinkle
@gristel
Jan 16 2016 12:29
More specific please :)
Arjun
@Ajju-Rocks
Jan 16 2016 12:30
err
Gristel Periwinkle
@gristel
Jan 16 2016 12:30
I’ll help you: you need to return those 4 words, but in a ‘special’ way
Arjun
@Ajju-Rocks
Jan 16 2016 12:30
in a jumbled up way?
Gristel Periwinkle
@gristel
Jan 16 2016 12:30
Once you figure out in what way you have to return them, you have the solution
No, that’s not what they are asking
Arjun
@Ajju-Rocks
Jan 16 2016 12:30
okay i will see....
Gristel Periwinkle
@gristel
Jan 16 2016 12:31
The answer is in the question: should contain all of the passed words separated by non-word characters
So not "dog", "big", "ran", “quickly”
But dog big ran quickly`
Arjun
@Ajju-Rocks
Jan 16 2016 12:33
Im still clueless....
But im sure i will figure it out
Thanks @gristel
CamperBot
@camperbot
Jan 16 2016 12:33
ajju-rocks sends brownie points to @gristel :sparkles: :thumbsup: :sparkles:
:star: 245 | @gristel | http://www.freecodecamp.com/gristel
Gristel Periwinkle
@gristel
Jan 16 2016 12:34
@Ajju-Rocks So: you need to return 1 string with 4 words, seperated by a blank space (“ “)
Arjun
@Ajju-Rocks
Jan 16 2016 12:35
yeah like
:
Gristel Periwinkle
@gristel
Jan 16 2016 12:35
@Ajju-Rocks I have to agree that the part about concatinating is not always clear though
Arjun
@Ajju-Rocks
Jan 16 2016 12:36
The ------ which was very ------- ------- extremely ------
------ mean blank spaces
Gristel Periwinkle
@gristel
Jan 16 2016 12:36
No
just return those 4 words
but with space in between them
Arjun
@Ajju-Rocks
Jan 16 2016 12:36
yeah
i get it
------- was just to be more clear....
Gristel Periwinkle
@gristel
Jan 16 2016 12:36
Oh, it got me confused, lol D
:D
Arjun
@Ajju-Rocks
Jan 16 2016 12:37
my fault....
Gristel Periwinkle
@gristel
Jan 16 2016 12:37
No worries
Arjun
@Ajju-Rocks
Jan 16 2016 12:37
yeah so i finally get the task?
Gristel Periwinkle
@gristel
Jan 16 2016 12:37
I’ll give you this: the question is more difficult than the solution :)
Arjun
@Ajju-Rocks
Jan 16 2016 12:38
yeah..... looks like i just make the question harder for myself....
Gristel Periwinkle
@gristel
Jan 16 2016 12:38
I think so :)
Arjun
@Ajju-Rocks
Jan 16 2016 12:38
yeah will show you the solution after i do it...
brb
Gristel Periwinkle
@gristel