17th
Feb 2016
bitgrower
@bitgrower
Feb 17 2016 00:00
@declanPaz -- you had a similar problem earlier ... the solution then is the same solution here ...
Mafalda
@otmeek
Feb 17 2016 00:01
@bitgrower I will try there
bitgrower
@bitgrower
Feb 17 2016 00:02
@declanPaz -- hint: what are you passing to the function ...
Norman Dela Cruz
@dcnr
Feb 17 2016 00:03
@declanPaz shouldn't arrayAnalyzer be function?
function arrayAnalyzer() ...
// or
var arrayAnalyzer = function () ...
bitgrower
@bitgrower
Feb 17 2016 00:04
lol ... that, too, @dcnr ...
Vik
@vvang044
Feb 17 2016 00:07
hello all....can any explain this to me....how "myRandom = 11"

return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin; // Change this line
}
// Change these values to test your function
var myRandom = randomRange(5, 15);
*anyone i meant
Moisés Man
@moigithub
Feb 17 2016 00:09
pick pen n paper.. n set a value to min and max... then replace those values on the variable :) n do calc
Vik
@vvang044
Feb 17 2016 00:10
Math.random() can be a number between 0 to .999999 correct?
John Roman
@jrroman
Feb 17 2016 00:10
how can i convert a unix time stamp for sunrise
"sys":{
"type":1,
"id":7758,
"message":0.2194,
"country":"India",
"sunrise":1410569741,
"sunset":1410614119
},
Moisés Man
@moigithub
Feb 17 2016 00:11

myMax = 15
myMin = 5
Math.random() (15 - 5 + 1)) + 5; //
Math.random()
(10 + 1)) + 5; //
Math.random() * (11)) + 5; //

Math.random() * (11)) -- generate a random num btw 0 and 10.999999
math.floor.. remove the decimals.. so u have a num bts 0 and 10
0..10 + 5 ... u get a num between 5 and 15

@vvang044 yes thats correct
bitgrower
@bitgrower
Feb 17 2016 00:12
@jrroman -- I'd only know that by googling it ...
Moisés Man
@moigithub
Feb 17 2016 00:12
@jrroman
var myDate = new Date(miliseconds);
bitgrower
@bitgrower
Feb 17 2016 00:13
dang!!!!
bitgrower @bitgrower swipes for code snippets ...
Vik
@vvang044
Feb 17 2016 00:13
thank you @moigithub thats what i thought and i appreciate the explanation
CamperBot
@camperbot
Feb 17 2016 00:13
vvang044 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 628 | @moigithub | http://www.freecodecamp.com/moigithub
John Roman
@jrroman
Feb 17 2016 00:13
@bitgrower I just didnt know if there was a built in function for that
thats all
@moigithub thank you
CamperBot
@camperbot
Feb 17 2016 00:13
jrroman sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 629 | @moigithub | http://www.freecodecamp.com/moigithub
bitgrower
@bitgrower
Feb 17 2016 00:13
ahh ... then that's the question you should ask!!! :)
John Roman
@jrroman
Feb 17 2016 00:14
:) haha i know it was very poorly worded
Moisés Man
@moigithub
Feb 17 2016 00:14
if that not give u the correct date.. probably u need to multiply by 1000 (some convertion formula)
John Roman
@jrroman
Feb 17 2016 00:14
yeah either way i will figure it out
thanks for the help guys
Jason
@J-Pitt
Feb 17 2016 00:35
Hey guys, I'm stuck on module 184, I'm not really sure what they're asking. I'm supposed to add "the" number to the end of the array, then remove the first element of the array? this is what I've got, any help would be appreciated.
function queue(arr, item) {
// Your code here
testArr.push(?);
testArr.shift(0);

return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I'm not sure what number to push to the array
Norman Dela Cruz
@dcnr
Feb 17 2016 00:36
@J-Pitt
You're supposed to work on arr and not testArr and
1. Insert item to the end of arr
2. Remove the first item
3. Return that item
Jason
@J-Pitt
Feb 17 2016 00:37
ok thanks @dcnr ! I'll try that
CamperBot
@camperbot
Feb 17 2016 00:37
j-pitt sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 637 | @dcnr | http://www.freecodecamp.com/dcnr
Davperino
@davidesamp
Feb 17 2016 00:42

Hi everyone I have a problem with Falsy Bouncer challenge, this is my code
'''
function bouncer(arr) {

return arr.filter(function(value){
return value !== null && value !== isNaN && value !== false && value !== 0 && value !== "" ;
});
}
'''
the challenge fail at this point
'''
bouncer([false, null, 0, NaN, undefined, ""]);
'''
the result is bouncer([false, null, 0, NaN, undefined, ""]);
Some suggestions?

Den McHenry
@denmch
Feb 17 2016 00:44
@davidesamp Hi David. Can you switch those apostrophes to back ticks? It's the top left key on the keyboard.
Nairuz.Abulhul
@nairuzabulhul
Feb 17 2016 00:46
@davidesamp it is easier to use filter with booelan parameter
Davperino
@davidesamp
Feb 17 2016 00:46
I have an italian keyboard sorry ....
Den McHenry
@denmch
Feb 17 2016 00:46
Ah, sorry.
@ZeeMax I think it's better to lead him to the answer than tell him the answer.
So you have:
function bouncer(arr) {
return arr.filter(function(value){
return value !== null && value !== isNaN && value !== false && value !== 0 && value !== "" ;
});
}
Unfortunately I'm about to hit the road so I can't walk you through it.
Nairuz.Abulhul
@nairuzabulhul
Feb 17 2016 00:49
@denmch yeah you right. next time I would only give hints
Davperino
@davidesamp
Feb 17 2016 00:50
Ok I've resolved with The Boolean object as suggestion on the problem question ... thanks
Norman Dela Cruz
@dcnr
Feb 17 2016 00:51
@davidesamp hi the first null you are getting is NaN, the second is from undefined
Den McHenry
@denmch
Feb 17 2016 00:52
@davidesamp This is a problem that once you find the really elegant solution, it will probably seem so simple. But try to spend a little more time on thinking through what's really happening and how cool and useful it is.
Norman Dela Cruz
@dcnr
Feb 17 2016 00:52
@davidesamp you forgot to check for value !== undefinedand to check for NaN you will have to use either Number.isNaN or isNaN the former one is to check for number isNaN, since NaN is special in that it will return false for everything except NaN !== NaN
William
@apswak
Feb 17 2016 00:53
@davidesamp David I suggest to simplify things just add a simple function within your bouncer function that checks for "isTruthy"
function bouncer(arg) {
function isTruthy(arg){
return Boolean(arg);
}
//some code here
}
Davperino
@davidesamp
Feb 17 2016 00:53
@dcnr Ok bu I have resolved with a more elegant solution, with Boolean object (return Boolean(value) == true)
Norman Dela Cruz
@dcnr
Feb 17 2016 00:54
@davidesamp If that's the case, you can just do return arr.filter(Boolean);
@davidesamp because .filter needs a function, and since you're only using Boolean, rather than use it inside just pass the function along
William
@apswak
Feb 17 2016 00:57
@dcnr Very intuitive answer
Norman Dela Cruz
@dcnr
Feb 17 2016 00:57
thanks @kreitzo
CamperBot
@camperbot
Feb 17 2016 00:57
dcnr sends brownie points to @kreitzo :sparkles: :thumbsup: :sparkles:
:star: 211 | @kreitzo | http://www.freecodecamp.com/kreitzo
William
@apswak
Feb 17 2016 00:58
@dcnr Thanks. to you.
@unlimiworks
Feb 17 2016 00:58
Hello guys
Davperino
@davidesamp
Feb 17 2016 00:58
@dcnr This is my solution
'''
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(value){
return Boolean(value) === true;
});
}
'''
sorry i don't find the right markdown :(
CamperBot
@camperbot
Feb 17 2016 00:58
:bulb: to format code use backticks!  more info
Davperino
@davidesamp
Feb 17 2016 00:59
thanks @camperbot
CamperBot
@camperbot
Feb 17 2016 00:59
davidesamp sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1200 | @camperbot | http://www.freecodecamp.com/camperbot
William
@apswak
Feb 17 2016 00:59
thanks @dcnr
CamperBot
@camperbot
Feb 17 2016 00:59
kreitzo sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 638 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 17 2016 01:00
@davidesamp to use the md formatting you use backquotes it's the key above Tab, left of 1, and below Esc :D
haha you're welcome :P @kreitzo
William
@apswak
Feb 17 2016 01:01
Could someone tell me how I assign the array to "initialArray" and the remaining to targets?
function destroyer(arr) {
var initialArray = ???
var targets = ???
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Norman Dela Cruz
@dcnr
Feb 17 2016 01:01
@kreitzo here's my shameless plug It's quite a read, but I hope you still do :P
@kreitzo I wrote it just for that damn bonfire lol
bitgrower
@bitgrower
Feb 17 2016 01:02
^^^^ @dcnr's shameless plug page is WELL worth reading ...
Davperino
@davidesamp
Feb 17 2016 01:02
this is my solution:
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(value){
return Boolean(value) === true;
});
}
William
@apswak
Feb 17 2016 01:03
Norman Dela Cruz
@dcnr
Feb 17 2016 01:04
@davidesamp that's a good solution :D some things though, you don't have to do the === true part. .filter evaluates any value that you return as a Boolean value. So in saying that, you don't even have to do Boolean(value)! You can even do it like this
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(value){
return value;
});
}
bitgrower
@bitgrower
Feb 17 2016 01:04
@kreitzo ... check out the Arguments Object page on MDN, which I believe is recommended in the "helpful hints" ... there's a line of code about 2 paragraphs down you can literally steal for your purposes ...
Norman Dela Cruz
@dcnr
Feb 17 2016 01:04
@davidesamp and any "falsy" value will be removed by filter
@bitgrower Oh yeah, I should link the MDN some people prefer those technical explanations
bitgrower
@bitgrower
Feb 17 2016 01:05
well ... it provides the line of code people need to take the next step -- after they realize that "arr" is not all the arguments ...
...and ... gets them in the habit of finding actual ANSWERS to problems in the documention (not unlike falsy bouncer)
Norman Dela Cruz
@dcnr
Feb 17 2016 01:07
@bitgrower oh so that's where you got your ternary bit!
bitgrower
@bitgrower
Feb 17 2016 01:07
yessir!
stole it directly from MDN ...
yepitsmandi
@yepitsmandi
Feb 17 2016 01:07
hey does anyone understand access multi dimensional arrays?
Norman Dela Cruz
@dcnr
Feb 17 2016 01:07
@bitgrower come think of it that's a really nice shortened version of my args snippet
bitgrower
@bitgrower
Feb 17 2016 01:07
then I sat around and tried to figure out what it did ... which I SORTA understand ... don't quite understand the apply(null, arguments) part ... but I'm getting there ...
Norman Dela Cruz
@dcnr
Feb 17 2016 01:07
thanks @bitgrower
CamperBot
@camperbot
Feb 17 2016 01:07
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 546 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 17 2016 01:08
@bitgrower that's way better than what I use
const args = Array.apply(null, new Array(arguments.length));
for (let i = 0; i < arguments.length; ++i) {
args[i] = arguments[i];
}
William
@apswak
Feb 17 2016 01:09

nice read. thanks @dcnr @bitgrower .

btw @davidesamp even simpler if you want

function bouncer(arg) {
return arg.filter(Boolean);
}

bouncer(["a", "b", "c"]);
CamperBot
@camperbot
Feb 17 2016 01:09
kreitzo sends brownie points to @dcnr and @bitgrower and @davidesamp :sparkles: :thumbsup: :sparkles:
:warning: kreitzo already gave dcnr points
:star: 547 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 269 | @davidesamp | http://www.freecodecamp.com/davidesamp
Norman Dela Cruz
@dcnr
Feb 17 2016 01:09
thanks @kreitzo
CamperBot
@camperbot
Feb 17 2016 01:09
dcnr sends brownie points to @kreitzo :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave kreitzo points
bitgrower
@bitgrower
Feb 17 2016 01:09
yep -- definitely simplifies that ... @dcnr ... :)
yepitsmandi
@yepitsmandi
Feb 17 2016 01:09
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];
what the heck does this mean and how do I make it equal 8
bitgrower
@bitgrower
Feb 17 2016 01:10
thanks @kreitzo @dcnr
CamperBot
@camperbot
Feb 17 2016 01:10
bitgrower sends brownie points to @kreitzo and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 212 | @kreitzo | http://www.freecodecamp.com/kreitzo
:star: 639 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 17 2016 01:10
@yepitsmandi the trick is to go about it step by step
@yepitsmandi first you'll have to find the sub array with the element you want, what index is it?
@yepitsmandi and once you got that, you can then go to your second brackets, and that's the index of the value you wanted in your sub array
yepitsmandi
@yepitsmandi
Feb 17 2016 01:11
@dcnr i'm what index? i'm not quite sure I understand your question. this is so embarrassing
Norman Dela Cruz
@dcnr
Feb 17 2016 01:12
@yepitsmandi ah the index is the position of the element in your array, it is how you access the array
array = ["the", "quick", "brown", "fox"];
index      0       1        2       3
bitgrower
@bitgrower
Feb 17 2016 01:13
thanks to @blauelf comes this succinct piece of advice ... :
1. When going for algorithms, carefully read the description, read the test cases (these might provide further hints), and try to understand how you would do this by yourself, without a computer, maybe using pen and paper. And try to form instructions that anybody could follow to perform the task, then translate those to computer code.
CamperBot
@camperbot
Feb 17 2016 01:13
bitgrower sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1212 | @blauelf | http://www.freecodecamp.com/blauelf
Norman Dela Cruz
@dcnr
Feb 17 2016 01:13
@yepitsmandi so if I want quickI would have to do
array[1];
yepitsmandi
@yepitsmandi
Feb 17 2016 01:13
@dcnr so for the first one it is 0 because nothing is inside of it?
Norman Dela Cruz
@dcnr
Feb 17 2016 01:13
@yepitsmandi ah no, it's just how arrays work, they start from 0 rather than 1
bitgrower
@bitgrower
Feb 17 2016 01:14
@yepitsmandi if nothing was inside of it, it wouldn't be 0, it would be "undefined" ...
in code ... things are numbered starting with 0, usually ...
Norman Dela Cruz
@dcnr
Feb 17 2016 01:14
@yepitsmandi another way to think about it is, the index is how many values before the value you wanted. So in my example, fox is array[3] because there are 3 values before it
bitgrower
@bitgrower
Feb 17 2016 01:15

thanks to @blauelf comes this succinct piece of advice ... :
When going for algorithms, carefully read the description, read the test cases (these might provide further hints), and try to understand how you would do this by yourself, without a computer, maybe using pen and paper. And try to form instructions that anybody could follow to perform the task, then translate those to computer code.

Let's try this again ...

CamperBot
@camperbot
Feb 17 2016 01:15
bitgrower sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave blauelf points
Norman Dela Cruz
@dcnr
Feb 17 2016 01:15
the, quick, and brown
that's not really the case, but another way to think about it
yepitsmandi
@yepitsmandi
Feb 17 2016 01:17
I see @dcnr
i get that part, but where does the second bracket come from?
Norman Dela Cruz
@dcnr
Feb 17 2016 01:21
@yepitsmandi let's see, I'll use your example hold on
William
@apswak
Feb 17 2016 01:21
Still having trouble assigning the rest of the args, any tips/help?
function destroyer(arr) {
var initialArray = arguments[0];
var targets = ???;
return targets;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
bitgrower
@bitgrower
Feb 17 2016 01:22
@kreitzo -- did you read the Arguments Object page in MDN ?
yepitsmandi
@yepitsmandi
Feb 17 2016 01:22
okay
Norman Dela Cruz
@dcnr
Feb 17 2016 01:22
@yepitsmandi
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
index             0        1        2               3

myArray[3] = [[10,11,12], 13, 14]
index             0        1   2

myArray[3][0] = [10, 11, 12]
index             0   1   2

myArray[3][0][1] = 11
@yepitsmandi the "index" is the "position of the value/element"
@yepitsmandi and it always starts with 0, instead of 1
William
@apswak
Feb 17 2016 01:23
@bitgrower yup
bitgrower
@bitgrower
Feb 17 2016 01:24
there is literally a line on that page which will provide you with the means to do what you asked about ...
yepitsmandi
@yepitsmandi
Feb 17 2016 01:24
hmmm @dcnr i'm going to try out something with what you wrote and i'll tell you if i have a lightbulb moment. thanks!
CamperBot
@camperbot
Feb 17 2016 01:24
yepitsmandi sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 640 | @dcnr | http://www.freecodecamp.com/dcnr
William
@apswak
Feb 17 2016 01:24
@bitgrower found it, ty
bitgrower
@bitgrower
Feb 17 2016 01:25
ahhh ty ... I dunno if @camperbot understands that thanks ... LOL ... looks like not ...
CamperBot
@camperbot
Feb 17 2016 01:25
bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1201 | @camperbot | http://www.freecodecamp.com/camperbot
yepitsmandi
@yepitsmandi
Feb 17 2016 01:35
//sooooo
myArray[2] = [[7, 8, 9], [10, 11, 12], 13]
index                       0                  1               2
myArray[2][0] = [7, 8, 9]
index                        0  1  2
my Array[2][0][1] = 8
Norman Dela Cruz
@dcnr
Feb 17 2016 01:37
@yepitsmandi why did you start with [2]
@yepitsmandi aah fro mthe original array
@yepitsmandi myArray[2] is just [7, 8, 9] :D
yepitsmandi
@yepitsmandi
Feb 17 2016 01:38
@dcnr oooh
@dcnr i thought i was going somewhere lol.
Norman Dela Cruz
@dcnr
Feb 17 2016 01:39
@yepitsmandi you're close! :D hold on I'll put in another visualization
yepitsmandi
@yepitsmandi
Feb 17 2016 01:40
okay haha :)
William
@apswak
Feb 17 2016 01:43
Lol at how TERRIBLE my code is. cant believe it worked
function destroyer(arr) {
//change arguments into array
var array = (arguments.length === 1?[arguments[0]]:Array.apply(null, arguments));
var arrayCopy = array;
var initialArray = arrayCopy.shift();
var targets = arrayCopy;
var newArray = [];

for(var i = 0; i < initialArray.length; i++){
if(initialArray[i] != targets[0] && initialArray[i] != targets[1] && initialArray[i] != targets[2]){
newArray.push(initialArray[i]);
}
}
return newArray;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
pngwn
@pngwn
Feb 17 2016 01:44
if it works it isn't terrible ;p
William
@apswak
Feb 17 2016 01:44
@peterallenio bet the best answer is a two liner ;P
Norman Dela Cruz
@dcnr
Feb 17 2016 01:44
@yepitsmandi
I dunno if this makes it easier to understand or what but lol
myArray = [
[1,2,3],          // myArray[0]
[4,5,6],          // myArray[1]
[7,8,9],          // myArray[2]
[                 // myArray[3][0] the entire array of [10,11,12], 13, 14]
[10,            //     myArray[3][0][0]
11,            //     myArray[3][0][1]
12],            //     myArray[3][0][2]
13,             // myArray[3][1]
14              // myArray[3][2]
]
]
Alex N.
@N0bl3
Feb 17 2016 01:46
hi!
yepitsmandi
@yepitsmandi
Feb 17 2016 01:48
hi #N0bl3
@N0bl3
@dcnr i kind of see it now
kiel barry
@kielbarry
Feb 17 2016 01:48
@N0bl3
$(document).ready(function(){$(".footerLight").click(function(){
$(this).addClass(".BoL"); });$('.footerDark').click(function(){
$(this).addClass(".LoB"); )}; }); yepitsmandi @yepitsmandi Feb 17 2016 01:49 buti don't see why myArray[3][0] includes 13 and 14 kiel barry @kielbarry Feb 17 2016 01:49 .footerLight { } .footerDark { } .LoB { color:white; background-color:black; } .BoL { color:black; background-color:white; }  <a href="#1" class="footerLight">make me light</a></div> <div class="footerDark"><a href="#2">make me dark</a></div> Alex N. @N0bl3 Feb 17 2016 01:50 @declanPaz what do you want to know? kiel barry @kielbarry Feb 17 2016 01:50 @N0bl3 it's not working in jsfiddle pngwn @pngwn Feb 17 2016 01:50 You don't need the dot when you're adding classes, just the clann name class* kiel barry @kielbarry Feb 17 2016 01:51 so -$(this).addClass("LoB");
pngwn
@pngwn
Feb 17 2016 01:51
yes
Alex N.
@N0bl3
Feb 17 2016 01:51
@declanPaz yes
kiel barry
@kielbarry
Feb 17 2016 01:52
ok, changed that, still don't work
pngwn
@pngwn
Feb 17 2016 01:52
can you link the jsfiddle?
Norman Dela Cruz
@dcnr
Feb 17 2016 01:53
@yepitsmandi
Here's mega indexing!
myArray = [
[            // myArray[0]
1,         // myArray[0][0]
2,         // myArray[0][1]
3          // myArray[0][2]
],

[            // myArray[1]
4,         // myArray[1][0]
5,         // myArray[1][1]
6          // myArray[1][2]
],

[            // myArray[2]
7,         // myArray[2][0]
8,         // myArray[2][1]
9          // myArray[2][2]
],

[            // myArray[3][0]
[
10,      // myArray[3][0][0]
11,      // myArray[3][0][1]
12       // myArray[3][0][2]
],
13,        // myArray[3][1]
14         // myArray[3][2]
]
];
Alex N.
@N0bl3
Feb 17 2016 01:53
@declanPaz are the classes set correctly on the footers?
kiel barry
@kielbarry
Feb 17 2016 01:53
that work?
yepitsmandi
@yepitsmandi
Feb 17 2016 01:54
@dcnr OHHHHHHH
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];
myArray[2] = [7, 8, 9];
myArray[2][1] = 8;
Norman Dela Cruz
@dcnr
Feb 17 2016 01:54
@yepitsmandi it's just like drilling down, starting from 0 again every start of the array :D
kiel barry
@kielbarry
Feb 17 2016 01:54
@N0bl3 yes i believe they are - tried assigning them on <a> and <div>
Norman Dela Cruz
@dcnr
Feb 17 2016 01:55
@yepitsmandi I think you got it now :D
yepitsmandi
@yepitsmandi
Feb 17 2016 01:55
i actually have myArray2 = 8; before you sent that
the goal is for it to equal 8
but it still says its wrong
Norman Dela Cruz
@dcnr
Feb 17 2016 01:55
ooh..
@yepitsmandi just think of it as individual [] is the value/element then you start indexing again with the second []
since it's another array inside
kiel barry
@kielbarry
Feb 17 2016 01:56
Jason
@carpediem1213
Feb 17 2016 01:57
function rot13(str) { // LBH QVQ VG!
var letter;
var encryptedLetter
var phrase;

for (var i = 0; i < str.length; i++) {
letter = str.charCodeAt(i);
if (letter >= 65+13) {
encryptedLetter = letter - 13;
}
else if (letter < 78 && letter > 65) {
encryptedLetter = letter + 13;
}
else if (letter < 65) {
encryptedLetter = letter;
}

console.log(JSON.stringify(letter + " " + encryptedLetter));
console.log(JSON.stringify(String.fromCharCode(encryptedLetter)));
phrase =+ String.fromCharCode(encryptedLetter);
}
return phrase;
}

// Change the inputs below to test
rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");
Hello all, I'm trying to get the phrase to come together using the for loop. I seem to be missing something. Any thoughts?
yepitsmandi
@yepitsmandi
Feb 17 2016 01:58
@dcnr thanks again SOO MUCH :)
CamperBot
@camperbot
Feb 17 2016 01:58
yepitsmandi sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: yepitsmandi already gave dcnr points
Alex N.
@N0bl3
Feb 17 2016 01:59
@declanPaz you need to put jQuery in your jsfiddle
pngwn
@pngwn
Feb 17 2016 02:01
yeah I did wonder if something was missing
Norman Dela Cruz
@dcnr
Feb 17 2016 02:11
you're welcome and thank you too! @yepitsmandi you just practice this nesting stuff, you'll be using it quite a lot!
CamperBot
@camperbot
Feb 17 2016 02:11
dcnr sends brownie points to @yepitsmandi :sparkles: :thumbsup: :sparkles:
:star: 201 | @yepitsmandi | http://www.freecodecamp.com/yepitsmandi
Theodore P.
@Ierofantis
Feb 17 2016 02:13

// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr="This is the first sentence.";
myStr+= "This is the second sentence.";

what is wrong whith my code?
I cannot understand where my concatenate is not ok
yepitsmandi
@yepitsmandi
Feb 17 2016 02:14
@dcnr i will! you really helped me to understand the pattern and the multiple array idea. the answer was indeed 2 i didn't think to replace 2 and 1 with the 0s
pngwn
@pngwn
Feb 17 2016 02:14
@Ierofantis do you need a space before the quote in the first string?
before the second quotation mark
yepitsmandi
@yepitsmandi
Feb 17 2016 02:15
@Ierofantis type  and then hit shift + enter and copy and paste your code into the space between. it will make it easier to read your code
Norman Dela Cruz
@dcnr
Feb 17 2016 02:15
This message was deleted
@carpediem1213 phrase =+ is wrong :P
Theodore P.
@Ierofantis
Feb 17 2016 02:16
ok lets try
Norman Dela Cruz
@dcnr
Feb 17 2016 02:16
@camperbot also, initialize your phrase to an empty string or you will have undefined as first value
DAMN @mention COMPLETION
@carpediem1213 also, initialize your phrase to an empty string or you will have undefined as first value
yepitsmandi
@yepitsmandi
Feb 17 2016 02:17
LOL
Norman Dela Cruz
@dcnr
Feb 17 2016 02:17
ahaha
Feb 17 2016 02:19
need help for Profile Lookup excercise.
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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"

Jason
@carpediem1213
Feb 17 2016 02:19
@dcnr Ah! Oops....
Feb 17 2016 02:20
function lookUp(firstName, prop){
// Only change code below this line

// Only change code above this line
}
Theodore P.
@Ierofantis
Feb 17 2016 02:21
@peterallenio ok I have had to add a space thanks!
CamperBot
@camperbot
Feb 17 2016 02:21
ierofantis sends brownie points to @peterallenio :sparkles: :thumbsup: :sparkles:
:star: 283 | @peterallenio | http://www.freecodecamp.com/peterallenio
Feb 17 2016 02:21
function lookUp(firstName, prop){
// Only change code below this line
var i=0;
while(contacts[i]){
if(contacts[i]["firstName"] == firstName && contacts[i][prop]){
return contacts[i][prop];
}
else if( !contacts[i+1] && contacts[i]["firstName"] == firstName){
return "No such contact";
}
i++;
}
// Only change code above this line
}
Here is how my lookUp fucntions looks like
pngwn
@pngwn
Feb 17 2016 02:22
@Ierofantis Yes, always need to double check when concatenating strings that your whitespace is correct because it will always print exactly what you tell it to.
Vick003
@Vick003
Feb 17 2016 02:24
can some help me with sum all odd fibonacci?
Theodore P.
@Ierofantis
Feb 17 2016 02:24
@peterallenio Ok I will have It in mind. I am new in Javacript and I didn't know that it is so case-sensitive language.
Jason
@carpediem1213
Feb 17 2016 02:24
@dcnr Thanks! That did it.
CamperBot
@camperbot
Feb 17 2016 02:24
carpediem1213 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 641 | @dcnr | http://www.freecodecamp.com/dcnr
Vick003
@Vick003
Feb 17 2016 02:26
If anyone can give me hints as to what's wrong with this code, I'd greatly appreciate it.
function sumFibs(num) {
var prevNum = 1,
currentNum = 1,
nextNum,
counter = 2,
total = 2;

while(counter < num) {
nextNum = prevNum + currentNum;
if( nextNum % 2 != 0){
total += nextNum;
}
prevNum = currentNum;
currentNum = nextNum;
counter++;
}
}
Ramins01
@Ramins01
Feb 17 2016 02:28
@Vick003 I think you're missing semicolons for the variables and each variable needs to be established as such (e.g. var currentNum, var nextNum) unless this is some cheat in JavaScript I haven't learned yet :P
Norman Dela Cruz
@dcnr
Feb 17 2016 02:29
@Ramins01 you can declare multiple variables like that, separated by commas :D
Vick003
@Vick003
Feb 17 2016 02:30
@Ramins01 Ah yeah, u can do variables like that when there are a bunch of them.
what @dcnr said
pngwn
@pngwn
Feb 17 2016 02:30
@dcnr You can miss off subsequent 'var' keyword if you separate your variables if you separate with a comma rather than ending the expression with a semicolon.
Norman Dela Cruz
@dcnr
Feb 17 2016 02:30
@Ramins01 you see it most often in for loops
pngwn
@pngwn
Feb 17 2016 02:30
and apparently i cant type
Norman Dela Cruz
@dcnr
Feb 17 2016 02:30
@peterallenio I personally don't like that style, I like to declare them separately
pngwn
@pngwn
Feb 17 2016 02:31
i like it when i want to declare them but not initialise them. but if i'm assigning a value i use the conventional method
Ramins01
@Ramins01
Feb 17 2016 02:31
How about that. Thanks @Vick003 and @dcnr
CamperBot
@camperbot
Feb 17 2016 02:31
ramins01 sends brownie points to @vick003 and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 35 | @vick003 | http://www.freecodecamp.com/vick003
:star: 642 | @dcnr | http://www.freecodecamp.com/dcnr
Alex Evans
@alex-evans
Feb 17 2016 02:32

In the wiki answer for "No repeats please" challenge it has the following call to a function that I think I get what it is trying to do but need someone to talk me through it:

swap(int % 2 ? 0 : i, int - 1);

It is the same as the following correct:

if(int % 2) {
return 0;
} else {
return int - 1;
}

And if that is the case then when is int % 2 ever false? When it doesn't equal 0? As in odd numbers or is it protecting for when int gets below 0 which it seems like there are easier ways to check that?

pngwn
@pngwn
Feb 17 2016 02:32
var one, two, three; etc.
Alex Evans
@alex-evans
Feb 17 2016 02:34
Sorry I wrote that wrong.
int % 2 ? 0 : i
is the same as
if(int % 2) {
return 0;
} else {
return i;
}
Norman Dela Cruz
@dcnr
Feb 17 2016 02:35
@alcatrats you can't have negative remainders, so it's just saying that if the remainder is 0 (even numbers), do i
Vick003
@Vick003
Feb 17 2016 02:36
@alcatrats I read that as a terneray statement
Alex Evans
@alex-evans
Feb 17 2016 02:36
I guess I don't follow that first piece. if(int % 2)... Would 3 % 2 still return a true value of 1 which would still pass the first check returning 0? I know I"m reading it wrong but just not making sense to me.
Norman Dela Cruz
@dcnr
Feb 17 2016 02:36
@alcatrats yes you're right, 3 % 2 is 1 which is true which in this case will return 0
Vick003
@Vick003
Feb 17 2016 02:36
@alcatrats anything greater than 0 would probably be truthy
Alex Evans
@alex-evans
Feb 17 2016 02:37
So why make it complicated like that and not just say if int > 0?
Jason
@carpediem1213
Feb 17 2016 02:37
I've finished the basic algorithms. Now I am up to the Random Quote Generator. I've looked at the sample project, but I'm not sure I have the skill set to accomplish this one yet. Which lessons/challenges should I review to be prepared for these intermediate front end projects?
Vick003
@Vick003
Feb 17 2016 02:37
it's the remainder @alcatrats
int % 2 will give u a remainder
Norman Dela Cruz
@dcnr
Feb 17 2016 02:38
@alcatrats without seeing the whole code, I interpret it as "If number is Odd, return 0, otherwise return the even number"
@alcatrats so you can't just say int > 0, coz even numbers are > 0
@alcatrats or whatever i is lol
Alex Evans
@alex-evans
Feb 17 2016 02:39
Ahhh 2 % 2 would return 0 which would fail the if statement?
pngwn
@pngwn
Feb 17 2016 02:39
for even numbers is should read if (int % 2 === 0) as it stands there is no condition
you cant just pass an operation into an iff statement it has to be able to return true or false
Norman Dela Cruz
@dcnr
Feb 17 2016 02:40
@peterallenio yes you can it will evaluate the value as a boolean
Vick003
@Vick003
Feb 17 2016 02:40
truthy values or falsy
pngwn
@pngwn
Feb 17 2016 02:40
well yes it will, but it won't give the desired result
Vick003
@Vick003
Feb 17 2016 02:40
If anyone can give me hints as to what's wrong with this code, I'd greatly appreciate it.
function sumFibs(num) {
var prevNum = 1,
currentNum = 1,
nextNum,
counter = 2,
total = 2;

while(counter < num) {
nextNum = prevNum + currentNum;
if( nextNum % 2 != 0){
total += nextNum;
}
prevNum = currentNum;
currentNum = nextNum;
counter++;
}
}
Norman Dela Cruz
@dcnr
Feb 17 2016 02:41
@peterallenio that would depend on the case though, and how you structure the conditional statements based on the result
@peterallenio int % 2 ? Odd : Even and it always be so assuming int > 0
wait lol i think i switched it
Alex Evans
@alex-evans
Feb 17 2016 02:42
@dcnr wouldn't that be flipped if I'm understanding it
Norman Dela Cruz
@dcnr
Feb 17 2016 02:42
yeah I flipped it lol
there
Alex Evans
@alex-evans
Feb 17 2016 02:43
Nice. Thanks @dcnr and thanks @Vick003. That makes more sense now.
CamperBot
@camperbot
Feb 17 2016 02:43
alcatrats sends brownie points to @dcnr and @vick003 :sparkles: :thumbsup: :sparkles:
:star: 36 | @vick003 | http://www.freecodecamp.com/vick003
:star: 643 | @dcnr | http://www.freecodecamp.com/dcnr
pngwn
@pngwn
Feb 17 2016 02:44
i still don't see why you would do it, even though you can, adding an explicity conditional rather than dealing with a falsy value is far easier to read and makes far more sense at a glance
it's good to know which values are falsey/truthy but relying on it for conditionals would be a mistake in my opinion
Norman Dela Cruz
@dcnr
Feb 17 2016 02:45
@peterallenio I agree with you on that part, sometimes it helps to be more explicit
pngwn
@pngwn
Feb 17 2016 02:46
I'd go so far as to say you should always be explicit unless you have a very good reason not to, avoids all kinds of problems
Norman Dela Cruz
@dcnr
Feb 17 2016 02:46
but that's the case with ternary anyway, over usage gets silly sometimes
Alex Evans
@alex-evans
Feb 17 2016 02:46
I agree with that @peterallenio
pngwn
@pngwn
Feb 17 2016 02:46
should check the 'Zen of Python'
quite fun, also good guidelines :P
Alex Evans
@alex-evans
Feb 17 2016 02:47
I had to stare at the code for awhile and ask the question here on what it was doing before finally understanding it. When I can always quickly tell what if (int % 2 === 0) is trying to do.
Norman Dela Cruz
@dcnr
Feb 17 2016 02:48
@peterallenio but but, what if you want stupid but working functions?!
function update(id, prop, value) {
return value
? prop === 'tracks'
? (collection[id].tracks.push(value), collection)
: (collection[id][prop] = value, collection)
: (delete collection[id][prop], collection);
}
pngwn
@pngwn
Feb 17 2016 02:51
You see, I just don't think thats readable at all. I'd rather be verbose and know at a glance what something is doing rather than concise but confusing.
something like that is fine in isolation but imagine several hundred lines of code like that and i'd just lose my mind.
Norman Dela Cruz
@dcnr
Feb 17 2016 02:52
ahaha yes I agree
same with variable and function naming
pngwn
@pngwn
Feb 17 2016 02:53
I think there is a special place in hell for ternary operators, although there are some things you can only do with a ternary.
flexbox forggy is really fun
froggy
Matt Gilbert
@Alquh
Feb 17 2016 02:58
var count = 0;

function cc(card) {
// Only change code below this line
var x = [2,3,4,5,6];
var y = [7,8,9];
var z = [10,'J','Q','K','A'];

if (card == x) {
count++;
return count + " " + "Bet";
}
else
if (card <= 0)
count--;
return "Hold";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
how wrong do i have this?
Norman Dela Cruz
@dcnr
Feb 17 2016 02:58
@Alquh you're comparing card to an array
Matt Gilbert
@Alquh
Feb 17 2016 02:59
I realize that, is there another way to do this?
Norman Dela Cruz
@dcnr
Feb 17 2016 02:59
@Alquh I get your point though, I solved it this way, but you'll have to use indexOf and for each array set
Matt Gilbert
@Alquh
Feb 17 2016 03:02
@dcnr I'll do some research on indexOf. does everything else make sense?
Norman Dela Cruz
@dcnr
Feb 17 2016 03:05
@Alquh yeah I think you have an ok approach
@Alquh I understand that what you want to do is check if card is in one of the sets, and you can do that with indexOf
Matt Gilbert
@Alquh
Feb 17 2016 03:07
@dcnr perfect, thanks for the tip!
CamperBot
@camperbot
Feb 17 2016 03:07
alquh sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 644 | @dcnr | http://www.freecodecamp.com/dcnr
Eduardo Garcia
@eagarcia8
Feb 17 2016 03:16
Hi everyone, I'm staring at some code, and can't seem to spot the problem! This is for "Profile Lookup":
function lookUp(firstName, prop){
// Only change code below this line

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

if (contacts[i].firstName == firstName) {

if ( contacts[i].hasOwnProperty(prop) ) {
return contacts[i].prop;
}else {
return "No such property";
}

}else {

return "No such contact";

}
}

// Only change code above this line
}
Sri Keerthi N
@keerthinerella
Feb 17 2016 03:16
@camperbot I'm not able to complete the "stand in line" challenge... please help me out
eeflores
@eeflores
Feb 17 2016 03:17
@eagarcia8 put the "no such contact" after the for loop
Eduardo Garcia
@eagarcia8
Feb 17 2016 03:17
@keerthinerella can you show me your code?
Sri Keerthi N
@keerthinerella
Feb 17 2016 03:17

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

testArr.pop();
testArr.push(item);

return item; // Change this line
}

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

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

eeflores
@eeflores
Feb 17 2016 03:18
@keerthinerella you'll want to use shift to get the first element in the array
push first, then shift
Sri Keerthi N
@keerthinerella
Feb 17 2016 03:19
ok i will try it out
should i clear the pop function?
eeflores
@eeflores
Feb 17 2016 03:20
yep
Eduardo Garcia
@eagarcia8
Feb 17 2016 03:20
@eeflores I see the error of my ways! Thanks eeflores I though placing it there If it fails to find the name, but I guess the first object will almost never match haha.
CamperBot
@camperbot
Feb 17 2016 03:20
eagarcia8 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 588 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Feb 17 2016 03:20
yw
Norman Dela Cruz
@dcnr
Feb 17 2016 03:20
@keerthinerella you should also be working on arr instead of testArr
eeflores
@eeflores
Feb 17 2016 03:21
oh yeah that too
Sri Keerthi N
@keerthinerella
Feb 17 2016 03:22
ok
Nicolas May
@hynso
Feb 17 2016 03:23
Hi all... I'm looking to get some feedback on the title case algorithm problem... Can someone help me out?
eeflores
@eeflores
Feb 17 2016 03:24
@hynso code?
Nicolas May
@hynso
Feb 17 2016 03:24
'''
CamperBot
@camperbot
Feb 17 2016 03:24
:bulb: to format code use backticks!  more info
Nicolas May
@hynso
Feb 17 2016 03:25
function titleCase(str) {
strArray = str.split(" ");
newArray = [];
for (var i = 0; i < strArray.length; i++) {
newString = strArray[i][0].toUpperCase();
for (var j = 1; j < strArray[i].length; j++) {
newString += strArray[i][j].toLowerCase();
}
newArray.push(newString);
}
sentenceString = newArray.join(" ");
return sentenceString;
}

titleCase("I'm a little tea pot");
@eeflores I'm thinking there's got to be a more efficient/better way than nested for loops
eeflores
@eeflores
Feb 17 2016 03:25
@hynso you may want to declare newString at the start of the function
Nicolas May
@hynso
Feb 17 2016 03:25
@eeflores I mean, it works... it just seems so cumbersome
Norman Dela Cruz
@dcnr
Feb 17 2016 03:26
@hynso you don't have to use loops, there are string functions that deal with "chopping" em up, like slice, substr, and substring
Nicolas May
@hynso
Feb 17 2016 03:26
@dcnr like in python?
eeflores
@eeflores
Feb 17 2016 03:27
@hynso you could call toLowerCase on the whole string before loops ...
before the split, then you'll only need to convert the first char of each word
Nicolas May
@hynso
Feb 17 2016 03:28
@eeflores @dcnr thanks for the tips... using slice I'm thinking I can combine it with map
CamperBot
@camperbot
Feb 17 2016 03:28
hynso sends brownie points to @eeflores and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 589 | @eeflores | http://www.freecodecamp.com/eeflores
:star: 645 | @dcnr | http://www.freecodecamp.com/dcnr
eeflores
@eeflores
Feb 17 2016 03:28
@hynso var strArray = str.toLowerCase().split(" ");
Norman Dela Cruz
@dcnr
Feb 17 2016 03:30
@hynso oh man would be really nice if we can just do it like python slice notationstring[:] etc
bitgrower
@bitgrower
Feb 17 2016 03:32
LOL ... there are LOTS of pythonics I miss here ...
as well as pointers ... from c ...
but ... it is what it is ... LOL ...
@dcnr -- any what's up with having those 3 different string functions ... slice, substr & substring ?
Norman Dela Cruz
@dcnr
Feb 17 2016 03:33

@bitgrower @hynso yeah would be awesome to just have

word = word[0].upper() + word[1:].lower()

or something, my python ain't good lol

@bitgrower :point_up: February 17, 2016 11:25 AM
Nicolas May
@hynso
Feb 17 2016 03:35
@eeflores @dcnr
function titleCase(str) {
strArray = str.toLowerCase().split(" ");
var newArray = strArray.map(function(strng) {
return (strng[0].toUpperCase() + strng.slice(1));
});
var newString = newArray.join(" ");
return newString;
}

titleCase("I'm a little tea pot");
@DiDzHey
Feb 17 2016 03:36
Am i the only one getting the "Oops! Something wen wrong. Try again later." notice?
Nicolas May
@hynso
Feb 17 2016 03:36
@eeflores @dcnr thanks again for the suggestions... map + slice are much cleaner
CamperBot
@camperbot
Feb 17 2016 03:36
hynso sends brownie points to @eeflores and @dcnr :sparkles: :thumbsup: :sparkles:
:warning: hynso already gave eeflores points
:warning: hynso already gave dcnr points
bitgrower
@bitgrower
Feb 17 2016 03:36
no, you are not @DiDzHey -- it's been going on for a few days ...
@DiDzHey
Feb 17 2016 03:37
@bitgrower thanks! Do you know why??
CamperBot
@camperbot
Feb 17 2016 03:37
didzhey sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 548 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 17 2016 03:37
@hynso yeah much easier to follow than nested for!
bitgrower
@bitgrower
Feb 17 2016 03:39
@DiDzHey -- nope -- think the FCC team has been trying to figure it out ...
@DiDzHey
Feb 17 2016 03:39
@bitgrower oh ok
bitgrower
@bitgrower
Feb 17 2016 03:40
@dcnr -- my python is worse off than yours ... I just vaguely remember parts from going thru the codecademy python course & the Learn Python the Hard Way Course last summer ... 6+ mos ... the info has kinda evaporated from my brain ...
Norman Dela Cruz
@dcnr
Feb 17 2016 03:42
@bitgrower I really like the hard way materials!
@hynso you can also use reduce instead of map!
Michelle
@Michelle2016
Feb 17 2016 03:52
Hello Everyone! I am on the Accessing Objects Properties with Variables Challenge. I have three out of the four little boxes under the submit button checked off and only one left! Can anyone please help me?
Norman Dela Cruz
@dcnr
Feb 17 2016 03:53
Salvatore Santamaria
@ssroman
Feb 17 2016 03:55

Hi, I'm having trouble with the Make Object Properties Private var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

i am completely lost
Michelle
@Michelle2016
Feb 17 2016 03:55

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16; // Change this Line
var player = testObj[16];

@dcnr
Norman Dela Cruz
@dcnr
Feb 17 2016 03:56
@Michelle2016 you'll have to use playerNumber instead of directly using 16 with testObj
Michelle
@Michelle2016
Feb 17 2016 03:57
@dcnr Argh!! Thank you!
CamperBot
@camperbot
Feb 17 2016 03:57
michelle2016 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 646 | @dcnr | http://www.freecodecamp.com/dcnr
Michelle
@Michelle2016
Feb 17 2016 03:57
@dcnr I am going to study it a bit so that I can gt it conceptually as well before I move forward.
Jonah Erlich
@jerlich97
Feb 17 2016 03:57
@bitgrower I had to run for dinner with my family but I'm still confused on smallest common multiple
Salvatore Santamaria
@ssroman
Feb 17 2016 03:58
nvm i think i got it
Norman Dela Cruz
@dcnr
Feb 17 2016 03:58
@ssroman you'll have to work on the Bike variable and do what the instructions say
@Michelle2016 Oh I hope you'll read this, and I hope it's not so confusing!
Michelle
@Michelle2016
Feb 17 2016 03:59
@dcnr Thank you, I definitely will!
CamperBot
@camperbot
Feb 17 2016 03:59
michelle2016 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:warning: michelle2016 already gave dcnr points
Norman Dela Cruz
@dcnr
Feb 17 2016 04:01
thank you! and tell me if there are parts that are confusing @Michelle2016
CamperBot
@camperbot
Feb 17 2016 04:01
dcnr sends brownie points to @michelle2016 :sparkles: :thumbsup: :sparkles:
:star: 221 | @michelle2016 | http://www.freecodecamp.com/michelle2016
Jonah Erlich
@jerlich97
Feb 17 2016 04:02
Any suggestions? all the tests work except the last input
function smallestCommons(arr) {
var min;
var max;
var range = [];
if(arr[0]>arr[1]){
max=arr[0];
min=arr[1];
}
else{
max=arr[1];
min=arr[0];
}
for(var i = min; i <= max; i++){
range.push(i);
}
console.log("range" + range + range[range.length-1]);
for(var j = range[range.length-1]; j <= 360361; j++){
if(isDivis(range, j)){
return j;
}
}
}

function isDivis(r, num){
console.log(r.length);
for(var k = r[0]; k <= r[r.length-1]; k++){
if(num%k!==0){
return false;
}
}
return true;
}
smallestCommons([1,13]);
Norman Dela Cruz
@dcnr
Feb 17 2016 04:04
@jerlich97 how did you come up with the 360361 part?
Jonah Erlich
@jerlich97
Feb 17 2016 04:06
@dcnr The challenge says the higher output will be 360360
highest*
@dcnr I'm warned of an infinite loop for the [1,13] input and doing noprotect crashes the tab
Norman Dela Cruz
@dcnr
Feb 17 2016 04:12
@jerlich97 yeah I'm having infiniteloop protection errors too :(
Jonah Erlich
@jerlich97
Feb 17 2016 04:13
@dcnr I asked about it earlier and another user mentioned something about prime numbers, but it didn't make too much sense to me
@dcnr "the algo I found that worked most easily for this is to realize every common divisor is going to be a prime ... and sometimes the prime has to be used more than once."
Norman Dela Cruz
@dcnr
Feb 17 2016 04:17
@jerlich97 for me, I just did it like how I would do it with pen and paper, I made a gcd function based on the Euclidean Algorithm and get the lcm through Reduction by GCD
Jonah Erlich
@jerlich97
Feb 17 2016 04:20
@dcnr but there is no gcd for an entire range such as [1,13]
Norman Dela Cruz
@dcnr
Feb 17 2016 04:37
@jerlich97 you can always get lcm(a, b) then the result of that with the next one etc something like lcm(lcm(lcm(a, b), c), d) etc
@jerlich97 so my LCM would look like this
// my lcm reduction
result = range.reduce(function(a, b) {
return lcm(a, b);
});
Bryan Gilbraith
@bryantheastronaut
Feb 17 2016 04:39
help chunky monkey
CamperBot
@camperbot
Feb 17 2016 04:39

# Explanation

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

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

Jonah Erlich
@jerlich97
Feb 17 2016 04:40
@dcnr I think I might understand, give me a few minutes
Norman Dela Cruz
@dcnr
Feb 17 2016 04:41
@jerlich97 here's some pseudocode implementation for gcd
Dinara Demi
@Gezehus
Feb 17 2016 04:42
Hello everyone! Advise me please good online resource to learn JSON and AJAX. I've done all the tasks in FCC but I didn't understand how to use them.
Norman Dela Cruz
@dcnr
Feb 17 2016 04:44
@Gezehus try asking in the main room and the FrontEnd too!
Jonah Erlich
@jerlich97
Feb 17 2016 04:46
@dcnr ohhh, I see
Nikolajs Korolkovs
@NickEU
Feb 17 2016 04:48
@jerlich97 your way is very slow, but ok... think of the smallest common multiple as something that will always be divisible by your max number in the range without a remainder.. and think about what do you need to change in your code ( the j++ part of your for loop specifically) to drastically reduce the number of iterations and isDivis calls u're gonna have to make..
Feb 17 2016 04:49
Man, that "Record Collection" exercise almost killed me, but everything is starting to click
Norman Dela Cruz
@dcnr
Feb 17 2016 04:50
@jerlich97 let's see if this works lol
welp my latex sucks
Jonah Erlich
@jerlich97
Feb 17 2016 04:51
@dcnr I think I'm on the right track, 1 sec
@dcnr I'm not getting the right output for reduce(gcd)
@dcnr It always gives me a 1


function smallestCommons(arr) {
arr = arr.sort(function(a,b){
return a - b;
});
var range = [];
for(var i = arr[0]; i <= arr[1]; i++){
range.push(i);
}
var result = range.reduce(function(a,b){
return gcd(a,b);
});
console.log(result);
return result;
}
function gcd(a, b){
var c;
while(b!==0){
c = b;
b = a%b;
a = c;
}
return a;
}

smallestCommons([1,5]);

 @dcnr

function smallestCommons(arr) {
arr = arr.sort(function(a,b){
return a - b;
});
var range = [];
for(var i = arr[0]; i <= arr[1]; i++){
range.push(i);
}
var result = range.reduce(function(a,b){
return gcd(a,b);
});
console.log(result);
return result;
}
function gcd(a, b){
var c;
while(b!==0){
c = b;
b = a%b;
a = c;
}
return a;
}

smallestCommons([1,5]);
Norman Dela Cruz
@dcnr
Feb 17 2016 04:53
@jerlich97 you'll have to use gcd with lcm
  function lcm(a, b) {
return a / gcd(a, b) * b;
}
@DiDzHey
Feb 17 2016 04:53
@Gezehus you could also try Udemy courses
Norman Dela Cruz
@dcnr
Feb 17 2016 04:53
@jerlich97 I don't really know if this is efficient though, doing lcm and gcd
@jerlich97 I'm not good with math, so I'm just going by the basics, there must be some other direct way
Jonah Erlich
@jerlich97
Feb 17 2016 04:54
@dcnr Thanks, that worked
CamperBot
@camperbot
Feb 17 2016 04:54
jerlich97 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 647 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 17 2016 04:54
@jerlich97 awesome!
Jonah Erlich
@jerlich97
Feb 17 2016 04:54
@dcnr Although, I do feel like I should improve my math skills too, any suggestions?
Norman Dela Cruz
@dcnr
Feb 17 2016 04:55
@jerlich97 yeah me too, I'd like to at least relearn my algebra lol. I'm just doing KhanAcademy stuff for now
@jerlich97 and Better Explained is awesome too
Jonah Erlich
@jerlich97
Feb 17 2016 04:56
@dcnr Cool. I've actually heard that conventional schooling (especially in the US) skips a lot of very important foundational pieces so I'll definitely check those out
Norman Dela Cruz
@dcnr
Feb 17 2016 04:56
@jerlich97 I didn't join the newsletters though
@jerlich97 I'm not from the US so I don't really know how they do their academics. I'm just thankful we have many resource we can use for self studies.
Norman Dela Cruz
@dcnr
Feb 17 2016 05:02
This message was deleted
Dinara Demi
@Gezehus
Feb 17 2016 05:03
@DiDzHey Thank you very much!
CamperBot
@camperbot
Feb 17 2016 05:03
gezehus sends brownie points to @didzhey :sparkles: :thumbsup: :sparkles:
:star: 256 | @didzhey | http://www.freecodecamp.com/didzhey
SuhasHosamani
@SuhasHosamani
Feb 17 2016 05:20
function mutation(arr) {
for(i=0;i<arr.length;i++){

if(arr[i].indexOf(arr[i+1])){
return true;
}else{
return false;
}

}

}

mutation(["hello", "neo"]);
this function is not returning false
whats wrong in this??
Norman Dela Cruz
@dcnr
Feb 17 2016 05:23
damn latex I finally got it! @jerlich97 lolol
${lcm}(a,b)=\left(\frac{|a|}{{gcd}(a,b)}\right)\cdot |b|=\left(\frac{|b|}{{gcd}(a,b)}\right)\cdot |a|.$
steve
@davidsonsteve
Feb 17 2016 05:24
@SuhasHosamani i'm no pro but what is that if statement being tested against?
Nikolajs Korolkovs
@NickEU
Feb 17 2016 05:24
@SuhasHosamani you have to check the individual letters of the second string.. and you are checking the whole string.. once :P
@davidsonsteve that too ;) indexOf() returns -1 if something is not found, which evaluates to true when converted to boolean... if it returns 0, which means it found the element u're looking for and it's at index 0 it will evaluate to false and the else statement will be executed @SuhasHosamani
Fayheim
@Fayheim
Feb 17 2016 05:29
hi
// Example
var ourArray = [1,2,3];
ourArray[1] = 3; // ourArray now equals [1,3,3].

// Setup
var myArray = [1,2,3];

// Only change code below this line.
var myArray = [3,2,3];
"You should be using correct index to modify the value in myArray.
"
the error im getting
Nikolajs Korolkovs
@NickEU
Feb 17 2016 05:31
@Fayheim take a good look at the example and read the description again ;) what u're doing is creating a new array twice basically... what you need to do is modify an existing array that was created in the setup line for you ;)
by accessing the n-th element of that array with a bracket notation and assigning a new value to that element
Fayheim
@Fayheim
Feb 17 2016 05:32
Allright
I'll try
Nikolajs Korolkovs
@NickEU
Feb 17 2016 05:34
@Fayheim you will NOT TRY... you will succeed and ace the fing challenge like a pro!
Unnikrishnan
@ukpa
Feb 17 2016 05:35
how does this "add(2)(3)" function call works?
bitgrower
@bitgrower
Feb 17 2016 05:36
you doing arguments optional @ukpa ?
Unnikrishnan
@ukpa
Feb 17 2016 05:36
yeah
bitgrower
@bitgrower
Feb 17 2016 05:37
@jerlich97 -- you still around ?
Nikolajs Korolkovs
@NickEU
Feb 17 2016 05:37
@ukpa if you're serious about learning javascript take a while and read/google all you can on closures = it's a very important and powerful concept = lots of good info there
bitgrower
@bitgrower
Feb 17 2016 05:37
to be honest, I don't really know ... what is that test case supposed to do ?
Unnikrishnan
@ukpa
Feb 17 2016 05:37
okay, i will do that :)
but i just wanted to know how these kind of function works
bitgrower
@bitgrower
Feb 17 2016 05:38
there's a udemy course js the weird parts -- you can pick it up for $10 with one of the ever-frequent udemy coupons ... it's a very good course -- you can watch the 1st 3.5 hours yt - he covers closures pretty well, as I recall ... JackeL @jackel27 Feb 17 2016 05:39 CodeAcademy covers some good JS Nikolajs Korolkovs @NickEU Feb 17 2016 05:39 @ukpa https://www.udacity.com/course/progress#!/c-ud015 pretty good video explanation of closures with visual illustration in this course and it's free, you can start there... or just read a few articles = there are a ton of them Unnikrishnan @ukpa Feb 17 2016 05:39 Okay, thanks a ton mate for all the help. I will do that :) bitgrower @bitgrower Feb 17 2016 05:39 @ukpa -- yeah ... don't have a free resource handy -- I don't recall if the guy covers clossures in the first 3.5 hours ... but I"m not the only one who likes it ... javascript resources help javascript resources CamperBot @camperbot Feb 17 2016 05:40 no wiki entry for: javascript resources bitgrower @bitgrower Feb 17 2016 05:40 help js resources CamperBot @camperbot Feb 17 2016 05:40 ## :point_right: js resources [wiki] ### Tutorials ### References Find javascript libraries at http://jster.net See Also: :loop: Quick JS | :watch: Challenges | :wrench: Exercises | :clipboard: Editors | :newspaper: Blogs | :books: Books Nikolajs Korolkovs @NickEU Feb 17 2016 05:40 i have found that watching/reading about the same concept from a few different sources and seeing it explained in different styles from different angles is the only thing that will let the stuff sink in very well ;) and obviously = practice ;) but it's kinda hard to practice things like that unless you understand wtf is going on Jineen Williams @jineen22 Feb 17 2016 05:40 I'm working on this challenge. http://www.freecodecamp.com/challenges/concatenating-strings-with-the-plus-equals-operator Here is my code. What is wrong?  // Example var ourStr = "I come first. "; ourStr += "I come second."; // Only change code below this line var myStr= ("This is the first sentence. "); myStr += ("This is the second sentence."); bitgrower @bitgrower Feb 17 2016 05:40 yup -- definitely ... Jineen Williams @jineen22 Feb 17 2016 05:40 // Example var ourStr = "I come first. "; ourStr += "I come second."; // Only change code below this line var myStr= ("This is the first sentence. "); myStr += ("This is the second sentence."); bitgrower @bitgrower Feb 17 2016 05:41 umm ... can you paste ALL of the code, please ? JackeL @jackel27 Feb 17 2016 05:41 @jineen22 What is your challenge? Nikolajs Korolkovs @NickEU Feb 17 2016 05:41 @jineen22 parenthesis are evil in this particular case at least :P bitgrower @bitgrower Feb 17 2016 05:41 hahahaha @NickEU Unnikrishnan @ukpa Feb 17 2016 05:41 @jineen22 don't use parenthesis JackeL @jackel27 Feb 17 2016 05:42 just finished AngularJS and wow. tough stuff Stephen Rawson @stephenrawson Feb 17 2016 05:45 Little lost on record collection, you are given id, prop and value, if value is non-blank and prop is not "tracks" then update or set the value for the prop? JackeL @jackel27 Feb 17 2016 05:47 @stephenrawson can you paste the details? Stephen Rawson @stephenrawson Feb 17 2016 05:47 You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information. Write a function which takes an id, a property (prop), and a value. For the given id in collection: If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop. If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array. If value is blank, delete that prop. Always return the entire collection object. @jackel27 , should I include the code for the question? JackeL @jackel27 Feb 17 2016 05:49 okay, so basically, create a function (id,prop,value){ for this.id.. if (value condition).... if (prop condition).... I am guessing you itterate through the id and check prop and values.. function to itterate through an array. @stephenrawson sure Stephen Rawson @stephenrawson Feb 17 2016 05:52 var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function update(id, prop, value) { if (value !== "") { if (prop !== "tracks") { collection.id.value = prop; } else { collection. } } return collection; } Carlos Leonard @gutty333 Feb 17 2016 05:54 hello everyone had some question regarding this function. I looked at the statements I cannot wrap my head around what the issue is: for (var x = 0; x < contacts.length; x++) { if (contacts[x].firstName != firstName) { return "No such contact"; } else if (!(contacts[x].hasOwnProperty([prop]))) { return "No such property"; } else if (contacts[x].firstName == firstName && contacts[x].hasOwnProperty([prop])) { return contacts[x][prop]; } } Stephen Rawson @stephenrawson Feb 17 2016 05:54 @jackel27 first time using the Help Chat, i'm not to sure how to format the code in the black box... Carlos Leonard @gutty333 Feb 17 2016 05:55 the challenge is saying that the issue is with the last condition, but to my eye things look good JackeL @jackel27 Feb 17 2016 05:55 explain format @stephenrawson CamperBot @camperbot Feb 17 2016 05:55 ## :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 bitgrower @bitgrower decides to use bigdata to determine the most frequently asked about challenges .... Profile Lookup has got to be among the top ... Jineen Williams @jineen22 Feb 17 2016 05:55 @NickEU @ukpa Thank you! CamperBot @camperbot Feb 17 2016 05:55 jineen22 sends brownie points to @nickeu and @ukpa :sparkles: :thumbsup: :sparkles: :star: 371 | @nickeu | http://www.freecodecamp.com/nickeu :star: 299 | @ukpa | http://www.freecodecamp.com/ukpa Stephen Rawson @stephenrawson Feb 17 2016 05:55 @jackel27 Thanks!!! Carlos Leonard @gutty333 Feb 17 2016 05:56 any ideas? bitgrower @bitgrower Feb 17 2016 05:56 yes, @gutty333 it's like this .... JackeL @jackel27 Feb 17 2016 05:57 @stephenrawson basically, I believe you are to iterate through the array, if the track does not exist, add it to the array. possibly going through a for loop as @gutty333 did bitgrower @bitgrower Feb 17 2016 05:57 if you have 20 marbles in a bag, how many do you have to look at before you know there are no black marbles in the bag (not a trick question ... this is designed to provide insight into the problem...) Carlos Leonard @gutty333 Feb 17 2016 05:58 20, search through all ? bitgrower @bitgrower Feb 17 2016 05:58 bingo!!!! you can't return with no contact found until you search 'em all ... JackeL @jackel27 Feb 17 2016 06:00 @stephenrawson what challenge is that called? Carlos Leonard @gutty333 Feb 17 2016 06:00 ok yeah I got, but that is odd it should have worked this way also. basically I had it as do a linear search if you find this or do that do this action Stephen Rawson @stephenrawson Feb 17 2016 06:00 @jackel27 its called Record Collection JackeL @jackel27 Feb 17 2016 06:00 @stephenrawson ok, let me check it out, one sec Stephen Rawson @stephenrawson Feb 17 2016 06:00 @jackel27 Thanks for taking a look CamperBot @camperbot Feb 17 2016 06:00 stephenrawson sends brownie points to @jackel27 :sparkles: :thumbsup: :sparkles: :star: 316 | @jackel27 | http://www.freecodecamp.com/jackel27 bitgrower @bitgrower Feb 17 2016 06:01 what is the problem you are having with it, @stephenrawson ? and did you post it formatted ? dang it, I can't pull up my solution atm ... Stephen Rawson @stephenrawson Feb 17 2016 06:03 @bitgrower i'm working on Record Collection...I haven't posted it formatted yet....I'll try to post it now. JackeL @jackel27 Feb 17 2016 06:03 @stephenrawson for the first instruction: If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop. You were close on your first line, but remember, you can also use the && operator @stephenrawson so something like this... if(value !== "" && prop !== "tracks"){ ...... } for the instruction states: If value is non-blank (value !== "") and prop is not "tracks" Keyword AND bitgrower @bitgrower Feb 17 2016 06:06 hmm ... you sure that doesn't mess up the subsequent else ? Stephen Rawson @stephenrawson Feb 17 2016 06:06 @jackel27 gotcha, then else if value !=="" && prop ==="tracks" bitgrower @bitgrower Feb 17 2016 06:07 This message was deleted oops sorry misread yeah, easier to just test the value !== "" just once ... JackeL @jackel27 Feb 17 2016 06:07 @stephenrawson also,,  collection.id.value = prop; instead of using dot notation use : collection[id][value] = prop; But that line is also wrong, well.. should not equal prop ;) Carlos Leonard @gutty333 Feb 17 2016 06:08 @bitgrower I am still a little apprehensive over this for (var x = 0; x < contacts.length; x++) { if (contacts[x].firstName != firstName) { return "No such contact"; } else if (!(contacts[x].hasOwnProperty([prop]))) { return "No such property"; } else if (contacts[x].firstName == firstName && contacts[x].hasOwnProperty([prop])) { return contacts[x][prop]; } } isn't the for loop doing exactly that searching through everything and if it meets the conditions it return the correct statement? JackeL @jackel27 Feb 17 2016 06:10 @stephenrawson then update or set the value for the prop. Stephen Rawson @stephenrawson Feb 17 2016 06:11 @jackel27 okay, so bracket notation for access...i'm setting prop = value? JackeL @jackel27 Feb 17 2016 06:12 @stephenrawson correct. collection[id][prop] = value; Markus Kiili @Masd925 Feb 17 2016 06:12 @gutty333 Your loop is going over all the contacts. Return no such contact must come after you have checked all the contacts. Stephen Rawson @stephenrawson Feb 17 2016 06:13 @jackel27 Gotcha, man-oh-man! Thanks!! It makes a lot of sense now!! CamperBot @camperbot Feb 17 2016 06:13 stephenrawson sends brownie points to @jackel27 :sparkles: :thumbsup: :sparkles: :warning: stephenrawson already gave jackel27 points JackeL @jackel27 Feb 17 2016 06:14 @stephenrawson no prob! when you get to the push part, it should be quite similar but with push() involved. bitgrower @bitgrower Feb 17 2016 06:14 @gutty333 -- what happens to the first member of the array it checks and finds that the contact isn't that one ... ? it returns ... can't iterate after it returns JackeL @jackel27 Feb 17 2016 06:14 @stephenrawson nice to help a fellow WA resident :) Carlos Leonard @gutty333 Feb 17 2016 06:15 I understand, but for example one of the test is "Kristian", "lastName" should return "Vos" oh nevermind I get it, even though is in the list, is checking a different index of the array bitgrower @bitgrower Feb 17 2016 06:16 forget the order ... forget the contents ... you have a bag of marbles, and the first time you found a non-black marble, you've returned and said there were no black marbles found SuhasHosamani @SuhasHosamani Feb 17 2016 06:17 @davidsonsteve @NickEU should i have one more for loop to check for each letter?? bitgrower @bitgrower Feb 17 2016 06:17 you have to go thru EVERY element of your array to say that the contact does not exist ... as @Masd925 said early -- you have to do this AFTER you've gone thru your for loop Carlos Leonard @gutty333 Feb 17 2016 06:23 ok got it working, thank you bitgrower @bitgrower Feb 17 2016 06:25 YAY!!!! happy coding ... @gutty333 and now that you have it working, @gutty333 -- do you understand WHY ? bitgrower @bitgrower Feb 17 2016 06:32 :point_up: February 16, 2016 9:23 PM too rad, @dcnr ... LaTex ... Ankit Panwar @coderNoob Feb 17 2016 06:41 @dcnr My reset button only works in DevTools mode. Why? http://codepen.io/coderNoob/pen/vLmyWN?editors=1010 Norman Dela Cruz @dcnr Feb 17 2016 06:42 @bitgrower it's pretty cool! $E=mc^{2}$ kirbyedy @kirbyedy Feb 17 2016 06:43 morning Norman Dela Cruz @dcnr Feb 17 2016 06:46 @coderNoob hi sorry I haven't really work on that end :( Stephen Rawson @stephenrawson Feb 17 2016 06:50 @jackel27 made it through that challenge and few more! Go team WA! Stanley @stanleyyylau Feb 17 2016 06:55 hi everyone <div class="test"><a>click</a></div> can i add some JS code, so when clicked, an alert box show up the html is here  <div class="test"><a>click</a></div>  but can't change the html can anyone help? Stanley @stanleyyylau Feb 17 2016 06:59 @kirbyedy no, i can't change the html kirbyedy @kirbyedy Feb 17 2016 07:01 I am afraid I dont understand your problem then Trevor @zicameau Feb 17 2016 07:02 This message was deleted Stanley @stanleyyylau Feb 17 2016 07:02 it's a real life situation, i can't change the html, i can only add JS to trigger an click function. because the html is genereated by wordpress Trevor @zicameau Feb 17 2016 07:04 This message was deleted CamperBot @camperbot Feb 17 2016 07:04 :bulb: to format code use backticks!  more info bitgrower @bitgrower Feb 17 2016 07:05 @bitgrower it's pretty cool! $E=mc^{2}$ Trevor @zicameau Feb 17 2016 07:05 If someone could help me with this, it would be most appreciated. I need to access the second tree type which is pine. // Setup var myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ]; // Only change code below this line var secondTree = myPlants.type.list[1]; // Change this line bitgrower @bitgrower Feb 17 2016 07:06 okay ... @zicameau -- what kind of data structure are you looking at ? what is myPlants ? is it a number? a function? an object? an array? what ? Trevor @zicameau Feb 17 2016 07:07 Well it's a JSON object with two types of type objects which are trees and flowers bitgrower @bitgrower Feb 17 2016 07:08 is it? what's that first character after the = sign ? Trevor @zicameau Feb 17 2016 07:08 oh it's an array bitgrower @bitgrower Feb 17 2016 07:08 :) bingo!!! an array of ? Trevor @zicameau Feb 17 2016 07:09 an array of objects? and thanks! bitgrower @bitgrower Feb 17 2016 07:10 yes, an array of objects ... :) Trevor @zicameau Feb 17 2016 07:10 Thanks a bunch man, much appreciated! bitgrower @bitgrower Feb 17 2016 07:10 whenever you are handed a data structure ... just walk it down and see what it is ... woman ... but your thanks are welcomed ... right, @camperbot ? CamperBot @camperbot Feb 17 2016 07:10 bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles: :star: 1202 | @camperbot | http://www.freecodecamp.com/camperbot Abhishek Kumar @abhishekKumar1 Feb 17 2016 07:11 wow you can send brownie points to camperbot nice thanks @camperbot CamperBot @camperbot Feb 17 2016 07:11 abhishekkumar1 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles: :star: 1203 | @camperbot | http://www.freecodecamp.com/camperbot bitgrower @bitgrower thanks @dcnr for cool LaTex stuff ... Trevor @zicameau Feb 17 2016 07:11 thanks @bitgrower CamperBot @camperbot Feb 17 2016 07:11 zicameau sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :star: 549 | @bitgrower | http://www.freecodecamp.com/bitgrower bitgrower @bitgrower Feb 17 2016 07:12 yw, @zicameau -- happy coding .... :) kirbyedy @kirbyedy Feb 17 2016 07:12 @bitgrower you are not working on the ziplines ? bitgrower @bitgrower Feb 17 2016 07:13 yeah, I am ... taking a break ... I fell down a bootstrap/css/css animations hole ... decided my brain needed some rest ... looking for interesting things to spice up my pages ... eye candy, baby .... :) digging into arcana like what colors go with what ... what are some cool fonts, etc ... how about you, @kirbyedy ? kirbyedy @kirbyedy Feb 17 2016 07:14 fck stuck with wikipedia I have to take a break bitgrower @bitgrower Feb 17 2016 07:15 sorry :( ... you tried the frontend room ... kirbyedy @kirbyedy Feb 17 2016 07:15 it will wait a bit, because once I start waking up with a headache, I know I have to stop bitgrower @bitgrower Feb 17 2016 07:16 time to take a break -- get some sunshine, take a walk, go outside ... or do something like I did ... stumbled over cool css animation stuff ... LOL ... yeah ... I'm anxious to get the first 2 ziplines out of the way ... I haven't found the key to opening up bootstrap understanding for my brain yet, though ... I could do it in straight html ... it doesn't actually say you have to make them responsive ... LOL .... ...but it just wouldn't feel right ... LOL ... kirbyedy @kirbyedy Feb 17 2016 07:19 :) bitgrower @bitgrower Feb 17 2016 07:21 create a link to an outside website ... in my sleep ... someone gave me a resource to checkout on bootstrap -- I think a little bit is seeping in, we shall see ... they did a good thing moving those first two ziplines ahead of js ... kirbyedy @kirbyedy Feb 17 2016 07:25 ah I see it now lots of ooops something went wrong so tribute page and portfolio is now first two ziplines and calculator and pomodoro are pushed to the end bitgrower @bitgrower Feb 17 2016 07:28 yeah ... people get into the algos and forget the html/jquery/bootstrap/css they just learned ... Wes @weslez Feb 17 2016 07:30 This message was deleted Hello friends, quick question on my Profile Lookup challenge. Is it possible to use a While Loop to solve this challenge? If not, can you help me understand the reason why not? And why the For Loop is the proper one? In my mind right now the two Loop types seem interchangeable in this challenge, with the While Loop just slightly more streamlined. //Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUp(firstName, prop){ // Only change code below this line i = 0; while (contacts[i].firstName !== firstName) { i++; return"No such contact"; } while (contacts[i].prop === "") { i++; return "No such property"; } while (contacts[i].firstName === firstName && prop !== "") { i++; return contacts[i].prop; } //contacts.firstName[0]; // Only change code above this line } // Change these values to test your function lookUp("Kristian", "lastName"); bitgrower @bitgrower Feb 17 2016 07:32 yes, you need a loop Mannu Gupta @theparadoxer02 Feb 17 2016 07:33 Encode the following sequence, separated by spaces: backslash tab tab carriage-return new-line and assign it to myStr bitgrower @bitgrower Feb 17 2016 07:33 easier to find when you've iterated thru all the objects ... is why you use a for loop Anita Leung @anitaleung Feb 17 2016 07:33 I'm stuck on the same problem as well! bitgrower @bitgrower Feb 17 2016 07:33 explain format CamperBot @camperbot Feb 17 2016 07:33 ## :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 bitgrower @bitgrower Feb 17 2016 07:33 follow @camperbot's instructions and post your code, please ... :) Mannu Gupta @theparadoxer02 Feb 17 2016 07:33 Encode the following sequence, separated by spaces: backslash tab tab carriage-return new-line and assign it to myStr stuck here Wes @weslez Feb 17 2016 07:34 @bitgrower Were you responding to me? bitgrower @bitgrower Feb 17 2016 07:34 LOL, no @weslez -- scroll up ... or ... you mean about loops -- yep -- that was for you ... yes that problem needs a loop, and the reason you need a for loop is you need to iterate thru all the objects ... Anita Leung @anitaleung Feb 17 2016 07:35 This is my code I have so far, but I got an error. function lookUp(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if (contacts[i].firstName === firstName) { if (contacts[i].hasProperty(prop)) { return contacts[i][prop]; } else { return "No such property"; } } return "No such contact"; } // Only change code above this line } The error I got had something to do with the .hasProperty() method bitgrower @bitgrower Feb 17 2016 07:37 that's because it's hasOwnProperty() Abhishek Kumar @abhishekKumar1 Feb 17 2016 07:37 @anitaleung try hasOwnProperty() bitgrower @bitgrower Feb 17 2016 07:38 the reason it's hasOwnProperty is because objects have something called a prototype chain which can come up with additional properties ... you want to know if this instance of the object has this property ... Anita Leung @anitaleung Feb 17 2016 07:41 Oh awesome! Thanks @bitgrower and @abhishekKumar1 ! Unfortunately it's still not satisfying all the conditions.. CamperBot @camperbot Feb 17 2016 07:41 anitaleung sends brownie points to @bitgrower and @abhishekkumar1 :sparkles: :thumbsup: :sparkles: :star: 550 | @bitgrower | http://www.freecodecamp.com/bitgrower :star: 340 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1 bitgrower @bitgrower Feb 17 2016 07:41 nope it's not ... @anitaleung -- think about this ... if you have 10 marbles in a bag, how many marbles do you have to look at to know that there are no black marbles in the bag ? (this is NOT a brain teaser...the answer should be obvious. I asked, because it's a similar problem...) Anita Leung @anitaleung Feb 17 2016 07:46 does it not iterate through all the objects in contacts by using contacts.length ? bitgrower @bitgrower Feb 17 2016 07:47 not if you return early ... you are basically looking at the first object and if it doesn't match your contact, returning ... you haven't looked at the rest of the array ... greg @wearenotgroot Feb 17 2016 07:47 Anita Leung @anitaleung Feb 17 2016 08:16 Okay I finally got it by moving around the return statements and using a boolean flag. Please let me know if there was an easier way to do this! Thanks @bitgrower and @wearenotgroot function lookUp(firstName, prop){ // Only change code below this line var hasContact = false; for (var i = 0; i < contacts.length; i++) { if (contacts[i].firstName === firstName) { hasContact = true; if (contacts[i].hasOwnProperty(prop)) { return contacts[i][prop]; } } } if (hasContact) { return "No such property"; } return "No such contact"; // Only change code above this line } CamperBot @camperbot Feb 17 2016 08:16 anitaleung sends brownie points to @bitgrower and @wearenotgroot :sparkles: :thumbsup: :sparkles: :warning: anitaleung already gave bitgrower points :star: 874 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot greg @wearenotgroot Feb 17 2016 08:17 @anitaleung the second if statement just needed an else chaitanya ashtekar @chaitanyaashtekar Feb 17 2016 08:17 @wearenotgroot i can see on;y 3 projects in basic front end projrcts.has something changed ?? greg @wearenotgroot Feb 17 2016 08:18 @anitaleung  if (contacts[i].hasOwnProperty(prop)) { return contacts[i][prop]; } else { return "No such property"; } @chaitanyaashtekar they been move @chaitanyaashtekar basic and intermediate Mateus Felipe C. C. Pinto @mateusfccp Feb 17 2016 08:18 @anitaleung function update(id, prop, value) { if(value !== "") { if(prop != 'tracks') { collection[id][prop] = value; } else { collection[id].tracks.push(value); } } else { console.log('deleting'); delete collection[id][prop]; } return collection; } greg @wearenotgroot Feb 17 2016 08:18 @chaitanyaashtekar but they are there chaitanya ashtekar @chaitanyaashtekar Feb 17 2016 08:19 @wearenotgroot ok.and what about the projects that were already present in intermediate and advanced ?? @wearenotgroot ok greg @wearenotgroot Feb 17 2016 08:20 @chaitanyaashtekar the name of the catergory is Basic front end and advanced Front end bitgrower @bitgrower Feb 17 2016 08:20 @chaitanyaashtekar -- they are mostly all still there ... greg @wearenotgroot Feb 17 2016 08:20 @chaitanyaashtekar the only thing that was remove was camper news i think bitgrower @bitgrower Feb 17 2016 08:20 they removed one and added the "tribute" challenge ... right, @wearenotgroot chaitanya ashtekar @chaitanyaashtekar Feb 17 2016 08:21 @wearenotgroot @bitgrower ok.thanks.and nothing else was removed ? where can i find about the changes made in github,wiki ?? thanks CamperBot @camperbot Feb 17 2016 08:21 chaitanyaashtekar sends brownie points to @wearenotgroot and @bitgrower :sparkles: :thumbsup: :sparkles: :star: 551 | @bitgrower | http://www.freecodecamp.com/bitgrower :star: 875 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot Anita Leung @anitaleung Feb 17 2016 08:22 @wearenotgroot okay makes sense, I thought I leaving the return "No such property" inside the for loop would stop the code prematurely, but it makes sense that there should only be one match to a firstName. @mateusfccp I'm on a different problem :) greg @wearenotgroot Feb 17 2016 08:23 @anitaleung well it is inside the first if that test the firstName so you know the contact exist @chaitanyaashtekar trying to find the post :smile: chaitanya ashtekar @chaitanyaashtekar Feb 17 2016 08:24 @wearenotgroot tell me if you find any :smile: @wearenotgroot ok chaitanya ashtekar @chaitanyaashtekar Feb 17 2016 08:28 @wearenotgroot thanks CamperBot @camperbot Feb 17 2016 08:28 chaitanyaashtekar sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles: :warning: chaitanyaashtekar already gave wearenotgroot points Yinka Adesesan @yadesesan Feb 17 2016 08:32 Hello guys. I need a little help here Markus Kiili @Masd925 Feb 17 2016 08:34 @yadesesan Hi. Just post your question and someone usually helps. Yinka Adesesan @yadesesan Feb 17 2016 08:36 Ok how do you return the number that was removed? Abhishek Kumar @abhishekKumar1 Feb 17 2016 08:37 help .shift CamperBot @camperbot Feb 17 2016 08:37 ## :point_right: challenge manipulate arrays with shift() [wiki] # Manipulate Arrays With shift() shift() removes the first element unlike pop() which removes the last. Abhishek Kumar @abhishekKumar1 Feb 17 2016 08:37 try this @yadesesan Yinka Adesesan @yadesesan Feb 17 2016 08:39 Thanks @abhishekKumar1 CamperBot @camperbot Feb 17 2016 08:39 yadesesan sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles: :star: 341 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1 Manan Kalra @manankalra Feb 17 2016 08:58 need help! // Setup var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if(myObj.hasOwnProperty("checkProp")){ return myObj.checkProp; } else{ return "Not Found"; } } // Test your code by modifying these values checkObj("gift"); Abhishek Kumar @abhishekKumar1 Feb 17 2016 08:59 remove the "" from checkProp and try Elior Boukhobza @mallowigi Feb 17 2016 09:00 you are passing checkProp, which is a string, yet you are wrapping it in quotes Manan Kalra @manankalra Feb 17 2016 09:00 tried! doesn't work! Elior Boukhobza @mallowigi Feb 17 2016 09:00 besides, when you are calling myObj.checkProp, you are asking for the property called "checkProp" you need to use brackets Aleksander Gębicki @Takumar Feb 17 2016 09:01 @mananKalra checkProp is a variable which contains string which is name of property, that is why you have to treat it in special way, not like name of property. You should use bracket notation for accessing its value as @mallowigi said. myObj[checkProp]; Manan Kalra @manankalra Feb 17 2016 09:04 Got it! Thank you @Takumar @mallowigi @abhishekKumar1 CamperBot @camperbot Feb 17 2016 09:04 manankalra sends brownie points to @takumar and @mallowigi and @abhishekkumar1 :sparkles: :thumbsup: :sparkles: :star: 56 | @mallowigi | http://www.freecodecamp.com/mallowigi :star: 2331 | @takumar | http://www.freecodecamp.com/takumar :star: 342 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1 Aleksander Gębicki @Takumar Feb 17 2016 09:04 @mananKalra you are welcome :-) Manan Kalra @manankalra Feb 17 2016 09:05 One more thing, when the object myObj is declared, shouldn't the propert names like gift, pet etc. be enclosed within quotes? Vick003 @Vick003 Feb 17 2016 09:07 @mananKalra they don't have to be but it's recommended that you do... to my knowledge Manan Kalra @manankalra Feb 17 2016 09:09 Alright! @Vick003 Pedro Abel Díaz Sánchez @coderHook Feb 17 2016 09:20 @Abel1987 Does somebody know why I am getting my string inversed in the calculator text-box? If I set this outside the text box, in a div for instance it shows it the correct way. http://codepen.io/DiazPedroAbel/pen/pgRXWv?editors=1010 Someone (I cannot remember who and I cannot see previous mentions :S) told me that I have to treat op similar way as current, but I don't see how to do it, in fact, I thought I was treating both similar way by adding them to the string. eval() works perfect so... Russell Wheatley @russellwheatley Feb 17 2016 09:26 Hey everybody, I'm currently trying to get the geolocation as part of the local weather task (zipline). I'm using the jQuery get method, and I've tried ---> http://ipinfo.io and ---> https://freegeoip.net/json/ . The problem is, they're only able to get the location of my country (United Kingdom) and not the name of my city (Liverpool), this is a problem because it's supposed to be local weather! Does anyone have any recommendations for another server? Thanks :) Edw. Yew @Edwyew Feb 17 2016 09:37 /// Dulshani Gunawardhana @dshgna Feb 17 2016 10:07 @Rusticman: Use the built-in navigator function http://www.freecodecamp.com/challenges/get-geolocation-data Nick Svanidze @nikasvan Feb 17 2016 10:07 Hi guys, is something wrong with return Math.random();? Shouldn't it return decimal? Generate Random Fractions with JavaScript Dulshani Gunawardhana @dshgna Feb 17 2016 10:11 @nikasvan yes it should. What is your output? Vamsidhar Reddy Bada @vamsidharBada Feb 17 2016 10:13 @nikasvan It should return decimal. Nothing is wrong with return Math.random(); in the exercise . Nick Svanidze @nikasvan Feb 17 2016 10:13 Whoaa, it works now ) It returned 0 for some reason but I just opened it in new tab and seems to work now. Strange) Vamsidhar Reddy Bada @vamsidharBada Feb 17 2016 10:14 @nikasvan Cool :) Dulshani Gunawardhana @dshgna Feb 17 2016 10:14 @nikasvan great Abhishek Kumar @abhishekKumar1 Feb 17 2016 10:14 0 is inclusive in the result so it can return 0 Vamsidhar Reddy Bada @vamsidharBada Feb 17 2016 10:15 @nikasvan as @abhishekKumar1 mentioned, Math.random() returns a random number from 0 (inclusive) up to but not including 1 (exclusive). Nick Svanidze @nikasvan Feb 17 2016 10:18 Ahaa, thanks so that there was a reasoning behind the 0. Tricky 0 got me again DOH! Mohamed Hamza @mohamedhamza1995 Feb 17 2016 10:49 function multiplyAll(arr) { var product = 1; // Only change code below this line for(var i = 0 ; i <arr.length;i++ ){ for(var j = 0 ; j < arr.length;j++){ product*=arr[i][j]; } } // Only change code above this line return product; } // Modify values below to test your code multiplyAll([[1,2],[3,4],[5,6,7]]); how can I multiply each array with the product in the for loop in this code? Abhishek Kumar @abhishekKumar1 Feb 17 2016 10:50 in second loop try j<arr[i].length Yuvraj Adagale @Yuvraj1989 Feb 17 2016 10:58 @mohamedhamza1995 you should loop j variable according i.... Mia Giovanetti @miagiovanetti Feb 17 2016 10:59 hi, can someone help me with my code? The instructions are to retrive the second tree from the variable myPlants using object dot and array bracket notation.. // Setup var myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ]; // Only change code below this line var secondTree = myPlants.trees.list[1]; // Change this line when i put trees or list in bracket notation, i get a prompt saying that both are better in dot notation Abhishek Kumar @abhishekKumar1 Feb 17 2016 11:01 @miagiovanetti think it through myPlants is an array so you can't access it using .trees correct it and you will get the answer use like you used to find pine from list which is also an array Mia Giovanetti @miagiovanetti Feb 17 2016 11:03 thanks @abhishekKumar1 , im giving it a try right now! CamperBot @camperbot Feb 17 2016 11:03 miagiovanetti sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles: :star: 343 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1 Mohamed Hamza @mohamedhamza1995 Feb 17 2016 11:05 @Yuvraj1989 @abhishekKumar1 thanks alot! CamperBot @camperbot Feb 17 2016 11:05 mohamedhamza1995 sends brownie points to @yuvraj1989 and @abhishekkumar1 :sparkles: :thumbsup: :sparkles: :star: 250 | @yuvraj1989 | http://www.freecodecamp.com/yuvraj1989 :star: 344 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1 Mia Giovanetti @miagiovanetti Feb 17 2016 11:06 @abhishekKumar1 i got it now, thank you!! Robert Uivarosi @URobert Feb 17 2016 11:19 @h4r1m4u Thanks CamperBot @camperbot Feb 17 2016 11:19 urobert sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles: :star: 1423 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u T N Surender @tnsurender Feb 17 2016 12:24 Hi Guys, Stuck in exercise 223 // Setup var myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ]; // Only change code below this line var secondTree = myPlants.trees1; // Change this line This is the question : Retrieve the second tree from the variable myPlants using object dot and array bracket notation. Codemzy @codemzy Feb 17 2016 12:26 @tnsurender try var secondTree = myPlants[1].list[1]; T N Surender @tnsurender Feb 17 2016 12:27 @codemzy thanks alot CamperBot @camperbot Feb 17 2016 12:27 tnsurender sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles: :star: 611 | @codemzy | http://www.freecodecamp.com/codemzy T N Surender @tnsurender Feb 17 2016 12:27 it worked Codemzy @codemzy Feb 17 2016 12:27 @tnsurender myPlants is an array and both 'flowers' and 'trees' are objects, but also elements of the array, so you can access 'trees' as the second object with myPlants[1] @tnsurender then you use dot notation to get list, and then get the second item from list (which is also an array) with [1] ... hope that makes sense to you how I got the answer? T N Surender @tnsurender Feb 17 2016 12:28 @codemzy Ya it makes sense now ... @codemzy It like accessing a multidimensional array... Codemzy @codemzy Feb 17 2016 12:29 @tnsurender :thumbsup: anthonygallina1 @anthonygallina1 Feb 17 2016 12:32 @codemzy :) :point_up: Codemzy @codemzy Feb 17 2016 12:33 @anthonygallina1 :wave: edwardmyung @edwardmyung Feb 17 2016 12:57 For a function which takes a queue, adds item on end, and removes + returns first item - is there a problem with the following: function queue(arr, item) { arr = arr.push(item); var x = arr.shift(); return x; } I'm getting "arr.shift is not a function" CorwinHicks @CorwinHicks Feb 17 2016 12:57 Hi i am having a hard time understanding setters and getters for Javascript. Russell Wheatley @russellwheatley Feb 17 2016 12:57 @dshgna thanks for the heads-up regarding geo location :) CamperBot @camperbot Feb 17 2016 12:57 rusticman sends brownie points to @dshgna :sparkles: :thumbsup: :sparkles: :star: 144 | @dshgna | http://www.freecodecamp.com/dshgna Codemzy @codemzy Feb 17 2016 13:02 @edwardmyung its because here arr = arr.push(item); maybe, you are turning arr into something else... just have arr.push(item);on that line to push the item to the array @edwardmyung as in get rid of the arr = Stanley @stanleyyylau Feb 17 2016 13:04 function diff(arr1, arr2) { var newArr = []; // Same, same; but different. var arr1Length=arr1.length; var arr2Length=arr2.length; var longerArr=[]; var shorterArr=[]; if(arr1Length>arr2Length){ longerArr=arr1; shorterArr=arr2; } else if(arr2Length>arr1Length){ longerArr=arr2; shorterArr=arr1; } var longerArrLength=longerArr.length; if (arr1Length===0){ newArr=arr2; } else if(arr2Length===0){ newArr=arr1; } else{ for (var i=0; i<longerArrLength; i++){ if(shorterArr.indexOf(longerArr[i])<0){ newArr=newArr.push(longerArr[i]); } } } return newArr; } diff([1, 2, 3, 5], [1, 2, 3, 4, 5]); my code don't work can someone help i spend two days still can't figure this out edwardmyung @edwardmyung Feb 17 2016 13:04 @codemzy Makes perfect sense! Thanks! CamperBot @camperbot Feb 17 2016 13:04 edwardmyung sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles: :star: 613 | @codemzy | http://www.freecodecamp.com/codemzy Elior Boukhobza @mallowigi Feb 17 2016 13:06 newArr=newArr.push(longerArr[i]); what's that? Stanley @stanleyyylau Feb 17 2016 13:08 push a value to new array if the longer array has an value that shorter array don't have Elior Boukhobza @mallowigi Feb 17 2016 13:09 so don't assign it, just push push modifies the new array anyway Stanley @stanleyyylau Feb 17 2016 13:10 oh, i thought push only add new value to the end of an array Elior Boukhobza @mallowigi Feb 17 2016 13:10 though i dont know if it is your problem Stanley @stanleyyylau Feb 17 2016 13:11 i pass a few items now i think i negelect the shorter array will also have some value that the longer array don't have have to rewrite the code Elior Boukhobza @mallowigi Feb 17 2016 13:13 what do you need to do ? Stanley @stanleyyylau Feb 17 2016 13:14 loop again i think thanks @mallowigi CamperBot @camperbot Feb 17 2016 13:14 stanleyyylau sends brownie points to @mallowigi :sparkles: :thumbsup: :sparkles: :star: 58 | @mallowigi | http://www.freecodecamp.com/mallowigi Stanley @stanleyyylau Feb 17 2016 13:14 i got it now thanks Elior Boukhobza @mallowigi Feb 17 2016 13:14 i remember this task you need to merge two arrays right ? Fayheim @Fayheim Feb 17 2016 13:19 // Setup var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]]; // Only change code below this line. var myData = myArray [8][8]; Help! how do i get it equal to 8? CamperBot @camperbot Feb 17 2016 13:19 no wiki entry for: how do i get it equal to 8 Fayheim @Fayheim Feb 17 2016 13:19 =.= I really having trouble understanding the instruction Blauelf @Blauelf Feb 17 2016 13:27 @Fayheim You are supposed to find the indexes for which the expression evaluates to 8. So if myArray[1] is [4,5,6], and myArray[1][2] is 6, what would be needed to get a result of 8? Stanley @stanleyyylau Feb 17 2016 13:27 @mallowigi passed now thanks CamperBot @camperbot Feb 17 2016 13:27 stanleyyylau sends brownie points to @mallowigi :sparkles: :thumbsup: :sparkles: :warning: stanleyyylau already gave mallowigi points Daniel Maldonado @danielmdesigns Feb 17 2016 13:41 could someone be so kind to explain why a remainder operator works to check a string vs a number? im confused on why myNum % 1 >= 0 actually knows if my input was a string or a number? Richard Andrews @Whiplash5057 Feb 17 2016 13:41 Gramble Duke @aront1981 Feb 17 2016 13:42 right. so, I've got to 'word blanks' and I don't get where to start? Can anyone give me a little direction please? Richard Andrews @Whiplash5057 Feb 17 2016 13:42 Hey guys ...why is my JS not working need help !! Selvalingam G @selva2389 Feb 17 2016 13:42 // Setup var myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ]; // Only change code below this line var secondTree = myPlants.trees["1"]; can anyone help? J Player @Heyjp Feb 17 2016 13:43 @SelvalingamG myPlants is an array, first step is to make sure you are selecting the right object in the array. Selvalingam G @selva2389 Feb 17 2016 13:43 "second tree from the variable myPlants using object dot and array bracket notation." --> myPlants.List["0"]; also not worked!! Elior Boukhobza @mallowigi Feb 17 2016 13:44 @SelvalingamG please use markdown for pasting code (wrap your code with js ) greg @wearenotgroot Feb 17 2016 13:44 @danielmdesigns well the interpreter will do it's best to test if the variable you gave can be converted into a number @danielmdesigns if it can be then it will perform the operation @danielmdesigns if not then if will say Not a Number or NaN J Player @Heyjp Feb 17 2016 13:45 @SelvalingamG forget objects for a moment - if you were selecting the second item in an array, how would you write it? Selvalingam G @selva2389 Feb 17 2016 13:46 Object.ArrayItemname['index'] -Is it correct? Sebastian @sebous Feb 17 2016 13:46 function abTest(a, b) { // Only change code below this line if (a < 0 or b < 0) { return undefined; } // Only change code above this line return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); } is it ok< ? J Player @Heyjp Feb 17 2016 13:47 if you took away "Object." then yes it would be Daniel Maldonado @danielmdesigns Feb 17 2016 13:47 @wearenotgroot ahhhhh.... duhhh. ok. so a number will produce a number greater than or less than zero. a string will produce NaN J Player @Heyjp Feb 17 2016 13:48 once you have the right item in the array selected, then you can begin to use dot notation afterwards greg @wearenotgroot Feb 17 2016 13:48 @danielmdesigns no Daniel Maldonado @danielmdesigns Feb 17 2016 13:48 i mean greater than or equal to 0 @wearenotgroot greg @wearenotgroot Feb 17 2016 13:48 @danielmdesigns if the number is surrounded by "" or '' the interpreter will see if it can be converted into a number. kirbyedy @kirbyedy Feb 17 2016 13:48 @sebous or ? like that? Selvalingam G @selva2389 Feb 17 2016 13:49 In my case i need to access throught object, right? var 'myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ];' myPlants.list2; - is it ok? greg @wearenotgroot Feb 17 2016 13:49 @danielmdesigns if it cannot be converted then it will give you NaN Sebastian @sebous Feb 17 2016 13:49 @kirbyedy well if A or B is less than 0 then it should just return undefined value Zachary Vacek @zacharyvacek Feb 17 2016 13:50 Hello all, I'm working on the "check for Palindomes" challenge and almost have it working pretty well. But I can't seem to get my replace method to replace undercore characters. If anyone can point me in the right direction I'd appreciate it greatly. function palindrome(str) { //create a newString for later comparison with str //on newString, lower case it, split it, reverse it, join it again, and replace all alphanumeric characters. var newString = str.toLowerCase().split("").reverse().join("").replace(/\_\W/gi, ""); //on original str, lower case it, and replace all alphanumeric characters str = str.toLowerCase().replace(/\_\W/gi, ""); console.log(str); //compare original str with newString if (newString === str) {; console.log(true); } else { console.log(false); } } palindrome("0_0 (: /-\ :) 0-0"); Sebastian @sebous Feb 17 2016 13:50 im not sure what im doing wrong Daniel Maldonado @danielmdesigns Feb 17 2016 13:50 @wearenotgroot sweet. so '2' would return as a num Blauelf @Blauelf Feb 17 2016 13:50 @SelvalingamG The object holding the flowers is myPlants[0], so what is the object holding the trees? J Player @Heyjp Feb 17 2016 13:50 wiki forma CamperBot @camperbot Feb 17 2016 13:50 ## :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 kirbyedy @kirbyedy Feb 17 2016 13:50 OR is wrong there is a sign for that greg @wearenotgroot Feb 17 2016 13:50 @danielmdesigns yep. J Player @Heyjp Feb 17 2016 13:50 wiki format CamperBot @camperbot Feb 17 2016 13:50 ## :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 J Player @Heyjp Feb 17 2016 13:50 oops Sebastian @sebous Feb 17 2016 13:50 @kirbyedy oh i forgot, thanks tou CamperBot @camperbot Feb 17 2016 13:50 sebous sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles: :star: 484 | @kirbyedy | http://www.freecodecamp.com/kirbyedy greg @wearenotgroot Feb 17 2016 13:51 @danielmdesigns just becareful how you do things. if the variable is supposed to be a number then it should be a number Daniel Maldonado @danielmdesigns Feb 17 2016 13:52 @wearenotgroot gotcha! ok... that lil test just did not make sense to me originally - but makes perfectly good sense now. thanks for explaining. ive got like a toddler brain i guess CamperBot @camperbot Feb 17 2016 13:52 danielmdesigns sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles: :star: 882 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot greg @wearenotgroot Feb 17 2016 13:53 @danielmdesigns YW Selvalingam G @selva2389 Feb 17 2016 13:53 @Blauelf Got it :smile: myPlants[1].list[1]; Blauelf @Blauelf Feb 17 2016 13:54 :) Gramble Duke @aront1981 Feb 17 2016 13:58 Never Mind. I over thought the challenge. William @apswak Feb 17 2016 13:59 Anyone got any tips for "Caesars Cipher"? Don't know where to get started greg @wearenotgroot Feb 17 2016 14:00 @kreitzo here ------->http://www.asciitable.com/ William @apswak Feb 17 2016 14:01 Thanks @wearenotgroot , looking now CamperBot @camperbot Feb 17 2016 14:01 kreitzo sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles: :star: 883 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot greg @wearenotgroot Feb 17 2016 14:01 @kreitzo :smile: GL William @apswak Feb 17 2016 14:02 @wearenotgroot this seem slike a big step up from the other challenges, is it? or does it just appear more complicated greg @wearenotgroot Feb 17 2016 14:02 @kreitzo not really @kreitzo just dont overcomplicate thing and you'll be fine Eric @rasliche Feb 17 2016 14:05 Anyone care to PM me their Caesars Cipher solution? I solved it, and I like most of my solution but it feels hacky and I'd like to see someone's solution that actually used the String.getCharAt() methods mentioned. William @apswak Feb 17 2016 14:05 I finished Andrew Egorcev @ttchopper Feb 17 2016 14:07 Hey guys! Is my solution for "Where do i belong" bonfire valid??? function where(arr, num) { // Find my place in this sorted array. return arr.concat(num).sort(function (a, b) { return a - b; }).indexOf(num); } kirbyedy @kirbyedy Feb 17 2016 14:07 @ttchopper does it passes ? Andrew Egorcev @ttchopper Feb 17 2016 14:08 @kirbyedy yeah kirbyedy @kirbyedy Feb 17 2016 14:08 so its valid :) Claudio Roberto Pereira Goncalves @Claudiogoncalves Feb 17 2016 14:08 Nesting For Loops help CamperBot @camperbot Feb 17 2016 14:08 Hi, I'm CamperBot! I can help you in this chatroom :smile: ### Basic Commands: • find TOPIC find all entries about topic. ex: find js • wiki TOPIC show contents of topic page • thanks @username send brownie points to another user • about @username shows info on that user • Algorithm BONFIRENAME info on a Algorithm :speech_balloon: meet CamperBot in this room! Andrew Egorcev @ttchopper Feb 17 2016 14:09 @kirbyedy oki doki))) Claudio Roberto Pereira Goncalves @Claudiogoncalves Feb 17 2016 14:14 help Nesting For Loops CamperBot @camperbot Feb 17 2016 14:14 ## :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 Mateus Felipe C. C. Pinto @mateusfccp Feb 17 2016 14:31 @Claudiogoncalves Você já resolveu teu problema? William @apswak Feb 17 2016 14:40 finally got Ceasars Cipher code to work for all challenges function rot13(str) { return str.replace(/([a-z])/ig, function(hi) { var c = hi.charCodeAt(0); return String.fromCharCode(c >= 97 ? (c + 13 + 26 - 97) % 26 + 97 : (c + 13 + 26 - 65) % 26 + 65); }); } Lê Thành @Luvata Feb 17 2016 14:41 This message was deleted Neeraj Lad @neeraj-lad Feb 17 2016 14:41 @kreitzo wow! that's a bit difficult to read William @apswak Feb 17 2016 14:43 @neeraj-lad a function within a replace function & long ternary operator will never be easy to read ;p Neeraj Lad @neeraj-lad Feb 17 2016 14:44 @kreitzo true :D Sebastian @sebous Feb 17 2016 14:46 @Luvata I'm stuck at the smae point :smile: Blauelf @Blauelf Feb 17 2016 14:46 @Luvata Use parentheses for calling a function: if (myObj.hasOwnProperty(checkProp)) { ... Lê Thành @Luvata Feb 17 2016 14:48 @Blauelf thanks, I thought it was [] :)) CamperBot @camperbot Feb 17 2016 14:48 luvata sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star: 1220 | @blauelf | http://www.freecodecamp.com/blauelf Blauelf @Blauelf Feb 17 2016 14:48 @kreitzo I have about the same function, even though lowercase letters were not required :) Sebastian @sebous Feb 17 2016 14:49 @Blauelf // Setup var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if (myObj.hasOwnProperty(checkProp)) { return myObj.checkProp; } else { return "Not Found"; } } @Blauelf its the same example but still won't work, thank u CamperBot @camperbot Feb 17 2016 14:49 sebous sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :star: 1221 | @blauelf | http://www.freecodecamp.com/blauelf Blauelf @Blauelf Feb 17 2016 14:50 @sebous The return statement will search for property with name "checkProp", not with the name specified by the variable checkProp. Use bracket notation instead. Sebastian @sebous Feb 17 2016 14:50 @Blauelf oh thank you CamperBot @camperbot Feb 17 2016 14:50 sebous sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles: :warning: sebous already gave blauelf points david @pfr-77 Feb 17 2016 14:50 howdee can anyone explain how sorting numerically works sigursiguros @sigursiguros Feb 17 2016 14:51 Hi guys I'm stuck with the drop it algorithm david @pfr-77 Feb 17 2016 14:51 var array = [1, 12, 21, 2]; array.sort(function(a, b) { return a - b; }); i'm not really sure what's going on in it and why it works sigursiguros @sigursiguros Feb 17 2016 14:52 function drop(arr, func) { // Drop them elements. if (arguments === true){ arr.shift(); } return arr; } drop([1, 2, 3], function(n) {return n < 3; }); Moisés Man @moigithub Feb 17 2016 14:52 @kreitzo u can remove the ternary n recheck ur calc david @pfr-77 Feb 17 2016 14:53 actually nevermind I found a thing good luck to y'all John Deegan @JohnDeegs Feb 17 2016 14:58 Hey all, I'm stuck on http://www.freecodecamp.com/challenges/make-object-properties-private and I can't make head nor tail of what they're asking me to do or how I go about it. Could someone explain this concept to me better? Thanks :) Mohanad Hafiz Suliman @moh7afiz90 Feb 17 2016 14:59 hey guys i need help with Moisés Man @moigithub Feb 17 2016 14:59 @JohnDeegs read the examples.. and the comments above... check the keywords... this and var Mohanad Hafiz Suliman @moh7afiz90 Feb 17 2016 14:59 Escape Sequences in Strings Codemzy @codemzy Feb 17 2016 15:01 @moh7afiz90 what you got so far? Claudio Roberto Pereira Goncalves @Claudiogoncalves Feb 17 2016 15:02 how is it done Nesting For Loops? Mohanad Hafiz Suliman @moh7afiz90 Feb 17 2016 15:02 @codemzy I got this var myStr= '\\ \t \t \r \n'; Moisés Man @moigithub Feb 17 2016 15:02 any fail test cases ? @moh7afiz90 Mohanad Hafiz Suliman @moh7afiz90 Feb 17 2016 15:03 @moigithub I dont got what u mean didnt get* KingxBanana @KingxBanana Feb 17 2016 15:03 @moh7afiz90 That should work Moisés Man @moigithub Feb 17 2016 15:03 check left side of ur screen KingxBanana @KingxBanana Feb 17 2016 15:03 @moh7afiz90 try refreshing page, if that doesnt work, restart browser and try again AnnasLab @AnnasLab Feb 17 2016 15:04 @linashedgehog u get it thanks bro CamperBot @camperbot Feb 17 2016 15:04 annaslab sends brownie points to @linashedgehog :sparkles: :thumbsup: :sparkles: :star: 88 | @linashedgehog | http://www.freecodecamp.com/linashedgehog Mohanad Hafiz Suliman @moh7afiz90 Feb 17 2016 15:04 i did everything Moisés Man @moigithub Feb 17 2016 15:04 below the RUN TEST button Codemzy @codemzy Feb 17 2016 15:04 @moh7afiz90 this exactly should work var myStr = "\\ \t \t \r \n"; Mohanad Hafiz Suliman @moh7afiz90 Feb 17 2016 15:04 still not working @KingxBanana Julio Duarte @jjuliodm Feb 17 2016 15:05 @zacharyvacek /[_\W+]/gmi Mohanad Hafiz Suliman @moh7afiz90 Feb 17 2016 15:05 @codemzy it works appreciate ur help @codemzy Codemzy @codemzy Feb 17 2016 15:05 @moh7afiz90 :thumbsup: William @apswak Feb 17 2016 15:07 Anyone else often get the "Oops! Something went wrong. Please try again later" message and get redirected to the map? Julio Duarte @jjuliodm Feb 17 2016 15:07 every time Codemzy @codemzy Feb 17 2016 15:08 @kreitzo yeah I'm getting that alot at the moment Mercy Shabusale @lomu99 Feb 17 2016 15:10 @kreitzo yes, what is that? John Deegan @JohnDeegs Feb 17 2016 15:10 @kreitzo yup Claudio Roberto Pereira Goncalves @Claudiogoncalves Feb 17 2016 15:10 help Nesting For Loops CamperBot @camperbot Feb 17 2016 15:10 ## :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 Claudio Roberto Pereira Goncalves @Claudiogoncalves Feb 17 2016 15:11 help Nesting For Loops function multiplyAll(arr) { var product = 1; // Only change code below this line for (var i=0; i < arr.length; i++) { for (var j=0; j < arr[i].length; j++) { console.log(arr[i][j]); } } // Only change code above this line return product; } // Modify values below to test your code multiplyAll([1,2,3]); CamperBot @camperbot Feb 17 2016 15:11 no wiki entry for: nesting for loops function multiplyallarr var product 1 only change code below this line for var i0 i arrlength i for var j0 j arrilength j consolelogarrij only change code above this line return product modify values below to test your codemultiplyall123 Julio Duarte @jjuliodm Feb 17 2016 15:14 @Claudiogoncalves product *= arr[i][j] Marko Nikic @MarkoN95 Feb 17 2016 15:15 Bonfire: Exact Change CamperBot @camperbot Feb 17 2016 15:15 ## :fire:Bonfire: Exact Change :link: function drawer(price, cash, cid) { var change; // Here is your change, ma'am. return change; } // Example cash-in-drawer array: // [['PENNY', 1.01], // ['NICKEL', 2.05], // ['DIME', 3.10], // ['QUARTER', 4.25], // ['ONE', 90.00], // ['FIVE', 55.00], // ['TEN', 20.00], // ['TWENTY', 60.00], // ['ONE HUNDRED', 100.00]] drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]); Design a cash register drawer function that accepts purchase price as the first argument, payment as the second argument, and cash-in-drawer (cid) as the third argument. more info: bf details | bf links | hint Marko Nikic @MarkoN95 Feb 17 2016 15:15 hint CamperBot @camperbot Feb 17 2016 15:15 :construction: Spoilers are only in the Bonfire's Custom Room :point_right: AnnasLab @AnnasLab Feb 17 2016 15:15 hello can ask for help here, or this room is just for review ( I didn't find help in others) Clyde @hea-hea Feb 17 2016 15:17 help Record Collection CamperBot @camperbot Feb 17 2016 15:17 ## :point_right: checkpoint record collection [wiki] # Checkpoint: Record Collection Instructions You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information. Write a function which takes an id, a property (prop), and a value. For the given id in collection: If value is non-blank (value !== ""), then update or set the value for the prop. If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array. If value is blank, delete that prop. Always return the entire collection object. Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code. Julio Duarte @jjuliodm Feb 17 2016 15:18 @camperbot just multiply the product with your arr[i][j] and assign that to your product @camperbot what do u need? Claudio Roberto Pereira Goncalves @Claudiogoncalves Feb 17 2016 15:19 @jjuliodm thanks!! Julio Duarte @jjuliodm Feb 17 2016 15:20 @hea-hea What do u need? Clyde @hea-hea Feb 17 2016 15:20 hi, I have a question about this Record Collection checkpoint wait a sec till I paste in the code ;) Julio Duarte @jjuliodm Feb 17 2016 15:20 @hea-hea ok Clyde @hea-hea Feb 17 2016 15:22 function update(id, prop, value) { if (value !== "" && prop !== "tracks") { collection[id][prop] = value; } else if (prop === "tracks" && value !== "") { collection[id].tracks.push(value); } else if (value === "") { delete collection[id][prop]; } return collection; } it did work that way, however when I used "collection[id].prop" instead of collection[id][prop] - it was wrong. Ken Haduch @khaduch Feb 17 2016 15:22 @AnnasLab - this is the room for basic JavaScript and Algorithms stuff... so if you are looking for help on that - ask away! Clyde @hea-hea Feb 17 2016 15:22 and I have trouble understanding what's the difference - I thought that bracket and dot work the same way Julio Duarte @jjuliodm Feb 17 2016 15:23 @hea-hea when you do this Collection[i].prop you are saying that you are looking for a property call it prop, so yo acces to the value of prop you need to put it like this collection[id][prop] to* Ken Haduch @khaduch Feb 17 2016 15:24 @hea-hea - there are specific times when you can use the "." and the brackets always work. One time when you cannot use the dot is when you have the property name (or the potential property name) in a variable. Dot notation works when you have the literal name of the property in your code, and certain times you have to use the brackets, such as when there are spaces in the property name, it is numeric or starts with a number, etc. Clyde @hea-hea Feb 17 2016 15:25 OK so if "prop" was an actual property and not a function parameter, I could acces it that way? Julio Duarte @jjuliodm Feb 17 2016 15:25 @hea-hea yes sigursiguros @sigursiguros Feb 17 2016 15:25 HI guys, I'm struggling with most of the intermediate algos. Do you have any suggestions on how to go about solving them? The read search ask model doesn't help that much for intermediate, relative to the beginner's algos. Clyde @hea-hea Feb 17 2016 15:26 @jjuliodm @khaduch thanks :) CamperBot @camperbot Feb 17 2016 15:26 hea-hea sends brownie points to @jjuliodm and @khaduch :sparkles: :thumbsup: :sparkles: :star: 253 | @jjuliodm | http://www.freecodecamp.com/jjuliodm :star: 538 | @khaduch | http://www.freecodecamp.com/khaduch Ken Haduch @khaduch Feb 17 2016 15:26 @hea-hea - yes, with the caveats about property names with spaces and numbers, etc. If "prop" is an actual property name, then you can write object.prop. @sigursiguros - you can ask for help here. If you ask the camperbot for help, it will point you to the blog articles that sometimes have more detailed help, including spoilers that you might want to avoid so that you have time to do and think about it, helps the learning process! sigursiguros @sigursiguros Feb 17 2016 15:29 Thanks @khaduch CamperBot @camperbot Feb 17 2016 15:29 sigursiguros sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star: 539 | @khaduch | http://www.freecodecamp.com/khaduch sigursiguros @sigursiguros Feb 17 2016 15:29 function unite(arr1, arr2, arr3) { arr1.push(...arr2); arr1.push(...arr3); arr1.filter(function(current,next){ return current !== next; }); return arr1; } unite([1, 3, 2], [5, 2, 1, 4], [2, 1]); why is my sorted union function not working? karencordova @karencordova Feb 17 2016 15:29 Hy people, someone can help here? What's wrong here? sigursiguros @sigursiguros Feb 17 2016 15:30 I've written an infinite loop and FCC keeps crashing whenever I return to that zipline. Is there any way to solvet his? Ken Haduch @khaduch Feb 17 2016 15:30 @karencordova - hello karencordova @karencordova Feb 17 2016 15:30 function palindrome(str) { var array = []; array = str.split(' ').join("").toLowerCase().replace(/([^\w]*)/gi, ''); for (var i = 0; i < array.length; i++){ for (var j = array.length-1; j >= 0; j--){ if (array[i] == array[j]){ return true; } return false; } } } palindrome("almostomla"); Ken Haduch @khaduch Feb 17 2016 15:31 @sigursiguros - this from some help article: By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL: run=disabled karencordova @karencordova Feb 17 2016 15:31 sorry. how i can paste code here? Blauelf @Blauelf Feb 17 2016 15:31 @sigursiguros filter returns a new array, you don't use that array. And the callback function gets (element, index, array) as its arguments, not (current,next). Ken Haduch @khaduch Feb 17 2016 15:31 help code format CamperBot @camperbot Feb 17 2016 15:31 ## :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 17 2016 15:33 @karencordova - what are you having a problem with on the palindromes? A general problem, or specific cases that are failing? Blauelf @Blauelf Feb 17 2016 15:33 @karencordova \w contains a-z, A-Z, 0-9, and the underscore _ Also, your loop instantly returns true on a match, should instantly return false on mismatch but true only after the whole loop finished without mismatch. karencordova @karencordova Feb 17 2016 15:34 function palindrome(str) { var array = []; array = str.split(' ').join("").toLowerCase().replace(/([^\w]*)/gi, ''); for (var i = 0; i < array.length; i++){ for (var j = array.length-1; j >= 0; j--){ if (array[i] == array[j]){ return true; } return false; } } } palindrome("almostomla"); sorry! :( Blauelf @Blauelf Feb 17 2016 15:34 @karencordova Use the code block with the triple backticks. karencordova @karencordova Feb 17 2016 15:35  function palindrome(str) { var array = []; array = str.split(' ').join("").toLowerCase().replace(/([^\w]*)/gi, ''); for (var i = 0; i < array.length; i++){ for (var j = array.length-1; j >= 0; j--){ if (array[i] == array[j]){ return true; } return false; } } } palindrome("almostomla"); Julio Duarte @jjuliodm Feb 17 2016 15:35 @karencordova you dont need to use the loop here karencordova @karencordova Feb 17 2016 15:35 /o\ i will try. Blauelf @Blauelf Feb 17 2016 15:36 Insert line breaks (Shift+Return) around the triple backticks (they have to have their own line, with the first triple optionally followed by js marking it as javascript). And you need one loop if you want to go that way, as j is array.length-1-i Julio Duarte @jjuliodm Feb 17 2016 15:36 @karencordova  function palindrome(str) { var array = []; array = str.split(' ').join("").toLowerCase().replace(/([^\w]*)/gi, '');  if (U need the original world without the space and alphanumeric stuff == the without the alphanimeric stuff and in reverse ){ return true; } return false; } } } palindrome("almostomla"); Blauelf @Blauelf Feb 17 2016 15:38 @karencordova Instead of looping (which done right is the most efficient way), you could use your solution of the reverse-a-string challenge for reversing the (both lowercase/punctuation-removed) string and comparing string and reversed string. Wenceslao Villegas Marset @SpiralOut17 Feb 17 2016 15:39 Hi i need help with this piece of code, i want to take the coordintaes value an assign them to the lat and lon values so then i can use them to build the API url i need. Here is the code:$(document).ready(function(){
var lat = "";
var lon = "";
var apiUrl= "api.openweathermap.org/data/2.5/weather?lat="; + lat + "&lon=" + lon + "&units=metric&APPID=388b9dfad805b961ba54355aedb86991"
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
lat = position.coords.latitude;
lon = position.coords.longitude;

});

}else {
$('#location-header').html('Geolocation is not available') }; }); The problem is that when i alert the apiUrl variable it shows the url but the values are not there its like the lat and lon variables were still empty strings. Thanks Blauelf @Blauelf Feb 17 2016 15:41 @SpiralOut17 You cannot use lat and lon before you have set them. Move that part past the assignments to lat and lon (so inside the callback). Also, that semicolon in var apiUrl... should be at the end of the line, not after the first string. karencordova @karencordova Feb 17 2016 15:42 function palindrome(str) { var array = []; array = str.split(' ').join("").toLowerCase().replace(/([^\w]*)/gi, ''); for (var i = 0; i < array.length; i++){ for (var j = array.length-1; j >= 0; j--){ if (array[i] == array[j]){ return true; } return false; } } } palindrome("almostomla"); Ok! I will try to reverse a string. This is only one ( "almostomla" ) doesn't work... Vamsidhar Reddy Bada @vamsidharBada Feb 17 2016 15:43 var array = [1,2,3,4,5,6,7]; var newArray = []; // Only change code below this line. newArray = array.reverse(); Reverse Arrays with reverse karencordova @karencordova Feb 17 2016 15:43 tks!! :D Vamsidhar Reddy Bada @vamsidharBada Feb 17 2016 15:44 Help me with this. What is wrong in this? CamperBot @camperbot Feb 17 2016 15:44 no wiki entry for: me with this what is wrong in this Sebastian @sebous Feb 17 2016 15:44 function update(id, prop, value) { if (value !== '' & prop !== 'tracks') { collection.id.prop = value; }else if (prop === 'tracks' & value !== '') { collection.id.prop.push(value); }else if (value !== '') { delete collection.id.prop; } return collection; } rphares @rphares Feb 17 2016 15:44 @sebous , use bracket in the {}s Julio Duarte @jjuliodm Feb 17 2016 15:45 @sebous you need to use brakets to acees to the objects Collection[id][prop] Blauelf @Blauelf Feb 17 2016 15:45 @karencordova When doing it the for-way, you need one loop:  for (var i = 0, j = array.length - 1; i < j; i++, j--) { if (array[i] !== array[j]) { return false; } } return true;` (several different ways for that for-loop, but always only one) Sebastian @sebous Feb 17 2016 15:45 @jjuliodm okay, I'm still a bit confused when to use brackets and when to use dot rphares @rphares Feb 17 2016 15:46 Julio Duarte @jjuliodm Feb 17 2016 15:46 @sebous if the property is call it Prop so u just say collection.prop but the prop = "likes", so you say collection[prop] rphares @rphares Feb 17 2016 15:46 that article helped me a lot (there are other good sources, this ones just my go-to now) @sebous Wenceslao Villegas Marset @SpiralOut17 Feb 17 2016 15:48 @Blauelf Hi, is this what you are referring to?$(document).ready(function(){
var lat = "";
var lon = "";
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
lat = position.coords.latitude;
lon = position.coords.longitude;
});

}else {
\$('#location-header').html('Geolocation is not available')
};
var apiUrl= "api.openweathermap.org/data/2.5/weather?lat="+ lat + "&lon=" + lon + "&units=metric&APPID=388b9dfad805b961ba54355aedb86991"
});

Julio Duarte
@jjuliodm
Feb 17 2016 15:49
@jjuliodm the object that you have on your json is call it "likes" so you have a parameter that recive than value, so prop = "likes" if you search on your json you wont see any object call it prop so thats why you use Collection.[prop]
Wenceslao Villegas Marset
@SpiralOut17
Feb 17 2016 15:49
@Blauelf I alert the apiUrl variable at the end and got the same
Blauelf
@Blauelf
Feb 17 2016 15:49
@SpiralOut17 Inside the geolocation callback, not the ready callback. You have lat and lon once that callback is called.