16th
Apr 2016
Marc Schöni
@marcschoeni
Apr 16 2016 00:00 UTC
thats what i not understand :worried:
Stephen James
@sjames1958gm
Apr 16 2016 00:00 UTC
processArg (7) That is calling processArg with an argument of 7
@Mooli88 What does your code look like now
Marc Schöni
@marcschoeni
Apr 16 2016 00:02 UTC
function processArg(num) {
return (num + 3) / 5;
}
i change num to 7?
Mooli
@Mooli88
Apr 16 2016 00:02 UTC
@sjames1958gm i restart the challenge :|
hjernefrys
@hjernefrys
Apr 16 2016 00:04 UTC
I need some help with the mutations algorithm challenge. All tests passes except the first one, and I can't figure out why it returns true. The code I have so far:
function mutation(arr) {

var firstString = arr[0];
var firstLowercase = firstString.toLowerCase();

var secondString = arr[1];
var secondLowerCase = secondString.toLowerCase();

for(var i = 0; i < firstLowercase.length; i++){
var contains = firstLowercase.indexOf(secondLowerCase[i]);

if(contains === -1){
return false;
}else{
return true;
}

}

return arr;
}

mutation(["hello", "hey"]);
Mooli
@Mooli88
Apr 16 2016 00:05 UTC
@sjames1958gm
function whereAreYou(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line

var arr = [];
// Only change code below this line
var arg2 = Object.keys(source);
var tempArr = [];

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

for(var key = 0; key < arg2.length; key++){

// console.log('key', key, '+ i', i);

if(!collection[i].hasOwnProperty(arg2[key])

&& collection[i][arg2[key]] !== source[arg2[key]]

&& Object.keys(collection[i]).length <= arg2.length){

console.log(false);

}//if

}//for

if(arr){
arr.push(collection[i]);
}
}//for
// Only change code above this line
return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Diego Mayer
@Chrono79
Apr 16 2016 00:06 UTC
@hjernefrys you are returning at the first loop
the h is in both words
so, true is returned
Stephen James
@sjames1958gm
Apr 16 2016 00:10 UTC
@Mooli88 In order to check for a bad value you need || not && . Before your second for put var good = true; inside your if good = false after your inside for if(good) { arr.push(collection[i]); }
@Mooli88 What the inner loop should be doing is looking for any key in source that is not in collection[i] OR the value for that key in collection is not equal to source value for that key
hjernefrys
@hjernefrys
Apr 16 2016 00:12 UTC
@Chrono79 ok, I see, but what are some good ways of changing it? I tried this, but without much luck. Is my logic still way off?

function mutation(arr) {

var firstString = arr[0];
var firstLowercase = firstString.toLowerCase();
var statement = false;

var secondString = arr[1];
var secondLowerCase = secondString.toLowerCase();

for(var i = 0; i < firstLowercase.length; i++){
var contains = firstLowercase.indexOf(secondLowerCase[i]);

if(contains === -1){
statement =  false;
}else{
statement = true;
}

}

return statement;
}

mutation(["hello", "hey"]);
Marc Schöni
@marcschoeni
Apr 16 2016 00:13 UTC
how can i assign processArg to processed? You should assign processArg to processed on the challange Assignment with a Returned Value
Stephen James
@sjames1958gm
Apr 16 2016 00:13 UTC
@marcschoeni processed = processArg(7)
Mooli
@Mooli88
Apr 16 2016 00:13 UTC
function whereAreYou(collection, source) {
// What's in a name?
var arr = [];

// Only change code below this line
var arg2 = Object.keys(source);
var tempArr = [];

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

var good = true;
for(var key = 0; key < arg2.length; key++){

if(!collection[i].hasOwnProperty(arg2[key])

|| collection[i][arg2[key]] !== source[arg2[key]]

|| Object.keys(collection[i]).length <= arg2.length){

good = false;

}//if

}//for

if(good){
arr.push(collection[i]);
}
}//for
// Only change code above this line
return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Diego Mayer
@Chrono79
Apr 16 2016 00:14 UTC

@hjernefrys

}else{
statement = true;
}

remove this
return false if your if condition is true and outside the for return true
inside the for loop if one of the values isn't there there is no need to keep looking at the rest

Stephen James
@sjames1958gm
Apr 16 2016 00:16 UTC
@Mooli88 Object.keys(collection[i]).length <= arg2.length should this be less than or equal ?
Marc Schöni
@marcschoeni
Apr 16 2016 00:16 UTC
This message was deleted
// Example
var changed = 0;

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

changed = change(10);

// Setup
var processedArg(7);

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

// Only change code below this line
Stephen James
@sjames1958gm
Apr 16 2016 00:17 UTC
@marcschoeni You were not supposed to change any existing code add code at the end.
@Mooli88 Either remove the third check, or make it <
Marc Schöni
@marcschoeni
Apr 16 2016 00:20 UTC
@sjames1958gm then its fail with Expected an assignement or function call and instead saw an expression
Moisés Man
@moigithub
Apr 16 2016 00:20 UTC
check the example above... @marcschoeni
first it have a variable.. with initial value of 0
Ross
@AnInsaneScientist
Apr 16 2016 00:20 UTC
I'm stuck on 'Generate Random Fractions with JavaScript'. I'm guessing there's some kind of control flow logic to make sure the function never returns a '0'. I feel like this should be easy but none of my attempts have worked DX
Moisés Man
@moigithub
Apr 16 2016 00:21 UTC
so u need to create a variable with initial value of 0 too... on ur case.. it should be named.. processedArg @marcschoeni
basiclly u need to copy the code above... with names changed...
Stephen James
@sjames1958gm
Apr 16 2016 00:21 UTC
@AnInsaneScientist What code did you add? And did it follow the instructions?
hjernefrys
@hjernefrys
Apr 16 2016 00:23 UTC
@Chrono79 thanks, but I still don't get it. It's 2 in the night here so I might just have a look at it tomorrow. Here is the current code, but I don't think I understood you correctly.
function mutation(arr) {

var firstString = arr[0];
var firstLowercase = firstString.toLowerCase();
var statement = true;

var secondString = arr[1];
var secondLowerCase = secondString.toLowerCase();

for(var i = 0; i < firstLowercase.length; i++){
var contains = firstLowercase.indexOf(secondLowerCase[i]);

if(contains === -1){
statement =  false;
}

}

return statement;
}

mutation(["hello", "hey"]);
CamperBot
@camperbot
Apr 16 2016 00:23 UTC
hjernefrys sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 412 | @chrono79 | http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
Apr 16 2016 00:23 UTC
@hjernefrys you should not keep looping after finding a mismatch
bkd705
@bkd705
Apr 16 2016 00:24 UTC
JavaScript arrays mainly objects confuse the piss out of me. What should I do to practice / learn more because fcc isn't really cutting it for me.
Ross
@AnInsaneScientist
Apr 16 2016 00:24 UTC
I just realized what I did wrong. Silly mistake. I thought you could use Math.random without '()' at the end.
Stephen James
@sjames1958gm
Apr 16 2016 00:25 UTC
@AnInsaneScientist :+1:
Diego Mayer
@Chrono79
Apr 16 2016 00:26 UTC
@hjernefrys
function mutation(arr) {

var firstString = arr[0];
var firstLowercase = firstString.toLowerCase();
var statement = true;

var secondString = arr[1];
var secondLowerCase = secondString.toLowerCase();

for(var i = 0; i < firstLowercase.length; i++){
var contains = firstLowercase.indexOf(secondLowerCase[i]);

if(contains === -1){ // this checks every individual letter on secondString is present on firstString, so if this is true, at least one is missing, no need to check the other
statement =  false; // I would return false here
}

}

return statement; // if all were present, statement is true here
}

mutation(["hello", "hey"]);
Stephen James
@sjames1958gm
Apr 16 2016 00:27 UTC
@hjernefrys The idea that @Chrono79 is saying is get out (return) at the first sign of trouble.
hjernefrys
@hjernefrys
Apr 16 2016 00:31 UTC
Am I just missing something, or is there something wrong with my code compared to the code of @Chrono79 ? It doesn't pass:

function mutation(arr) {

var firstString = arr[0];
var firstLowercase = firstString.toLowerCase();
var statement = true;

var secondString = arr[1];
var secondLowerCase = secondString.toLowerCase();

for(var i = 0; i < firstLowercase.length; i++){
var contains = firstLowercase.indexOf(secondLowerCase[i]);

if(contains === -1){
statement = false;
}

}

return statement;
}

mutation(["hello", "hey"]);
Diego Mayer
@Chrono79
Apr 16 2016 00:33 UTC
@hjernefrys
for(var i = 0; i < secondLowercase.length; i++){
var contains = firstLowercase.indexOf(secondLowerCase[i]);
Stephen James
@sjames1958gm
Apr 16 2016 00:33 UTC
@hjernefrys Replace the statement = false with return false
hjernefrys
@hjernefrys
Apr 16 2016 00:36 UTC
thanks @Chrono79 and @sjames1958gm I changed it to: for(var i = 0; i < secondLowercase.length; i++) per the suggestion and it passed. My logic was a bit backwards
CamperBot
@camperbot
Apr 16 2016 00:36 UTC
hjernefrys sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: hjernefrys already gave chrono79 points
:star: 655 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Apr 16 2016 00:37 UTC
go to sleep now @hjernefrys a tired brain is not the best pilot when you're coding ;)
Stephen James
@sjames1958gm
Apr 16 2016 00:38 UTC
@Chrono79 :+1:
hjernefrys
@hjernefrys
Apr 16 2016 00:38 UTC
@Chrono79 haha, yes I think that might be a good idea :-P
Mauricio
@maudevelop
Apr 16 2016 00:42 UTC
function fearNotLetter(str) {
var strlen = str.length;
var minRange = str.charCodeAt(0);
var maxRange = str.charCodeAt(strlen-1);
var newStr=[];
var result="";
for (var i = minRange; i<=maxRange; i++){
newStr.push(String.fromCharCode(i));
}
console.log(newStr.join());
if (str == newStr.join() ){
return undefined;
}else{
for (i=0; i<newStr.length; i++) {
if (str.indexOf(newStr[i]) == -1){
result += newStr[i];
}
}
return result;
}
}
fearNotLetter("bcd");
why is this not working? it's either being correct on the first 2 or on the last 2
but can't get it to work on both
Stephen James
@sjames1958gm
Apr 16 2016 00:43 UTC
@maudevelop Which challenge?
Diego Mayer
@Chrono79
Apr 16 2016 00:43 UTC
@maudevelop paste the case that doesn't pass
why return undefined?
Mauricio
@maudevelop
Apr 16 2016 00:45 UTC
The challenge tells you that, but woah, i just got it, it was only missing newStr.join('') instead of newStr.join()
@Chrono79

"Find the missing letter in the passed letter range and return it.

If all letters are present in the range, return undefined."

CamperBot
@camperbot
Apr 16 2016 00:45 UTC
find the missing letter in the passed letter range and return itif all letters are present in the range return undefined
nothing found
Mauricio
@maudevelop
Apr 16 2016 00:46 UTC
It's working now though, haha, im not sure if i made a mess on making the bonfire, is the code too messy/
?
Diego Mayer
@Chrono79
Apr 16 2016 00:46 UTC
@maudevelop you can solve it in only one for
Nate
@nateReiners
Apr 16 2016 00:49 UTC

Noob here... is it

(code here)

OR

(code here)
oh. I see.
Mauricio
@maudevelop
Apr 16 2016 00:50 UTC
@Chrono79 how would i do that?
Nate
@nateReiners
Apr 16 2016 00:50 UTC
In this code, I can't see the source array. What am I missing?
Array.prototype.map = function(projectionFunction) {
var results = [];
this.forEach(function(itemInArray) {

// ------------ INSERT CODE HERE! ----------------------------
// Apply the projectionFunction to each item in the array and add
// each result to the results array.
// Note: you can add items to an array with the push() method.
// ------------ INSERT CODE HERE! ----------------------------

});

return results;
};
bkd705
@bkd705
Apr 16 2016 00:51 UTC
@nateReiners Ayeee it's you!!
Nate
@nateReiners
Apr 16 2016 00:51 UTC
yo man
Diego Mayer
@Chrono79
Apr 16 2016 00:51 UTC
@maudevelop do you want to discover how to do it yourself or do you prefer I send you my solution by PM?
Nate
@nateReiners
Apr 16 2016 00:51 UTC
are you the guy i was racing?
haha
@bkd705 -_-
Mauricio
@maudevelop
Apr 16 2016 00:52 UTC
@Chrono79, any hint on how to do it, just so i can think about it myself haha
bkd705
@bkd705
Apr 16 2016 00:52 UTC
Yes yes 😂 @nateReiners
Stephen James
@sjames1958gm
Apr 16 2016 00:52 UTC
@maudevelop
function fearNotLetter(str) {

var expect = str.charCodeAt(0) + 1;
for (var i = 1; i < str.length; i++) {
if (str.charCodeAt(i) != expect) {
return String.fromCharCode(expect);
}
expect++;
}

return undefined;
}
bkd705
@bkd705
Apr 16 2016 00:52 UTC
How far are you now? @nateReiners
Diego Mayer
@Chrono79
Apr 16 2016 00:52 UTC
@maudevelop ok, I'll try
inside the for advance the char you are checking in the string and compare it with should be expected
does it make sense to you?
Tim
@codemymind
Apr 16 2016 00:53 UTC
a bit confused on this challenge to convert celsius to F
Anyone mind, helping me out a bit please?
Stephen James
@sjames1958gm
Apr 16 2016 00:53 UTC
@maudevelop Start from the beginning of the string and stop when you find a missing char
Nate
@nateReiners
Apr 16 2016 00:53 UTC
@bkd705 Er. Not far. You're definitely ahead of me!! I've been working through some stuff on a different site in preparation for a code camp interview. Focusing on functional programming as much as I can since that's what will be tested in my technical interview.
I haven't done 1 challenge since I went to sleep and said my brain was mush @bkd705 lol #theshameisreal
bkd705
@bkd705
Apr 16 2016 00:54 UTC
Ahh true. I'm midway through the JavaScript challenges now like the palindrome and shtufffff @nateReiners
Nate
@nateReiners
Apr 16 2016 00:55 UTC
@bkd705 impressive!!! keep it up man
bkd705
@bkd705
Apr 16 2016 00:55 UTC
Aww true. Well at least I'm winning. ;). Is the code camp like a real life thing?
Stephen James
@sjames1958gm
Apr 16 2016 00:55 UTC
@codemymind The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
Tim
@codemymind
Apr 16 2016 00:56 UTC
@sjames1958gm I see that in the instructions, but not really sure how to write out the equation. Im a noob
Diego Mayer
@Chrono79
Apr 16 2016 00:56 UTC
Stephen James
@sjames1958gm
Apr 16 2016 00:56 UTC
@codemymind fahrenheit = Celsius times 9/5, plus 32.
Nate
@nateReiners
Apr 16 2016 00:56 UTC
@bkd705 yessir I have interviews scheduled for App Academy and Makersquare. App Academy usually does their interviews in Ruby, but I asked and they said Javascript would be just fine as long as I can write code that completes the challenges.
Mauricio
@maudevelop
Apr 16 2016 00:57 UTC
@sjames1958gm wouldn't that only return the first character not found in the string?
Nate
@nateReiners
Apr 16 2016 00:57 UTC
@bkd705 I'm the tortoise in this fable. ;)
Tim
@codemymind
Apr 16 2016 00:58 UTC

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

fahrenheit = celsius * 9.5 + 32

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

// Change the inputs below to test your code
convertToF(30);

not sure how to paste the screenshot - sorry
Stephen James
@sjames1958gm
Apr 16 2016 00:58 UTC
@maudevelop Which is what the instructions said - find "the" missing letter
Diego Mayer
@Chrono79
Apr 16 2016 00:58 UTC
@maudevelop depends on what you do then, but as @sjames1958gm said it says the letter, not the letters
Stephen James
@sjames1958gm
Apr 16 2016 00:58 UTC
@codemymind 9.5 is different that 9 / 5
bkd705
@bkd705
Apr 16 2016 00:58 UTC
@nateReiners ah well that's way more impressive than me winning this race. Congrats dude and good luck on the tests!!
Stephen James
@sjames1958gm
Apr 16 2016 00:59 UTC
This message was deleted
Tim
@codemymind
Apr 16 2016 00:59 UTC
@sjames1958gm haha it worked. well damn
@sjames1958gm Thank you
CamperBot
@camperbot
Apr 16 2016 00:59 UTC
codemymind sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 656 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 16 2016 00:59 UTC
:+1:
help format
CamperBot
@camperbot
Apr 16 2016 00:59 UTC

## :point_right: code formatting [wiki]

### Multi line Code

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

then press [shift + enter ⏎]

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

Nate
@nateReiners
Apr 16 2016 01:00 UTC
@bkd705 Thanks man. Could be a gamechanger for me so I'm excited. I feel like I'll have a shot at getting in, but if I don't get in on my first try, I'll just put my head down and keep studying and try again.
CamperBot
@camperbot
Apr 16 2016 01:00 UTC
natereiners sends brownie points to @bkd705 :sparkles: :thumbsup: :sparkles:
:star: 259 | @bkd705 | http://www.freecodecamp.com/bkd705
Tim
@codemymind
Apr 16 2016 01:01 UTC

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

fahrenheit = celsius * 9/5 + 32

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

// Change the inputs below to test your code
convertToF(30);

CamperBot
@camperbot
Apr 16 2016 01:01 UTC
:bulb: to format code use backticks!  more info
Tim
@codemymind
Apr 16 2016 01:01 UTC
oops, sorry just a practice to figure this out :)

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

fahrenheit = celsius * 9/5 + 32

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

// Change the inputs below to test your code
convertToF(30);

hmm, lol
Nate
@nateReiners
Apr 16 2016 01:03 UTC
make sure you put  at the end of your code too
I was using the snip tool for a while to paste pictures of my code in here lol
Tim
@codemymind
Apr 16 2016 01:03 UTC
oh, gotcha - ty - do i need to type js like js <code>
bkd705
@bkd705
Apr 16 2016 01:03 UTC
If you do the ticks and press enter it will automatically do it for you.
Tim
@codemymind
Apr 16 2016 01:03 UTC

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

fahrenheit = celsius * 9/5 + 32

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

// Change the inputs below to test your code
convertToF(30);


Diego Mayer
@Chrono79
Apr 16 2016 01:04 UTC
@codemymind  should be the only thing in that line, use shift+enter to go to next line
Tim
@codemymind
Apr 16 2016 01:04 UTC
sorry im blowing up the feed -
Stephen James
@sjames1958gm
Apr 16 2016 01:04 UTC
@codemymind shift-return after the first three ticks
Nate
@nateReiners
Apr 16 2016 01:04 UTC
for(i=0; i < Noob; i--) { }
hmm. that enter trick didn't seem to work
Diego Mayer
@Chrono79
Apr 16 2016 01:04 UTC
Stephen James
@sjames1958gm
Apr 16 2016 01:04 UTC
shift-return
Nate
@nateReiners
Apr 16 2016 01:04 UTC
@sjames1958gm thanks
CamperBot
@camperbot
Apr 16 2016 01:04 UTC
natereiners sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Mauricio
@maudevelop
Apr 16 2016 01:04 UTC
@Chrono79 and @sjames1958gm ohhhh right, haha I just made it that way and it's almost exactly like your code, thanks both!
CamperBot
@camperbot
Apr 16 2016 01:04 UTC
maudevelop sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 657 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 413 | @chrono79 | http://www.freecodecamp.com/chrono79
:star: 658 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Apr 16 2016 01:05 UTC
no problem
bkd705
@bkd705
Apr 16 2016 01:05 UTC
Do the ticks. Press enter. Then paste code.
Mauricio
@maudevelop
Apr 16 2016 01:06 UTC
Apparently I think very differently hahaa
bkd705
@bkd705
Apr 16 2016 01:06 UTC
It autocompletes
Mauricio
@maudevelop
Apr 16 2016 01:06 UTC
My solution was way more complex than it should have been
Tim
@codemymind
Apr 16 2016 01:06 UTC
ty for the advice guys, great group here. excited to learn and contribute when i can
Bob Evermore
@BeeQuickest
Apr 16 2016 01:06 UTC
Can anyone offer some suggestions to get me past this challenge? I've just about burned out on it...

var value = "";
function updateRecords(id, prop, value) {
if ((value) !== "") {
if ((prop) !== "tracks") {
collection[id][prop]=prop;
collection[id][prop][value]=value;
return collection[id][prop][value];

// } else delete collection
} else collection[id][prop].push(value);
} else delete (collection[id][prop]);

return collection.id.prop.value;
}

Nate
@nateReiners
Apr 16 2016 01:07 UTC
Is it against the rules to post questions about non-FCC javascript challenges here?
Bob Evermore
@BeeQuickest
Apr 16 2016 01:07 UTC
Nate that's an interesting question that I don't know the answer to...
bkd705
@bkd705
Apr 16 2016 01:09 UTC
Is there really rules here? I think it's fine honestly. I've asked non fcc coding questions in the main chat.
We're all here to help each other so who really cares where it's from.
Nate
@nateReiners
Apr 16 2016 01:10 UTC
Right on. I think you're probably right. I just noticed the little "Activity" feed on the right and saw some people have been banned. I'd hate to show up on that feed! lol
Bob Evermore
@BeeQuickest
Apr 16 2016 01:11 UTC
Yeah, probably not where you want to end up.
Nate
@nateReiners
Apr 16 2016 01:11 UTC
I value this chatroom maybe more than any one individual resource on the web.
bkd705
@bkd705
Apr 16 2016 01:11 UTC
Lmfao probably mostly spammers. Bots and trolls.
Yeah I don't think I'd have made it through half the js challenges without these chats.
Bob Evermore
@BeeQuickest
Apr 16 2016 01:12 UTC
Speaking of making it through challenges, does anyone have suggestions about the code I posted 5 minutes ago?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:13 UTC
if ((prop) !== "tracks") {
collection[id][prop]=prop;
collection[id][prop][value]=value;
return collection[id][prop][value];

you should be looking to update just the value. consider collection[id][prop][value]=value as you telling the object that this is now a property inside collection that equals this value. which now means you can rule out collection[id][prop]=prop;

if ((prop) !== "tracks")

here you are using parenthesis around (prop) unnecessarily since nothing is happening inside those parenthesis

return collection[id][prop][value];

You only need this to be returned at the end of your function and not inside your if statements since you want it to cycle through them and then return whatever changes are proper inside your condition statements if/else

@BeeQuickest
bkd705
@bkd705
Apr 16 2016 01:14 UTC
Looks like he's got you covered aha.
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:15 UTC
// } else delete collection
} else collection[id][prop].push(value);
} else delete (collection[id][prop]);
look to add an if statement here that will add to the tracks array if the collection property contains and then run the delete as the final else statement @BeeQuickest
Bob Evermore
@BeeQuickest
Apr 16 2016 01:16 UTC
Thanks Jamie. I'm finding it hard to see the results of changes I make in the code because all I get are instant syntax warnings and a single statement about the last error encountered.
The last time I was learning to write code I was working on a terminal with a greenbar printer for output. And a much more BASIC language.
Matthew Fricker
@mattfricker
Apr 16 2016 01:17 UTC
This message was deleted
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:18 UTC
You want your function to declare the value for you. When you do var value = "" it's not needed because the function has an argument to take value in for you.
Your syntax errors are coming from your else format. Look into how if and else statements are formed, as well as nesting. @BeeQuickest that should help to fix those errors
if(something === true) {
if(otherThing === false) {
//do something inside nested if when if(something === true) && (otherThing === false) are both true
} else {
// push up something
>>>> this runs if (otherThing === false) is not true
} else {
//take out something
} >>>>  this runs if (something === true) is not true
notice how there's an if condition at the top that has two nested conditions inside of it if and else and then you have a final else statement for the parent condition if when something === true is not met @BeeQuickest
Tim
@codemymind
Apr 16 2016 01:23 UTC
how do you post the code like that? @Jlipschitz
Bob Evermore
@BeeQuickest
Apr 16 2016 01:24 UTC
I was wondering the same thing, Tim
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:24 UTC
help format
CamperBot
@camperbot
Apr 16 2016 01:24 UTC

## :point_right: code formatting [wiki]

### Multi line Code

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

then press [shift + enter ⏎]

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:24 UTC
@codemymind follow the format above using ticks to post code like that :D
Tim
@codemymind
Apr 16 2016 01:25 UTC
function convertToF(celsius) {
// Only change code below this line

var fahrenheit = (celsius * (9/5)) + 32;

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

// Change the inputs below to test your code
convertToF(30);
aha~!
@Jlipschitz thank you
CamperBot
@camperbot
Apr 16 2016 01:25 UTC
codemymind sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 117 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Tim
@codemymind
Apr 16 2016 01:28 UTC
man, this website / chat group is kinda invaluable - what a great setup
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:31 UTC
i've definitely had a lot help from others in this chat. it's great that people are willing to take out the time to help you out! @codemymind
Bob Evermore
@BeeQuickest
Apr 16 2016 01:32 UTC
Does the multi-line formatting work in Chrome browsers?

Nate
@nateReiners
Apr 16 2016 01:33 UTC
@bkd705 http://reactivex.io/learnrx/ thought I'd share this in case you're curious. This is the study material provided by Makersquare (and also Hack Reactor, though their interview slots are completely booked through JULY). The dude said if I make it through #16 I'd probably be good to go for the interview, in case you're wondering what it takes to get in. Apparently they value functional programming above all else.
Bob Evermore
@BeeQuickest
Apr 16 2016 01:33 UTC
js
function updateRecords(id, prop, value) {
if ((value) !== "") {
if (prop !== "tracks") {
collection[id][prop]=prop;
collection[id][prop][value]=value;

//    } else delete collection
} else { collection[id][prop].push(value);
} else delete (collection[id][prop]);
}

return collection[id][prop][value];
}
I guess so... lol
Marc Schöni
@marcschoeni
Apr 16 2016 01:34 UTC
why thats not go?
// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
return (num + 3) / 5;
}
function processedArg(num) {
var  processed = processedArg(7);
}

// Only change code below this line
Diego Mayer
@Chrono79
Apr 16 2016 01:35 UTC

@marcschoeni don't define another function

function processedArg(num) {
var  processed = processedArg(7);
}

replace that with this:

processed = processArg(7);
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:36 UTC

@BeeQuickest you want to return collection at the end of the function, not return collection[id][prop][value]; because you want the whole thing to come back after you've updated it, not just one property + value you passed in

collection[id][prop]=prop;

you're setting the property when you do collection[id][prop][value]=value so this can be taken out

} else { collection[id][prop].push(value);
} else delete (collection[id][prop]);
}

look at the nesting here. you have two else inside your parent if condition if ((value) !== "")

you're doing great man. you're really close!!!!!!! @BeeQuickest
Ozan Araz
@haraldur12
Apr 16 2016 01:42 UTC
I am such at basic js
can someone help me?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:43 UTC
plenty of people are willing to help. just ask away! @haraldur12
Marc Schöni
@marcschoeni
Apr 16 2016 01:44 UTC
Great thank @Chrono79
CamperBot
@camperbot
Apr 16 2016 01:44 UTC
marcschoeni sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 414 | @chrono79 | http://www.freecodecamp.com/chrono79
Ozan Araz
@haraldur12
Apr 16 2016 01:44 UTC
I am stuck at wordBlanks
can't I sum the variable inside result ?
" var1 + var2 "
WilliamDecker
@WilliamDecker
Apr 16 2016 01:45 UTC
I have a question in regards to accessing data in an array (related to the record collection)
Ozan Araz
@haraldur12
Apr 16 2016 01:45 UTC
for example?
Diego Mayer
@Chrono79
Apr 16 2016 01:45 UTC
Ozan Araz
@haraldur12
Apr 16 2016 01:46 UTC

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

WilliamDecker
@WilliamDecker
Apr 16 2016 01:46 UTC
in earlier exercises it discussed using the dot operator and bracket notation
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:46 UTC
@haraldur12 attempt to do the exercise first and then we will be able to help out
Stephen James
@sjames1958gm
Apr 16 2016 01:46 UTC
@WilliamDecker For an array it is always []
WilliamDecker
@WilliamDecker
Apr 16 2016 01:46 UTC
is collection[id][prop] = value ; not the same as collection.id.prop = value;
?
Ozan Araz
@haraldur12
Apr 16 2016 01:47 UTC
I tried but I couldn't run it
Stephen James
@sjames1958gm
Apr 16 2016 01:47 UTC
@WilliamDecker If id and prop are variables, then no
Ozan Araz
@haraldur12
Apr 16 2016 01:47 UTC
I know how to solve it but can't apply it
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:47 UTC
that's fine . post the code that wouldn't run and we'll help guide you
Apr 16 2016 01:47 UTC
@haraldur12 - I don't know if you've posted all of your code, but you cannot concatenate the variables within quotation marks, as you have shown in a previous comment. (Not sure if your post was exactly as you were trying to do.) But in order to concatenate two variables, you cannot do this:"var1 + var2" but you must do this: var1 + var2 (note the lack of quotation marks in the second code example.)
WilliamDecker
@WilliamDecker
Apr 16 2016 01:48 UTC
so when accessing an array with a variable you always have to use bracket notation?
Stephen James
@sjames1958gm
Apr 16 2016 01:48 UTC
@WilliamDecker What you are showing is accessing an object (not an array) when accessing object properties with variables you must use brackets.
Apr 16 2016 01:49 UTC
@haraldur12 - and as they show in the examples on that exercise, if I recall correctly, you have to explicitly add spaces between words, using a syntax like this: var1 + ' ' + var2, etc.
Diego Mayer
@Chrono79
Apr 16 2016 01:49 UTC
@WilliamDecker [] is not only for arrays, you can use it to access object properties too
Ozan Araz
@haraldur12
Apr 16 2016 01:49 UTC
@khaduch Ken thanks for the tip!
CamperBot
@camperbot
Apr 16 2016 01:49 UTC
haraldur12 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Ozan Araz
@haraldur12
Apr 16 2016 01:49 UTC
I solved the problem
Bob Evermore
@BeeQuickest
Apr 16 2016 01:49 UTC
@JLipschitz The reason I put the <collection[id][prop]=prop; > is because I'm getting TypeError: Cannot set propety 'ABBA' of undefined. That error goes away when I set the value of prop but still not getting any green check marks...
Ozan Araz
@haraldur12
Apr 16 2016 01:49 UTC
it was because of the quotes
Apr 16 2016 01:49 UTC
@haraldur12 - great!
WilliamDecker
@WilliamDecker
Apr 16 2016 01:50 UTC
okay thanks @sjames1958gm
CamperBot
@camperbot
Apr 16 2016 01:50 UTC
williamdecker sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 659 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 16 2016 01:50 UTC
Bob Evermore
@BeeQuickest
Apr 16 2016 01:51 UTC
js
function updateRecords(id, prop, value) {
if (value !== "") {
if (prop !== "tracks") {
//        collection[id][prop]=prop;
collection[id][prop][value]=value;

}
else {
// push value into array at end of existing data
collection[id][prop].push(value);

}
} else {
//    } else delete collection property
delete (collection[id][prop]);
//  }
}

//    return collection[id][prop][value];
return collection;
}
Diego Mayer
@Chrono79
Apr 16 2016 01:53 UTC

@BeeQuickest

collection[id][prop][value]=value;

should be

collection[id][prop]=value;
Stephen James
@sjames1958gm
Apr 16 2016 01:53 UTC
@BeeQuickest collection[id][prop][value]=value; this is not correct.
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:53 UTC
collection[id][prop][value]=value; you want to change the property to = the value here which in turn changes the value inside that property
Bob Evermore
@BeeQuickest
Apr 16 2016 01:54 UTC
How do I send brownie points? You guys are the best!
Stephen James
@sjames1958gm
Apr 16 2016 01:54 UTC
@BeeQuickest Use their id with a thanks
CamperBot
@camperbot
Apr 16 2016 01:54 UTC
sjames1958gm sends brownie points to @beequickest :sparkles: :thumbsup: :sparkles:
:star: 227 | @beequickest | http://www.freecodecamp.com/beequickest
Bob Evermore
@BeeQuickest
Apr 16 2016 01:55 UTC
@sjames1958gm thanks!
CamperBot
@camperbot
Apr 16 2016 01:55 UTC
beequickest sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 660 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Bob Evermore
@BeeQuickest
Apr 16 2016 01:55 UTC
@jlipshitz Thanks!
CamperBot
@camperbot
Apr 16 2016 01:55 UTC
beequickest sends brownie points to @jlipshitz :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jlipshitz
Ozan Araz
@haraldur12
Apr 16 2016 01:55 UTC

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

Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:57 UTC
@haraldur12 that's great! now look to do something about adding spaces in between your variables var1 + "space" + var2 so that's its not all joined together
Diego Mayer
@Chrono79
Apr 16 2016 01:57 UTC
@BeeQuickest you don't need to type the id, left click on their picture, mention copy and paste their id for you
Hal Trazo
@htdesign
Apr 16 2016 01:57 UTC
not sure if im at the right room or not. but which parallax plugin do you guys use?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 01:58 UTC
@BeeQuickest missing a c there in my name^_^
Diego Mayer
@Chrono79
Apr 16 2016 01:58 UTC
@haraldur12 don't forget to put words in between so the final sentence makes sense
help rooms
CamperBot
@camperbot
Apr 16 2016 01:58 UTC

# FreeCodeCamp Chat Rooms

### Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap FreeCodeCamp/Help
JavaScript/Algorithms FreeCodeCamp/HelpJavaScript
Front End FreeCodeCamp/HelpFrontEnd
Data Visualization FreeCodeCamp/HelpDataViz
Back End FreeCodeCamp/HelpBackEnd

Choose the right room for your questions!

Diego Mayer
@Chrono79
Apr 16 2016 01:59 UTC
@htdesign isn't that a front end related question?
Bob Evermore
@BeeQuickest
Apr 16 2016 01:59 UTC
@Jlipschitz THANKS!!!
CamperBot
@camperbot
Apr 16 2016 01:59 UTC
beequickest sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 119 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Bob Evermore
@BeeQuickest
Apr 16 2016 01:59 UTC
@Chrono79 Thanks!!!
CamperBot
@camperbot
Apr 16 2016 01:59 UTC
beequickest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 415 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 16 2016 02:00 UTC
@BeeQuickest no problem, you can also mention more than one person at a time ;)
Ozan Araz
@haraldur12
Apr 16 2016 02:02 UTC
@Chrono79 which words?
Frank XC
@tenkdayz
Apr 16 2016 02:02 UTC

can someone explain this to me?

var arr = [1,2,3];
var temp = arr;
delete arr[1];
return temp; // temp: [1,,3];

why?

UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 02:03 UTC
@tenkdayz because index starts from 0
Ozan Araz
@haraldur12
Apr 16 2016 02:03 UTC
delete arr1gets the value of the second object
Frank XC
@tenkdayz
Apr 16 2016 02:03 UTC
@UtkarshShukla7 no look i delete it form arr .. not temp
so why is temp same as arr?
Ozan Araz
@haraldur12
Apr 16 2016 02:03 UTC
because you are assigning var temp to arr
Diego Mayer
@Chrono79
Apr 16 2016 02:04 UTC
@haraldur12
big dog ran quickly <- doesn't make sense to me (unless you are Tarzan ;)), you have to put some words in between to fix that
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 02:04 UTC
@tenkdayz becuase no new array is created only the reference is passed
Frank XC
@tenkdayz
Apr 16 2016 02:04 UTC
@haraldur12 isnt temp a copy of arr?
Ozan Araz
@haraldur12
Apr 16 2016 02:05 UTC
you are saying that the are equal so when you delete it from the arr the outcome of the var is 1 -2 since [1] the array starts with 0
Frank XC
@tenkdayz
Apr 16 2016 02:06 UTC
@haraldur12 I understand the index thing.. I just dont see why is temp affected if Im not doing anything to it.
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 02:06 UTC
I wouldn't say that it's because they are equal but rather you are referencing that array. any changes made to the original will reflect on the var you referenced it to
var temp = arr is just telling the compiler to point to arr when you use temp
Mauricio
@maudevelop
Apr 16 2016 02:07 UTC
So I just did the "Sorted Union" which is just uniting all values unique in many arrays, and I got it working with a little help with the Mozilla documentation, but have a question on how exactly this array reduce function is doing its work?
function uniteUnique(arr1, arr2, arr3) {
//Flatten array
var args = Array.from(arguments).reduce(function (a,b){
return a.concat(b);
});
the function (a,b) exactly, what is being passed on as A and what as B?
Jamie Lipschitz
@Jlipschitz
Apr 16 2016 02:08 UTC
@tenkdayz http://stackoverflow.com/questions/4220611/why-does-changing-one-array-alters-the-other check this link out for a better understanding
Frank XC
@tenkdayz
Apr 16 2016 02:09 UTC
@UtkarshShukla7 @haraldur12 @Jlipschitz thanks guys.
CamperBot
@camperbot
Apr 16 2016 02:09 UTC
tenkdayz sends brownie points to @utkarshshukla7 and @haraldur12 and @jlipschitz :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Apr 16 2016 02:09 UTC
@maudevelop a is the previous value and b is the current value of the array being processed. The initial "previous" value can be specified after the }
CamperBot
@camperbot
Apr 16 2016 02:09 UTC
:star: 120 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
:star: 312 | @utkarshshukla7 | http://www.freecodecamp.com/utkarshshukla7
:star: 176 | @haraldur12 | http://www.freecodecamp.com/haraldur12
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 02:09 UTC
@tenkdayz np
Mauricio
@maudevelop
Apr 16 2016 02:09 UTC
@sjames1958gm but what's the previous value?
Stephen James
@sjames1958gm
Apr 16 2016 02:10 UTC
@maudevelop I would write it this way to be explicit
var args = Array.from(arguments).reduce(function (prev, curr) {
return prev.concat(curr);
}, []);
Mauricio
@maudevelop
Apr 16 2016 02:10 UTC
prev is just [0] and current is [1]?
and then so on and so on
Stephen James
@sjames1958gm
Apr 16 2016 02:11 UTC
The value returned from the inside function is the prev value on the next cycle, or the return value from reduce at the end of the loop
@maudevelop No
Mauricio
@maudevelop
Apr 16 2016 02:12 UTC
Hmm
Stephen James
@sjames1958gm
Apr 16 2016 02:12 UTC
This would sum the values in the array [1, 2, 3].reduce(function(prev, curr) { return prev + curr; }, 0); prev is 0, 1, 3 and curr 1, 2, 3 and 6 is returned
@sjames1958gm The previous value is sometimes called the accumulator as it is building up the final value.
Mauricio
@maudevelop
Apr 16 2016 02:15 UTC
okay so the current one is basically a counter running through all the array and the previous value is what the return function is doing to that value (the accumulator)
That's how im getting it right now, is that correct?
Stephen James
@sjames1958gm
Apr 16 2016 02:20 UTC
yes
If you have an array and you need a single value think reduce
Pat Lee
@pleedesigner
Apr 16 2016 02:24 UTC
This message was deleted
WilliamDecker
@WilliamDecker
Apr 16 2016 02:28 UTC
working on the Profile Lookup challenge
jesus it's hard for me to try to get through...I don't want to lookup the solution or try to google too much because I don't feel like I'm learning if I do that
but there is a greater than 0 chance my head may explode lol
Jarod Spiewak
@Memj
Apr 16 2016 02:32 UTC
part of Being a developer is knowing how to use Google.
WilliamDecker
@WilliamDecker
Apr 16 2016 02:34 UTC
I have a hard time figuring out where my logic is failing with the feedback
cannelflow
@cannelflow
Apr 16 2016 02:35 UTC
Jarod Spiewak
@Memj
Apr 16 2016 02:35 UTC
Can you paste what you have?
WilliamDecker
@WilliamDecker
Apr 16 2016 02:35 UTC
yeah, I don't know if it's a mess, it's my brain failing, so it's still in progress :D
right now that's giving me the result of "No such property"
"Bob","number" passes with "No such contact"
and all the others fail
are the tests done top to bottom?
Stephen James
@sjames1958gm
Apr 16 2016 02:36 UTC
@WilliamDecker Can you explain what the inner for loop is for?
WilliamDecker
@WilliamDecker
Apr 16 2016 02:37 UTC
I think it's for going through the secondary arrays? the like's
I just realized there is the test item at the bottom for testing your function
Stephen James
@sjames1958gm
Apr 16 2016 02:38 UTC
@sjames1958gm "the given property (prop) is a property of that contact." There is nothing about going through any loops
Jarod Spiewak
@Memj
Apr 16 2016 02:39 UTC

That's the function call @WilliamDecker . You can use it to test but that's what actually allows your function to run.

Without a function call myFunction(); the function wont run.

WilliamDecker
@WilliamDecker
Apr 16 2016 02:40 UTC
I think I'm reading the question incorrectly, I think I can fix this
Stephen James
@sjames1958gm
Apr 16 2016 02:45 UTC
@WilliamDecker Reading these challenges sometime I can see why those where English is not their first language have so much trouble.
WilliamDecker
@WilliamDecker
Apr 16 2016 02:48 UTC
holy shit...I'm a native English speaker
:)
don't worry I didn't start with an ego, so you didn't bruise much :)
Stephen James
@sjames1958gm
Apr 16 2016 02:49 UTC
No insult was intended
WilliamDecker
@WilliamDecker
Apr 16 2016 02:49 UTC
none taken :)
Joe B
@jbreality
Apr 16 2016 02:52 UTC
I'm stuck on that profile look up too heh
I should've known it needed a for look considering I just went over it, was trying to do it only with if/else if commands
Stephen James
@sjames1958gm
Apr 16 2016 02:54 UTC
These two statements are confusing and lead to incorrect code:
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.
Joe B
@jbreality
Apr 16 2016 02:55 UTC
yea, I think that was what was throwing me as well
Stephen James
@sjames1958gm
Apr 16 2016 02:56 UTC
The first inclination is to do if (firstname matches and property matches) return value else ...
Johnny K Juarez
@Reapnsow
Apr 16 2016 02:56 UTC
Hello, I'm currently stuck on the Local Scope and Functions lesson.
it's asking me to declare myVar inside of a function, then run the function
and afterwards to delete the second console.log
Son Dang
@viiiprock
Apr 16 2016 02:57 UTC
so do it
Frank XC
@tenkdayz
Apr 16 2016 02:57 UTC
just do it!
Joe B
@jbreality
Apr 16 2016 02:57 UTC
yep, I tried several different versions of that Stephen, and nothing was working, I'm going to clear my head and figure out a for statement
Johnny K Juarez
@Reapnsow
Apr 16 2016 02:57 UTC
Well After i do it, I get a red X next to "No global myVar variable", but when I add a global myVar
nothing changes
Stephen James
@sjames1958gm
Apr 16 2016 02:57 UTC
@jbreality You need a for statement to loop over the contacts, but not another one.
@Reapnsow You are supposed to run it and see there is an error in the little black window and then comment out the console.log outside the function run it again and it should pass
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:00 UTC
@sjames1958gm that doesn't work either.
Son Dang
@viiiprock
Apr 16 2016 03:00 UTC
Stephen James
@sjames1958gm
Apr 16 2016 03:00 UTC
@jbreality What it really means is if (firstname matches) if (property exists) return value of property else no such property
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:00 UTC

function myLocalScope() {
'use strict';
var myVar = "hello";

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

Stephen James
@sjames1958gm
Apr 16 2016 03:01 UTC
@Reapnsow Did you remove or comment out the second console.log
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:01 UTC
@sjames1958gm both
Son Dang
@viiiprock
Apr 16 2016 03:02 UTC
what, you are just remove the console.log out side the function
just remove or comment it
and pass

function myLocalScope() {
'use strict';
var myVar = "hello";

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
//console.log(myVar);

// Now remove the console log line to pass the test

Johnny K Juarez
@Reapnsow
Apr 16 2016 03:03 UTC
@viiiprock I have done that, and it doesn't pass.......
Son Dang
@viiiprock
Apr 16 2016 03:04 UTC
function myFunction() {
'use strict';
var myVar;
console.log(myVar);
}
myFunction();
this is what I did lol
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:05 UTC
doing that gives me "console.log never called"
Diego Mayer
@Chrono79
Apr 16 2016 03:06 UTC
g'nite people
ALMY91
@ALMY91
Apr 16 2016 03:09 UTC
are values which can be manipulated called types?
Jarod Spiewak
@Memj
Apr 16 2016 03:09 UTC
They're called mutable
Types are String, Int, Boolean, Double, Float, etc.
Son Dang
@viiiprock
Apr 16 2016 03:11 UTC
@Reapnsow you could did right, but I don't know what bug is it, just reset & paste it again
function myLocalScope() {
'use strict';
var myVar = "hello";
console.log(myVar);
}
myLocalScope();
Johnny K Juarez
@Reapnsow
Apr 16 2016 03:11 UTC
@sjames1958gm @viiiprock solved it, apparently, if you mess up you HAVE to refresh the page to reset the requirements to pass the test.
Dylan
@dhcodes
Apr 16 2016 03:11 UTC
night @Chrono79
ALMY91
@ALMY91
Apr 16 2016 03:11 UTC
Im reading the definitive guide @Memj
@Memj and it states that "The kinds of values that can be represented and manipulated in a programming language are known as types"
Jarod Spiewak
@Memj
Apr 16 2016 03:14 UTC
ALMY91
@ALMY91
Apr 16 2016 03:15 UTC
@Memj okay let me rephrase this , values in javascript are also known as types, of which they could be primitive or objects types. And they can be further divided into mutable and non mutable ones.
@Memj are we on the same page? cause the book is confusing me
Jarod Spiewak
@Memj
Apr 16 2016 03:21 UTC

yes, values are types.

var myArray = [0,1,2]; //Type: Array
var integer = 4; //Type: Int

These values can be manipulated in JS easily (code source MDN)

var foo = 42;    // foo is now a Number
var foo = "bar"; // foo is now a String
var foo = true;  // foo is now a Boolean
Son Dang
@viiiprock
Apr 16 2016 03:22 UTC
buonarfcc
@buonarfcc
Apr 16 2016 03:32 UTC

Please help with what I miss applying object & prop's name on these codes of mine: Thanks. ->//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 lookUpProfile(firstName,lastName,number,likes, prop){
// Only change code below this line
for(var i=0; i < contacts.length; i++) {
var contact = contacts[i];
if (contact.firstName === firstName){return contact[prop];}
else if ( contact.firstName.prop === lastName) {return contacts[prop];}
else if ( contact.firstName.number === number){return contacts[prop];}
else if ( contact.firstName.likes === likes){return contacts[prop];}
else return "No such property";
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");

WilliamDecker
@WilliamDecker
Apr 16 2016 03:41 UTC
I did it
I powered through my stupid to get the results to the Profile Lookup
it's amazing how quickly I forgot the lessons of the immediate previous exercises
WilliamDecker
@WilliamDecker
Apr 16 2016 03:47 UTC
@buonarfcc contact I believe should be contacts
@buonarfcc also you need to use bracket notation for variables
Erin Heard
@ufi16
Apr 16 2016 03:49 UTC
i'm confused on the Return Early Patterns for Functions challenge. how do i set it up so that when a var is less than 0 the function will exit with undefined?
Jarod Spiewak
@Memj
Apr 16 2016 03:51 UTC
use return
Erin Heard
@ufi16
Apr 16 2016 03:51 UTC
i am and the test isn't running correctly
Jarod Spiewak
@Memj
Apr 16 2016 03:52 UTC
Erin Heard
@ufi16
Apr 16 2016 03:52 UTC

// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0, b < 0) {
return;
}

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

Jarod Spiewak
@Memj
Apr 16 2016 03:52 UTC
you need to use or || not a comma
so a < 0, b < 0 should be a < 0 || b < 0
Erin Heard
@ufi16
Apr 16 2016 03:53 UTC
thank you @Memj
CamperBot
@camperbot
Apr 16 2016 03:53 UTC
ufi16 sends brownie points to @memj :sparkles: :thumbsup: :sparkles:
:star: 319 | @memj | http://www.freecodecamp.com/memj
Son Dang
@viiiprock
Apr 16 2016 03:55 UTC
for(var i=0; i < contacts.length; i++) {
var contact = contacts[i];
if (contact.firstName === firstName) {
sorry
V Arun Kumar
@arunvkumr
Apr 16 2016 03:57 UTC
wiki profile
CamperBot
@camperbot
Apr 16 2016 03:57 UTC

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

ewpratt
@ewpratt
Apr 16 2016 03:57 UTC
having an issue with the queue problem.

function nextInLine(arr, item) {
var removed;
testArr.push(item);
removed = testArr.shift(0);
return removed; // Change this line
}

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

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

 but the results are: nextInLine([], 1) should return 1
nextInLine(pugjs/pug#2184, 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
V Arun Kumar
@arunvkumr
Apr 16 2016 03:58 UTC
@ewpratt remove 0 in shift
ewpratt
@ewpratt
Apr 16 2016 03:58 UTC
nope... same result
Son Dang
@viiiprock
Apr 16 2016 03:59 UTC
@buonarfcc I think it should be
for(var i=0; i < contacts.length; i++) {
var contact = contacts[i];
if (contact.firstName === firstName) {
if (contact[prop]) {
return contact[prop]
} else {
return "No such property";
}
}
return "No such contact";
V Arun Kumar
@arunvkumr
Apr 16 2016 03:59 UTC
@ewpratt use arr not testArr, testArr is global you have to use arr as the value.
ewpratt
@ewpratt
Apr 16 2016 03:59 UTC
the console log lines seem to be correct, but the checks aren't working out
ritzdacanay24
@ritzdacanay24
Apr 16 2016 04:00 UTC
Hello
ewpratt
@ewpratt
Apr 16 2016 04:01 UTC
thanks @arunkumrv
CamperBot
@camperbot
Apr 16 2016 04:01 UTC
ewpratt sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 461 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 16 2016 04:03 UTC

@buonarfcc

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

you're first if condition is correct, now you have to check if the property exists, for that you have to check with the contacts objects, not contacts[i].firstNameand to check if prop exists or not. you can use hasOwnProperty function.

buonarfcc
@buonarfcc
Apr 16 2016 04:05 UTC
Son Dang why not contacts instead of contact?
Erin Heard
@ufi16
Apr 16 2016 04:06 UTC
am i supposed to use a switch or if/else argument in the Counting Cards challenge?
Jarod Spiewak
@Memj
Apr 16 2016 04:06 UTC
if else is how I did it
V Arun Kumar
@arunvkumr
Apr 16 2016 04:08 UTC
@ufi16 you can solving it by any way you want, if it is not mentioned in the challenge.
Erin Heard
@ufi16
Apr 16 2016 04:12 UTC
i think i set up the switch right, but i don't think my return is right

var count = 0;

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

// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

V Arun Kumar
@arunvkumr
Apr 16 2016 04:14 UTC
wiki count
CamperBot
@camperbot
Apr 16 2016 04:14 UTC

# Count Backwards With a For Loop

A for loop can also count backwards, so long as we can define the right conditions.

In order to count backwards by twos, we'll need to change our initialization, condition, and final-expression.

We'll start at i = 10 and loop while i > 0. We'll decrement i by 2 each loop with i -= 2.

var ourArray = [];

for(var i = 10; i > 0; i -= 2) {

ourArray.push(i);

}

ourArray will now contain [10,8,6,4,2]

Luis
@zdrifted
Apr 16 2016 04:14 UTC
I'm confused here. Any previous maps I should refer too that would help me understand this "Profile Lookup" challenge?
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 lookUpProfile(firstName, prop){
// Only change code below this line
if ( contacts[firstName] === true && contacts[firstName[prop]] === true) {
return contacts[firstName][prop];
}
if (contacts[firstName] === false) {
return "No such contact";
}
if (contacts[firstName][prop] === false) {
return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
V Arun Kumar
@arunvkumr
Apr 16 2016 04:14 UTC
wiki count cards
CamperBot
@camperbot
Apr 16 2016 04:14 UTC
no wiki entry for: count cards
V Arun Kumar
@arunvkumr
Apr 16 2016 04:14 UTC
find cards
CamperBot
@camperbot
Apr 16 2016 04:14 UTC

find cards

V Arun Kumar
@arunvkumr
Apr 16 2016 04:14 UTC
wiki cards
CamperBot
@camperbot
Apr 16 2016 04:14 UTC

# Checkpoint: Counting Cards

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

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

Instructions

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.

Example Output:

Jarod Spiewak
@Memj
Apr 16 2016 04:15 UTC
@ufi16 switch statements need a default
buonarfcc
@buonarfcc
Apr 16 2016 04:15 UTC
txs for explanation @arunkumrv
CamperBot
@camperbot
Apr 16 2016 04:15 UTC
buonarfcc sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 462 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 16 2016 04:15 UTC
@Memj default is not mandatory.
Jarod Spiewak
@Memj
Apr 16 2016 04:17 UTC
no? Hm. Well, it's still good language practice to include it
Erin Heard
@ufi16
Apr 16 2016 04:17 UTC
thank you @camperbot
CamperBot
@camperbot
Apr 16 2016 04:17 UTC
ufi16 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1556 | @camperbot | http://www.freecodecamp.com/camperbot
Erin Heard
@ufi16
Apr 16 2016 04:18 UTC
thank you @arunkumrv
CamperBot
@camperbot
Apr 16 2016 04:18 UTC
ufi16 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 463 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Son Dang
@viiiprock
Apr 16 2016 04:21 UTC
@buonarfcc you declared var contact = contacts[i], so you could look up contact[prop] instead of contacts[i][prop]
V Arun Kumar
@arunvkumr
Apr 16 2016 04:21 UTC

@Rushh contacts is an array of objects.. to check with every entry you have to use a loop. This is what you need to do.

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.

Using the variable firstName check if the contacts exists or not and if he does return the property(for this you can check out hasOwnProperty function( or compare it with undefined).

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

If contact doesn't exist return no such property.

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

After checking with all the entries if you didn't find the contact return no such property.

Apr 16 2016 04:23 UTC

@Rushh - hello there - I don't have more than a couple minutes, but you'll want to review (or recall) for loops, because the contacts structure is an array with objects, you need to have a loop to process through it to find matching names. You'll also want to review the Object.hasOwnProperty() method, which they link to in the exercise. Also how to access object properties using variables. Oh, and the Array.push() method.

Good luck!

Luis
@zdrifted
Apr 16 2016 04:25 UTC
CamperBot
@camperbot
Apr 16 2016 04:25 UTC
rushh sends brownie points to @khaduch and @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 464 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 16 2016 04:25 UTC

@ufi16

Instructions
You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.

Inside each case you have to use the global count variable(either increment or decrement) using the table given and after that print count with either Bet or Hold using the condition given in the challenge.

ALMY91
@ALMY91
Apr 16 2016 04:29 UTC
values in javascript are also known as types, of which they could be primitive or objects types. And they can be further divided into mutable and non mutable ones.
am i correct?
V Arun Kumar
@arunvkumr
Apr 16 2016 04:30 UTC
@ALMY91 ya, i think that's right.
Luis
@zdrifted
Apr 16 2016 04:37 UTC
@arunkumrv Am I on the right track here?

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

V Arun Kumar
@arunvkumr
Apr 16 2016 04:42 UTC
@Rushh Close..
hasOwnProperty function returns boolean values (i.e either true or false). So you have to return the property not true or false.. and the first if condition you have to compare with the firstName value of object to the firstname of the function. not the property firstName exists or not.
Luis
@zdrifted
Apr 16 2016 04:53 UTC
Would a for in loop help there?
ALMY91
@ALMY91
Apr 16 2016 04:55 UTC
has anyone tried jsjiddle.net?
jsfiddle.net
Luis
@zdrifted
Apr 16 2016 04:56 UTC
I use it sometimes
V Arun Kumar
@arunvkumr
Apr 16 2016 04:57 UTC
@Rushh your for is fine.. first if condition you need to compare it with the firstname of the function argument. like contacts[i].firstName === firstName, the problem with your if condition contacts[i].hasOwnProperty(firstName) is that it only checks if the firstName property exists in the contacts array. So for any value of firstName it will always return true.
then once the conditions are done.. return property of the contact.
ALMY91
@ALMY91
Apr 16 2016 04:58 UTC
im just wondering why isn the code working after i clicked run, this is my first time using it
@Rushh
Luis
@zdrifted
Apr 16 2016 04:58 UTC
if( contacts[i][firstName] == firstName && contacts[i][prop] == prop ) {
return contacts[i][prop];
V Arun Kumar
@arunvkumr
Apr 16 2016 05:00 UTC
@ALMY91 i think this value you will see in dev console. press F12.
@Rushh ya that's right.. but the second if condition your contact[i][prop] is value of the property and you are comparing with the property name.
@Rushh you can compare it with undefined to check if the value exists like contacts[i][prop] != undefined or using the hasOwnProperty function like you did in your previous code :point_up_2:
Nari Roh
@NariRoh
Apr 16 2016 05:04 UTC
help Using Objects for Lookups
CamperBot
@camperbot
Apr 16 2016 05:04 UTC

# Challenge: Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"
V Arun Kumar
@arunvkumr
Apr 16 2016 05:05 UTC
@ALMY91 you are working only in js then try this site, https://repl.it/languages/javascript . it supports other languages as well
ALMY91
@ALMY91
Apr 16 2016 05:06 UTC
@arunkumrv whats a dev console? and other than a dev console what else are there?
Luis
@zdrifted
Apr 16 2016 05:07 UTC
Ok so I have this so far
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
if( contacts[i][firstName] === firstName && contacts[i][prop] !== undefined ) {
return contacts[i][prop];
}
if( contacts[i].hasOwnProperty(firstName) === false) {
return "No such contact";
}
if( contacts[i].hasOwnProperty(prop) === false ) {
return "No such property";
}
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
ALMY91
@ALMY91
Apr 16 2016 05:09 UTC
Is anybody able to help me out in here?
Luis
@zdrifted
Apr 16 2016 05:10 UTC
Alright I'm going to take a break and stretch a bit. I'm brain locking right now
ALMY91
@ALMY91
Apr 16 2016 05:10 UTC
I tried running my file using chrome but it just prints out all the code i hv written
Luis
@zdrifted
Apr 16 2016 05:10 UTC
Thanks again though for the help Arun
V Arun Kumar
@arunvkumr
Apr 16 2016 05:11 UTC
@Rushh instead of using 3 if, you can try else-if clause it's efficient and remove the no such contact clause because you wouldn't need it now. and if you read the instruction for no such property it's says if the property doesn't exist then return no such property... so it will be almost same as the first if's condition, the only diff would be you will check it with undefined this time.
like contacts[i][prop] == undefined
henrywashere
@henrywashere
Apr 16 2016 05:13 UTC

anyone know what im suppose to do here:

Instructions
Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.
Call the function.

functionWithArgs(1,2) should output 3
functionWithArgs(7,9) should output 16

ALMY91
@ALMY91
Apr 16 2016 05:13 UTC
this is what happens when i try running it in internet explorer
it just prints out everything that i have written
kirbyedy
@kirbyedy
Apr 16 2016 05:14 UTC
@henrywashere you should create a function that is suppose to sum two numbers in the brackest
Apr 16 2016 05:14 UTC
do you guys know if there is a handy method to say "for each element in this array except this one"?
Like, if I'm iterating over an array or arrays, and when focusing on element #2, I want to compare things in it to those in element #0, #1, #3 and #4, but not itself
henrywashere
@henrywashere
Apr 16 2016 05:15 UTC
ok ill try it
V Arun Kumar
@arunvkumr
Apr 16 2016 05:15 UTC
@ALMY91 did you save the file correctly? you are runnin xampp so i think you have a local server right? and save the file in .html format looks like you saved it in chapter3.1.5
ALMY91
@ALMY91
Apr 16 2016 05:16 UTC
@arunkumrv i saved it in html format , that was my subject for the file
kirbyedy
@kirbyedy
Apr 16 2016 05:16 UTC
@henrywashere and you have to output the result to the console... with console.log
V Arun Kumar
@arunvkumr
Apr 16 2016 05:17 UTC
@ALMY91 is your xampp server running?
Frank XC
@tenkdayz
Apr 16 2016 05:17 UTC
@Radascript use something like if indoxof arr i !== j ?
henrywashere
@henrywashere
Apr 16 2016 05:18 UTC

this is what i wrote so far

function functionWithArgs(value1, value2) {
console.log(value1, value2);
}

ALMY91
@ALMY91
Apr 16 2016 05:18 UTC
@arunkumrv i forgot abt tt haha, just turned it on but it still ain working... when i open it in internet explorer it prints out everything tt i have written, wheras in chrome nth is printed out
V Arun Kumar
@arunvkumr
Apr 16 2016 05:18 UTC
@ALMY91 open dev console.. press F12 in chrome it will open the console there you will see the output..
kirbyedy
@kirbyedy
Apr 16 2016 05:19 UTC
@henrywashere what does the console.log output?
Apr 16 2016 05:19 UTC
@tenkdayz yeah I've been manually skipping it within a loop, was wondering if there is some better syntax along the lines of "eachElementExcepe" or whatever. ty though
Frank XC
@tenkdayz
Apr 16 2016 05:20 UTC
@Radascript are you working on symmetric difference?
ALMY91
@ALMY91
Apr 16 2016 05:20 UTC
nth is appearing @arunkumrv
Apr 16 2016 05:20 UTC
@tenkdayz haha yes
Joe B
@jbreality
Apr 16 2016 05:20 UTC
So I was at like 95% of the code figured out for the profile lookup, but I looked up what i was misisng
Frank XC
@tenkdayz
Apr 16 2016 05:21 UTC
@Radascript I was just working on that also.. embrace the pain.
V Arun Kumar
@arunvkumr
Apr 16 2016 05:21 UTC
@ALMY91 type console.log("hello from dev console"); inside your script tag.
Joe B
@jbreality
Apr 16 2016 05:21 UTC
and I don't get why if (contacts[x][prop]) works and it's not if (prop == contact[x][prop])
V Arun Kumar
@arunvkumr
Apr 16 2016 05:21 UTC
@ALMY91 do you see anything now?
Apr 16 2016 05:22 UTC
@tenkdayz I skipped it yesterday because I wasn't sure how to start and solved Exact Change, took me so long. Now back to that one
Joe B
@jbreality
Apr 16 2016 05:22 UTC
contacts[x][prop] does not work
sorry
ALMY91
@ALMY91
Apr 16 2016 05:24 UTC
@arunkumrv wait where again?
Frank XC
@tenkdayz
Apr 16 2016 05:24 UTC
@Radascript I'll give it another shot in a bit..
ALMY91
@ALMY91
Apr 16 2016 05:24 UTC
@arunkumrv do u mean here? or the console tab?
V Arun Kumar
@arunvkumr
Apr 16 2016 05:25 UTC
@ALMY91 inside your html file, inside<scritp> </script> tag
Apr 16 2016 05:25 UTC
@tenkdayz I also have skipped 4 internediate challenges - Missing Letters, Spinal Tap Case, Smallest Common Multiple and Steamroller. I'll be coming back to those in a bit
Frank XC
@tenkdayz
Apr 16 2016 05:25 UTC
@Radascript I just solved the last one I forgot the name.. that one is easier I think.
Apr 16 2016 05:26 UTC
@tenkdayz the phone numbers one?
Frank XC
@tenkdayz
Apr 16 2016 05:26 UTC
ALMY91
@ALMY91
Apr 16 2016 05:27 UTC
@arunkumrv nope nth
Frank XC
@tenkdayz
Apr 16 2016 05:27 UTC
missing letter was fun one.. I just like the feeling when you solve something on your own
Apr 16 2016 05:27 UTC
@tenkdayz ohh last one in that section, cool. I haven't looked at it yet
ALMY91
@ALMY91
Apr 16 2016 05:27 UTC
@arunkumrv ohyeah i do get smth if i press f12 tho
Apr 16 2016 05:28 UTC
@tenkdayz yes, especially when you've been banging your head against the wall for a few hours and then you get that green checkmark
ALMY91
@ALMY91
Apr 16 2016 05:28 UTC
@arunkumrv
@arunkumrv is this what ur looking at?
Frank XC
@tenkdayz
Apr 16 2016 05:28 UTC
@Radascript and when you get the green checkmark and wonder why ha
V Arun Kumar
@arunvkumr
Apr 16 2016 05:29 UTC
@ALMY91 yea.. everything is working fine.. now you need to type valid code to get the output. :smile:
Frank XC
@tenkdayz
Apr 16 2016 05:29 UTC
@Radascript if youre doing the advance ones you'll find the intermediate easier you just have to look at the from a different point of view.
ALMY91
@ALMY91
Apr 16 2016 05:30 UTC
@arunkumrv actually why does it only work in f12 ? im not too sure why it does work when i save the file under js, but it only works if i save it in html format..
@arunkumrv and what does development console means?
Apr 16 2016 05:30 UTC
@tenkdayz yeah what happened with those four is I decided to start over but I was so fed up with that I just decided that I'm better off returning in a little bit
henrywashere
@henrywashere
Apr 16 2016 05:31 UTC

@kirbyedy didnt go through :(

function functionWithArgs(value1, value2) {
console.log(value1, value2);
}
functionWithArgs(1, 2);

ALMY91
@ALMY91
Apr 16 2016 05:31 UTC
@arunkumrv i mean it does not work when i save the file under js
Joe B
@jbreality
Apr 16 2016 05:32 UTC
would someone mind if I PM'ed thing, I have a question about a specific piece of the Profile Lookup challenge
*them
V Arun Kumar
@arunvkumr
Apr 16 2016 05:33 UTC
@ALMY91 F12 opens the developer console, this is like the magic wand for web developers :wink: . It shows the errors and it helps you to change the code of other sites to see how it works.. FCC has a challenge for dev console. you can check it out if you want to learn.
kirbyedy
@kirbyedy
Apr 16 2016 05:34 UTC
@henrywashere in the console log line in the brackets sum the values
ALMY91
@ALMY91
Apr 16 2016 05:35 UTC
@arunkumrv but why doesn it work the normally like how a html file does? for example im not getting the output im looking at just by saving the file under .js and running it directly.
kirbyedy
@kirbyedy
Apr 16 2016 05:35 UTC
now, you are just logging them
@henrywashere if you put an operator it should output the sum of those two values
V Arun Kumar
@arunvkumr
Apr 16 2016 05:35 UTC
@ALMY91 i think that's because everything in works under html, so js should be included in html to make it work either internally or externally.
Frank XC
@tenkdayz
Apr 16 2016 05:35 UTC
@Radascript symmetric diff. suggest using reduce are you using that?
ALMY91
@ALMY91
Apr 16 2016 05:36 UTC
@arunkumrv okay i see, but for css files if u include them internally, u cld just run it straight . u don hv to go into f12 to see the end results , if u get where i am coming from
@arunkumrv although it needs html to work as well
henrywashere
@henrywashere
Apr 16 2016 05:37 UTC
awesome i got it
thanks @kirbyedy
CamperBot
@camperbot
Apr 16 2016 05:37 UTC
henrywashere sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 872 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
ALMY91
@ALMY91
Apr 16 2016 05:39 UTC
@arunkumrv and not forgotting externally, u cld run it straight in the browser too so long u have included the link to the css file in the html file
@arunkumrv so im a tad confused w how javascript works. why is it so that we have to enter f12 to view the results?
V Arun Kumar
@arunvkumr
Apr 16 2016 05:42 UTC
@ALMY91 if you open either of the js or css file you will see the entire code of the file.. when they are included in html they all work under it.
js needs a console because it's a scripting language and when you F12 what you get is the Javascript console only works for JS. you need console to rectify errors and to find bugs.
ALMY91
@ALMY91
Apr 16 2016 05:42 UTC
Does anybody know the answer to this? Im stuck on page 35 of a 1000 page book haha and i cant move forward without having an answer to this...
Coy Sanders
@coymeetsworld
Apr 16 2016 05:43 UTC
yeah f12 is just the key to open up some tools for a browser like the console
ALMY91
@ALMY91
Apr 16 2016 05:45 UTC
@arunkumrv @coymeetsworld okay correct me if im wrong, so ur saying if i open a css file or js file directly in the browser, the entire code of css/js would appear in it. ONLY when a css file and js file is included in a html file will they then work. HOWEVER for js file we will need a console that is under F12 , and this console will ONLY work for javascript , we won b able to view css or html codes in it
Coy Sanders
@coymeetsworld
Apr 16 2016 05:46 UTC
f12 has a console, but it has other things too
ALMY91
@ALMY91
Apr 16 2016 05:46 UTC
@arunkumrv @coymeetsworld in layman terms what does a console mean?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:46 UTC
console is basically a text screen showing output of your code
its a good tool to use for debugging
for example if you put in your javascript code console.log("hello world");, it would print out hello world
V Arun Kumar
@arunvkumr
Apr 16 2016 05:47 UTC
@ALMY91 right click in chrome and go to inspect element you will get lots more toys to work on. :smile:
Coy Sanders
@coymeetsworld
Apr 16 2016 05:48 UTC
but a more practical use would be to display variables as you run your code, so you can see how your code runs
ALMY91
@ALMY91
Apr 16 2016 05:49 UTC
@arunkumrv @coymeetsworld okay hold on haha info overload..... let me try getting this work first... i tried console.log("hello world"); between my js tags and it works fine in the console
@arunkumrv @coymeetsworld now im trying to get this work but nth is appearing
Coy Sanders
@coymeetsworld
Apr 16 2016 05:49 UTC
get what to work @ALMY91 ?
ALMY91
@ALMY91
Apr 16 2016 05:50 UTC
@coymeetsworld this..
Vivienne Sales
@Natto278
Apr 16 2016 05:51 UTC
Hi. I'm at the Counting Card challenge. I've re-written my code and now nothing works. I'm getting a SyntaxError: Unexpected identifier. What am I doing wrong?

var count = 0;

function cc(card) {
// Only change code below this line
var count =0;
if card >= 2 && <= 6 count ++;
return "5 Bet";

else if card  >= 7 && <= 9 count 0;

return "0 Hold";

else if card = 10 count --;

}

// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

ALMY91
@ALMY91
Apr 16 2016 05:51 UTC
@coymeetsworld did i do anything wrong
@arunkumrv hey thanks bud
CamperBot
@camperbot
Apr 16 2016 05:51 UTC
almy91 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 465 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Coy Sanders
@coymeetsworld
Apr 16 2016 05:51 UTC
what are you trying to accomplish @ALMY91 ? do you want that to be in the console?
@Natto278 you want to use a case/switch statement
because card may not be a number, you can't compare it with >= or <=
ALMY91
@ALMY91
Apr 16 2016 05:52 UTC
@coymeetsworld i would like my code to be running, and if its running the results shd have appeared in the console right?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:53 UTC
no @ALMY91, if you want it to show in the console, you have to put the value you want to display as an argument for console.log()
Apr 16 2016 05:53 UTC
@tenkdayz I wasn't, and I just thought I was done but it turns out if it's in all three arrays it counts again?! what the crappppppp
Coy Sanders
@coymeetsworld
Apr 16 2016 05:53 UTC
so if you wanted to print out elapsed, you would write console.log(elapsed);
ALMY91
@ALMY91
Apr 16 2016 05:53 UTC
@coymeetsworld but how will i know if my js code is working properly?
Paul Borawski
@iAmNawa
Apr 16 2016 05:53 UTC
@coymeetsworld wouldn’t that be an error?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:54 UTC
or if you want to be more descriptive, write something like console.log("Time elapsed: " + elapsed);
what would be an error @iAmNawa ?
Paul Borawski
@iAmNawa
Apr 16 2016 05:54 UTC
i mean if elapsed was undefined, sorry I didn’t read anythign before
Vivienne Sales
@Natto278
Apr 16 2016 05:54 UTC
@coymeetsworld Card may or may not be a number?!?! I used case and switch statements earlier and got the 1st three conditions right. But then I was told I need to use the global count variable.
ALMY91
@ALMY91
Apr 16 2016 05:54 UTC
@ALMY91 im actually calling out a date () constructor, so i wld like to know if the method is working out , and the only way to know if my js is working properly is if it prints out the results right on the console, no?
Coy Sanders
@coymeetsworld
Apr 16 2016 05:54 UTC
no @iAmNawa, @ALMY91 is wondering why nothing is showing up on the console, but he has no console.log commands in it thats why
yeah @Natto278 you need to use the count variable
in the case switch statment
ALMY91
@ALMY91
Apr 16 2016 05:55 UTC
@coymeetsworld its actually grabbing data form my Date() constructor
Coy Sanders
@coymeetsworld
Apr 16 2016 05:55 UTC
add by 1 if card is 2,3,4,5,6
ALMY91
@ALMY91
Apr 16 2016 05:55 UTC
@coymeetsworld from*
Coy Sanders
@coymeetsworld
Apr 16 2016 05:55 UTC
do nothing if its 7,8,9
subtract one from count if its 10, 'J', 'Q', 'K', 'A'
thats all you should do in the case/switch statement
then after, look at the count value and depending on what it is, print either hold or bet with the count number included
Paul Borawski
@iAmNawa
Apr 16 2016 05:56 UTC
@coymeetsworld Sorry, I only saw what you had wrote after, I didn’t know there was actual code, my bad
Coy Sanders
@coymeetsworld
Apr 16 2016 05:56 UTC
right @ALMY91 but you're not printing anything to the console, you still need to do that part
np @iAmNawa lol
ALMY91
@ALMY91
Apr 16 2016 05:57 UTC
@coymeetsworld okay cos i actually went through all the javascript challenges and while i was doing it i didn have to include the console.log in it..
Frank XC
@tenkdayz
Apr 16 2016 05:57 UTC
@Radascript hah yea thats the hard part.
Coy Sanders
@coymeetsworld
Apr 16 2016 05:57 UTC
where are these challenges from @ALMY91 ? is this from free code camp?
ALMY91
@ALMY91
Apr 16 2016 05:57 UTC
@coymeetsworld so i was confused why do i have to add a console.log now when all i have to do is to call the function in the challenges
@coymeetsworld yes
@coymeetsworld it was from free code camp
Coy Sanders
@coymeetsworld
Apr 16 2016 05:58 UTC
but you should be writing it inside the screen it gives you on the specific challenge
then when you click run tests it will verify the values for you in the background and see if your code is right or not
got confused because you're using notepad++ for this
which is fine, just after you want to put that code in the challenge window and execute
ALMY91
@ALMY91
Apr 16 2016 05:59 UTC
@coymeetsworld so do u mean for the FCC challenges they have already included console.log as default? thats why i didn hv to write them for the challenges i did?
Coy Sanders
@coymeetsworld
Apr 16 2016 06:00 UTC
no they don't use console.log, that's just what you can use as a debugging tool
to see how your code is running
they probably do something else to verify your code works, i don't know what exactly but it doesn't really matter
what challenge are you on exactly @ALMY91?
ALMY91
@ALMY91
Apr 16 2016 06:00 UTC
@coymeetsworld ahhh i see okay...
@coymeetsworld im done with all the javascript challenges, moving on to the definitive guidebook.. im on page 35 haha and i have 1000pages more to go
@coymeetsworld thanks bud
CamperBot
@camperbot
Apr 16 2016 06:01 UTC
almy91 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 569 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 06:01 UTC
wait, so this isn't in free code camp? lol
thought you said it was
ALMY91
@ALMY91
Apr 16 2016 06:02 UTC
@coymeetsworld ive alr completed all the challenges in FCC, now im just trying to get some codes from the definitive guidebook to work in a normal setting like notepad++
@coymeetsworld but it isn working like how it used to when i was doing the FCC challenges thats why i got confused
Coy Sanders
@coymeetsworld
Apr 16 2016 06:03 UTC
ok maybe i misunderstood then
yeah FCC does validation for you, if you want to see your code work you need to utilize something like console.log
thats probably the best option
ALMY91
@ALMY91
Apr 16 2016 06:03 UTC
@coymeetsworld okay cool. i'd try working w that. thanks again bud
CamperBot
@camperbot
Apr 16 2016 06:03 UTC
almy91 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: almy91 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Apr 16 2016 06:04 UTC
sure np
Prateek Vasisht
@vaspv
Apr 16 2016 06:10 UTC
Hi - I have a loop problem. Doing Twitch TV and have an array but when I want to get array name in url, it comes undefined. Any ideas where I'm going wrong? CodePen is http://codepen.io/vaspv/pen/VaXLyG
Vivienne Sales
@Natto278
Apr 16 2016 06:15 UTC

@coymeetsworld I've got the 1st three items correct on the Counting Card challenge, but now I 'm having trouble with the 4th item. It keeps returning a "-1 Hold". What am I doing wrong? ar count = 0;

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

case 7:
case 8:
case 9:
return "0 Hold";

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
return "-5 Hold";
break;

case 3:
count++;
case 7:
case 'Q':
count--;
case 8:
case 'A':
count--;
return "-1 Hold";
break;
ALMY91
@ALMY91
Apr 16 2016 06:19 UTC
does anybody know why my lines ain breaking up into 3?
Frank XC
@tenkdayz
Apr 16 2016 06:21 UTC
@vaspv you have to use /channels not /streams to get the info on the offline people
Prateek Vasisht
@vaspv
Apr 16 2016 06:21 UTC
@Natto278 I think you need to put an if statement check for count because - When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.
This message was deleted
Vivienne Sales
@Natto278
Apr 16 2016 06:24 UTC
Thanks for helping get the 1st three items of Counting Cards correct @coymeetsworld
CamperBot
@camperbot
Apr 16 2016 06:24 UTC
natto278 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 570 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:24 UTC
@ALMY91 try console.log("one\nmore\nline");
Prateek Vasisht
@vaspv
Apr 16 2016 06:25 UTC
@tenkdayz ah ok will try that. but also do you know why when I try to get userlist[i] further dow n in the if function, then it comes undefined?
Apr 16 2016 06:25 UTC
@tenkdayz solved it!!!!
ALMY91
@ALMY91
Apr 16 2016 06:26 UTC
@UtkarshShukla7 hey it works but im just wondering , the book states that in ECMAScript 5 we can break a string literal across multiple lines by ending each line but the last w a backslash
@UtkarshShukla7 im not sure why it isn working in my case
Frank XC
@tenkdayz
Apr 16 2016 06:26 UTC
@vaspv Ill take a look.
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:26 UTC
@Natto278 try to return count+"xyz";
Nely
@nextasy2010
Apr 16 2016 06:27 UTC
hey guys
Im stuck on the stand in line challenge
my code is returning the correct answer but seems not to be recognised
Prateek Vasisht
@vaspv
Apr 16 2016 06:27 UTC
@tenkdayz thanks - and yes I will change the url and that gives me the name of the streamer so that will solve the problem but still keen to know why my loop cannot pick the the iterated data
CamperBot
@camperbot
Apr 16 2016 06:27 UTC
vaspv sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 399 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Coy Sanders
@coymeetsworld
Apr 16 2016 06:28 UTC
yw @Natto278
Nely
@nextasy2010
Apr 16 2016 06:28 UTC
Coy Sanders
@coymeetsworld
Apr 16 2016 06:28 UTC
yeah also what everyone else is saying, you don't want to return anything in the case/switch statement
Frank XC
@tenkdayz
Apr 16 2016 06:29 UTC
@Radascript I'm still hacking at it. :d
Coy Sanders
@coymeetsworld
Apr 16 2016 06:29 UTC
you just want to modify the count variable, after the switch statement you need to check if its positive or negative
Frank XC
@tenkdayz
Apr 16 2016 06:29 UTC
@vaspv i know whats going on
Coy Sanders
@coymeetsworld
Apr 16 2016 06:29 UTC
@nextasy2010 use arr, not testArr
you want to use array that is passed into the function
also you don't need to create a variable addNum since you don't do anything with it
Apr 16 2016 06:30 UTC
@tenkdayz i didn't use reduce fwiw, and my code is 40 lines long after tidying it up
Vivienne Sales
@Natto278
Apr 16 2016 06:30 UTC
@UtkarshShukla7 What do you mean by count+"xyz"? I'm confused by the"xyz" part.
Coy Sanders
@coymeetsworld
Apr 16 2016 06:31 UTC
@Natto278 he just wrote xyz to mean either Bet or Hold
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:31 UTC
@Natto278 :smile: yes
Coy Sanders
@coymeetsworld
Apr 16 2016 06:31 UTC
you would write bet if the count is greater than 0, if count is 0 or less you put Hold
Frank XC
@tenkdayz
Apr 16 2016 06:31 UTC
@vaspv when you query the json object you have to sue the parameter variable in your case json to refer to the obj.. for example to get the name you have to use json.display_name
Nely
@nextasy2010
Apr 16 2016 06:31 UTC
i dont get it @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 06:31 UTC
your function has 2 parameters, arr and item right?
Nely
@nextasy2010
Apr 16 2016 06:32 UTC
yes
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32 UTC
you want to use both
Frank XC
@tenkdayz
Apr 16 2016 06:32 UTC
@Radascript did you have to reduce the arrays to their unique values?
Nely
@nextasy2010
Apr 16 2016 06:32 UTC
yes
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32 UTC
you're using item correctly by pushing it into an array, but you want to push it to arr, the array youre passing into the function
Prateek Vasisht
@vaspv
Apr 16 2016 06:32 UTC
@tenkdayz ah ok - so basically as soon as I get into the JSON then the iterations work for the initial feed but for all other data I have to use the values that json processes?
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32 UTC
not the global array testArr
Apr 16 2016 06:32 UTC
@tenkdayz no I didn't do that at all
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:32 UTC
@ALMY91 man I don't know about that technique.
btw where did you find it
Coy Sanders
@coymeetsworld
Apr 16 2016 06:32 UTC
thats your only issue, just fix that and you'll be fine
Nely
@nextasy2010
Apr 16 2016 06:33 UTC
ok, let me try that
thanks @coymeetsworld
CamperBot
@camperbot
Apr 16 2016 06:33 UTC
nextasy2010 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 571 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 06:33 UTC
np
Apr 16 2016 06:33 UTC
@tenkdayz I really don't know how reduce can apply there, maybe I'll go google the solution and see if other people used it
Frank XC
@tenkdayz
Apr 16 2016 06:33 UTC
@vaspv yeah in the getJSON function you query the data using json or whatever your var is
ALMY91
@ALMY91
Apr 16 2016 06:33 UTC
@UtkarshShukla7 im working on the definitive guidebook
@Radascript i was going through the exercises yesterday too, and i still hv no idea what are they good for haha
Prateek Vasisht
@vaspv
Apr 16 2016 06:34 UTC
@tenkdayz great. thanks for the explanation. Now I'll use the other channels url as well to get other data. :)
CamperBot
@camperbot
Apr 16 2016 06:34 UTC
vaspv sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:warning: vaspv already gave tenkdayz points
Coy Sanders
@coymeetsworld
Apr 16 2016 06:34 UTC
are you on symmetric difference @Radascript ?
Vivienne Sales
@Natto278
Apr 16 2016 06:35 UTC
Okay!
Apr 16 2016 06:35 UTC
@ALMY91 yeah I'm generally not very comfortbale with reduce, but there I don't even really understand how it can apply. I think my code wasn't too messy without it
@coymeetsworld just solved it like 6 minutes ago. Frank is working on it.
Frank XC
@tenkdayz
Apr 16 2016 06:35 UTC
@Radascript I looked at one of the answers but didnt know what was going on.. I still have it on a note to study it.
Coy Sanders
@coymeetsworld
Apr 16 2016 06:35 UTC
oh ok, yeah I eventually figured out how to use reduce to solve it
it was tricky, I had to call it twice, once for each array, then combine the results together
not sure if that was the right way but that's how i solved it with using reduce
Frank XC
@tenkdayz
Apr 16 2016 06:36 UTC
@coymeetsworld Im guessing if you use reduce it wouldnt be a one step solution would it?
Vivienne Sales
@Natto278
Apr 16 2016 06:36 UTC
If you can't use the return statement to show the messsage "Bet" or "hold" how are you supposed to show the messages, @coymeetsworld?
ALMY91
@ALMY91
Apr 16 2016 06:36 UTC
@Radascript i decided to move on to the javascript definitive guidebook after completing the challenges ...in hopes tt it cld enlighten me better
Coy Sanders
@coymeetsworld
Apr 16 2016 06:36 UTC
it wasn't for me @tenkdayz no, but not 100% sure if you could do it with just one reduce call
i would say no
you use the return statement @Natto278 , just not within the case/switch statement
Frank XC
@tenkdayz
Apr 16 2016 06:38 UTC
@coymeetsworld I see.. thought so too.
ALMY91
@ALMY91
Apr 16 2016 06:38 UTC
@coymeetsworld @UtkarshShukla7 i forgotten if i'd thank you guys, anw here you go..
CamperBot
@camperbot
Apr 16 2016 06:38 UTC
almy91 sends brownie points to @coymeetsworld and @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:warning: almy91 already gave coymeetsworld points
:star: 316 | @utkarshshukla7 | http://www.freecodecamp.com/utkarshshukla7
Coy Sanders
@coymeetsworld
Apr 16 2016 06:39 UTC
you break up the function into two steps: look at the card and modify the count where applicable
then after looking at the card, look at the count value and either print out Bet or Hold depending on the value of count
UtkarshShukla7
@UtkarshShukla7
Apr 16 2016 06:39 UTC
@ALMY91 np
Coy Sanders
@coymeetsworld
Apr 16 2016 06:40 UTC
yeah np @ALMY91
Eldar Tinjić
@EldarT90
Apr 16 2016 06:42 UTC
is this good start /approach to this problem ?
function sumPrimes(num) {
var count = 0;
var newArr = [];
for (var i = 0; i<=num; i++)
{
newArr.push(i);
}

for (i=0;i<=num;i++) {

for (j=0;j<newArr.length;j++)
{
if (newArr[j] % i === 0)
{
count += j;
}
}

}

return count;

}

sumPrimes(10);
@coymeetsworld could you take a look at it mate
Coy Sanders
@coymeetsworld
Apr 16 2016 06:45 UTC
let me look
well one thing is you don't need to start i = 0 since you know 0 and 1 are not prime numbers
you might have an error there?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:47 UTC
well for 10, instead of 17 i get 135
so obviously too many numbvers are passing the statement
oh lol
Coy Sanders
@coymeetsworld
Apr 16 2016 06:48 UTC
yeah I know what I did, I'm trying to see why yours doesn't work
i think it would give more numbers than it should
like for example when you have i=6
Eldar Tinjić
@EldarT90
Apr 16 2016 06:48 UTC
now when i think about logc
my logic is not good in this problem
Coy Sanders
@coymeetsworld
Apr 16 2016 06:48 UTC
when j is 3 or 2 the mod is going to be 0
Eldar Tinjić
@EldarT90
Apr 16 2016 06:48 UTC
this is completely wrong logic
Coy Sanders
@coymeetsworld
Apr 16 2016 06:48 UTC
so you're going to be counting 6 twice into your count
which you don't want to do, you only want to count it once
Eldar Tinjić
@EldarT90
Apr 16 2016 06:49 UTC
yes
i dont think its fixable tbh
just need different approach perhas
Coy Sanders
@coymeetsworld
Apr 16 2016 06:50 UTC
no not necessarily
you're on the right path needs some tweaking
ALMY91
@ALMY91
Apr 16 2016 06:51 UTC
var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split('S');
guys when i do this why doesn it give me
Eldar Tinjić
@EldarT90
Apr 16 2016 06:51 UTC
you dont want to split it by s
you want to split it by "nothing
which means by ("")
Coy Sanders
@coymeetsworld
Apr 16 2016 06:51 UTC
well, spaces
ALMY91
@ALMY91
Apr 16 2016 06:52 UTC
["S" ,"plit me into an array"];
Coy Sanders
@coymeetsworld
Apr 16 2016 06:53 UTC
split by space @ALMY91
ALMY91
@ALMY91
Apr 16 2016 06:53 UTC
yep i understood what the question was asking but i was just trying this out
Eldar Tinjić
@EldarT90
Apr 16 2016 06:53 UTC
command split
look at it
ALMY91
@ALMY91
Apr 16 2016 06:53 UTC
Eldar Tinjić
@EldarT90
Apr 16 2016 06:53 UTC
@ALMY91 listen
ALMY91
@ALMY91
Apr 16 2016 06:53 UTC
js
["" ,"plit me into an array"];

Eldar Tinjić
@EldarT90
Apr 16 2016 06:53 UTC
@ALMY91 your command takes certain value , in this case you put there "S" ; split("S") - that means splti when you see "S"
@ALMY91 you dont want to split when see "S", you want to split every letter, not jsut capital S
ALMY91
@ALMY91
Apr 16 2016 06:54 UTC
i understood that it was asking me to split by spaces, but what if i wanna split it by S?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:54 UTC
@ALMY91 you just did split it by S
@ALMY91 but they are not asking you to split it by S
@ALMY91 they want every letter to be an array
ALMY91
@ALMY91
Apr 16 2016 06:54 UTC
shouldn it give me
["S" ,"plit me into an array"];
Coy Sanders
@coymeetsworld
Apr 16 2016 06:55 UTC
nope
ALMY91
@ALMY91
Apr 16 2016 06:55 UTC
@EldarT90 yes i understood they are asking me to split by spaces and not by S, im just playing around w the code
Coy Sanders
@coymeetsworld
Apr 16 2016 06:55 UTC
the item you're splitting is removed from the array
ALMY91
@ALMY91
Apr 16 2016 06:55 UTC
@coymeetsworld ahh i see that makes sense now thanks
CamperBot
@camperbot
Apr 16 2016 06:55 UTC
almy91 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: almy91 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Apr 16 2016 06:55 UTC
ya
Clay Sheffler
@ClaySheffler
Apr 16 2016 06:56 UTC
where to learn how to update json ?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:56 UTC
@coymeetsworld i am just doing everything twice for every number and even that is not only mistake
Clay Sheffler
@ClaySheffler
Apr 16 2016 06:56 UTC
stackoverflow answers use loops, didnt get there yet..
Coy Sanders
@coymeetsworld
Apr 16 2016 06:56 UTC
doing everything twice?
Eldar Tinjić
@EldarT90
Apr 16 2016 06:57 UTC
@coymeetsworld yes, but problem is that statement is so wrong; newArr[j] % i === 0
Coy Sanders
@coymeetsworld
Apr 16 2016 06:58 UTC
well that part is fine
Eldar Tinjić
@EldarT90
Apr 16 2016 06:58 UTC
@coymeetsworld it just means every number will be added
Coy Sanders
@coymeetsworld
Apr 16 2016 06:58 UTC
although you don't need an array for that, you can just use the value j
but what you need to do is once that statement is true, stop running the for loop further
or else like i said before, some numbers you're going to count it twice, like 6
when i is 6 and j is 2 and also when j is 3
Eldar Tinjić
@EldarT90
Apr 16 2016 06:59 UTC
@coymeetsworld but every number will pass it ; when it goes to i = 6 and j = 6; it will pass
and 6 is not primary number
prime*
Coy Sanders
@coymeetsworld
Apr 16 2016 06:59 UTC
right
but you're adding to count when it isn't prime :)
right?
Eldar Tinjić
@EldarT90
Apr 16 2016 07:00 UTC
well this way i am adding them regardless
if its not % 0
than it iwll add when i = 6 and j = 5
Coy Sanders
@coymeetsworld
Apr 16 2016 07:01 UTC
can't do that either
Eldar Tinjić
@EldarT90
Apr 16 2016 07:01 UTC
Coy Sanders
@coymeetsworld
Apr 16 2016 07:01 UTC
sometimes it helps writing pseudocode to think about how to run the code
Eldar Tinjić
@EldarT90
Apr 16 2016 07:01 UTC
hmm let me try working on it for a while and i ll get back to you
and need to grab something to eat
Coy Sanders
@coymeetsworld
Apr 16 2016 07:02 UTC
sure thing
Eldar Tinjić
@EldarT90
Apr 16 2016 07:02 UTC
@coymeetsworld tnx anyway and cya soon
CamperBot
@camperbot
Apr 16 2016 07:02 UTC
eldart90 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 572 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 16 2016 07:02 UTC
yeah see ya
Vivienne Sales
@Natto278
Apr 16 2016 07:14 UTC
Re: Counting Cards / I understand why my current code for items #1-#3, but not for items #4-#7. Am I on the right track if I close my switch statement and start a bunch of if / else if statements?
Clay Sheffler
@ClaySheffler
Apr 16 2016 07:16 UTC
How to fix this error? "TypeError: Cannot read property 'push' of undefined" function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks") {
collection[id][prop] = value;
}
if (prop === "tracks" && value !== "") {
collection[id][prop].push(value);
}
if (value === "") {
collection[id].pop();
}
return collection;
}
ALMY91
@ALMY91
Apr 16 2016 07:21 UTC
just wondering why does it only work in chrome but not in IE?
nth is appearing in my IE but when i open my console under chrome it works just fine
jw1540
@jw1540
Apr 16 2016 07:27 UTC
Hey, be super grateful if someone could offer some feedback on my completed local weather challenge? N.B. For some reason VueJS doesn't work in embedded codepens
http://codepen.io/jw1540/full/revLaz/
ALMY91
@ALMY91
Apr 16 2016 07:28 UTC
why does it seem exceptionally dead in this chatroom ...
usually its buzzling with convos back and fro every min
lol
and whats the diff between /\D+\/and /\d+/
/\D+/
helooooooooooooooo
:worried:
jw1540
@jw1540
Apr 16 2016 07:33 UTC
@ALMY91 d is for one digit
D is for one non-digit
• is for one or more
/\D+\/ = 1 or more non-digit
/\d+/ = 1 or more digit
@ALMY91 I use this basically all the time haha https://www.debuggex.com/cheatsheet/regex/javascript
ALMY91
@ALMY91
Apr 16 2016 07:36 UTC
hokay hahahah @jw1540 thanks
CamperBot
@camperbot
Apr 16 2016 07:36 UTC
almy91 sends brownie points to @jw1540 :sparkles: :thumbsup: :sparkles:
:star: 155 | @jw1540 | http://www.freecodecamp.com/jw1540
Eldar Tinjić
@EldarT90
Apr 16 2016 07:50 UTC
@coymeetsworld i dont know how to write it
that it is the only number it should have % = 0
Matt Green
@mattxgreen
Apr 16 2016 07:51 UTC
@jw1540 Isn't one of the requirement to get the users location?
Eldar Tinjić
@EldarT90
Apr 16 2016 07:52 UTC
function sumPrimes(num) {
var count = 0;
var newArr = [];
var counter = 0;
for (var i = 0; i<=num; i++)
{
newArr.push(i);
}

for (i=2;i<=num;i++) {

for (j=2;j<newArr.length;j++)
{
if (newArr[j] % i === 0)

{
counter += 1;

}

if (counter === 1) {
count += j;
}
}

}

return count;

}

sumPrimes(10);
this loooks bit more sensible
but still it is missing something
jw1540
@jw1540
Apr 16 2016 07:52 UTC
@mattxgreen thanks for taking a look. yeah, i just assumed it didn't have to be automatically detected (i.e. through navigation.geolocation)
CamperBot
@camperbot
Apr 16 2016 07:53 UTC
jw1540 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
Matt Green
@mattxgreen
Apr 16 2016 07:53 UTC
@jw1540 I would also do some form validation... If no city is entered, and you press submit it returns undefined
CamperBot
@camperbot
Apr 16 2016 07:53 UTC
:star: 453 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
jw1540
@jw1540
Apr 16 2016 07:53 UTC
@mattxgreen ooh, good shout actually
Matt Green
@mattxgreen
Apr 16 2016 07:54 UTC
@jw1540 If you don't want to use geolocation, nor geoip, you could consider the google places api for autocomplete
Vivienne Sales
@Natto278
Apr 16 2016 07:57 UTC
@sonjamoisset Thank you for helping me with the Counting Card challenge.
CamperBot
@camperbot
Apr 16 2016 07:57 UTC
natto278 sends brownie points to @sonjamoisset :sparkles: :thumbsup: :sparkles:
jw1540
@jw1540
Apr 16 2016 07:57 UTC
@mattxgreen yeah i found geoip was being wildly inaccurate; i didn't know about the google places api though, that's really cool I'll definitely look to implement that
CamperBot
@camperbot
Apr 16 2016 07:57 UTC
:warning: could not find receiver for sonjamoisset
Matt Green
@mattxgreen
Apr 16 2016 07:58 UTC
@EldarT90 Did you want help with that function?
Eldar Tinjić
@EldarT90
Apr 16 2016 08:03 UTC
@mattxgreen yes, but i like hints rather than direct help
Matt Green
@mattxgreen
Apr 16 2016 08:06 UTC
Xf
@Darcy-FzR
Apr 16 2016 08:07 UTC
This message was deleted
Eldar Tinjić
@EldarT90
Apr 16 2016 08:09 UTC
@mattxgreen hmm this looks like algorythm that i should be using
ofc if i can convert it to the right syntax
Matt Green
@mattxgreen
Apr 16 2016 08:09 UTC
@EldarT90 aye!
Eldar Tinjić
@EldarT90
Apr 16 2016 08:10 UTC
@mattxgreen tnx for your help, i have to go afk anyway so will bookmark this and hopefully i will ne able to convert it succesfully ^^ take care
CamperBot
@camperbot
Apr 16 2016 08:10 UTC
eldart90 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 454 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
ALMY91
@ALMY91
Apr 16 2016 08:11 UTC
hello guys
null is a language keyword that evaluates to a special value that is usually used to indicate the absence of a value. Using the typeof operator on null returns the string "no object"
is anyone able to do an illustration of how this works out?
ive yet to come across this in the FCC challenges and im not too sure what is typeof used for and how is it to be used
Justin
@daemedeor
Apr 16 2016 08:13 UTC
try in the console > typeof null
you'll find that it return object
@ALMY91 typeof is a nifty comparison to tell you what the typeof the supplied variable is
ALMY91
@ALMY91
Apr 16 2016 08:14 UTC
@daemedeor ohyeah its an object
Justin
@daemedeor
Apr 16 2016 08:14 UTC
in this case, for JS -> null is an object ... confusing but thats what the spec calls for
ALMY91
@ALMY91
Apr 16 2016 08:14 UTC
@daemedeor whats a ifty
nifty
Justin
@daemedeor
Apr 16 2016 08:15 UTC
@ALMY91 particularly good, skillful, or effective.
dictionary :D
so if you did var greeting = "heeey"; console.log(typeof greeting ); //"string"
ALMY91
@ALMY91
Apr 16 2016 08:16 UTC
@daemedeor wait a minute....
@daemedeor it states that values of javascript types can be categories into primative type and object types. Of which, primitive types are numbers, strings,booleans,null and undefined
Justin
@daemedeor
Apr 16 2016 08:17 UTC
bassssically
ALMY91
@ALMY91
Apr 16 2016 08:17 UTC
Object types are non-primitive, ect, functions
so how does null become an object in this case?
Justin
@daemedeor
Apr 16 2016 08:18 UTC
defined
ALMY91
@ALMY91
Apr 16 2016 08:18 UTC
weird.......they stated null falls under primitive type not object types?
so why was typeof for null printed as an object
Justin
@daemedeor
Apr 16 2016 08:19 UTC
because the spec definition
ALMY91
@ALMY91
Apr 16 2016 08:20 UTC
i dont understand can i u explain in layman terms
Justin
@daemedeor
Apr 16 2016 08:22 UTC
basically just... read the docs, its a bug
ALMY91
@ALMY91
Apr 16 2016 08:23 UTC
what do u mean its a bug haha
and why's the chatroom so quiet today...
Justin
@daemedeor
Apr 16 2016 08:24 UTC
@ALMY91 typeof null // object (bug in ECMAScript, should be null)
ALMY91
@ALMY91
Apr 16 2016 08:24 UTC
@daemedeor when they mentioned its a bug what does it mean
Justin
@daemedeor
Apr 16 2016 08:25 UTC
@ALMY91 a bug is something that is wrong, thats not intended, a pest
so if your code is buggy, something is wrong
Piyush Kaushik
@KaushikDev
Apr 16 2016 08:25 UTC
Hi, i need the following code to return true, but this some bi* is returning false

function truthCheck(collection, pre) {
// Is everyone being true?
var flag=0;

for(var i=0;i<collection.length;i++){
var obj=collection[i];

if(isNaN(obj[pre])===false && obj[pre]!==null && obj[pre]!=="" && obj[pre]!==undefined && obj[pre]!==0 && obj[pre]!==false || obj[pre]==="yes" ){

flag+=1;

}

}
if (flag===collection.length){

return true;

}

else return false;

}

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

Anyone???
Justin
@daemedeor
Apr 16 2016 08:27 UTC
@KaushikDev could you put it in a code block
help format
CamperBot
@camperbot
Apr 16 2016 08:27 UTC

## :point_right: code formatting [wiki]

### Multi line Code

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

then press [shift + enter ⏎]

 ⇦ Type 3 backticks, then press [enter ⏎]

### Single line Code

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

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

ALMY91
@ALMY91
Apr 16 2016 08:27 UTC
@daemedeor so what do i do if the result is appearing object instead of null. How do i fix this bug?
Justin
@daemedeor
Apr 16 2016 08:28 UTC
@ALMY91 you can't fix it... unless you work on the JS language yourself... which is unlikely, you'll have to find some way to deal with it
these kinda bugs in the language tend to be called.... quirks
ALMY91
@ALMY91
Apr 16 2016 08:32 UTC
@daemedeor so weird...
@daemedeor thanks anw
CamperBot
@camperbot
Apr 16 2016 08:32 UTC
almy91 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 402 | @daemedeor | http://www.freecodecamp.com/daemedeor
Piyush Kaushik
@KaushikDev
Apr 16 2016 08:56 UTC
@daemedeor sorry, i didn't get that :(
alpox
@alpox
Apr 16 2016 08:57 UTC
@ALMY91 Primitive types will not be showed as that with the typeof operator. The typeof operator shows its actual type so an integer, which also is a primitive type, will be shown as "Number". Since if a primitive type cannot just have no value for usual, the absence of any value in javascript is shown as 'undefined'. The indicator 'null' is an object because it shows the absence of an object. It means, that at this place, there should be an object, but there isnt. So its null. About the same way works 'NaN', which is typeof Number, but indicates that there is no number defined even if there should be a number.
I hope this clears things out a bit
@daemedeor Btw. thats not a bug in ECMAScript :-)
Marius
@rasmus1610
Apr 16 2016 09:03 UTC
function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks" && collection.hasOwnProperty(prop)) {
collection[id][prop] = value;
} else if (value !== "" && prop == "tracks" && collection.hasOwnProperty(prop)) {
collection[id][prop].push(value);
} else if (value === "") {
delete collection[id][prop];
}

return collection;
}
can anyone help me with this function? cant see what's wrong
Aleksej
@tip14
Apr 16 2016 09:08 UTC
hello! can someone explain my, why this for (i=0; i<arr.length; i+2) is an infinite loop?
Marius
@rasmus1610
Apr 16 2016 09:09 UTC
@tip14 well how does your array look like?
Aleksej
@tip14
Apr 16 2016 09:10 UTC
@rasmus1610 ["a", "b", "c", "d","v", "g"]
Justin
@daemedeor
Apr 16 2016 09:10 UTC
@alpox accoding to MDN it is :D
Coryphaeus
@cvdeby
Apr 16 2016 09:10 UTC
@rasmus1610 try to change == to === on second condition
Justin
@daemedeor
Apr 16 2016 09:10 UTC
@tip14 cause you never reassign i
alpox
@alpox
Apr 16 2016 09:10 UTC
@daemedeor Hmm I don't think this is a bug :-)
Coryphaeus
@cvdeby
Apr 16 2016 09:11 UTC
@tip14 You're not assigned new i value - instead of i+2 use i+=2
Marius
@rasmus1610
Apr 16 2016 09:11 UTC
@cvdeby you mean where I test whether prop equals "tracks"?
didnt work
Aleksej
@tip14
Apr 16 2016 09:11 UTC
@daemedeor @cvdeby thank you!!!
CamperBot
@camperbot
Apr 16 2016 09:11 UTC
tip14 sends brownie points to @daemedeor and @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 340 | @cvdeby | http://www.freecodecamp.com/cvdeby
Justin
@daemedeor
Apr 16 2016 09:12 UTC
@alpox there are definitely WORSE bugs to have but in many languges null is null its crazy
CamperBot
@camperbot
Apr 16 2016 09:12 UTC
:star: 403 | @daemedeor | http://www.freecodecamp.com/daemedeor
alpox
@alpox
Apr 16 2016 09:12 UTC
@daemedeor Yeah in other languages, but javascript is defined in a different way
Justin
@daemedeor
Apr 16 2016 09:13 UTC
@alpox i would be careful it looks like in 2017 draft they're changing it to the null type: https://tc39.github.io/ecma262/#sec-null-value

4.3.12null value#

primitive value that represents the intentional absence of any object value

4.3.13Null type#

type whose sole value is the null value

Coryphaeus
@cvdeby
Apr 16 2016 09:14 UTC
@rasmus1610 I didn't get any mistakes. It's was just one small thought) Maybe it is a bug?
alpox
@alpox
Apr 16 2016 09:16 UTC
@daemedeor Seems so ^^ but i can see why they had it as an object before
Coryphaeus
@cvdeby
Apr 16 2016 09:16 UTC
@rasmus1610 I have the same solution, ahah)
if(value !== "" && prop !== "tracks")
collection[id][prop] = value;
else if (value !== "" && prop === "tracks")
collection[id][prop].push(value);
else if (value === "")
delete collection[id][prop];
return collection;
Justin
@daemedeor
Apr 16 2016 09:17 UTC
@alpox ya i can reason about the object for sure, they're also having an undefined type :O
Marius
@rasmus1610
Apr 16 2016 09:18 UTC
@cvdeby ah the problem was with the .hasOwnProperty check
somehow
Justin
@daemedeor
Apr 16 2016 09:18 UTC
i actually haven't read the new spec....
Son Dang
@viiiprock
Apr 16 2016 09:46 UTC

I passed Slasher Flick challenge (actually easy to pass), but still wonder why this is right.
function slasher(arr, howMany) {
// it doesn't always pay to be first
return arr.splice(howMany);
}

slasher([1, 2, 3], 2);

function slasher(arr, howMany) {
// it doesn't always pay to be first
return arr.splice(0, howMany);
}
slasher([1, 2, 3], 2);

Andrew McKeever
@andmckvr13
Apr 16 2016 09:54 UTC
does anyone know what the callback=? means/is doing in this API link? http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=callback=?
Coryphaeus
@cvdeby
Apr 16 2016 09:54 UTC
@viiiprock Ahah, nice)) arr.splice(0, 2) // returns [1,2] and arr.splice(2) return [2,3], you tried to put into start 0, what is wrong, you should start from the given howMany value.
TanYiXun
@TanYiXun
Apr 16 2016 09:56 UTC

guys can someone help me?

function sequentialSizes(val) {
// Only change code below this line
switch(val){
case 1:
case 2:
case 3:
result="Low";
break;
case 4:
case 5:
case 6:
result="Mid";
break;
case 7:
case 8:
case 9:
result="High";

}

// Only change code above this line
}

// Change this value to test
sequentialSizes(5);

Instructions
Write a switch statement to set answer for the following ranges:
1-3 - "Low"
4-6 - "Mid"
7-9 - "High"

Note
You will need to have a case statement for each number in the range.

Coryphaeus
@cvdeby
Apr 16 2016 09:57 UTC
@TanYiXun For start put break; into the end of each one case body
If you'll not to do that, result every time will equal to 'High';
@TanYiXun And if you're using result variable - return and define result variable
TanYiXun
@TanYiXun
Apr 16 2016 09:59 UTC
really? @cvdeby but the example was like
switch(val) {
case 1:
case 2:
case 3:
result = "1, 2, or 3";
break;
case 4:
result = "4 alone";
}
Justin
@daemedeor
Apr 16 2016 09:59 UTC
@viiiprock because the first parameter is where to start slicing and the second (optional) parameter is how far. so if you pass in 0 and then how many, you only slice off the front
Coryphaeus
@cvdeby
Apr 16 2016 09:59 UTC
@TanYiXun I'm sorry, I didn't saw that, I think, I need to sleep))
TanYiXun
@TanYiXun
Apr 16 2016 10:00 UTC
haha alright @cvdeby
Coryphaeus
@cvdeby
Apr 16 2016 10:00 UTC
@TanYiXun Every time I use it like this case 9: something; break; // in one line ))
Justin
@daemedeor
Apr 16 2016 10:01 UTC
@TanYiXun the reason why is because you're not returning result
if you're going to do that you should change that var name to answer ^.^
@cvdeby he can do those fallthroughs in the switch statement
i say if the language allows that type of switch to happen great
Justin
@daemedeor
Apr 16 2016 10:02 UTC
@viiiprock cool
Coryphaeus
@cvdeby
Apr 16 2016 10:02 UTC
@daemedeor I know that, but I use this in my code and didn't see that in another code)
Bharat
@BharatKalluri
Apr 16 2016 10:03 UTC

Can Anyone have a look at the code

function where(arr, num) {

arr.sort(function(a, b) {
return a - b;
});

var pos = 0;

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

if(arr[i] < num){
pos = i + 1;
} else {
break;
}
}
return pos;

}

getIndexToIns([2, 5, 10], 15);

all conditions except the 2,5,10 work

Son Dang
@viiiprock
Apr 16 2016 10:03 UTC
well thanks guys, how to send brownie anyway :))
Coryphaeus
@cvdeby
Apr 16 2016 10:04 UTC
@viiiprock thanks, thnx, thank you...
CamperBot
@camperbot
Apr 16 2016 10:04 UTC
cvdeby sends brownie points to @viiiprock :sparkles: :thumbsup: :sparkles:
:star: 202 | @viiiprock | http://www.freecodecamp.com/viiiprock
Aleksander Gębicki
@Takumar
Apr 16 2016 10:05 UTC
@viiiprock look at this:
explain brownie
CamperBot
@camperbot
Apr 16 2016 10:05 UTC

## :point_right: brownie points [wiki]

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

There are two ways you can get Brownie Points:

1. Complete challenges - you get one point per challenge you complete
2. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

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

Son Dang
@viiiprock
Apr 16 2016 10:06 UTC
haha right, thanks @cvdeby @daemedeor @Takumar
CamperBot
@camperbot
Apr 16 2016 10:06 UTC
viiiprock sends brownie points to @cvdeby and @daemedeor and @takumar :sparkles: :thumbsup: :sparkles:
:star: 3099 | @takumar | http://www.freecodecamp.com/takumar
:star: 404 | @daemedeor | http://www.freecodecamp.com/daemedeor
:star: 341 | @cvdeby | http://www.freecodecamp.com/cvdeby
TanYiXun
@TanYiXun
Apr 16 2016 10:07 UTC
@daemedeor @cvdeby somehow i still cant manage to solve
Bharat
@BharatKalluri
Apr 16 2016 10:08 UTC
Hey guys! why is the listed condition not working with the code
function where(arr, num) {

arr.sort(function(a, b) {
return a - b;
});

var pos = 0;

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

if(arr[i] < num){
pos = i + 1;
} else {
break;
}
}
return pos;

}

getIndexToIns([2, 5, 10], 15);
it returns nothing
Justin
@daemedeor
Apr 16 2016 10:08 UTC
@TanYiXun you changed result to answer?
Coryphaeus
@cvdeby
Apr 16 2016 10:10 UTC
@TanYiXun You're using result variable, then return result variable, but you return answer which equal to empty string.
TanYiXun
@TanYiXun
Apr 16 2016 10:13 UTC
thanks @daemedeor @cvdeby
CamperBot
@camperbot
Apr 16 2016 10:13 UTC
tanyixun sends brownie points to @daemedeor and @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 343 | @cvdeby | http://www.freecodecamp.com/cvdeby
:star: 405 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 16 2016 10:13 UTC
sigh
usharya
@usharya
Apr 16 2016 10:35 UTC
anyone online?
Justin
@daemedeor
Apr 16 2016 10:40 UTC
yes @usharya just quiiiiiiiiet
usharya
@usharya
Apr 16 2016 10:41 UTC
can you help me with jQuery for a bit? @daemedeor
I want to change the height of a slider that requires it. I don't know jQuery nicely and hence I am probably making a mistake
The doc for the slider: http://materializecss.com/media.html
My code
$(document).ready(function() {$('.slider').slider({height: 600px});
});
Justin
@daemedeor
Apr 16 2016 10:44 UTC
@usharya get rid of px
usharya
@usharya
Apr 16 2016 10:46 UTC
Nope, not working :(
I got it working like this now hehe
('.slider').css({"height":" 600px"}); Thank you @daemedeor CamperBot @camperbot Apr 16 2016 10:46 UTC usharya sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles: :star: 408 | @daemedeor | http://www.freecodecamp.com/daemedeor jw1540 @jw1540 Apr 16 2016 10:46 UTC @mattxgreen made a couple of updates after fiddling with geolocation. Would really appreciate your opinion :) http://s.codepen.io/jw1540/debug/revLaz Justin @daemedeor Apr 16 2016 10:46 UTC @usharya hmmmmm Rada @Radascript Apr 16 2016 10:49 UTC Hey guys I'm on the sorting inventory challenge and I got all the right elements in the array but trying to figure out how to alphabetically sort it by the 1st element in a nested array usharya @usharya Apr 16 2016 10:50 UTC @daemedeor you know what, your solution is better god damn, I am stupid :( @daemedeor Thanks CamperBot @camperbot Apr 16 2016 10:51 UTC usharya sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles: :warning: usharya already gave daemedeor points Justin @daemedeor Apr 16 2016 10:51 UTC i don't like strings it makes things crazy XD @Radascript you can use .sort(callback) @usharya so you could get rid of px, i was like, was i reading the docs wrong? did you totally remove 600? usharya @usharya Apr 16 2016 10:53 UTC @daemedeor haha, yeah getting rid of px was everything. No, I just removed the px and it worked like a charm .css did more harm than good xD Brendan Kinahan @BKinahan Apr 16 2016 10:53 UTC @Radascript you can refer to those elements within the callback function of .sort() Justin @daemedeor Apr 16 2016 10:54 UTC @usharya haha its why i prefer to set and take off classes rather than pass in options esp for things like height, transition and duration between transitions XD custom CSS! ftw Rada @Radascript Apr 16 2016 10:55 UTC @daemedeor @BKinahan thanks just did that, it worked. CamperBot @camperbot Apr 16 2016 10:55 UTC radascript sends brownie points to @daemedeor and @bkinahan :sparkles: :thumbsup: :sparkles: :star: 1302 | @bkinahan | http://www.freecodecamp.com/bkinahan :star: 409 | @daemedeor | http://www.freecodecamp.com/daemedeor Yoerivw @Yoerivw Apr 16 2016 10:55 UTC Good day guys, I am wondering if anyone could help me with a problem. I've been sitting with it for a couple of hours trying to figure it out by myself. Alas, I am resorting to the chatroom for some support :) "function nextInLine(arr, item) { // Your code here testArr.push(item); var removed = testArr.shift(); return removed;// Change this line } // Test Setup var testArr = [1,2,3,4,5]; // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine([5,6,7,8,9],5)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); " i am at basic javascript: standing in line. Rada @Radascript Apr 16 2016 10:56 UTC now that it's solved, I'm gonna go see the github solution now because I think my code is a little too complicated again. but maybe not. usharya @usharya Apr 16 2016 10:57 UTC do you know why this happens? When I increased my height, I lost my indicators :( http://i.imgur.com/ugdYaG7.png (before) http://i.imgur.com/ygjHmru.png (after) jw1540 @jw1540 Apr 16 2016 10:57 UTC @Yoerivw coudl you format your code by putting  before and after your code snippet? Justin @daemedeor Apr 16 2016 10:57 UTC @usharya no clue.... i'd need to see your code Yoerivw @Yoerivw Apr 16 2016 10:58 UTC @jw1540 Thanks for the tip :) CamperBot @camperbot Apr 16 2016 10:58 UTC yoerivw sends brownie points to @jw1540 :sparkles: :thumbsup: :sparkles: :star: 156 | @jw1540 | http://www.freecodecamp.com/jw1540 Justin @daemedeor Apr 16 2016 10:58 UTC @Yoerivw you should just return testArr usharya @usharya Apr 16 2016 10:59 UTC Slider code <!-- Slider --> <div> <div class="slider"> <ul class="slides"> <li> <img src="images/1.jpg" class="responsive-img"> <!-- random image --> <div class="caption center-align"> <h3>This is our big Tagline!</h3> <h5 class="light grey-text text-lighten-3">Here's our small slogan.</h5> </div> </li> <li> <img src="images/2.jpg" class="responsive-img"> <!-- random image --> <div class="caption left-align"> <h3>Left Aligned Caption</h3> <h5 class="light grey-text text-lighten-3">Here's our small slogan.</h5> </div> </li> <li> <img src="images/3.jpg" class="responsive-img"> <!-- random image --> <div class="caption right-align"> <h3>Right Aligned Caption</h3> <h5 class="light grey-text text-lighten-3">Here's our small slogan.</h5> </div> </li> <li> <img src="images/4.jpg" class="responsive-img"> <!-- random image --> <div class="caption center-align"> <h3>This is our big Tagline!</h3> <h5 class="light grey-text text-lighten-3">Here's our small slogan.</h5> </div> </li> </ul> </div> </div> My scripts <script>(document).ready(function(){ $('.slider').slider({full_width: true}); });</script> <script>$(document).ready(function() { $('.slider').slider({height: 600}); });</script> @daemedeor Justin @daemedeor Apr 16 2016 10:59 UTC @usharya you should pass in height and fullWidth at the same time <script>$(document).ready(function(){ \$('.slider').slider({full_width: true, height: 600}); });</script>
what likely is happening is that you are reinstantiating the slider on the classes
so it redoes the thing
Yoerivw
@Yoerivw
Apr 16 2016 11:02 UTC
@daemedeor the script works, the only checkmark I am not getting is the "nextInLine([5,6,7,8,9], 1) should return 5" and just returning the testArr doesn't fix the problem.
phorekka
@phorekka
Apr 16 2016 11:02 UTC
stuck at world bank exercise in java script.
usharya
@usharya
Apr 16 2016 11:03 UTC
@daemedeor You are my savior :D
Thanks tons hehe :D
CamperBot
@camperbot
Apr 16 2016 11:03 UTC
usharya sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:warning: usharya already gave daemedeor points
usharya
@usharya
Apr 16 2016 11:03 UTC
note to self: I should start learning jQuery
Justin
@daemedeor
Apr 16 2016 11:03 UTC
@Yoerivw which one was it again?
i need to double check the instructions
Yoerivw
@Yoerivw
Apr 16 2016 11:04 UTC
Basic javascript: Stand in line @daemedeor
phorekka
@phorekka
Apr 16 2016 11:04 UTC

var result = "";
// Your code below this line

result="cat,little,hit,slowly";
// Your code above this line
return result;
}

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

Help me out .. anyone?
CamperBot
@camperbot
Apr 16 2016 11:04 UTC
no wiki entry for: me out anyone
Justin
@daemedeor
Apr 16 2016 11:06 UTC
@Yoerivw okay i don't know what testArr is, so you need to use the arr provided for you
Apr 16 2016 11:06 UTC
@Yoerivw within your function, you should refer to arr and item, rather than the outside variable testArr
function nextInLine(arr, item) {

arr.push(item);
var removed = arr.shift();
console.log(removed);
return removed;// Change this line
}
this passes
Justin
@daemedeor
Apr 16 2016 11:07 UTC
or even simpler
function nextInLine(arr, item) {
arr.push(item);
return arr.shift();  // Change this line
}
This message was deleted
usharya
@usharya
Apr 16 2016 11:07 UTC
@daemedeor Can you help me with the scrollspy also?
Doc: http://materializecss.com/scrollspy.html
Example: http://www.w3schools.com/bootstrap/trybs_theme_company_full.htm
In the above example, the navbar changes its active state as we scroll up and down.
I am not able to do it with scrollspy :(
Here is my full code: http://codepen.io/Usharya/pen/xVjVmP?editors=1100
However, I can go up and down, when I click on the navbar...
Justin
@daemedeor
Apr 16 2016 11:09 UTC
@usharya okay, so first off, for code pen you don't need to do the full html, if you're trying to do that, possibly use pastie or something
put the JS code in the js part (it'll also have the js on ready)
usharya
@usharya
Apr 16 2016 11:09 UTC
I just copy pasted from sublime text hehe
I will do that from next time :)
Justin
@daemedeor
Apr 16 2016 11:10 UTC
but umm one moment
if you have a repo its' easier tbh
X
D
XD\
usharya
@usharya
Apr 16 2016 11:11 UTC
repo? whats that?
Justin
@daemedeor
Apr 16 2016 11:11 UTC
@usharya repo = repository for github
usharya
@usharya
Apr 16 2016 11:11 UTC
ahh, I don't know how to use github :(
and I am on windows so console commands don't work in powershell
Justin
@daemedeor
Apr 16 2016 11:12 UTC
you can use the repo... but seems ... let me fix up your codepen might take a bit
there's a lot of 404s and blocks thats why
usharya
@usharya
Apr 16 2016 11:12 UTC
I can wait :)
Thank you so much for helping me
Justin
@daemedeor
Apr 16 2016 11:24 UTC
@usharya errrr... do you have an active class?
Justin
@daemedeor
Apr 16 2016 11:27 UTC
@usharya okay so to test: what you do is add an active class to a menu item and then see if something happens
because when i inspect the code, the scrollSpy is working as intended
oh wait
one moment
wrong class is getting applied
@usharya okay i know whats wrong
@usharya something looks off so i'm not sure whats wrong but put table-of-contents onto your UL
so it ends up like; <ul class="right hide-on-med-and-down table-of-contents">
Justin
@daemedeor
Apr 16 2016 11:35 UTC
it would pay to learn git though
Coryphaeus
@cvdeby
Apr 16 2016 11:35 UTC
I got right value for each one condition, but still didn't pass the test.
var result = [];
function steamrollArray(arr) {
// I'm a steamroller, baby
for(var i = 0; i < arr.length; i++) {
if(Array.isArray(arr[i])) {
steamrollArray(arr[i]);
} else {
result.push(arr[i]);
}
}
return result;
}
steamrollArray([[["a"]], [["b"]]]);
Justin
@daemedeor
Apr 16 2016 11:38 UTC
@cvdeby for one yes
@cvdeby but the problem with the code is that it adds over time
because its a global variable
here are some outputs of result
obviously the ["a","b"] does not belong
and it builds over time
Coryphaeus
@cvdeby
Apr 16 2016 11:41 UTC
@daemedeor Thanks)
CamperBot
@camperbot
Apr 16 2016 11:41 UTC
cvdeby sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 411 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 16 2016 11:42 UTC
close though @cvdeby you can do it!
maybe i should join that room....
Coryphaeus
@cvdeby
Apr 16 2016 11:43 UTC
@daemedeor I'm trying to find, what should I make instead of result.push(arr[i]); :smile:
Justin
@daemedeor
Apr 16 2016 11:43 UTC
well... you should do recursion instead :D
usharya
@usharya
Apr 16 2016 11:44 UTC
@daemedeor what did you do? How did you come to this conclusion?
Wow, I was thinking from last night how to solve this and you instantly found a solution haha
Justin
@daemedeor
Apr 16 2016 11:44 UTC
you're on the right track you just gotta scope it right
usharya
@usharya