22nd
Feb 2016
Nicolas Accetta
@niconiahi
Feb 22 2016 00:00
@moigithub i seeeeee know omg thanks. ill try again
CamperBot
@camperbot
Feb 22 2016 00:00
niconiahi sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 650 | @moigithub | http://www.freecodecamp.com/moigithub
Timofey Votyakov
@tvotyakov
Feb 22 2016 00:01
@niconiahi good
Nicolas Accetta
@niconiahi
Feb 22 2016 00:02
@tvotyakov ftr i deleted prop == contacts[i].hasOwnProperty(prop)
@tvotyakov its just contacts[i].hasOwnProperty(prop)
Norman Dela Cruz
@dcnr
Feb 22 2016 00:03
@bitgrower the regex in your validate us phone num is like those mint garnishes in dishes :P
bitgrower
@bitgrower
Feb 22 2016 00:03
LOL...
Norman Dela Cruz
@dcnr
Feb 22 2016 00:04
brb
Timofey Votyakov
@tvotyakov
Feb 22 2016 00:04
@niconiahi yep
bitgrower
@bitgrower
Feb 22 2016 00:05
yeah, I s'pose I could go back and add more to it ... but, the task is validating the phone numbers, not showing off uber regexes ... :)
Timofey Votyakov
@tvotyakov
Feb 22 2016 00:05
@niconiahi and you need to change another similar line in your code.
bitgrower
@bitgrower
Feb 22 2016 00:06
the whole solution was much cleaner before I realized the manipulations I had to do for parens ... and, it still would validate some pretty funny looking phone numbers...
Nicolas Accetta
@niconiahi
Feb 22 2016 00:08
@tvotyakov the loop is ok at least?
Moisés Man
@moigithub
Feb 22 2016 00:10
@niconiahi you returning "too soon", remember returnexit the function immediatelly
Timofey Votyakov
@tvotyakov
Feb 22 2016 00:16
Edison Brito
@edisonbrito
Feb 22 2016 00:17
Hi guys!
someone can help me
i have difficulty with Initializing Variables with the Equal Operator
i don't understend

// Initialize these three variables
var a = 6;
var b = 15;
var c = "I am a String!";

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

???
Moisés Man
@moigithub
Feb 22 2016 00:20
@edisonbrito initialize means give a variable some value
check the bottom left side .. which test pass.. or not..
Edison Brito
@edisonbrito
Feb 22 2016 00:21
i see, but i have this:
a - should be defined and have a value of 6
b - should be defined and have a value of 15
c - should not contain undefined and should have a value of "I am a String!"
d- Do not change code below the line
Andrew Perrin
@Pezz18
Feb 22 2016 00:22
hi, i am a little stuck on the Seek & Destroy challenge...
matthew3454
@matthew3454
Feb 22 2016 00:22
@bitgrower @tvotyakov I'm apologize, but I'm not sure what you mean by "having js on a line all by itself." Also, I tried to split the string into characters and store them in an array without avail.

function reverseString(str) {

var reverseString= ["h", "e", "l", "l", "o"];

reverseString.reverse();

return str.split([separator = 'hello' ]);
}



bitgrower
@bitgrower
Feb 22 2016 00:23
@matthew3454 -- I'm talking about formatting ....
Moisés Man
@moigithub
Feb 22 2016 00:23
@niconiahi IF u have 4 pockets.. and u put money on 'em, HOW many pockets u need to check to know how much money in total u got ?
1 or 2 will be enough ?
so u can apply same logic to contacts.. and see if testing 1 or 2 will be enough to say "no such contact"
bitgrower
@bitgrower
Feb 22 2016 00:23
not about the problem solution ...
@edisonbrito -- is your solution not passing ?
Andrew Perrin
@Pezz18
Feb 22 2016 00:23
function destroyer(arr) {
var compare = [];
var result = [];
for(var i=1; i<arguments.length; i++) {
compare.push(arguments[i]);
}

console.log(compare);

var remove = arr.filter(function (val){
return !(val == compare[0] || val == compare[1]);
});

return (remove);

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Moisés Man
@moigithub
Feb 22 2016 00:23
@edisonbrito u not taking in consideration the calculation below ur variable initialization....
Edison Brito
@edisonbrito
Feb 22 2016 00:23
@moigithub no, my solution is:
// Initialize these three variables
var a = 6;
var b = 15;
var c = "I am a String!";
is not passing
bitgrower
@bitgrower
Feb 22 2016 00:24
if it's not passing, you might have some extraneous stuff in your solution box ...
Andrew Perrin
@Pezz18
Feb 22 2016 00:24
my result is working, however, at the moment i am manually having to type in the arguments, rather than the code automatically working out how many there are...
Craig Banach
@CraigBanach
Feb 22 2016 00:24
@bitgrower Thanks, using the alternator made my code quite easy to follow.
CamperBot
@camperbot
Feb 22 2016 00:24
cragsify sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Moisés Man
@moigithub
Feb 22 2016 00:24
so... IF it expects a to be 6 but the extra code below.. says a = a + 1;
var a = 6;<-- is correct ??
var a = 4;<-- or probably should be this??
@edisonbrito
CamperBot
@camperbot
Feb 22 2016 00:24
:star: 601 | @bitgrower | http://www.freecodecamp.com/bitgrower
Andrew Perrin
@Pezz18
Feb 22 2016 00:26
does anyone know how to use array.filter?
bitgrower
@bitgrower
Feb 22 2016 00:26
@Pezz18 -- first, tell me what you think arr is ?
Moisés Man
@moigithub
Feb 22 2016 00:26
@edisonbrito ur a currently have the value 7
Andrew Perrin
@Pezz18
Feb 22 2016 00:27
@bitgrower the arr part is the actual array being passed into the function - declared at the bottom [1,2,3,1,2,3]....
bitgrower
@bitgrower
Feb 22 2016 00:28
@Pezz18 -- your solution is assuming that there are always 2 values after the array to test .... you need to make a solutiion which is more general ... and can handle ANY number of additional arguments ...
@Pezz18 -- good, just checking -- lots of folks get that wrong ...
Edison Brito
@edisonbrito
Feb 22 2016 00:29
@moigithub it's great, i undertend...
:)
Andrew Perrin
@Pezz18
Feb 22 2016 00:29
@bitgrower yes, thats my understanding, however, struggling to work out how to automatically work out how many args there are,,, hence why at the beginning i added them to an array, so i know what they are 2 and 3
Edison Brito
@edisonbrito
Feb 22 2016 00:29
now worked
thanks @moigithub
CamperBot
@camperbot
Feb 22 2016 00:29
edisonbrito sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Feb 22 2016 00:30
also, your return statement uses negative logic, which is not the easiest thing to understand ... unless you're handy with DeMorgan's theorem ...
CamperBot
@camperbot
Feb 22 2016 00:30
:star: 651 | @moigithub | http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Feb 22 2016 00:30
:)
Edison Brito
@edisonbrito
Feb 22 2016 00:30
@camperbot how to do this?
bitgrower
@bitgrower
Feb 22 2016 00:31
you might want to also read up on array.filter on MDN, too ... to see whether it returns a value ... (that is, that remove contains what you expect it to ...
Edison Brito
@edisonbrito
Feb 22 2016 00:32
@moigithub :+1:
bitgrower
@bitgrower
Feb 22 2016 00:32
MANY of the functional array methods do not return a value, they simply work on the array ... look at some of the examples on the MDN page
Andrew Perrin
@Pezz18
Feb 22 2016 00:32
i did try putting it into a for loop, by using the compare.length
Moisés Man
@moigithub
Feb 22 2016 00:33
@Pezz18 u can check for Array.indexOf or Array.every probably one of those can help....
Andrew Perrin
@Pezz18
Feb 22 2016 00:34
@moigithub @bitgrower thanks for help :) gonna get some sleep now and resume tomorrow! got work in morning too :( brrrrrrrr
CamperBot
@camperbot
Feb 22 2016 00:34
pezz18 sends brownie points to @moigithub and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 652 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 602 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 22 2016 00:34
basically ... array.filter will keep or remove values in the array, based on the IIFE function you provide it -- it will keep or not keep them based upon the falseness or truthness of what you return ...
and yes ... Array.index is VERY handy in destroyer ...
have a good evening @Pezz18
Andrew Perrin
@Pezz18
Feb 22 2016 00:34
ok, i will keep that in mind
bitgrower
@bitgrower
Feb 22 2016 00:35
Go read the Array.filter page before you go to sleep and let your sleeping mind work on it for a bit ...
amazing what insights can happen when you feed your brain right before going to sleep...
Andrew Perrin
@Pezz18
Feb 22 2016 00:36
ok, i will head on over,,,, thanks again.
bitgrower
@bitgrower
Feb 22 2016 00:37
def look at the examples ... :)
Norman Dela Cruz
@dcnr
Feb 22 2016 00:38
but that callback isn't an iife!
or is it
hmm
bitgrower
@bitgrower
Feb 22 2016 00:51
well ... yeah, it doesn't have to be ..

http://www.rexegg.com/regex-lookarounds.html

Norman Dela Cruz
@dcnr
Feb 22 2016 00:55
wonder why js doesn't have lookbehind
bitgrower
@bitgrower
Feb 22 2016 00:58
just didn't know if you'd seen something like this page before ... I haven't seen the topic addressed much in various regex resources ... (granted, I should probably dig into them more ... )
Norman Dela Cruz
@dcnr
Feb 22 2016 00:59
@bitgrower I used this http://www.regular-expressions.info/
bitgrower
@bitgrower
Feb 22 2016 01:00
looks good !!!
lion
@lihe6666
Feb 22 2016 01:00
good
Norman Dela Cruz
@dcnr
Feb 22 2016 01:01
@bitgrower try this too http://regexone.com/
@bitgrower gets you up with the basics fast enough
bitgrower
@bitgrower
Feb 22 2016 01:02
I don't need basics ... not really ... :)
but thank you, @dcnr -- always appreciate recommended regex resources ...
CamperBot
@camperbot
Feb 22 2016 01:03
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 685 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 22 2016 01:03
ah, finally, I am in the same 100s as you !!!
probably not for long, though ..
Norman Dela Cruz
@dcnr
Feb 22 2016 01:04
thanks too @bitgrower everybody needs basics! you always warm up before an exercise :D
CamperBot
@camperbot
Feb 22 2016 01:04
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 603 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 22 2016 01:04
lool
bitgrower
@bitgrower
Feb 22 2016 01:04
:)
yojamny
@yojamny01
Feb 22 2016 01:27
I'm trying to encode the: backslash tab tab carriage-return new-line, but I don't understand the instruction. Any help , thanks .
matthew3454
@matthew3454
Feb 22 2016 01:28
@dcnr I attempted to apply the information you gave me, but I haven't gotten very far with it yet. Here's my work.
Norman Dela Cruz
@dcnr
Feb 22 2016 01:28
@yojamny01 there's a table to the right that you can follow for example to escape a quote \'
matthew3454
@matthew3454
Feb 22 2016 01:28

function reverseString(hello) {

var splitStr = str.split("");
reverseString.reverse();

return str = "hello";
str.split("");
}



Norman Dela Cruz
@dcnr
Feb 22 2016 01:30
@matthew3454 hi have you done all the previous javascript lessons?
@matthew3454 I'll just pm you hold on
matthew3454
@matthew3454
Feb 22 2016 01:31
@dcnr I sure have, but I don't think I properly encoded my memory of them.
Norman Dela Cruz
@dcnr
Feb 22 2016 01:31
yojamny
@yojamny01
Feb 22 2016 01:32
thanks you dcnr
Norman Dela Cruz
@dcnr
Feb 22 2016 01:32
@yojamny01 you're welcome! thanks too
CamperBot
@camperbot
Feb 22 2016 01:32
dcnr sends brownie points to @yojamny01 :sparkles: :thumbsup: :sparkles:
:star: 219 | @yojamny01 | http://www.freecodecamp.com/yojamny01
Mafalda
@otmeek
Feb 22 2016 01:37
just spent 30 mins banging my head against the wall trying to understand why my code didn't work. realised just now that I had a typo
Hereshk
@Hereshk
Feb 22 2016 01:38
@otmeek I feel you
Norman Dela Cruz
@dcnr
Feb 22 2016 01:38
@otmeek that's why you need a good editor/ide!
Mafalda
@otmeek
Feb 22 2016 01:39
@dcnr the thing is I'm using cloud9 and a node js module that walks you through some exercises and the module's own output was obscuring the error message
Norman Dela Cruz
@dcnr
Feb 22 2016 01:39
ooh
Mafalda
@otmeek
Feb 22 2016 01:39
I finally spotted it pointing at the misspelled variable
I want to shoot myself after that
x_x
Norman Dela Cruz
@dcnr
Feb 22 2016 01:43
@matthew3454 hi where are you?
Jon
@jcmockbee
Feb 22 2016 01:43
Hi I was hpoing someone will help on the card counting challenge . I think I am setting it up correctly
Edison Brito
@edisonbrito
Feb 22 2016 01:43
hi...
i need help
i don't understend this:
backslash tab tab carriage-return new-line and assign it to myStr
Jon
@jcmockbee
Feb 22 2016 01:44

var count = 0;

function cc(card) {
// Only change code below this line
switch (val) {

case (2, 3, 4, 5, 6): {return"5 Bet";}
break;
case (7, 8, 9): {return "0 Hold";}
break;
case (10, J, Q, K, A): {return "-1 Hold";}
break;
case ( 3, 7, Q, 8, A ): {return "-1 Hold";}
break;
case (2, J, 9, 2, 7 ):  {return "1 Bet";}
break;
case ( 3, 2, A, 10, K): {return "-1 Hold";}
break; }

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

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

Edison Brito
@edisonbrito
Feb 22 2016 01:44
var myStr = "\ \r \n";
Jon
@jcmockbee
Feb 22 2016 01:45
it gives me this reference error val is not defined
the value should be the card sequence ?
Norman Dela Cruz
@dcnr
Feb 22 2016 01:46
@jcmockbee you can't make case statements like that. It will only match the last value
Mafalda
@otmeek
Feb 22 2016 01:46
This message was deleted
Edison Brito
@edisonbrito
Feb 22 2016 01:46
someone?
Clarence W.
@leo81202
Feb 22 2016 01:46

New solution for title case a sentence

function titleCase(str) {
var tempStr;

str = str.toLowerCase().split(" ");

str.forEach(function(element, index, array) {

for (i = 0; i < element.length; i++) {
if (i === 0) {
if (index === 0) {
tempStr = element.charAt(i).toUpperCase();
} else {
tempStr += element.charAt(i).toUpperCase();
}
} else {
tempStr += element.charAt(i);
}
if (i == element.length - 1 && index != array.length - 1)
tempStr += " ";
}
});

console.log(tempStr);
return tempStr;
}

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

would it be worth submitting this to the wiki for it.

Hereshk
@Hereshk
Feb 22 2016 01:46
@jcmockbee the exercice is about updating the "count" variable first and then testing it to return the count value and if you hold or bet
Mateus Felipe C. C. Pinto
@mateusfccp
Feb 22 2016 01:47
@leo81202 No.
Norman Dela Cruz
@dcnr
Feb 22 2016 01:47
@edisonbrito hi the table to escape characters is listed there too, just follow those
Jon
@jcmockbee
Feb 22 2016 01:47
ok thankyou both let me try something here
Mateus Felipe C. C. Pinto
@mateusfccp
Feb 22 2016 01:47
@leo81202 So much complex.
Clarence W.
@leo81202
Feb 22 2016 01:48
@mateusfccp true, I seen the for each loop for an array and I wanted to try and use it.
Edison Brito
@edisonbrito
Feb 22 2016 01:48
the list: myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
Norman Dela Cruz
@dcnr
Feb 22 2016 01:49
@leo81202 you don't have to do a loop inside your for each, you can use string functions to modify your string
Edison Brito
@edisonbrito
Feb 22 2016 01:49
my job: var myStr = "\ \r\n";
Norman Dela Cruz
@dcnr
Feb 22 2016 01:49
@edisonbrito yes so you should follow that! you're on the right track except to escape a backslash you need to do \\
so escape all of the needed ones backslash tab tab carriage-return new-line
Clarence W.
@leo81202
Feb 22 2016 01:50
@dcnr after I got the solution, I took a look at the answer and seen that
Norman Dela Cruz
@dcnr
Feb 22 2016 01:50
also separate them with spaces
Edison Brito
@edisonbrito
Feb 22 2016 01:51
@dcnr I go try now.
Mateus Felipe C. C. Pinto
@mateusfccp
Feb 22 2016 01:52
@leo81202 titleCase = (str) => str.split(' ').map(v => v[0].toUpperCase().concat(v.slice(1).toLowerCase())).join(' ')
Clarence W.
@leo81202
Feb 22 2016 01:52
@mateusfccp that's a lot
Mateus Felipe C. C. Pinto
@mateusfccp
Feb 22 2016 01:53
This is a less complex solution. Sure, you will want to break it to make more readable.
Clarence W.
@leo81202
Feb 22 2016 01:53
Norman Dela Cruz
@dcnr
Feb 22 2016 01:53
function titleCase(str) {
'use strict';

return str
.toLowerCase()
.split(' ')
.map(val => val[0].toUpperCase() + val.slice(1))
.join(' ');
}
That's why I like to format it like this
matthew3454
@matthew3454
Feb 22 2016 01:54
@dcnr I have not progressed since the last message I sent you. What did you mean by pm?
Clarence W.
@leo81202
Feb 22 2016 01:54
whats val => ?
Edison Brito
@edisonbrito
Feb 22 2016 01:55
@dcnr i made attempts, but i'dont undestend "\"... i did this: var myStr = '\ \r \n'; but not worked
Norman Dela Cruz
@dcnr
Feb 22 2016 01:55
@matthew3454 private massage i've been trying to private message you click on my name at the right, bottom of the list of the chat rooms
George Phalen
@gphalen
Feb 22 2016 01:55
Stuck on 218. It wants me to return the "value" of a variable. All I can think of doing is using the valueOf keyword, which just returns the variable itself.

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

function checkObj(checkProp) {

if (myObj.hasOwnProperty(checkProp)){
return checkProp.valueOf();
}

else
}

// Test your code by modifying these values

Norman Dela Cruz
@dcnr
Feb 22 2016 01:56
@edisonbrito the char in the description is all you need so you need to refer to that. for example it says how to escape a single quote, and it's written as \'
Mateus Felipe C. C. Pinto
@mateusfccp
Feb 22 2016 01:56
@dcnr You must lower-case the slice to it pass all tests.
Norman Dela Cruz
@dcnr
Feb 22 2016 01:56
@mateusfccp str is already lowercased before the split
Mateus Felipe C. C. Pinto
@mateusfccp
Feb 22 2016 01:57
@dcnr Sure, my mistake.
Edison Brito
@edisonbrito
Feb 22 2016 01:57
@dcnr oh my god, now undestend.
Norman Dela Cruz
@dcnr
Feb 22 2016 01:58
@edisonbrito that's great! :D
Edison Brito
@edisonbrito
Feb 22 2016 01:58
thanks @dcnr
CamperBot
@camperbot
Feb 22 2016 01:58
edisonbrito sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 686 | @dcnr | http://www.freecodecamp.com/dcnr
Jon
@jcmockbee
Feb 22 2016 02:07
I got it thankyou both I realized each card had a parameter vs the whole hand.

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
default:
break;
}

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

// Only change code above this line
}

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

or variable would be the more appropriate term
Hereshk
@Hereshk
Feb 22 2016 02:12
@jcmockbee good job, its also possible to have the same result with if and else if instead of switch
var count = 0;

function cc(card) {
// Only change code below this line

if(card == 2 || card == 3  || card == 4  || card == 5  || card == 6) {
count++;
}
else if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A") {
count--;
}

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

// Only change code above this line
}
Jon
@jcmockbee
Feb 22 2016 02:15
now that's cool
Norman Dela Cruz
@dcnr
Feb 22 2016 02:16
@jcmockbee you could also put them in an array and use indexOf, lots of ways you can solve these problems!
Jon
@jcmockbee
Feb 22 2016 02:17
indexOf a function as well then ?
Norman Dela Cruz
@dcnr
Feb 22 2016 02:20
@jcmockbee I mean you can group em up
var countPlus = [2, 3, 4, 5, 6];
if (countPlus.indexOf(card) > -1) {
// count++ etc etc
}
Jon
@jcmockbee
Feb 22 2016 02:21
Now I got it I see thankyou
Norman Dela Cruz
@dcnr
Feb 22 2016 02:25
@jcmockbee It's probably inefficient though :P but yeah, lots of ways to solve things
Patrick Thibault
@tiboclan
Feb 22 2016 02:26
Hey guys need help with this one
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; ) //have no clue
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Michael Mazzone
@GitMazzone
Feb 22 2016 02:27
Hey everyone, I was hoping someone could help me with a logic error. This is only fixing the first word, so I must be doing something too short. here's the code for the ROT13 bonfire:
function rot13(str) {
var solvedStr = "";
var unicodeArr = [];  //Holds unicode values for each char
var lettersArr = [];  //Holds A-Z unicode values

//Loop to get char code of each char in str
for(var i = 0; i < str.length; i++) {
unicodeArr.push(str.charCodeAt(i));
}

//Loops to push all letter values to an array to check against later
//A-Z is 65-90
for(var capVal = 65; capVal < 91; capVal++) {
lettersArr.push(capVal);
}

//Loops to check each char value in unicodeArr
//If it isn't a letter value, do nothing
//Otherwise, get unicode value of char, add 13 to it, and push to string
function isInArray(value, array) {
return array.indexOf(value) > -1;
}
//Loop through unicodeArr
for(var j = 0; j < unicodeArr.length; j++) {
//Handle capital letters
if(isInArray(unicodeArr[j], lettersArr)) {
if(unicodeArr[j] + 13 > 91) {
unicodeArr[j] = ((unicodeArr[j] + 13) - 91) + 65;
} else {
unicodeArr[j] = unicodeArr[j] + 13;
}
} else {
break;
}
solvedStr += String.fromCharCode(unicodeArr[j]);
}

return solvedStr;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");
CamperBot
@camperbot
Feb 22 2016 02:27
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Patrick Thibault
@tiboclan
Feb 22 2016 02:28
it's for Nesting for loops challenge
matthew3454
@matthew3454
Feb 22 2016 02:33
@brainyfarm @dcnr spank you very much.
Patrick Thibault
@tiboclan
Feb 22 2016 02:33
@tiboclan anybody
matthew3454
@matthew3454
Feb 22 2016 02:33
Oh it didn't work whoops.
Patrick Thibault
@tiboclan
Feb 22 2016 02:33
This message was deleted
matthew3454
@matthew3454
Feb 22 2016 02:33
@dcnr thank you very much
CamperBot
@camperbot
Feb 22 2016 02:33
matthew3454 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 687 | @dcnr | http://www.freecodecamp.com/dcnr
Michael Mazzone
@GitMazzone
Feb 22 2016 02:34
Found my problem - thanks anyways fam.
Norman Dela Cruz
@dcnr
Feb 22 2016 02:34
you're welcome, thanks too @matthew3454

@GitMazzone
You can also rewrite this

unicodeArr[j] = ((unicodeArr[j] + 13) - 91) + 65;

to

unicodeArr[j] = unicodeArr[j] - 13;
$x + 13 - 91 + 65$
$x - 78 + 65$
$x - 13$
Norman Dela Cruz
@dcnr
Feb 22 2016 02:39
fancy!
Richard Corbett
@reacorbett
Feb 22 2016 02:39
I am on the Stand in line Challenge. I do not understand what is happening. How is this working?
function queue(arr, item) {
arr.push(item);
return   arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Norman Dela Cruz
@dcnr
Feb 22 2016 02:40
@reacorbett
push inserts the thing you want to insert to the end of the array you called push on.
shift removes the first element of the array you called it on, and gives back the value too
so
1. You are pushing item to the end of arr
2. Removing the first element of arr with shift() and returning it with return
Patrick Thibault
@tiboclan
Feb 22 2016 02:43
good evening everybody
Paul
@PJonestown
Feb 22 2016 02:43
Hey guys, I'm getting a TypeError because a function is expecting an array parameter. Problem is I'm definitely passing in an array. I checked like 10 times. Am I going crazy? What could cause this?
Norman Dela Cruz
@dcnr
Feb 22 2016 02:43
good evening :zzz:
@PJonestown it might have been transformed or accessed inappropriately
somewhere
Patrick Thibault
@tiboclan
Feb 22 2016 02:44
would somebody help me with the challenge Nesting for loops
ankit2122
@ankit2122
Feb 22 2016 02:44
Hello , i am on challenge "Using Objects for Lookups" . But i am not able to figure it out. Please Help .....
Amanda
Feb 22 2016 02:44
@tiboclan Where are you stuck?
Patrick Thibault
@tiboclan
Feb 22 2016 02:45
function multiplyAll(arr) {
var product = 1;
// Only change code below this line

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
i have no clue with this one
i have to "Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr"
Richard Corbett
@reacorbett
Feb 22 2016 02:47
@dcnr i guess what I am trying to say is, how does the function queue(arr, item) know that to do with [1,2,3,4,5] . Does it just know that item is a number and arr is the array?
Paul
@PJonestown
Feb 22 2016 02:48
@dcnr


@dcnr

if(gon.available_dates instanceof Array) {
$('.datetimepicker').datetimepicker({ enabledDates:gon.available_dates }); }; This returns the typerror because it's expecting an array. I can't imagine where it would transform. Any ideas? Amanda @invaderrizz Feb 22 2016 02:50 @tiboclan I haven't gotten there yet, so I can't pull my code, but it looks to me like you're working to take the "product" variable, and multiply that out by each number in the array. I would assume since you have only one variable returned, and not an array, you are multiplying three numbers together - "variable", array0, and array1. Norman Dela Cruz @dcnr Feb 22 2016 02:51 @PJonestown unfortunately, I'm sorry I really don't know :( Patrick Thibault @tiboclan Feb 22 2016 02:51 ok yeah i see , i'll try something Paul @PJonestown Feb 22 2016 02:51 @dcnr Thanks for looking CamperBot @camperbot Feb 22 2016 02:51 pjonestown sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 688 | @dcnr | http://www.freecodecamp.com/dcnr Patrick Thibault @tiboclan Feb 22 2016 02:51 thanks @invaderrizz CamperBot @camperbot Feb 22 2016 02:51 tiboclan sends brownie points to @invaderrizz :sparkles: :thumbsup: :sparkles: :star: 219 | @invaderrizz | http://www.freecodecamp.com/invaderrizz Norman Dela Cruz @dcnr Feb 22 2016 02:52 thanks too @PJonestown have you tried the Front End and main chat rooms? They're keener on this kind of problem CamperBot @camperbot Feb 22 2016 02:52 dcnr sends brownie points to @pjonestown :sparkles: :thumbsup: :sparkles: :star: 260 | @pjonestown | http://www.freecodecamp.com/pjonestown Paul @PJonestown Feb 22 2016 02:53 @dcnr Good idea. I'll give that a try tomorrow. I've been racking my brain over this for a few hours and I'm spent :) Malcolm @noinkling Feb 22 2016 02:53 @PJonestown console.log or set a breakpoint and see what gon.available_dates is that's the first step Norman Dela Cruz @dcnr Feb 22 2016 02:53 @reacorbett ah whatever you passed to your function is assigned to its arguments so if you do queue([1, 2, 3,4], 10) arr would be [1,2,3,4] and item would be 10. So the order is important. so if you didn't pass in an array for arr, you would get an error because arr.push(item) and arr.shift() would be invalid @PJonestown good luck! :D Richard Corbett @reacorbett Feb 22 2016 02:57 @dcnr Thanks, I understand it a little better now. CamperBot @camperbot Feb 22 2016 02:57 reacorbett sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 689 | @dcnr | http://www.freecodecamp.com/dcnr Richard Corbett @reacorbett Feb 22 2016 02:59 @dcnr I understand completely. I wasn't even looking at console.log(queue(testArr, 6)); know it makes total since Norman Dela Cruz @dcnr Feb 22 2016 02:59 @reacorbett something like function foo(bar, baz) { bar /* is hello */, baz /* is world */ } ^ ^ | | | +-----+ | | foo("hello", "world"); Richard Corbett @reacorbett Feb 22 2016 03:00 @dcnr Thanks again. CamperBot @camperbot Feb 22 2016 03:00 reacorbett sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :warning: reacorbett already gave dcnr points Norman Dela Cruz @dcnr Feb 22 2016 03:00 you're welcome, thanks too @reacorbett CamperBot @camperbot Feb 22 2016 03:00 dcnr sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles: :star: 193 | @reacorbett | http://www.freecodecamp.com/reacorbett Norman Dela Cruz @dcnr Feb 22 2016 03:01 I'm going good night/day all @bitgrower byes! Hereshk @Hereshk Feb 22 2016 03:01 goodnight @dcnr Norman Dela Cruz @dcnr Feb 22 2016 03:02 :sleeping: @Hereshk :D Richard Corbett @reacorbett Feb 22 2016 03:08 ah Kendra Lyndon @KendraLyndon Feb 22 2016 03:20 Could someone help me with the challenge Falsy Bouncer? Solehjon @Solehjon Feb 22 2016 03:23 Hello Guys! Need help! this is the task studlyCapVar should use camelCase in both declaration and assignment sections. // Declarations var studlyCapVar; var properCamelCase; var titleCaseOver; // Assignments studlyCapVaR = 10; properCamelCase = "A String"; titleCaseOver = 9000; this was my code tommy @tommygebru Feb 22 2016 03:25 its good practice to provide LINK & TITLE to your challenge or show your previous work :thumbsup: Franco Zapata @Francozt01 Feb 22 2016 03:25 @Solehjon studlyCapVaR Var instead of VaR ?¿ Solehjon @Solehjon Feb 22 2016 03:25 @Francozt01 What do you mean? Franco Zapata @Francozt01 Feb 22 2016 03:26 u are using camelCase but ur variable was declared studlyCapVaR the last R is suppose to be R or r ? Solehjon @Solehjon Feb 22 2016 03:27 @Francozt01 Got it, is suppose to be r! Thanks CamperBot @camperbot Feb 22 2016 03:27 solehjon sends brownie points to @francozt01 :sparkles: :thumbsup: :sparkles: :star: 550 | @francozt01 | http://www.freecodecamp.com/francozt01 Franco Zapata @Francozt01 Feb 22 2016 03:28 @Solehjon cool :D :+1: Kendra Lyndon @KendraLyndon Feb 22 2016 03:29 Hi everyone, I'm working on the challenge Falsy Bouncer (remove all falsy values from an array). This is my code so far: function bouncer(arr) { if(arr){ return arr; } else{} } [7, "ate", "", false, 9].filter(bouncer); this returns [7, "ate",9] so it looks like the code is working as it should but it's not passing the challenge. Lewis @Lewis65 Feb 22 2016 03:32 bonfire no repeats please CamperBot @camperbot Feb 22 2016 03:32 ## :fire:Bonfire: No repeats please :link: function permAlone(str) { return str; } permAlone('aab'); Return the number of total permutations of the provided string that don't have repeated consecutive letters. more info: bf details | bf links | hint Lewis @Lewis65 Feb 22 2016 03:32 hint CamperBot @camperbot Feb 22 2016 03:32 :construction: Spoilers are only in the Bonfire's Custom Room :point_right: Jesus Vega @ParagonChuy Feb 22 2016 03:32 Does anybody have experience with Firebase? Hereshk @Hereshk Feb 22 2016 03:33 @tiboclan I just manage to finish that challenge, the example gives most of what you need, my problem was that I was not updating the "product" variable before the end of the loop... Vadim Grigorov @Chichavl Feb 22 2016 03:35 Hi, This is my console output when working with floats. I expect 96.74 - 60 = 36.74 I understand right that I should round result after every operation? Or there is another strategy? cidObj["TWENTY"] 60 changeSum 96.74 96.74 - 60 36.739999999999995 bitgrower @bitgrower Feb 22 2016 03:52 @KendraLyndon -- my VERY best advice for Falsy Bouncer is to read the helpful hints pages ... carefully... :) I wish I'd done that to begin with -- would have saved me hours of time & frustration ... Kendra Lyndon @KendraLyndon Feb 22 2016 03:54 @bitgrower thank you! It took me a while to realize even though my code filtered out falsy values I still wasn't following the instructions exactly. CamperBot @camperbot Feb 22 2016 03:54 kendralyndon sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :star: 604 | @bitgrower | http://www.freecodecamp.com/bitgrower Vadim Grigorov @Chichavl Feb 22 2016 04:11 Can anyone help with my question? ↑ Rashida Thompson @rashidathompson Feb 22 2016 04:35 Hi everyone! Can someone be an extra set of eyes & let me know what I'm doing wrong on the "Multiple Identical Options in Switch Statements" problem? function myTest(val) { var answer = ""; // 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"; break; } // Only change code above this line return answer; } // Change this value to test myTest(1); uriznik @uriznik Feb 22 2016 04:38 @rashidathompson check what value you are actually returning Robert Valmassoi @valmassoi Feb 22 2016 04:38 try moves 1, 2, 3 not sure why my if(userMoves == wins[0]){ isnt running Rashida Thompson @rashidathompson Feb 22 2016 04:41 @uriznik Aha! Thank you! CamperBot @camperbot Feb 22 2016 04:41 rashidathompson sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles: :star: 307 | @uriznik | http://www.freecodecamp.com/uriznik Eric Meling @Gnilemcire Feb 22 2016 04:41 help Introducing JavaScript Object Notation JSON CamperBot @camperbot Feb 22 2016 04:41 ## :point_right: challenge introducing javascript object notation json [wiki] # Challenge: Introducing JavaScript Object Notation JSON JavaScript Object Notation or JSON uses the format of JavaScript Objects to store data. JSON is flexible because it allows for Data Structures with arbitrary combinations of strings, numbers, booleans, arrays, and objects. Here is an example of a JSON object: var ourMusic = [ { "artist": "Daft Punk", "title": "Homework", "release_year": 1997, "formats": [ "CD", "Cassette", "LP" ], "gold": true } ]; Ashley @asberrie Feb 22 2016 04:45 Hi.... I know that this isn't covered here on FreeCodeCamp, but I'm wondering if anyone provide some insight into how to use "The prototype property" (it's kind of covered in other material I'm using for class, but not enough description/detail for me to understand) Thanks! uriznik @uriznik Feb 22 2016 04:50 @valmassoi you need to compare the contents of the arrays yourself Robert Valmassoi @valmassoi Feb 22 2016 04:51 are you saying [1,2,3] != [1,2,3] ? i need to check each index equal? @uriznik uriznik @uriznik Feb 22 2016 04:52 @valmassoi yes, try it :) Robert Valmassoi @valmassoi Feb 22 2016 04:53 i know i will need to completly change that code anyways. i was just starting the project and wanted a quick check. didnt know about this though Nick Robson @nickrobson Feb 22 2016 05:06 @asberrie An class's prototype affects all instances of the class. That means that if you add a function to the Array class prototype, you'll be able to use it on all array objects. For example, you could use Array.prototype.first = function() { return this.length ? this[0] : undefined; } Which would allow you to go: [1, 2, 3, 4].first(); // => 1 Similarly, you could use Object.prototype.[something] to modify all Objects' prototypes. Ashley @asberrie Feb 22 2016 05:13 @nickrobson so are you basically adding another property to the object? Nick Robson @nickrobson Feb 22 2016 05:14 @asberrie Yes, you're adding one to all current and to-be-created objects. Ashley @asberrie Feb 22 2016 05:15 @nickrobson ok, thank you :) CamperBot @camperbot Feb 22 2016 05:15 asberrie sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles: :star: 394 | @nickrobson | http://www.freecodecamp.com/nickrobson Richard Corbett @reacorbett Feb 22 2016 05:16 the "Return Early Pattern for Functions " challenge is giving me a headache. I am not understanding it at all. uriznik @uriznik Feb 22 2016 05:19 help Return Early Pattern for Functions CamperBot @camperbot Feb 22 2016 05:19 ## :point_right: challenge return early pattern for functions [wiki] # Challenge: Return Early Pattern for Functions When a return statement is reached, the execution of the current function stops and control returns to the calling location. ## Example function myFun() { console.log("Hello"); return "World"; console.log("byebye") } myFun(); The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement. :pencil: read more about challenge return early pattern for functions on the FCC Wiki Richard Corbett @reacorbett Feb 22 2016 05:20 @uriznik i figured it out. thanks // Setup function abTest(a, b) { // Only change code below this line if(a < 0 || b < 0){ return undefined; } // Only change code above this line return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); } // Change values below to test your code abTest(2,2); CamperBot @camperbot Feb 22 2016 05:20 reacorbett sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles: :star: 308 | @uriznik | http://www.freecodecamp.com/uriznik Richard Corbett @reacorbett Feb 22 2016 05:21 @uriznik is that the correct way? uriznik @uriznik Feb 22 2016 05:23 @reacorbett yes Solehjon @Solehjon Feb 22 2016 05:57 @Solehjon Guys need help! Convert Celsius to Fahrenheit convert(0) should return a number convert(-30) should return a value of -22 convert(-10) should return a value of 14 convert(0) should return a value of 32 convert(20) should return a value of 68 convert(30) should return a value of 86 Ashley @asberrie Feb 22 2016 06:06 @Solehjon what specifically do you need help with? Hereshk @Hereshk Feb 22 2016 06:06 @Solehjon What did you try so far? You need to create a variable "fahrenheit" that is the result of the algorithm you apply to the "celsius" variable. Nick Robson @nickrobson Feb 22 2016 06:18 @Solehjon You just need to apply the equation. Ramon Jacinto Conanan @pipoconanan45 Feb 22 2016 06:22 help on profile lookup here's my code CamperBot @camperbot Feb 22 2016 06:22 no wiki entry for: on profile lookup heres my code Ramon Jacinto Conanan @pipoconanan45 Feb 22 2016 06:23 help profile lookup function lookUp(firstName, prop){ // Only change code below this line for (var i=0;i<contacts.length;i++){ for (var o=0;o<contacts[i].length;o++){ if (firstName === contacts[i] && prop === contacts[i]){ console.log(contacts[prop]); }else if (firstName === contacts[i]){ console.log("No such contacts"); }else if(prop === contacts[i]){ console.log("No such property"); } } } // Only change code above this line } CamperBot @camperbot Feb 22 2016 06:23 no wiki entry for: profile lookupfunction lookupfirstname prop only change code below this linefor var i0icontactslengthi for var o0ocontactsilengtho if firstname contactsi prop contactsi consolelogcontactsprop else if firstname contactsi consolelogno such contacts else ifprop contactsi consolelogno such property only change code above this line Olawale Akinseye @brainyfarm Feb 22 2016 06:25 What is the issue @pipoconanan45? Ramon Jacinto Conanan @pipoconanan45 Feb 22 2016 06:26 having a hard time solving the challenge. I posted my code above. Olawale Akinseye @brainyfarm Feb 22 2016 06:26 You do not need to loop more than once @pipoconanan45. The second for loop is not necessary. Ramon Jacinto Conanan @pipoconanan45 Feb 22 2016 06:27 Wait..what. Imma try that. Thanks. Still not working, maybe something wrong with my if statements? zhouxh @zhouxh Feb 22 2016 06:31 you can defined a local var "bool found=false" Olawale Akinseye @brainyfarm Feb 22 2016 06:31 Yes, your conditions are not right yet. zhouxh @zhouxh Feb 22 2016 06:31 var found = false Olawale Akinseye @brainyfarm Feb 22 2016 06:32 Post your most recent code @pipoconanan45. Ramon Jacinto Conanan @pipoconanan45 Feb 22 2016 06:32 function lookUp(firstName, prop){ // Only change code below this line for (var i=0;i<contacts.length;i++){ if (firstName === contacts[i]){ console.log(contacts[firstName][prop]); }else if (firstName === contacts[i]){ console.log("No such contacts"); }else if(prop === contacts[i]){ console.log("No such property"); } } // Only change code above this line } Olawale Akinseye @brainyfarm Feb 22 2016 06:34 For example, your first condition should be if (firstName === contacts[i].firstName) @pipoconanan45. Then you check if the property now exist. zhouxh @zhouxh Feb 22 2016 06:35 You should find the contacts[firstName] first ,then next . Olawale Akinseye @brainyfarm Feb 22 2016 06:35 I suggest you review the Javascript object lessons again @pipoconanan45 Hello @zhouxh :wave: zhouxh @zhouxh Feb 22 2016 06:36 Hello Olawale Akinseye @brainyfarm Feb 22 2016 06:38 Is that you in the picture? zhouxh @zhouxh Feb 22 2016 06:39 ha ,you can guess? rphares @rphares Feb 22 2016 06:40 ( @zhouxh , i love your pic :blush: ) zhouxh @zhouxh Feb 22 2016 06:41 me too TheKingIsHere @TheKingIsHere Feb 22 2016 06:42 hello everyone, I was having trouble with challenge accessing nested array in json. My problem arises from myPlants.tree1 not being defined, not sure step I'm missing // Setup var myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ]; // Only change code below this line var secondTree = "pine"; // Change this secondTree = myPlants.trees[1]; anthonygallina1 @anthonygallina1 Feb 22 2016 06:47 @TheKingIsHere You are looking for it in the wrong spot in the arrays @TheKingIsHere Very close though how about 1 1? Anindya Maiti @amaiti504 Feb 22 2016 06:48 @TheKingIsHere "trees" is a value. Not a key anthonygallina1 @anthonygallina1 Feb 22 2016 06:49 @amaiti504 yes there is a diff key just like you said Anindya Maiti @amaiti504 Feb 22 2016 06:49 @TheKingIsHere myPlants(1).list anthonygallina1 @anthonygallina1 Feb 22 2016 06:50 close Olawale Akinseye @brainyfarm Feb 22 2016 06:50 That would be a world record @zhouxh :P anthonygallina1 @anthonygallina1 Feb 22 2016 06:51 [ ] [ ] @TheKingIsHere are you sill Here? TheKingIsHere @TheKingIsHere Feb 22 2016 06:52 yes anthonygallina1 @anthonygallina1 Feb 22 2016 06:53 @TheKingIsHere have you tried the list key? TheKingIsHere @TheKingIsHere Feb 22 2016 06:54 this is what I have so far secondTree = myPlants.type.list[1]; Salvatore Santamaria @ssroman Feb 22 2016 06:55 hi im very new. how do i post my code to the chat ? TheKingIsHere @TheKingIsHere Feb 22 2016 06:56 @anthonygallina1 is this the right track Nick Robson @nickrobson Feb 22 2016 06:57 help format CamperBot @camperbot Feb 22 2016 06:57 ## :point_right: code formatting [wiki] ### Inline code This an inline <paste code here> code formatting with a single backtick() at start and end around the code. ### Code Block js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css) <paste your code here>, then press [shift + enter ⏎]  ⇦ Type 3 backticks, then press [enter ⏎] See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics Anindya Maiti @amaiti504 Feb 22 2016 06:57 @TheKingIsHere you are confusing array & objects. myPlants is an array, myPlants(1) is an object Abhishek Kumar @abhishekKumar1 Feb 22 2016 06:57 @TheKingIsHere think of it this way myPlants is an array with two objects out of which you have to select the second one then in that object you have to select list which is again an array in which u have to select the second element. anthonygallina1 @anthonygallina1 Feb 22 2016 06:57 This message was deleted Salvatore Santamaria @ssroman Feb 22 2016 06:58 test anthonygallina1 @anthonygallina1 Feb 22 2016 06:59 @TheKingIsHere myPlants[1].list[1] TheKingIsHere @TheKingIsHere Feb 22 2016 06:59 @anthonygallina1 thanks CamperBot @camperbot Feb 22 2016 06:59 thekingishere sends brownie points to @anthonygallina1 :sparkles: :thumbsup: :sparkles: :star: 893 | @anthonygallina1 | http://www.freecodecamp.com/anthonygallina1 TheKingIsHere @TheKingIsHere Feb 22 2016 06:59 @amaiti504 thanks CamperBot @camperbot Feb 22 2016 06:59 thekingishere sends brownie points to @amaiti504 :sparkles: :thumbsup: :sparkles: :star: 295 | @amaiti504 | http://www.freecodecamp.com/amaiti504 TheKingIsHere @TheKingIsHere Feb 22 2016 07:00 @abhishekKumar1 thanks anthonygallina1 @anthonygallina1 Feb 22 2016 07:00 @TheKingIsHere See how it is nested? the arrays Salvatore Santamaria @ssroman Feb 22 2016 07:01 return stringArray[i].length; jsfunction findLongestWord(str) { var stringArray = str.split(" "); var longest = str[0].length; for (i = 0; i < stringArray.length; i++ ) { if (stringArray[i].length > longest) return stringArray[i].length; TheKingIsHere @TheKingIsHere Feb 22 2016 07:02 yes after being in the myPlants function I select second option, and list array second option, from my understanding Salvatore Santamaria @ssroman Feb 22 2016 07:03 jsfunction findLongestWord(str) { var stringArray = str.split(" "); var longest = str[0].length; for (i = 0; i < stringArray.length; i++ ) { if (stringArray[i].length > longest) return stringArray[i].length; Ihor @KindOf Feb 22 2016 07:03 hey guys! I have problem with Using Objects for Lookups lesson. phoneticLookup("") should equal undefined marked as incorrect but my code working properly/ what should i do? anthonygallina1 @anthonygallina1 Feb 22 2016 07:04 @TheKingIsHere i know you were stuck here since last night. Was trying to tell you in a way that you see it earlier. Glad you got over that bump:) @TheKingIsHere Happy Coding TheKingIsHere @TheKingIsHere Feb 22 2016 07:08 @anthonygallina1 yes and I had a few things going on so I had to leave early. Glad to get keep moving forward, one question, was my explanation clear and concise? Salvatore Santamaria @ssroman Feb 22 2016 07:09 This message was deleted anthonygallina1 @anthonygallina1 Feb 22 2016 07:10 @TheKingIsHere yes But it is hard some times to lead one to the ansswer without giving the answer. @TheKingIsHere Yes second would be 1 because 0 is a number. anthonygallina1 @anthonygallina1 Feb 22 2016 07:18 @TheKingIsHere I recommend playing around with that code and accessing different parts of the array. rphares @rphares Feb 22 2016 07:47 @KindOf , could you paste your code,please? :blush: Josh Yap @joshyap Feb 22 2016 07:54 is anyone able to help me with the queue exercise? Olawale Akinseye @brainyfarm Feb 22 2016 08:01 Post your code @yoshuajap :D faraz @silentarrowz Feb 22 2016 08:02 hi, having problems showing the weather with my weather app. could you tell what's wrong?? here's the link to codepen - http://codepen.io/silentarrowz/pen/YwoGMB could you help @brainyfarm Nick Svanidze @nikasvan Feb 22 2016 08:02 Thanks @Rafase282 @shadowfool @Hallaathrad for your help with Algorithm: Find the Longest Word in a String CamperBot @camperbot Feb 22 2016 08:02 nikasvan sends brownie points to @rafase282 and @shadowfool and @hallaathrad :sparkles: :thumbsup: :sparkles: :star: 403 | @shadowfool | http://www.freecodecamp.com/shadowfool :star: 450 | @hallaathrad | http://www.freecodecamp.com/hallaathrad :star: 993 | @rafase282 | http://www.freecodecamp.com/rafase282 faraz @silentarrowz Feb 22 2016 08:02 @anthonygallina1 Nick Svanidze @nikasvan Feb 22 2016 08:03 Maybe another solution to Maybe another solution for finding the longest word in a string ? function findLongestWord(str) { var separator = ' '; var separatedArray = []; separatedArray = str.split(separator); var maxItem = separatedArray[1]; for(var i=1;i<(separatedArray.length+1);i++){ if(maxItem.length>separatedArray[i-1].length){ maxItem = maxItem; } else { maxItem = separatedArray[i-1]; } } return maxItem.length; } findLongestWord("The quick brown fox jumped over the lazy dog");  Olawale Akinseye @brainyfarm Feb 22 2016 08:05 @silentarrowz, you have to get everything done, that is your API call inside you getPosition function otherwise, longitude and latitude would be undefined. Fitd First, confirm that your geolocation api works and that it returns the current position. Charles Chung @chulmo Feb 22 2016 08:10 @silentarrowz your app returns the correct lon / lat coordinates - now you just need to render the remaining details however you like. faraz @silentarrowz Feb 22 2016 08:12 yeah, @brainyfarm @chulmo . I used geolocation to get the location working and it is working correctly. it shows up in the #location id. but I am using openweatherapi to get the weather working but it doesnt show up in the #weather id? i think there's something wrong with my get json command, could you tell me what is that?? Wangach @Wangach Feb 22 2016 08:13 Hey! Can somebody help me here please! I am stuck in this challenge. Here is the linkhttp://www.freecodecamp.com/challenges/convert-celsius-to-fahrenheit Aharon Hyman @nachamuami Feb 22 2016 08:14 @Wangach can we see what you have coded so far Wangach @Wangach Feb 22 2016 08:15 function convert(celsius) { // Only change code below this line var fahrenheit = 0; // Only change code above this line if ( typeof fahrenheit !== 'undefined' ) { return fahrenheit; } else { return 'fahrenheit not defined'; } } // Change the inputs below to test your code convert(30); Not much though. Js is quite hard for me.... Richard Corbett @reacorbett Feb 22 2016 08:17 help Introducing JavaScript Object Notation JSON CamperBot @camperbot Feb 22 2016 08:17 ## :point_right: challenge introducing javascript object notation json [wiki] # Challenge: Introducing JavaScript Object Notation JSON JavaScript Object Notation or JSON uses the format of JavaScript Objects to store data. JSON is flexible because it allows for Data Structures with arbitrary combinations of strings, numbers, booleans, arrays, and objects. Here is an example of a JSON object: var ourMusic = [ { "artist": "Daft Punk", "title": "Homework", "release_year": 1997, "formats": [ "CD", "Cassette", "LP" ], "gold": true } ]; Wangach @Wangach Feb 22 2016 08:20 @nachamuami any solutions yet? Wangach @Wangach Feb 22 2016 08:30 @reacorbett can you help on the question please? kirbyedy @kirbyedy Feb 22 2016 08:31 @Wangach well eventually you have to convert fahrenheit to celsius right ? Richard Corbett @reacorbett Feb 22 2016 08:31 @Wangach what is the question? Wangach @Wangach Feb 22 2016 08:32 @kirbyedy Yes i have to kirbyedy @kirbyedy Feb 22 2016 08:32 or simply (celsius*(9/5))+32 Richard Corbett @reacorbett Feb 22 2016 08:34 celsius * 9 / 5 + 32 dont use the brackets @kirbyedy kirbyedy @kirbyedy Feb 22 2016 08:34 does it make any difference ? Wangach @Wangach Feb 22 2016 08:35 @reacorbett Not the formulae but thanks anyway. I need the Javascript code check out this link http://www.freecodecamp.com/challenges/convert-celsius-to-fahrenheit CamperBot @camperbot Feb 22 2016 08:35 wangach sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles: :star: 230 | @reacorbett | http://www.freecodecamp.com/reacorbett Blauelf @Blauelf Feb 22 2016 08:35 @kirbyedy No difference in Javascript, but difference in languages that do an integer division on (9/5) Richard Corbett @reacorbett Feb 22 2016 08:35 copy and paste it. the link is opening my solution. kirbyedy @kirbyedy Feb 22 2016 08:36 @Blauelf ah ok, thanks CamperBot @camperbot Feb 22 2016 08:36 kirbyedy sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star: 1272 | @blauelf | http://www.freecodecamp.com/blauelf Blauelf @Blauelf Feb 22 2016 08:37 @kirbyedy If celsius is float, celsius*9/5 would do a float division instead. As I said, JS does only float division. Richard Corbett @reacorbett Feb 22 2016 08:37 @kirbyedy you almost have it. lose this line and you will get it right. var convert=30; @kirbyedy look at line 16. that is the input for the formula. line one tell convert to be celsius and line 16 gets the input for it. Wangach @Wangach Feb 22 2016 08:42 @reacorbett Have done away with the line and the input now is null......... Richard Corbett @reacorbett Feb 22 2016 08:42 show me what you have @kirbyedy halaszj @halaszj Feb 22 2016 08:44 ok... im stuck on "Make Object Properties Private" the whole bike gear problem Neeraj Jha @Jonsnow21 Feb 22 2016 08:44 i m stuck on falsy bouncer problem function bouncer(arr) { for( var i = 0; i < arr.length; i++){ if(!arr[i]){ arr.splice(i, 1); i = i - 1; break; } } return arr; } bouncer([7, "ate", "", false, 9]); Wangach @Wangach Feb 22 2016 08:45 @halaszj Share a link! Neeraj Jha @Jonsnow21 Feb 22 2016 08:45 this is my solution but its not working Richard Corbett @reacorbett Feb 22 2016 08:45 This is what you should have function convert(celsius) { // Only change code below this line var fahrenheit = celsius * 9 / 5 + 32; // Only change code above this line if ( typeof fahrenheit !== 'undefined' ) { return fahrenheit; } else { return 'fahrenheit not defined'; } } // Change the inputs below to test your code convert(30); Neeraj Jha @Jonsnow21 Feb 22 2016 08:46 var gear = 0; this.setGear = function() { return gear; }; this.getGear = function() { return gear; }; Richard Corbett @reacorbett Feb 22 2016 08:46 @kirbyedy Neeraj Jha @Jonsnow21 Feb 22 2016 08:46 this should work @halaszj halaszj @halaszj Feb 22 2016 08:47 that is EXACTLY what I have @Jonsnow21 Neeraj Jha @Jonsnow21 Feb 22 2016 08:47 ohh lol wait in set method kirbyedy @kirbyedy Feb 22 2016 08:47 @reacorbett ? Richard Corbett @reacorbett Feb 22 2016 08:47 @kirbyedy kirbyedy @kirbyedy Feb 22 2016 08:47 ? Neeraj Jha @Jonsnow21 Feb 22 2016 08:48 in set gear method put x as function parameter and set gear = x; this should work @halaszj Richard Corbett @reacorbett Feb 22 2016 08:48 sorry wrong person Wangach @Wangach Feb 22 2016 08:48 @reacorbett yes! kirbyedy @kirbyedy Feb 22 2016 08:48 :laughing: Neeraj Jha @Jonsnow21 Feb 22 2016 08:48 @halaszj in setgear mathod u dont need to return anything Richard Corbett @reacorbett Feb 22 2016 08:49 @Wangach did you get it? line 4 had convert instead of celcius. Neeraj Jha @Jonsnow21 Feb 22 2016 08:49 i m stuck on falsy bouncer problem function bouncer(arr) { for( var i = 0; i < arr.length; i++){ if(!arr[i]){ arr.splice(i, 1); i = i - 1; break; } } return arr; } bouncer([7, "ate", "", false, 9]); halaszj @halaszj Feb 22 2016 08:50 var gear = 0; this.setGear = function() { }; this.getGear = function() { return gear; }; still not working :/ Blauelf @Blauelf Feb 22 2016 08:50 @Jonsnow21 Use filter, and look up the definition of falsy. help js falsy CamperBot @camperbot Feb 22 2016 08:50 ## :point_right: js falsy [wiki] Something which evaluates to FALSE. There are only five falsey values in JavaScript: undefined, null, NaN, 0, "" (empty string), and false of course. See also: truthy | Truthy & Falsey blog post :pencil: read more about js falsy on the FCC Wiki Wangach @Wangach Feb 22 2016 08:51 @reacorbett you have not defined the variable celcius....Still wrong Neeraj Jha @Jonsnow21 Feb 22 2016 08:51 @halaszj this.setGear = function(x) { gear = x; }; Blauelf @Blauelf Feb 22 2016 08:51 @halaszj setGear should set gear, so take an argument and set gear to that value. Richard Corbett @reacorbett Feb 22 2016 08:52 @Wangach function convert(celsius) { // Only change code below this line var fahrenheit = celsius * 9 / 5 + 32; // Only change code above this line if ( typeof fahrenheit !== 'undefined' ) { return fahrenheit; } else { return 'fahrenheit not defined'; } } // Change the inputs below to test your code convert(30); halaszj @halaszj Feb 22 2016 08:52 thanks @Blauelf CamperBot @camperbot Feb 22 2016 08:52 halaszj sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star: 1273 | @blauelf | http://www.freecodecamp.com/blauelf Neeraj Jha @Jonsnow21 Feb 22 2016 08:52 @Blauelf ok i will look at that but please have a look at my solution and point out anything wrong Blauelf @Blauelf Feb 22 2016 08:53 @Jonsnow21 Use js for the first triple backticks to get JS-style syntax highlighting. Wangach @Wangach Feb 22 2016 08:53 @reacorbett Thats exactly what i have. Just try running the code.. Richard Corbett @reacorbett Feb 22 2016 08:54 show me what you have @Wangach because that is right Neeraj Jha @Jonsnow21 Feb 22 2016 08:54 ok Blauelf @Blauelf Feb 22 2016 08:55 @Jonsnow21 I would argue that one should not change arr, maybe a copy of it (I really like pure functions, functions without side-effects), but your code fails on the "break;" statement, remove that and it works (but as I said, I do not like changing arr as this is the same object as the calling function uses) Neeraj Jha @Jonsnow21 Feb 22 2016 08:57 @Blauelf that notorious break statement I forgot to remove the code works now thnx Richard Corbett @reacorbett Feb 22 2016 08:57 reset your code and try it again. because it is right. @Wangach Blauelf @Blauelf Feb 22 2016 08:58 @Jonsnow21 Consider var myArr=["foo",null,1,false]; var bounced=bouncer(myArr); console.log(myArr); console.log(bounced); Wangach @Wangach Feb 22 2016 08:59 Link me to your code please @reacorbett Wangach @Wangach Feb 22 2016 09:00 @reacorbett Got it!!!!! I had a spelling mistake. I had written celcius instead of celsius!!! Lol!!! Stupid me!! Neeraj Jha @Jonsnow21 Feb 22 2016 09:00 @Blauelf can u explain i understand u r using recursion but how exactly will this code work Richard Corbett @reacorbett Feb 22 2016 09:01 sometimes you have to reset it or reload your browser. @Wangach @Wangach lol. that happends to me all the time. @Wangach Have fun and good luck with the rest. Wangach @Wangach Feb 22 2016 09:03 Huh! So i am not the only one!OK Thanks for your assistance. I appreciate!!! @reacorbett CamperBot @camperbot Feb 22 2016 09:03 wangach sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles: :warning: wangach already gave reacorbett points Richard Corbett @reacorbett Feb 22 2016 09:04 @Wangach Not a problem at all. Any time, and glad i could help. arjunpunnam @arjunpunnam Feb 22 2016 09:04 Hi,Im presently doing Mutations excercise in JS Neeraj Jha @Jonsnow21 Feb 22 2016 09:05 ok so? arjunpunnam @arjunpunnam Feb 22 2016 09:05 I am not sure how is that challange completed with the use of String.indexOf() Neeraj Jha @Jonsnow21 Feb 22 2016 09:05 yea i just used charAt() arjunpunnam @arjunpunnam Feb 22 2016 09:05 because it matches a part of the string yeah that works better so you havent used String.indexOf() at all ? @Jonsnow21 Neeraj Jha @Jonsnow21 Feb 22 2016 09:07 ya i try to solve it using string.indexOf() the code was getting unnecessarily bigger and messier Blauelf @Blauelf Feb 22 2016 09:08 @Jonsnow21 That snippet I wrote was meant to be executed in an environment where the bouncer function already exists. What would you expect to be the output? I would not expect the passed array to be changed, that's why I don't like the idea of using splice on it (maybe on a copy, but why bother at all?) Neeraj Jha @Jonsnow21 Feb 22 2016 09:08 so i used charAt() and got over with it @Blauelf k smarty pants not able to understand the documentation of either filter() or boolean object can anyone here shed some light on both the topics? it will be a great help Blauelf @Blauelf Feb 22 2016 09:14 @Jonsnow21 filter() is called on an array and called with a callback function. It will then call the callback function for each element of the array and return a new array that consists only of those elements the callback returned a truthy value for. While you probably used only one argument (the value of the current element), the callback is actually called using three arguments: The current element, its index, and the array itself. But you don't have to give them names or use them all. Boolean is probably almost never to be used as a constructor (using new keyword), but can also be used as a converting tool to boolean. Boolean(x) will be false for falsy values of x, true for truthy values. Neeraj Jha @Jonsnow21 Feb 22 2016 09:15 can u share a solution of falsy bouncer using these too ? J Player @Heyjp Feb 22 2016 09:15 @Jonsnow21 What helped me a lot when trying to get to grips with things like filter, is looking at what parameters it takes and then using console.log inside the function to see what it is outputting. so arr.filter(function (a, b) {console.log(a, b)}); ooops Neeraj Jha @Jonsnow21 Feb 22 2016 09:16 *two Blauelf @Blauelf Feb 22 2016 09:16 @Jonsnow21 One could do return arr.filter(Boolean);, as Boolean when used as a function returns true for truthy and false for falsy values. There is probably not much difference to defining an own function returning just the value itself. Neeraj Jha @Jonsnow21 Feb 22 2016 09:17 ok cool let me try it on falsy bouncer Blauelf @Blauelf Feb 22 2016 09:18 @Heyjp Yeah, console.log is probably most valuable tool for debugging :D Neeraj Jha @Jonsnow21 Feb 22 2016 09:18 @Blauelf it worked awesome anyone on ? Neeraj Jha @Jonsnow21 Feb 22 2016 09:23 i stuck on seek and destroy m Blauelf @Blauelf Feb 22 2016 09:24 What's your code? Are you already using the arguments object? Richard Corbett @reacorbett Feb 22 2016 09:26 Accessing Nested Arrays in JSON What am I doing wrong here? // Setup var myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ]; // Only change code below this line var secondTree = "myPlants.type.trees[1]"; // Change this line Blauelf @Blauelf Feb 22 2016 09:27 @reacorbett "myPlants.type.trees[1]" is a string and has nothing to do with myPlants. And myPlants is an array (the [] mark an array literal here), so you might want to access its element using [] syntax. Neeraj Jha @Jonsnow21 Feb 22 2016 09:27 maybe this is stupid to u but this is the best i could come up with function destroyer(arr) { for(var i = 0; i < arguments.length; i++){ arr.filter(arguments[i]); } } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Blauelf @Blauelf Feb 22 2016 09:28 @Jonsnow21 filter takes a function. Also, filter returns a filtered array, does not change the original array. Neeraj Jha @Jonsnow21 Feb 22 2016 09:28 ohh k cannelflow @cannelflow Feb 22 2016 09:29 var myPlants = [<====myPlant is an array here type: "flowers", list: [ "rose", "tulip",<====if you want to accedd tulip then it is like myPlants[].list[] "dandelion" ] }, { type: "trees", list: [ "fir", "pine",<====== you need to access this "birch" ] } ]; @reacorbett Neeraj Jha @Jonsnow21 Feb 22 2016 09:29 but how should I work with variable no of arguments? @Blauelf u there ? Richard Corbett @reacorbett Feb 22 2016 09:33 @cannelflow var secondTree = myPlants[1].list[1]; Thanks that helped a lot. Nice. CamperBot @camperbot Feb 22 2016 09:33 reacorbett sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles: :star: 818 | @cannelflow | http://www.freecodecamp.com/cannelflow Anindya Maiti @amaiti504 Feb 22 2016 09:33 @Jonsnow21 there is an arguments param intrinsic to every func. Use that. It's an array like object corresponding to args passed to a func Neeraj Jha @Jonsnow21 Feb 22 2016 09:35 @amaiti504 what are you writing I didn't got it? get any links will be helpful Anindya Maiti @amaiti504 Feb 22 2016 09:36 Search JavaScript arguments in Google. Go to the 1st link in developer.Mozilla Neeraj Jha @Jonsnow21 Feb 22 2016 09:37 Anindya Maiti @amaiti504 Feb 22 2016 09:38 There is a built in object 'arguments' which contains func arguments like an array Yes Neeraj Jha @Jonsnow21 Feb 22 2016 09:51 it is giving this error when I use console.log(arguments[1]); ReferenceError: arguments is not defined what should I do? Anindya Maiti @amaiti504 Feb 22 2016 09:52 @Jonsnow21 plz post the entire code. Difficult to say without the context Aleksander Gębicki @Takumar Feb 22 2016 09:52 @Jonsnow21 do you write this statement inside your function? Neeraj Jha @Jonsnow21 Feb 22 2016 09:53 no console ok i see whats happening Aleksander Gębicki @Takumar Feb 22 2016 09:53 @Jonsnow21 arguments exists inside function :-) Anindya Maiti @amaiti504 Feb 22 2016 09:54 @Takumar correct Neeraj Jha @Jonsnow21 Feb 22 2016 09:56 ya just noticed my, stupidity Alessandro Giordo @bovas85 Feb 22 2016 09:56 can anyone help me with a function iterating through an array? You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array. Example: longest_consec(["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"], 2) --> "abigailtheta" n being the length of the string array, if n = 0 or k > n or k <= 0 return "". Can anyone help me with the logic of this? Richard Corbett @reacorbett Feb 22 2016 09:58 what am i doing wrong here? i am getting Maximum vall stack size exceede error. // Setup var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function update(id, prop, value) { if (value !== "" && prop !== "tracks"){ update(value); } if (prop == "tracks" && value !== ""){ tracks.push(value); } if (value === ""){ prop = undefined; } return collection; } // Alter values below to test your code update(5439, "artist", "ABBA"); Aleksander Gębicki @Takumar Feb 22 2016 10:01 @reacorbett you have created recursion here: update(value); instead you should just update or set value of chosen object Richard Corbett @reacorbett Feb 22 2016 10:02 @Takumar oh, I see it. Thanks. CamperBot @camperbot Feb 22 2016 10:02 reacorbett sends brownie points to @takumar :sparkles: :thumbsup: :sparkles: :star: 2358 | @takumar | http://www.freecodecamp.com/takumar Alessandro Giordo @bovas85 Feb 22 2016 10:03 @reacorbett also you are not adding to that specific key or property. It should target that id.prop and add that value Aleksander Gębicki @Takumar Feb 22 2016 10:03 @reacorbett also my advice would be to use if/else if/ else construction instead of three ifs. In this line: prop = undefined; you should use delete as I remember good. Neeraj Jha @Jonsnow21 Feb 22 2016 10:04 function destroyer(arr) { var l = arguments.length; var myArr = arguments[0]; for( var i = 0; i < myArr.length; i++ ){ for( var j = 1; j < arguments.length; j++ ){ if( myArr[i] === arguments[j] ){ myArr.splice( i, 1 ); i -= 1; break; } } } return myArr; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); any other ways to solve this question seek and destroy maybe using array.filter(); Aleksander Gębicki @Takumar Feb 22 2016 10:05 @Jonsnow21 var myArr = arguments[0]; is not needed because it is the same as arr array. Neeraj Jha @Jonsnow21 Feb 22 2016 10:05 ok cool Richard Corbett @reacorbett Feb 22 2016 10:05 @Takumar @bovas85 thanks guys. I think i am going to save this one for later. It is 4am here and the lines are starting to blur together. CamperBot @camperbot Feb 22 2016 10:05 reacorbett sends brownie points to @takumar and @bovas85 :sparkles: :thumbsup: :sparkles: :warning: reacorbett already gave takumar points :star: 285 | @bovas85 | http://www.freecodecamp.com/bovas85 Alessandro Giordo @bovas85 Feb 22 2016 10:05 @reacorbett never code when tired. You are going to do much better if you sleep over it Aleksander Gębicki @Takumar Feb 22 2016 10:05 @Jonsnow21 and yes, work on this problem using filter() Neeraj Jha @Jonsnow21 Feb 22 2016 10:06 @reacorbett that's passion but how filter needs an function as an argument Richard Corbett @reacorbett Feb 22 2016 10:06 @bovas85 good advice @Jonsnow21 lol. Neeraj Jha @Jonsnow21 Feb 22 2016 10:07 i usually wake till 3:00am if next day is off or not :P Richard Corbett @reacorbett Feb 22 2016 10:08 Good night all. Happy Coding. Alessandro Giordo @bovas85 Feb 22 2016 10:12 @Jonsnow21 try using Array.prototype.slice.call(arguments) Neeraj Jha @Jonsnow21 Feb 22 2016 10:13 ugh so many mathods Neeraj Jha @Jonsnow21 Feb 22 2016 10:18 @bovas85 can figure it out Alessandro Giordo @bovas85 Feb 22 2016 10:19 ? Neeraj Jha @Jonsnow21 Feb 22 2016 10:19 how to use array.slice.call(arguments) in this question Alessandro Giordo @bovas85 Feb 22 2016 10:20 oh ok, have you googled what it does? Robert Uivarosi @URobert Feb 22 2016 10:20 @Jonsnow21 which question? Neeraj Jha @Jonsnow21 Feb 22 2016 10:21 seek and destroy yea i checked mdn and w3schools Alessandro Giordo @bovas85 Feb 22 2016 10:21 So let's say you do this var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments); Robert Uivarosi @URobert Feb 22 2016 10:21 @Jonsnow21 link me, show me what you got Alessandro Giordo @bovas85 Feb 22 2016 10:22 that basically means, you take the "arguments" of arr and create a new array of those arguments. A result of the first test is [Array(6), 2, 3] Bryce Turner @AbryceT Feb 22 2016 10:22 a bit of help with the Profile lookup... I am not getting something... function lookUp(firstName, prop){ // Only change code below this line for (var i = 0; i <contacts.length; i++) { if (i === contacts["firstName"][prop]) { return contacts[firstName][prop]; } else if (contacts[i][prop] != contacts[prop]) { return "No such property"; } return "No such contact."; } Neeraj Jha @Jonsnow21 Feb 22 2016 10:23  function destroyer(arr) { var l = arguments.length; var myArr = arguments[0]; for( var i = 0; i < myArr.length; i++ ){ for( var j = 1; j < arguments.length; j++ ){ if( myArr[i] === arguments[j] ){ myArr.splice( i, 1 ); i -= 1; break; } } } return myArr; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Alessandro Giordo @bovas85 Feb 22 2016 10:23 Try thinking of a way to get only the last 2 arguments of that args Neeraj Jha @Jonsnow21 Feb 22 2016 10:23 function destroyer(arr) { var l = arguments.length; var myArr = arguments[0]; for( var i = 0; i < myArr.length; i++ ){ for( var j = 1; j < arguments.length; j++ ){ if( myArr[i] === arguments[j] ){ myArr.splice( i, 1 ); i -= 1; break; } } } return myArr; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Alessandro Giordo @bovas85 Feb 22 2016 10:23 and then use it to filter the arr Neeraj Jha @Jonsnow21 Feb 22 2016 10:24 ya it would be var args = Array.prototype.slice.call(arguments, 1); srinivas @srinivasdasu Feb 22 2016 10:24 help on exact change CamperBot @camperbot Feb 22 2016 10:24 no wiki entry for: on exact change Robert Uivarosi @URobert Feb 22 2016 10:25 @Jonsnow21 your code is working? What's the matter ? Alessandro Giordo @bovas85 Feb 22 2016 10:25 no you have to leave that as it is var args = Array.prototype.slice.call(arguments); then you have to do something to args fluffystub @RakshithNM Feb 22 2016 10:26 How can i animate one button when i click on another Alessandro Giordo @bovas85 Feb 22 2016 10:26 @RakshithNM use jQuery UI, google it it's quite neat Neeraj Jha @Jonsnow21 Feb 22 2016 10:26 @URobert i want to solve it in another way using array.filter(); Bryce Turner @AbryceT Feb 22 2016 10:29 help profile lookup CamperBot @camperbot Feb 22 2016 10:29 ## :point_right: checkpoint profile lookup [wiki] # Checkpoint: Profile Lookup Instructions We have an array of objects representing different people in our contacts lists. A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you. The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact. If both are true, then return the "value" of that property. If firstName does not correspond to any contacts then return "No such contact" If prop does not correspond to any valid properties then return "No such property" Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code. Alessandro Giordo @bovas85 Feb 22 2016 10:30 @AbryceT what's the issue there? if you want share your code using code share https://codeshare.io/ as it's easier to help you there as you can see me modifying the code Robert Uivarosi @URobert Feb 22 2016 10:31 @Jonsnow21 did you write the code yourself for the solution you pasted? Neeraj Jha @Jonsnow21 Feb 22 2016 10:31 yea bro i am a good coder C++ is my bitch Robert Uivarosi @URobert Feb 22 2016 10:32 @Jonsnow21 ;) Bryce Turner @AbryceT Feb 22 2016 10:33 @bovas85 I would prefer to try on my own with hints Alessandro Giordo @bovas85 Feb 22 2016 10:33 yeah it's just to give you hints not gonna change your code Aleksander Gębicki @Takumar Feb 22 2016 10:33 @AbryceT i is number variable, use it to select one of objects from contacts, i.e. contacts[i] don't compare it with properties of object i === contacts["firstName"][prop] Robert Uivarosi @URobert Feb 22 2016 10:34 @Jonsnow21 function destroyer(arr) { var args = Array.prototype.slice.call(arguments); args.splice(0,1); return arr.filter(function(element) { return args.indexOf(element) === -1; }); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); @Jonsnow21 from: http://wulkan.me/bonfire-seek-and-destroy/ - I think this is one of the most minimalistic way of doing it by using array.filter() method Aleksander Gębicki @Takumar Feb 22 2016 10:35 @AbryceT contacts["firstName"][prop] this line is also not correct, you could try something like that if contacts is object and firstName is object and prop is variable containing name of property of object firstName ! Bryce Turner @AbryceT Feb 22 2016 10:36 @Takumar ok ... let me try changing some things Neeraj Jha @Jonsnow21 Feb 22 2016 10:37 can u explain the filter part ? @URobert kirbyedy @kirbyedy Feb 22 2016 10:43 did anyone had similar problem ? Refused to display 'http://s.codepen.io/boomerang/0c68daeb7a4c59557499e242b73bf5331456137712560/%3Ehttps://en.wikipedia.org/wiki/Horsens' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. Robert Uivarosi @URobert Feb 22 2016 10:44 @Jonsnow21 I changed it up so it gets a bit more explicit: function destroyer(arr) { var args = Array.prototype.slice.call(arguments); args.splice(0,1); var result = arr.filter(function(element) { return args.indexOf(element) === -1; }); return result; } var z = destroyer([1, 2, 3, 1, 2, 3], 2, 3); console.log(z); Bryce Turner @AbryceT Feb 22 2016 10:45 @Takumar So here is what I have and I have all green GO except for my "no contact" isn't working for (var i = 0; i < contacts.length; i++) { if (contacts[i].firstName === firstName) { if (contacts[i][prop]) { return contacts[i][prop]; }else { return "No such property"; } return "No such contact."; } } fluffystub @RakshithNM Feb 22 2016 10:46 guys now when i click on my next button the loading button rotates i would like it to stop when the next quote comes in how do i do it? Robert Uivarosi @URobert Feb 22 2016 10:48 @Jonsnow21 result is getting the value of the result of arr.filter method. Arr filter here looks if element (a value from from arr's first argument is present in args. if that check comes out negative, the element is push to result. Makes sense ? fluffystub @RakshithNM Feb 22 2016 10:48 @bovas85 i checked google i have done it in a way....can you tell me if i am right? Alessandro Giordo @bovas85 Feb 22 2016 10:49 @RakshithNM try with toggle instead for the spinner otherwise set a timeout and remove the class fa-spin Neeraj Jha @Jonsnow21 Feb 22 2016 10:51 @URobert that is some decent piece of code Aleksander Gębicki @Takumar Feb 22 2016 10:52 @AbryceT put return "No such contact."; after your loop, because you have to check every contact in your array. Also message is: "No such contact" I believe. Bryce Turner @AbryceT Feb 22 2016 10:53 @Takumar Thank you! Got it CamperBot @camperbot Feb 22 2016 10:53 abrycet sends brownie points to @takumar :sparkles: :thumbsup: :sparkles: :star: 2362 | @takumar | http://www.freecodecamp.com/takumar Robert Uivarosi @URobert Feb 22 2016 10:53 @Jonsnow21 yup, but original not mine, as I mentioned the link. I just mod it to make it easier to understand Aleksander Gębicki @Takumar Feb 22 2016 10:54 @AbryceT you are welcome :-) fluffystub @RakshithNM Feb 22 2016 10:54 @bovas85 i tried the .toggleClass now the button starts and stops with alternative clicks Robert Uivarosi @URobert Feb 22 2016 10:55 @RakshithNM can i see your code ? fluffystub @RakshithNM Feb 22 2016 10:56 @URobert Robert Uivarosi @URobert Feb 22 2016 10:57 @RakshithNM what's the effect you are looking for ? fluffystub @RakshithNM Feb 22 2016 11:00 when i click button if it takes time to load the next quote i need the spinning button to be animated and it should stop once the quote is loaded @URobert Robert Uivarosi @URobert Feb 22 2016 11:03 @RakshithNM use a function and setTimeout @RakshithNM the length of it should be as long as it takes for your new quote to load @RakshithNM but Im not 100% to what you are looking for, because you get the quotes from a local array, not an API call... so there is no loading time. Quotes change instantly. I like the idea you are looking for, but it can't really fit here IM. IMo* Alessandro Giordo @bovas85 Feb 22 2016 11:08 true, you should use an API like in the example if you want to use the loader. Otherwise you could possibly set a timeout for 1 second and load the quote after that so that it has time to spin otherwise you can use mousedown/mouseup to create a spin only when holding the mouse on the > icon fluffystub @RakshithNM Feb 22 2016 11:10 @URobert @bovas85 k...so i am not thinking appropriately...but all the clicks are not fetching the quotes i felt that is happening because of some delay !!! can you run and check please? @bovas85 @URobert Robert Uivarosi @URobert Feb 22 2016 11:15 @RakshithNM they do switch instantly for me, unless I'm trying to spam the button fluffystub @RakshithNM Feb 22 2016 11:18 is there any delay that is inherent with buttons? Alessandro Giordo @bovas85 Feb 22 2016 11:22 @RakshithNM you think they are not fetching because it fetches the same quote as you have not many in your array Alex Tsiras @arialblack14 Feb 22 2016 11:25 Hello all I don't know if my question is unrelated to this chat... I keep seeing "i use babel for that, gulp/grunt for that, browserify for this". Is there any resource i could read (that is readable to a noob like myself) on what each one does and how i could use it to improve my workflow...? fluffystub @RakshithNM Feb 22 2016 11:31 @bovas85 k i get it....is there any way to make the random number generator more efficient? Emil Aasa @emilaasa Feb 22 2016 11:32 @arialblack14 a lot of those tools are aimed at making production work easier Alex Tsiras @arialblack14 Feb 22 2016 11:34 @emilaasa yes, i 've seen their sites, but how does one use them and how do they help me? Emil Aasa @emilaasa Feb 22 2016 11:34 Well if we go thru your list Alex Tsiras @arialblack14 Feb 22 2016 11:34 @emilaasa is there a "gulp/babel for dummies" :) Emil Aasa @emilaasa Feb 22 2016 11:35 Babel makes it so you can write ES6 and compile it backwards so it will still work everywhere grunt/gulp are build tools srinivas @srinivasdasu Feb 22 2016 11:36 anyone done woth exact change Emil Aasa @emilaasa Feb 22 2016 11:36 They are pretty much just small programs that run tasks off a list And yes there are intro courses and tutorials etc Alex Tsiras @arialblack14 Feb 22 2016 11:37 I ve seen babel and sort of get whst it does, what about gulp/grunt. What do they do? You mean youtube? Emil Aasa @emilaasa Feb 22 2016 11:37 Yeah that would do it chaya @chayakrishnaprasad Feb 22 2016 11:37 This message was deleted find pairwise CamperBot @camperbot Feb 22 2016 11:38 find pairwise :zero: algorithm pairwise Alex Tsiras @arialblack14 Feb 22 2016 11:38 Will check it out @emilaasa thanks CamperBot @camperbot Feb 22 2016 11:38 arialblack14 sends brownie points to @emilaasa :sparkles: :thumbsup: :sparkles: :star: 290 | @emilaasa | http://www.freecodecamp.com/emilaasa Emil Aasa @emilaasa Feb 22 2016 11:38 A build tool just runs a bunch of menial tasks that you need it to do like minify your code, maybe run a code quality checker, whatever you need it to do Sort of like a shell script or bat file It gets more useful the more complex your work is pretty much Alex Tsiras @arialblack14 Feb 22 2016 11:40 Ahh, that makes sense Alessandro Giordo @bovas85 Feb 22 2016 11:41 @RakshithNM you can find a bigger list of quotes and add it there or use a quotes API Alex Tsiras @arialblack14 Feb 22 2016 11:41 :+1: @emilaasa Omg gitter for android... Sorry Lol fluffystub @RakshithNM Feb 22 2016 11:46 @bovas85 @URobert thanks for your help CamperBot @camperbot Feb 22 2016 11:46 rakshithnm sends brownie points to @bovas85 and @urobert :sparkles: :thumbsup: :sparkles: :star: 613 | @urobert | http://www.freecodecamp.com/urobert :star: 286 | @bovas85 | http://www.freecodecamp.com/bovas85 Dinara Demi @Gezehus Feb 22 2016 11:47 Hello everyone! I can't find the resource list (of books, blogs, podcasts) for learning JS. I only remember that there was a book "Eloquent JS" and "Good Parts of JS". Who knows where I can find this list? Earlier the list was on FCC's website. Emil Aasa @emilaasa Feb 22 2016 11:47 Alex Tsiras @arialblack14 Feb 22 2016 11:50 @emilaasa someone pointed me to a udavity course on web tooling and automation which teaches exactly what i asked. Again thank you :) CamperBot @camperbot Feb 22 2016 11:50 arialblack14 sends brownie points to @emilaasa :sparkles: :thumbsup: :sparkles: :warning: arialblack14 already gave emilaasa points Alex Tsiras @arialblack14 Feb 22 2016 11:51 Your links seem great! Aleksander Gębicki @Takumar Feb 22 2016 11:51 Dinara Demi @Gezehus Feb 22 2016 11:52 @Takumar Thank you very much! CamperBot @camperbot Feb 22 2016 11:52 gezehus sends brownie points to @takumar :sparkles: :thumbsup: :sparkles: :star: 2365 | @takumar | http://www.freecodecamp.com/takumar Alessandro Giordo @bovas85 Feb 22 2016 11:52 @Takumar thank you Aleksander Gębicki @Takumar Feb 22 2016 11:53 @Gezehus I am glad that I could help. @emilaasa gave you much more resources, you may want to check this, but you searched for FCC links I think. Alessandro Giordo @bovas85 Feb 22 2016 11:53 where should I learn how to consume APIs with JS? Emil Aasa @emilaasa Feb 22 2016 11:53 Pick an API and read their docs they will tell you Something very basic might look like this: function searchTwitter(query) {$.ajax({
dataType: 'jsonp',
success: function(data) {
var tweets = $('#tweets'); tweets.html(''); for (res in data['results']) { tweets.append('<div>' + data['results'][res]['from_user'] + ' wrote: <p>' + data['results'][res]['text'] + '</p></div><br />'); } } }); } a little bit ugly but the central part is pretty much the$.ajax() function
and then the RESTFul api you are talking to will give you information in their API docs about what to query
Emil Aasa
@emilaasa
Feb 22 2016 12:01
For some oldschool vanilla JS http requests =)
sigursiguros
@sigursiguros
Feb 22 2016 12:02
Hi campers, I need help with regex.
Emil Aasa
@emilaasa
Feb 22 2016 12:02
Shoot!
sigursiguros
@sigursiguros
Feb 22 2016 12:03
function telephoneCheck(str) {
// Good luck!
var re =/^1?[\s-]?$$?(\d{3})$$?[\s-]?\d{3}[\s-]?\d{4}$/; return re.test(str); } telephoneCheck("555-555-5555"); my code is not working for an input like telephoneCheck("555)-555-5555") should return false. telephoneCheck("(555-555-5555") should return false. telephoneCheck("1 555)555-5555") should return false. is there a if that I can use? like if there's no open bracket, there shouldn't be a close bracket Emil Aasa @emilaasa Feb 22 2016 12:05 Hmm I can’t think of a regex way to do it right away I stripped all non digit input first Blauelf @Blauelf Feb 22 2016 12:05 You can use the | inside groups to get that. Something like ($$\d{3}$$|d{3}) (with the right things around, matches "(555)", "555", but not "(555" or "555)") Emil Aasa @emilaasa Feb 22 2016 12:06 regex is cool -- anthonygallina1 @anthonygallina1 Feb 22 2016 12:09 hi Blauelf @Blauelf Feb 22 2016 12:09 lo Nick Svanidze @nikasvan Feb 22 2016 12:09 hi @anthonygallina1 :) anthonygallina1 @anthonygallina1 Feb 22 2016 12:09 ;) has any one done Symmetric Difference? Blauelf @Blauelf Feb 22 2016 12:12 Many have. You have a real question? Nick Svanidze @nikasvan Feb 22 2016 12:13 guys need help with Title Case a Sentence please ) function titleCase(str) { var separator = ' '; var wordArray = str.split(separator); var newArray = []; var firstLetter= ''; var replacedWord = ''; for (var i=0, j=0;i<wordArray.length; i++){ y=wordArray[i][j].toUpperCase(); replacedWord = wordArray[i].replace(/^[a-z]/,y); newArray.push(replacedWord); } return newArray.join(' '); } titleCase("i'm a little tea pot"); This works with first words(converts first words in uppercase), but I am stuck at making rest of the words(if they are upper case) lower case. any ideas on how can I approach this? Blauelf @Blauelf Feb 22 2016 12:13 @nikasvan One way would be to form wordArray from str.toLowerCase(), not str itself. That way, you need to call toLowerCase() only once. anthonygallina1 @anthonygallina1 Feb 22 2016 12:15 @Blauelf yes well the way I am reading it is "he mathematical term "symmetric difference" of two sets is the set of elements which are in either of the two sets, but not in both" ([1, 2, 5], [2, 3, 5], [3, 4, 5] It is expecting to get back 5 but it is in both Not under standing that. actualy 1 4 and 5 1 and 4 I can understand Blauelf @Blauelf Feb 22 2016 12:17 @anthonygallina1 This is actually like XORing all the arrays, you calculate the difference for two arrays, then the difference of the result and the third array, then the result of that diffed with the fourth array and so on. So first step creates [1, 3], second step [1, 4, 5]. anthonygallina1 @anthonygallina1 Feb 22 2016 12:18 @Blauelf yes but is it not considering it to be both on the 5 because it is actualy in 3? @Blauelf my code gets me 1 and 4 Blauelf @Blauelf Feb 22 2016 12:20 As I said, it's doing two at a time, like XORing multiple values. Any number that's in an odd number of arrays will appear in the result (similar to the bits in XORed numbers). anthonygallina1 @anthonygallina1 Feb 22 2016 12:20 oh thank you @Blauelf CamperBot @camperbot Feb 22 2016 12:20 anthonygallina1 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star: 1274 | @blauelf | http://www.freecodecamp.com/blauelf sigursiguros @sigursiguros Feb 22 2016 12:22 Thanks @emilaasa @Blauelf CamperBot @camperbot Feb 22 2016 12:22 sigursiguros sends brownie points to @emilaasa and @blauelf :sparkles: :thumbsup: :sparkles: :star: 291 | @emilaasa | http://www.freecodecamp.com/emilaasa :star: 1275 | @blauelf | http://www.freecodecamp.com/blauelf Robert Uivarosi @URobert Feb 22 2016 12:37 @RakshithNM yw Antonin Archer @nicknem Feb 22 2016 12:41 I can't figure out why I'm wrong here Blauelf @Blauelf Feb 22 2016 12:43 @Takumar answered this on the other channel. Timofey Votyakov @tvotyakov Feb 22 2016 12:47 @nicknem because you need to set a gear value, not increment it Antonin Archer @nicknem Feb 22 2016 12:47 Ok I was on the wrong channel Yes, stupid mistake :) thanks guys William @apswak Feb 22 2016 12:54 Hi guys for "Roman Numerals" would anyone know how I can break up a number? for example for 3928. Break it up into 3000, 900, 20 and 8? Or am I thinking too far and it's more simple than that? Blauelf @Blauelf Feb 22 2016 13:11 One way would be to have a list of literals (like "M", "CM", "D", "CD", "C", ...) that you compare to your number (descending of course), and whenever the number is at least the value of that roman literal, concatenate that to your string, and subtract its value from the number. If you go 10-9-5-4-1, you'll have to allow multiple matches of the same rule in a row (for 3->three times 1, or 7->once 5, twice 1) sigursiguros @sigursiguros Feb 22 2016 13:14 @Rafase282 @guyjoseph @jjmax75 for your help with Algorithm: Symmetric Difference Thanks Thank you @Rafase282 @guyjoseph @jjmax75 for your help with Algorithm: Symmetric Difference CamperBot @camperbot Feb 22 2016 13:14 sigursiguros sends brownie points to @rafase282 and @guyjoseph and @jjmax75 :sparkles: :thumbsup: :sparkles: :star: 307 | @jjmax75 | http://www.freecodecamp.com/jjmax75 :star: 336 | @guyjoseph | http://www.freecodecamp.com/guyjoseph :star: 994 | @rafase282 | http://www.freecodecamp.com/rafase282 anthonygallina1 @anthonygallina1 Feb 22 2016 13:15 @Rafase282 @guyjoseph @jjmax75 for your help with Algorithm: Symmetric Difference thank you CamperBot @camperbot Feb 22 2016 13:15 anthonygallina1 sends brownie points to @rafase282 and @guyjoseph and @jjmax75 :sparkles: :thumbsup: :sparkles: :star: 337 | @guyjoseph | http://www.freecodecamp.com/guyjoseph :star: 308 | @jjmax75 | http://www.freecodecamp.com/jjmax75 :star: 995 | @rafase282 | http://www.freecodecamp.com/rafase282 Rafael J. Rodriguez @Rafase282 Feb 22 2016 13:16 you are all welcome Abhisek Pattnaik @abhisekp Feb 22 2016 13:24 huh? chaya @chayakrishnaprasad Feb 22 2016 13:35 find friendly date ranges CamperBot @camperbot Feb 22 2016 13:36 find friendly date ranges Pallavi Hegde @pallavihegde1 Feb 22 2016 14:00 hello can i echo out a function function reverseString(str) { return str; } reverseString("hello"); how do return it in a html page? sorry for the silly doubt :worried: Alessandro Giordo @bovas85 Feb 22 2016 14:07 hi @pallavihegde1 what do you mean? is your function reversing stuff? It's just returning the argument of the function so far. To print something you have different choices. You can open an alert(str) or document.write it or console.log it among other things Pallavi Hegde @pallavihegde1 Feb 22 2016 14:12 okay.. ill have to call the function within the doc.writeln right? Ken Haduch @khaduch Feb 22 2016 14:14 @kreitzo - I found that that the page that they linked in the exercise, with the description of the Roman Numeral conversion, helped me tremendously when I was thinking about this. You break it down by 1000's, 100's, 10's and generate the parts from there. Andrew Sweet @mrsweety Feb 22 2016 14:15 hello can anyone point me in the direction of a completed code solution for Nested For loops please Ken Haduch @khaduch Feb 22 2016 14:16 @pallavihegde1 - if you're doing that exercise that I think you're doing, you don't have to try and figure out how to write to the HTML (web) page. If you need to see results as you are working through the problem, insert console.log statements and open the browser javascript console. @mrsweety - what point are you at with this problem? Do you have specific questions? Pallavi Hegde @pallavihegde1 Feb 22 2016 14:17 na , exercise i got the output, just wanted to know how to print in a html page Andrew Sweet @mrsweety Feb 22 2016 14:17 hello , i'd like to look over the completed code cheers Ken Haduch @khaduch Feb 22 2016 14:19 help nesting for loops CamperBot @camperbot Feb 22 2016 14:19 ## :point_right: challenge nesting for loops [wiki] # Challenge: Nesting For Loops If you have a multi-dimensional array, you can use the same logic as the prior Challenge to loop through both the array and any sub-arrays. Here is an example: var arr = [ [1,2], [3,4], [5,6] ]; for (var i=0; i < arr.length; i++) { for (var j=0; j < arr[i].length; j++) { console.log(arr[i][j]); } } This outputs each sub-element in arr one at a time. Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array. :pencil: read more about challenge nesting for loops on the FCC Wiki Andrew Sweet @mrsweety Feb 22 2016 14:20 thanks , i see that , i was looking for a completed working answer to the challenge Ken Haduch @khaduch Feb 22 2016 14:21 I cannot see the original setup for that page, it only shows my solution. If you want to look at my solution, here is a link: which I think will be a long URL, I've never pasted this before. Andrew Sweet @mrsweety Feb 22 2016 14:22 On another note , i might have found a bug - FreeCodeCamp/FreeCodeCamp#7191 Cheers for that :) sigursiguros @sigursiguros Feb 22 2016 14:23 can someone please explain this code to me? var register = cid.reduce(function(acc, curr) { acc.total += curr[1]; acc[curr[0]] = curr[1]; return acc; }, {total: 0}); Andrew Sweet @mrsweety Feb 22 2016 14:24 great stuff , i see i was missing the = , i'd used ... Thanks @khaduch CamperBot @camperbot Feb 22 2016 14:25 mrsweety sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star: 564 | @khaduch | http://www.freecodecamp.com/khaduch Ken Haduch @khaduch Feb 22 2016 14:26 @mrsweety - good! Don't hesitate to post your code here and ask what is wrong. Sometimes a simple thing that you missed causes all kinds of problems. If people guide you toward a solution, most seem to do that quite readily, it helps in the learning process. This is a good environment for that! And you're welcome - it's always good to be helpful! Manan Kalra @manankalra Feb 22 2016 14:27 function where(arr, num) { var pos, temp = arr.sort(); for(var i=0;i<arr.length;i++){ if(num>temp[i]){ pos = i+1; } else if(num == temp[i]){ pos = i; } } return pos; } where([5,3,20,3], 5); Why my else if is not working correctly? http://www.freecodecamp.com/challenges/where-do-i-belong Blauelf @Blauelf Feb 22 2016 14:28 @sigursiguros Creates an object with a property total, initialized with 0, and properties depending on the first elements of the arrays contained in cid, with values of the second elements. Total is the sum of those values. So the result is something like {DIME:1.10, QUARTER:0.75, total: 1.85} (plus properties for all the other coin/bill types) Ken Haduch @khaduch Feb 22 2016 14:28 @mrsweety - I think that your solution for Accessing Nested Objects in JSON is correct? Sometimes I see people say that they have to reload the exercise (or maybe clear the browser temporary storage) and then it works? sigursiguros @sigursiguros Feb 22 2016 14:31 @Blauelf can I confirm the new object is returning total because the reduce function is using it as an initial value? Ken Haduch @khaduch Feb 22 2016 14:31 @mananKalra - you might just be missing the 'sort' comparison function? you have to make sure to sort the array numerically. Manan Kalra @manankalra Feb 22 2016 14:32 @khaduch I did sort it and saved the sorted array in temp[]. The thing is, if I set pos in the else if to be equal to i-1, the test cases are accepted. Blauelf @Blauelf Feb 22 2016 14:34 @sigursiguros The initial object is changed and passed on, so it will still have the total property. sigursiguros @sigursiguros Feb 22 2016 14:34 Got it thank you @Blauelf CamperBot @camperbot Feb 22 2016 14:34 sigursiguros sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: Ken Haduch @khaduch Feb 22 2016 14:34 @mananKalra - check the information here about the comparison function for the Array.sort method: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort CamperBot @camperbot Feb 22 2016 14:34 :star: 1277 | @blauelf | http://www.freecodecamp.com/blauelf Manan Kalra @manankalra Feb 22 2016 14:34 But why? As per the arguments that I've given, 5 must be assigned pos to be equal to 2, but it's output is coming out to be 3. @khaduch @khaduch Yeah, I'll do @khaduch As per the question requirements, I only need to sort the array in ascending order which I already did. Ken Haduch @khaduch Feb 22 2016 14:36 @mananKalra - if you look at the result of the sort as you have it currently written: var arr = [5,3,20,3] undefined arr.sort() [20, 3, 3, 5] You'll see that it is sorted alphabetically, not numerically. (Alphabetically according to the character code values). That page I linked to has a bit about sorting numbers. Manan Kalra @manankalra Feb 22 2016 14:37 Oh, thanks. I'll check. :) @khaduch CamperBot @camperbot Feb 22 2016 14:37 manankalra sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star: 565 | @khaduch | http://www.freecodecamp.com/khaduch Ken Haduch @khaduch Feb 22 2016 14:39 @mananKalra - you're welcome. I'll admit that I had to look at the Array.sort page to refresh my memory about the proper way to specify that... The key is knowing where to look! The item to look for on the page, in specific, has the text "The sort method can be conveniently used with function expressions (and closures)" Andrew Sweet @mrsweety Feb 22 2016 14:40 @khaduch thanks , i'll give that a try and add what i find to the bug post CamperBot @camperbot Feb 22 2016 14:40 :warning: mrsweety already gave khaduch points mrsweety sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: Ken Haduch @khaduch Feb 22 2016 14:44 @mrsweety - I think I see what the problem is. Did you change the variable name in your exercise? I have a variable named gloveBoxContents, where you have myStorage. The test is looking for the former, not the latter... Nicolas S. @Nic48 Feb 22 2016 14:46 how can i post my code here ? Ken Haduch @khaduch Feb 22 2016 14:46 @mrsweety - and I see that someone commented and you saw that... best of luck with the rest! Markus Kiili @Masd925 Feb 22 2016 14:46 wiki format CamperBot @camperbot Feb 22 2016 14:46 ## :point_right: code formatting [wiki] ### Inline code This an inline <paste code here> code formatting with a single backtick() at start and end around the code. ### Code Block js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css) <paste your code here>, then press [shift + enter ⏎]  ⇦ Type 3 backticks, then press [enter ⏎] See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics Ken Haduch @khaduch Feb 22 2016 14:46 help post code CamperBot @camperbot Feb 22 2016 14:46 ## :point_right: how to post code [wiki] use backticks  Nicolas S. @Nic48 Feb 22 2016 14:46 thx function palindrome(str) { str = str.toLowerCase(); var expression = /[\.\s\d\,#()!"§$%&:=?]/gi;
var expression2 = /[-_/]/gi;

str = str.replace(expression,"").replace(expression2,"");
var left = 0;
var right = str.length-1;

while(right > left) {
if(str[left] != str[right]){
return false;
}
left++;
right--;
}

return true;
}

palindrome("1 eye for of 1 eye.");
can you tell me why it's returning "false" ? Isnt it a palindrome ?
Todd Demone
@todd-demone
Feb 22 2016 14:47
let's try this again. sorry! here is the palindromes code
function palindrome(str) {
// Good luck!

/* remove non-alphanumeric */
var newString = str.replace(/[^A-Za-z0-9]/gi, '');

/* convert remaining characters to lowercase */
newString.toLowerCase();

var newArray = newString.split('');

newArray.reverse();

var reverseString = newArray.join('');

if (str === reverseString) {
return true;
}

else {
return false;
}

}

palindrome("Eye");
Nicolas S.
@Nic48
Feb 22 2016 14:49
could u give me an advice whats wrong with my code ?
Markus Kiili
@Masd925
Feb 22 2016 14:50
This message was deleted
This message was deleted
Todd Demone
@todd-demone
Feb 22 2016 14:50
ok thanks @Masd925 !
CamperBot
@camperbot
Feb 22 2016 14:50
tabcd9 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1016 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Feb 22 2016 14:51
@tabcd9 Lowercase does nothing. Reverse does.
Nicolas S.
@Nic48
Feb 22 2016 14:51
yes but whats the matter with MY code ? :D
Todd Demone
@todd-demone
Feb 22 2016 14:51
Sorry so should I assign the results of toLowerCase to a new variable?
Markus Kiili
@Masd925
Feb 22 2016 14:52
@tabcd9 You can use the same variable if you like.
Todd Demone
@todd-demone
Feb 22 2016 14:52
ok thanks!
Joana
@bapeshark
Feb 22 2016 14:53
Who wants to be my PHP buddy ? :D
Blauelf
@Blauelf
Feb 22 2016 14:55
PHP? :worried:
Joana
@bapeshark
Feb 22 2016 14:55
yes :D I am trying to learn php but I need somebody willing to help haha
Feb 22 2016 14:55
@Nic48 - one tip that will make your life a bit easier on this is to save your original string, and make a "reversed" copy of it, and just compare the two with === - it will simplify your comparison... also your regular expressions could be much less complex if you use a different regular expression selector.
Nicolas S.
@Nic48
Feb 22 2016 14:58
how does the different reg expr. look like ?
thx for the advice by the way
my fault was checking for digits
function palindrome(str) {
str = str.toLowerCase();
var expression = /[\.\s\,#()!"§\$%&:=?`]/gi;
var expression2 = /[-_/]/gi;

var oldString = str;
var reversedString = str.reverse();

if(oldString === reversedString){
return true;
} else {
return false;
}
this is much better, thanks @khaduch
CamperBot
@camperbot
Feb 22 2016 15:02
nic48 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: