10th
May 2016
manu4216
@manu4216
May 10 2016 00:06
This message was deleted
CamperBot
@camperbot
May 10 2016 00:06
:bulb: to format code use backticks!  more info
manu4216
@manu4216
May 10 2016 00:06
This message was deleted
Diego Mayer
@Chrono79
May 10 2016 00:09
@ereinertsen any progress?
Stephen James
@sjames1958gm
May 10 2016 00:11
@moigithub :+1: I knew about let and I knew about this for loop problem, thanks for heads up just read about for (let i ...) causing i to be block scoped to each iteration and this problem goes away without IIFE. thanks
CamperBot
@camperbot
May 10 2016 00:11
sjames1958gm sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1108 | @moigithub |http://www.freecodecamp.com/moigithub
manu4216
@manu4216
May 10 2016 00:11

function smallestCommons(arr) {
var a = Math.min(arr[0], arr[1]);
var b = Math.max(arr[0], arr[1]);
var result = 1;

for (var i = a; i <= b; i++ ) {
result = smallestCommons2(i, result);
}
return result;
}

function smallestCommons2(x,y){

for (var j = 1; j <= x; j++) {
if (y*j % x === 0) {
return y*j;
}
}
}

smallestCommons([2,4]);
This solution works, but can someone pls tell if it's not too messy JS ? Thanks
Kyle B.
@manbearkyle
May 10 2016 00:12
thanks @sannek :clap: Worked to perfection
CamperBot
@camperbot
May 10 2016 00:12
manbearkyle sends brownie points to @sannek :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
May 10 2016 00:14
@manu4216 Looks good
Vivek Rai
@raivivek
May 10 2016 00:14
@saifat29 hey! thanks! :) I’m glad to know.
CamperBot
@camperbot
May 10 2016 00:14
vivekiitkgp sends brownie points to @saifat29 :sparkles: :thumbsup: :sparkles:
Matthew Horsman
@Karnivool89
May 10 2016 00:15
Hey guys, I'm on the "Check for Palindromes" challenge in basic algos, and it says "you will need to remove all non-alphanumeric characters" but then tests for in instance involving brackets and backslashes and everything. Is this a bug or am I missing something?
Angelo Ryndon
@AIRyndon
May 10 2016 00:16
@Karnivool89 not a bug bro
Diego Mayer
@Chrono79
May 10 2016 00:16
@Karnivool89 you have to remove them before comparing it with it's reverse
Travis
@dukenukethem
May 10 2016 00:16
help Caesars Cipher
CamperBot
@camperbot
May 10 2016 00:16

## :point_right: algorithm caesars cipher [wiki]

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :memo:

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take a string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
rahuynh
@rahuynh
May 10 2016 00:16
Hey folks, I did a very roundabout way toward almost solving the"Return Largest Numbers" problem, but how do you turn subarray to an integer? Also, any suggestions on making it more efficient?
manu4216
@manu4216
May 10 2016 00:17
@sjames1958gm Ok, if you say so. I hope you're an expert :smile:
Matthew Horsman
@Karnivool89
May 10 2016 00:17
So I need to find an alternative to using str.replace(/\W/g, "");, because this will remove characters such as < and /
@Chrono79 So I need to find an alternative to using str.replace(/\W/g, "");, because this will remove characters such as < and /
Angelo Ryndon
@AIRyndon
May 10 2016 00:17
@Karnivool89 regexer.com i think to test regex
Matthew Horsman
@Karnivool89
May 10 2016 00:18
@AIRyndon okay thanks I'll check that out
CamperBot
@camperbot
May 10 2016 00:18
karnivool89 sends brownie points to @airyndon :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
May 10 2016 00:18
@Karnivool89 yes and no, you have to remove any character that's not a letter or a number, yo do want to get rid of < and / too
Angelo Ryndon
@AIRyndon
May 10 2016 00:19
Diego Mayer
@Chrono79
May 10 2016 00:20
@rahuynh in the first loop, you sort every inner array, you could retrieve the max value of each one there too, using pop or shift depending on how you sorted them
Matthew Horsman
@Karnivool89
May 10 2016 00:21
@Chrono79 If I remove any character that;s not a letter or a number, I cannot pass the "0_0 (: /-\ :) 0-0" test. Do I have to build a special case of these characters?
Diego Mayer
@Chrono79
May 10 2016 00:22
@Karnivool89 look at that test case, the only way that's a palindrome it's if you discard all that's not a number (or a letter) and you've left with 0000
Joseph
@revisualize
May 10 2016 00:23
Hey.
if you want to learn regex.. www.regexone.com
Matthew Horsman
@Karnivool89
May 10 2016 00:24
@Chrono79 I just realized that too, but my use of "str.replace(/\W/g, "");" leaves the underscore (_) and results in the palindrome test failing. Maybe I will just include a special case to remove the underscore.
Angelo Ryndon
@AIRyndon
May 10 2016 00:24
@Karnivool89 use brackets on your regex
Diego Mayer
@Chrono79
May 10 2016 00:24
@Karnivool89 yes, in your regex, there are at least 2 ways of doing that
Matthew Horsman
@Karnivool89
May 10 2016 00:24
Okay, perfect, I'll find those out. Thanks @Chrono79
CamperBot
@camperbot
May 10 2016 00:24
karnivool89 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Angelo Ryndon
@AIRyndon
May 10 2016 00:26
@Karnivool89 if you are filtering for something, you can filter for something that is not too :)
Luke
@lhovee
May 10 2016 00:28
function rot13(str) { // LBH QVQ VG!

for (var i=0; i < str.length; i++) {return str.charCodeAt(i);}

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
this code is only returning one number .... what do I need to do in order to make it return a UTF-16 number for every number in 'str' ? Help please!
Angelo Ryndon
@AIRyndon
May 10 2016 00:28
@luke hint ascii
@lhovee ascii
Luke
@lhovee
May 10 2016 00:28
should I google that? I've never heard of that
Angelo Ryndon
@AIRyndon
May 10 2016 00:29
you can...essentially every character has a corresponding number assigned
so dumb computers can understand :)
A === 65
Z === 90
Diego Mayer
@Chrono79
May 10 2016 00:30
@lhovee when you return it exits your function, try to store the values in some var and return that outside the loop
Luke
@lhovee
May 10 2016 00:31
right on man! @Chrono79 thanks man
CamperBot
@camperbot
May 10 2016 00:31
lhovee sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Angelo Ryndon
@AIRyndon
May 10 2016 00:32
@lhovee now you can just do the reverse thingy
Riston Denaux
@ToccataN
May 10 2016 00:38
function palindrome(str) {
var lowStr = str.replace(/[^a-zA-Z0-9]/g,"").toLowerCase().split('');
for(var i =0; i< lowStr.length;i++){
if (lowStr[i]===lowStr[lowStr.length-1]){
lowStr.pop();
lowStr.shift();
if(lowStr.length < 2){
return true;
}
}
else {
return false;
}
}
}
Angelo Ryndon
@AIRyndon
May 10 2016 00:39
@ToccataN there is a reverse function bro
Diego Mayer
@Chrono79
May 10 2016 00:41
@ToccataN also if you lowerCase first your regex could be shorter ;)
Riston Denaux
@ToccataN
May 10 2016 00:52
sweet thankyou
ereinertsen
@ereinertsen
May 10 2016 00:52
Can someone please help me? I know my function is incorrect but I don't understand what I should fix
bitgrower
@bitgrower
May 10 2016 00:54
there are a few things wrong @ereinertsen ...
bitgrower
@bitgrower
May 10 2016 00:55
first, you should be using the parameter being passed to the function, not the Global variable...
second, review the preceding 4 challenges on the following array functions: push, pop, shift and unshift.
Mike Moss
@MMux
May 10 2016 00:55
help html entities
CamperBot
@camperbot
May 10 2016 00:55

# Problem Explanation:

• You have to create a program that will convert HTML entities from string to their corresponding HTML entities. There are only a few so you can use different methods.
bitgrower
@bitgrower
May 10 2016 00:56
this challenge can be solved easily in 3 lines of code .. even two lines of code (stand in line, that is)
Travis
@dukenukethem
May 10 2016 00:58
help ceasers cipher
CamperBot
@camperbot
May 10 2016 00:58
no wiki entry for: ceasers cipher
bitgrower
@bitgrower
May 10 2016 00:58
and @ereinertsen -- 3rd, you need to return a value obtained from the array ... currently you are returning a parameter without any modification ...
Travis
@dukenukethem
May 10 2016 00:58
help caesars cipher6
CamperBot
@camperbot
May 10 2016 00:58
no wiki entry for: caesars cipher6
bitgrower
@bitgrower
May 10 2016 00:58
help caesars cipher
CamperBot
@camperbot
May 10 2016 00:58

## :point_right: algorithm caesars cipher [wiki]

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :memo:

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take a string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Travis
@dukenukethem
May 10 2016 00:58
crud my typing ftw
This challenge is going to be the bane of my existence on FCC
Diego Mayer
@Chrono79
May 10 2016 00:59
@ereinertsen
inside you function use your params (arr and item)
review what push, unshift and shift do (and how do you call this methods)
you have to return the element removed, not the one added (as it is right now, item is the one you add)
ereinertsen
@ereinertsen
May 10 2016 01:03
I've been reviewing those lessons but I still don't understand what I am doing wrong.
Diego Mayer
@Chrono79
May 10 2016 01:03
@ereinertsen push needs a parameter, the value you add to the array
unshift is not the function you want to use to remove the first item of an array, it's shift, no param needed with this one
you have to return another thing, not item, unless you change the value of item before, because you have to return the value removed with shift
ereinertsen
@ereinertsen
May 10 2016 01:11
@Chrono79 @bitgrower thanks of the help, but I still can't figure this out. Maybe I'll come back to this lesson another day
CamperBot
@camperbot
May 10 2016 01:11
ereinertsen sends brownie points to @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1038 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 10 2016 01:14

@ereinertsen -- you probably need to try and go slower ... really deconstruct what's going on in the previous array challenges -- see how code for those solutions differ from what you are doing ...

Specifically focus on ...

1. what does the function take as a parameter, if any
2. what does it DO with that parameter...
3. what does it return, and how (in other words, does it modify the array "in place", or do you have to use the array function to return a value to a new variable ...
orribu
@orribu
May 10 2016 01:14
Hey guys, I'm a bit stumped on this exercise and could use some help ;A;
bitgrower
@bitgrower
May 10 2016 01:15
well ... let's see your code, and let us know what the exercise is ...
orribu
@orribu
May 10 2016 01:15
It's the stand in Line exercise, and I uh-- have no idea what it's asking of me-- at the risk of sounding dumb OTL
This message was deleted
oops-- uh--
Diego Mayer
@Chrono79
May 10 2016 01:16
@orribu look some posts above yours, we were discussing that challenge
orribu
@orribu
May 10 2016 01:16
Oh-- really?! Thank you!!
I'll check that out. C:
Diego Mayer
@Chrono79
May 10 2016 01:17
if you don't find what you're looking for ask again
Aparna
@Aparna-S
May 10 2016 01:17
hi am currently working on "Record Collection" challenge
Stephen James
@sjames1958gm
May 10 2016 01:17
The results are in profile lookup, record collection and stand in line rank as the most questions asked
IMO
Aparna
@Aparna-S
May 10 2016 01:17
i dono if my interpretation is qwrong, can anyone help.. below is my code

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

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

return collection;
}

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

Diego Mayer
@Chrono79
May 10 2016 01:18
@Aparna-S you're not using id, collection is an object
Stephen James
@sjames1958gm
May 10 2016 01:19
@Aparna-S you need to use id and prop on collection
Aparna
@Aparna-S
May 10 2016 01:19
i gave this generic statment - function updateRecords(id, prop, value)
is that wrong>?
Diego Mayer
@Chrono79
May 10 2016 01:20
we meant inside your function, you have to use id to access certain collection object
Aparna
@Aparna-S
May 10 2016 01:21
like this? :(

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "" && prop!= "tracks")
{
collection.id =updateRecords;
}

return collection;
}

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

Stephen James
@sjames1958gm
May 10 2016 01:22
@Aparna-S closer but you are supposed to assign value you need brackets when using variables like id and need to use prop as well
VultureBetrayer
@VultureBetrayer
May 10 2016 01:22
anyone got any idea about case syntax? the challenge really doesn't explain the syntax so I'm not sure what's wrong with my code
function caseInSwitch(val) {
// Only change code below this line

case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;

// Only change code above this line
}

// Change this value to test
caseInSwitch(1);
code example
daniel akerley
@darkSkiesUniverse
May 10 2016 01:23
Diego Mayer
@Chrono79
May 10 2016 01:23
@VultureBetrayer you're missing switch(...) {}
Stephen James
@sjames1958gm
May 10 2016 01:23
@VultureBetrayer you are missing the surrounding switch statement (caseInSwitch)
daniel akerley
@darkSkiesUniverse
May 10 2016 01:24
you need to add the variable to the JSON array
VultureBetrayer
@VultureBetrayer
May 10 2016 01:24
but I'm not supposed to change that line
it specifically says taht
daniel akerley
@darkSkiesUniverse
May 10 2016 01:25
@VultureBetrayer sorry was meant for @Aparna-S :S
VultureBetrayer
@VultureBetrayer
May 10 2016 01:26
I think this challenge is wrong then, because I think I should be changing the function no?
daniel akerley
@darkSkiesUniverse
May 10 2016 01:26
they mean you need to add it like
Stephen James
@sjames1958gm
May 10 2016 01:26
@VultureBetrayer You need to wrap the cases with the a switch statement switch(val) { }
Diego Mayer
@Chrono79
May 10 2016 01:26
No, inside your function, your switch block is missing switch(somevarname) { case... }
VultureBetrayer
@VultureBetrayer
May 10 2016 01:26
or do I need to embed the switch statement inside the other function?
Stephen James
@sjames1958gm
May 10 2016 01:27
@VultureBetrayer no
daniel akerley
@darkSkiesUniverse
May 10 2016 01:27
switch {
case 1:
case 2:
case3:
//etc
}
VultureBetrayer
@VultureBetrayer
May 10 2016 01:27
ah so you don't specify the switch statement as a function as itself, they want an embedded function within the function
daniel akerley
@darkSkiesUniverse
May 10 2016 01:28
@VultureBetrayer if you look you're missing the switch {}
Diego Mayer
@Chrono79
May 10 2016 01:28

switch is not a function per se, it's a sentence like ifs

switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
}

Compare it with what you got and complete your code

VultureBetrayer
@VultureBetrayer
May 10 2016 01:29
understand I've seen all these syntaxes, that doesn't help
I don't know what variable to declare in my switch statement, nor do I understand how that is referenced from the other function
function caseInSwitch(val) {
// Only change code below this line

switch (num){
case 1:
num = "alpha";
break;
case 2:
num = "beta";
break;
case 3:
num = "gamma";
break;
case 4:
num = "delta";
break;

}

// Only change code above this line
}

// Change this value to test
caseInSwitch(1);
thats an example that doesn't work
Aparna
@Aparna-S
May 10 2016 01:30
@darkSkiesUniverse @sjames1958gm @Chrono79 is it this way? :(

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "" && prop!= "tracks")
{
collection.id ="updateRecords";
}

return collection;
}

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

VultureBetrayer
@VultureBetrayer
May 10 2016 01:30
so I don't understand how the switch statement reads the other variable
Stephen James
@sjames1958gm
May 10 2016 01:30
@VultureBetrayer you aren't declaring a variable you use the one passed in.
Diego Mayer
@Chrono79
May 10 2016 01:30
@Aparna-S num is not there, which var or param are you not using? look at your function params
daniel akerley
@darkSkiesUniverse
May 10 2016 01:31
@Aparna-S not quite you gotta remember variable go in square brackets
for example
Stephen James
@sjames1958gm
May 10 2016 01:31
@Aparna-S no use value not "updateRecords" you need to use id and prop
VultureBetrayer
@VultureBetrayer
May 10 2016 01:31
function caseInSwitch(val) {
// Only change code below this line

switch (num){
case 1:
val = "alpha";
break;
case 2:
val = "beta";
break;
case 3:
val = "gamma";
break;
case 4:
val = "delta";
break;

}

// Only change code above this line
}

// Change this value to test
caseInSwitch(1);
daniel akerley
@darkSkiesUniverse
May 10 2016 01:32
myArr[var1] = [addedVar];
@Aparna-S
Diego Mayer
@Chrono79
May 10 2016 01:32
@VultureBetrayer no, num should be val, that's the value passed to your function as a param
inside your case assign "alpha" etc to answer like you did before
VultureBetrayer
@VultureBetrayer
May 10 2016 01:32
never mind I'll seek help elsewhere, thanks
Stephen James
@sjames1958gm
May 10 2016 01:32
?
daniel akerley
@darkSkiesUniverse
May 10 2016 01:33
@Aparna-S but you want artist in there so youd add it similarly
myArr[var1][var2] = [addedVar];
Aparna
@Aparna-S
May 10 2016 01:34

@darkSkiesUniverse var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}

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

daniel akerley
@darkSkiesUniverse
May 10 2016 01:34
@Aparna-S again not quite, the last part of that phrase should be a var remember so the user can change it
Aparna
@Aparna-S
May 10 2016 01:35
@Chrono79 @sjames1958gm we need to be specific with one id prop value in the code? or we have to take the value from the updaterecord..so that it will change for any speified id?
Diego Mayer
@Chrono79
May 10 2016 01:35
@Aparna-S Look at the test cases:
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
After updateRecords(2548, "artist", ""), artist should not be set
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2548, "tracks", ""), tracks should not be set
Stephen James
@sjames1958gm
May 10 2016 01:36
If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop. you need to set value on the property.
Aparna
@Aparna-S
May 10 2016 01:36

@Chrono79 @darkSkiesUniverse @sjames1958gm // Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "" && prop!= "tracks")
{
collection[id]= id;
collection[prop]= prop;
collection[value]=value;
}

return collection;
}

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

so does this take id prop value from down - update record?
daniel akerley
@darkSkiesUniverse
May 10 2016 01:37
your if statement should be using all the var given to you in the beginning of the function @Aparna-S
Diego Mayer
@Chrono79
May 10 2016 01:37
@Aparna-S set the value for the prop <- the prop referred here is collection[id][prop]
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA" means that collection[5439]["artist"] should be "ABBA"
daniel akerley
@darkSkiesUniverse
May 10 2016 01:40
function myFunction(var1, var2, var3) {
if (var3 !== "" && var2 !== "phrase"){
myArr[var1][var2] = var3;
}
}
myArr finds var1 then adds Var2:Var3 if the conditions are met
then once you understand that the second part is easy using the.push() function
Aparna
@Aparna-S
May 10 2016 01:42
@Chrono79 @darkSkiesUniverse hey guys, its getting late for my work, will get back in the evening and check your help..will update and let you know by then!! :)
dontchaknow
@dontchaknow
May 10 2016 01:42
var swap = function (array, pos1, pos2) {
var temp = array[pos1];
array[pos1] = array[pos2];
array[pos2] = temp;
};

var heapsPermute = function (array, output, n) {
n = n || array.length; // set n default to array.length
if (n === 1) {
output(array);
} else {
for (var i = 1; i <= n; i += 1) {
heapsPermute(array, output, n - 1);
if (n % 2) {
var j = 1;
} else {
var j = i;
}
swap(array, j - 1, n - 1); // -1 to account for javascript zero-indexing
}
}
};
I found this on a blog but I don't understand how recursion works here.
daniel akerley
@darkSkiesUniverse
May 10 2016 01:43
@Aparna-S sounds good, let us know how it goes :)
dontchaknow
@dontchaknow
May 10 2016 01:43
does it break out of the for loop to call the function again?
Diego Mayer
@Chrono79
May 10 2016 01:44
no, it calls again, and again until it returns a result and that result comes back to where it was
Stephen James
@sjames1958gm
May 10 2016 01:44
@dontchaknow recursion just calls the the same function. The last parameter is reduced by one to cause the function to terminate when n == 1
Diego Mayer
@Chrono79
May 10 2016 01:45
recursion is something not so easy to explain and in this particular case is worst
dontchaknow
@dontchaknow
May 10 2016 01:45
ahhhh yes! I missed that.
that's how it terminates
@Chrono79 are you alluding to the fact that a for loop is unnecessary here?
Diego Mayer
@Chrono79
May 10 2016 01:47
no, sometimes recursion doesn't use loop just calling the same function inside itself
like factorial function in recursive form
that's easier to understand
dontchaknow
@dontchaknow
May 10 2016 01:48
right. thanks @Chrono79 @sjames1958gm
CamperBot
@camperbot
May 10 2016 01:48
dontchaknow sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1034 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kahlil
@lillil25
May 10 2016 01:49

Hey guys, I'm having an issue with this golf code exercise. Mainly because I don't play golf. Anyway, here is what I've
got so far. Everything seems to work except the "Bogey, Double Bogey and Go Home".

function golfScore(par, strokes) {

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

}

// Change these values to test
golfScore(4, 5);

Stephen James
@sjames1958gm
May 10 2016 01:50
@lillil25 par === par is always going to pass and you'll never make it further maybe that needs fixing.
Diego Mayer
@Chrono79
May 10 2016 01:50
@lillil25 else if(par === par){
Kahlil
@lillil25
May 10 2016 01:50
@sjames1958gm and @Chrono79 hey guys, great to see your online.
Stephen James
@sjames1958gm
May 10 2016 01:50
@lillil25 Hey!
Kahlil
@lillil25
May 10 2016 01:51
@sjames1958gm and @Chrono79 Let me run through it from what you guys have told me and see if I can figure it out now.
Stephen James
@sjames1958gm
May 10 2016 01:51
shoot
VultureBetrayer
@VultureBetrayer
May 10 2016 01:54
the switch challenge "Selecting from many options with Switch Statements" really needs to be revised. I was able to get this to work, but it does a terrible job of explaining what variables you need to call to do the correct syntax.
I added comments on one of the numerous bug reports on this challenge, but here's a tip: if you're going to give help on challenges, don't just cut and paste example code that is already in the challenge, that is just frustrating to new people
Stephen James
@sjames1958gm
May 10 2016 01:56
@VultureBetrayer Well, just trying to be helpful without giving out the answer.
Diego Mayer
@Chrono79
May 10 2016 01:56
your switch statetement was incomplete to start with, how do you propose we give you a hint on how to complete without giving you the whole code?
VultureBetrayer
@VultureBetrayer
May 10 2016 01:57
I get that, but the problem is the example code given at the beginning of the problem doesn't even explain the switch statement is embedded in a function
so to someone new we think 'hey I can't edit this function, and the challenge doesn't talk about embedding statements, yet I can't change the function' it makes no sense
Stephen James
@sjames1958gm
May 10 2016 01:58
@VultureBetrayer The challenge specifically says only change code between the two lines.
Diego Mayer
@Chrono79
May 10 2016 01:59
the switch statement is like an if or a for loop, it's not rare it's inside a function, it's like one of the bricks that you should use to build your function
VultureBetrayer
@VultureBetrayer
May 10 2016 01:59
that's my point, without knowing how to embed the switch statement and what variable to tie it to, how would we know how to do it?
Stephen James
@sjames1958gm
May 10 2016 01:59
Write a switch statement which tests val and sets answer for the following conditions:
VultureBetrayer
@VultureBetrayer
May 10 2016 02:00
you can sit here and tell me it tells me everything, yet you can click on bug report and view all the other people who didn't understand the challenge as well
I'm done, no reason to try and explain it I guess
Stephen James
@sjames1958gm
May 10 2016 02:02
This message was deleted
Diego Mayer
@Chrono79
May 10 2016 02:02
try suggesting a new description/instructions for that challenge
VultureBetrayer
@VultureBetrayer
May 10 2016 02:04
I did that after figuring it out, unfortunately there are about 20 complaints on this one so I didn't go through all of them, just the main one
Diego Mayer
@Chrono79
May 10 2016 02:05
and what would your description/instructions be? I'm curious
VultureBetrayer
@VultureBetrayer
May 10 2016 02:05
they already did a revision on it once linking the java page on switch, but that still is missing the problem new folks miss, and that's how to tie the variable from the function to the switch statement and how to return the correct answer
Diego Mayer
@Chrono79
May 10 2016 02:06
isn't that in the sentence that @sjames1958gm pasted?
Lavie Ruan
@Lavioli
May 10 2016 02:07
hi guys!
i am trying to solve the algorithm destroyer, and this is what i got so far:

function destroyer(arr) {

var input = arguments[0];
var argumentElements = [];

for (var i = 1; i < arguments.length; i++) {
argumentElements.push(arguments[i]);
}

console.log("This is argumentElements array: " + argumentElements);

function filtering(num){

for (var j = 0; j < argumentElements.length; j++) {

return num !== argumentElements[j] && num !== argumentElements[j+1];

}
}

return input.filter(filtering);

}

destroyer([2, 3, 2, 3], 2, 3);

VultureBetrayer
@VultureBetrayer
May 10 2016 02:08
I would so the following example:
function callSomething(num){

switch (num) {
case value1:
statement = val1;
break;
case value2:
statement = val2;
break;
...
case valueN:
statementN;
break;
}

}
return statement(val);
or something similar
just so people understand that switch is embedded and that they can see how the return statement vars work
Lavie Ruan
@Lavioli
May 10 2016 02:09
was wondering if the input of the function destoryer is [3, 5, 1, 2, 2], 2, 3, 5, it doesn't run
find Seek and Destroy
CamperBot
@camperbot
May 10 2016 02:12

find seek and destroy

Diego Mayer
@Chrono79
May 10 2016 02:12
@LavieMaru your logic isn't right there, why not using indexOf ?
Stephen James
@sjames1958gm
May 10 2016 02:13
@LavieMaru Since you only have a return in the for loop it will exit when on the first pass when j = 0
May 10 2016 02:13
can anyone help me with my javascript code?

$(document).ready(function() { function Mobile() { var sidebar =$("#sidebar");
var windoWidth = $(window).width; if (windoWidth < 768) { sidebar.toggleSlide(); console.log(windo); } else { return(); } }$(window).resize(Mobile());
});

VultureBetrayer
@VultureBetrayer
May 10 2016 02:14
@renemaduena if you type  and hit SHIFT+ENTER, paste your code, then hit CTRL + ENTER it will format your code so it's easily readable
May 10 2016 02:14
sorry its toggle() not toggleSlide() but its still not working
Diego Mayer
@Chrono79
May 10 2016 02:15
May 10 2016 02:15
is that 3 apostrophes?
Diego Mayer
@Chrono79
May 10 2016 02:15
no, 3 backticks
help format
CamperBot
@camperbot
May 10 2016 02:15

## :point_right: code formatting [wiki]

### Multi line Code

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 ⏎]

### Single line Code

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

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

VultureBetrayer
@VultureBetrayer
May 10 2016 02:16
its the left  above the ~ key at the upper left corner of the keyboard (not sure on a mac though)
Diego Mayer
@Chrono79
May 10 2016 02:16
depends on keyboard layout
May 10 2016 02:16

yeah the variable i named it windoWidth



$(document).ready(function() { function Mobile() { var sidebar =$("#sidebar");
var windoWidth = $(window).width; if (windoWidth < 768) { sidebar.toggleSlide(); console.log(windo); } else { return(); } }$(window).resize(Mobile());
});

VultureBetrayer
@VultureBetrayer
May 10 2016 02:16
$(document).ready(function() { function Mobile() { var sidebar =$("#sidebar");
var windoWidth = $(window).width; if (windoWidth < 768) { sidebar.toggleSlide(); console.log(windo); } else { return(); } }$(window).resize(Mobile());
});
May 10 2016 02:16
did not work.. let me read instructions
VultureBetrayer
@VultureBetrayer
May 10 2016 02:17
it's cool, I just posted it to help everyone else out
I sometimes see where the bottom back ticks don't show up
May 10 2016 02:18
is it just 3 or 3 and the code type like html or js?
3
Diego Mayer
@Chrono79
May 10 2016 02:18
if it's multiline, 
if it's only one line
VultureBetrayer
@VultureBetrayer
May 10 2016 02:18
just  then you hold shift and hit enter, then paste then control and enter
Diego Mayer
@Chrono79
May 10 2016 02:18
you have to enclose your code with that
Arjun Narayanan
@anarayanan86
May 10 2016 02:19
Hey guys in the "spinal tap case" algo challenge, I'm having a hard time seeing how you can fulfill all the criteria at once
May 10 2016 02:19
oh ok so i need it at end too?
but dont have to tell it what language it is?
VultureBetrayer
@VultureBetrayer
May 10 2016 02:19
yes, it auto formats for you if you do the shift+enter
Diego Mayer
@Chrono79
May 10 2016 02:20
@anarayanan86 solve this first: spinalCase("thisIsSpinalTap") should return "this-is-spinal-tap".
it requires regex with groups
May 10 2016 02:20

$(document).ready(function() { function Mobile() { var sidebar =$("#sidebar");
var windoWidth = $(window).width; if (windoWidth < 768) { sidebar.toggle(); console.log(windoWidth); } else { return(); } }$(window).resize(Mobile());
});
it is not hiding the sidebar whenever i change it to mobile mode
VultureBetrayer
@VultureBetrayer
May 10 2016 02:21
beautiful
Stephen James
@sjames1958gm
May 10 2016 02:22
@renemaduena What are you doing to change it to mobile mode?
May 10 2016 02:23
what do you mean? i go to developers console and toggle device mode. coding responsive css
Arjun Narayanan
@anarayanan86
May 10 2016 02:23
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
var regEx1 = /[\s_]/g;
var regEx2 = /[A-Z]/g;
return str.replace(regEx2, " $&").trim().replace(regEx1, "-").toLowerCase(); //replace(regEx2, "$&").trim()
}

spinalCase('thisIsSpinalTap');
ok, but now this only fulfills spinalCase("thisIsSpinalTap")
Stephen James
@sjames1958gm
May 10 2016 02:24
@renemaduena Not being entirely familiar with that does that reload the page?
May 10 2016 02:25
it should just resize it and i can choose the dimensions of the screen. like small screen for cell phones and tablets
Diego Mayer
@Chrono79
May 10 2016 02:25
@anarayanan86 which test case isn't passing?
Arjun Narayanan
@anarayanan86
May 10 2016 02:25
spinalCase("thisIsSpinalTap") is the only one that passes now, haha
Stephen James
@sjames1958gm
May 10 2016 02:25
Then it probably isn't calling document ready so your code doesn't run.
Diego Mayer
@Chrono79
May 10 2016 02:27
@anarayanan86 you're adding more spaces than needed
Arjun Narayanan
@anarayanan86
May 10 2016 02:28
well, if the string already has spaces, then yes
thats the challenge
it has to support strings without spaces and strings that already have spaces
May 10 2016 02:28
how would i fix the (document).ready?
Diego Mayer
@Chrono79
May 10 2016 02:28
@anarayanan86 you could only add spaces in the case when there are no spaces
Arjun Narayanan
@anarayanan86
May 10 2016 02:28
is there a way to do that with regex?
Diego Mayer
@Chrono79
May 10 2016 02:29
@anarayanan86 yes, using groups
you have to target a lowercase letter followed by an uppercase letter and replace that with the lowercase letter, a space and the uppercase letter (that way, you don't add more spaces than needed)
Stephen James
@sjames1958gm
May 10 2016 02:29
@renemaduena I don't know for sure, but there probably is an event for resize that you could trigger on.
Travis
@dukenukethem
May 10 2016 02:35
How long did it take the people that have finished Caesars Cipher, to finish it...or rather understand how to even start it ?
Diego Mayer
@Chrono79
May 10 2016 02:36
@dukenukethem not much, but I speak for myself here and I like cryptography
Arjun Narayanan
@anarayanan86
May 10 2016 02:39
@dukenukethem I was able to finish it a while ago...once you understand what to do it wasn't terribly difficult (but one can say the same about any of these algorithm challenges)
Diego Mayer
@Chrono79
May 10 2016 02:41
@anarayanan86 any progress?
Arjun Narayanan
@anarayanan86
May 10 2016 02:41
not really, im still trying to make sense of the "grouping" concept
Travis
@dukenukethem
May 10 2016 02:42
This last challenge is making me facedesk so hard; I'm having the hardest time figuring out what to do/how to begin
Diego Mayer
@Chrono79
May 10 2016 02:42
how do you capture a single lowercase letter followed by a single uppercase letter?
Josh
@joshweaver23
May 10 2016 02:42
@Chrono79 regex
Dylan
@dhcodes
May 10 2016 02:43
regex to the rescue
Diego Mayer
@Chrono79
May 10 2016 02:43
@joshweaver23 Yes, I already know, I'm guiding @anarayanan86 to the expression he needs
Dylan
@dhcodes
May 10 2016 02:43
@Chrono79 if you need a helper on regex, i found www.regexone.com to be fast and good
oh
@anarayanan86
check out regexone.com
Arjun Narayanan
@anarayanan86
May 10 2016 02:43
haha thanks @dhcodes
CamperBot
@camperbot
May 10 2016 02:43
anarayanan86 sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
Brian
@sludge256
May 10 2016 02:43
The ol' Gitter question and answer switcheroo
Dylan
@dhcodes
May 10 2016 02:44
we're all just so darn helpful
Arjun Narayanan
@anarayanan86
May 10 2016 02:44
/[a-z][A-Z]/ would be my guess
Josh
@joshweaver23
May 10 2016 02:44
@Chrono79 haha, just saw the question not directed to anyone so I thought it was yours
Diego Mayer
@Chrono79
May 10 2016 02:44
yes, that's right
@joshweaver23 no problem
one being the lowercase letter and the other the uppercase
Arjun Narayanan
@anarayanan86
May 10 2016 02:45
as in /([a-z])([A-Z])/?
Diego Mayer
@Chrono79
May 10 2016 02:45
yes
Arjun Narayanan
@anarayanan86
May 10 2016 02:46
what's the difference?
Diego Mayer
@Chrono79
May 10 2016 02:46
now we can add g modificator
wait for it
Arjun Narayanan
@anarayanan86
May 10 2016 02:46
/([a-z])([A-Z])/g
Diego Mayer
@Chrono79
May 10 2016 02:46
now we can refer to that matched groups in our replace
like this replace(/([a-z])([A-Z])/g, '$1$2')
and we've added a space between one lowercase letter and one uppercase letter
and only in that case
$1 is group 1 and$2 group 2
Arjun Narayanan
@anarayanan86
May 10 2016 02:48
oh wow cool!
Diego Mayer
@Chrono79
May 10 2016 02:49
now the only thing you have to do is replace spaces or underscores for - and send all to lowercase
Arjun Narayanan
@anarayanan86
May 10 2016 02:49
so only when you have groupings with parentheses you can use the $notation? Micah Bales @micahbales May 10 2016 02:50 Howdy! I'm working on the Smallest Common Multiple algorithm challenge, and this code is not working for me. (It says I've got a potential infinite loop.) Any ideas? function smallestCommons(arr) { // find high and low numbers var high = arr[1] > arr[0] ? arr[1] : arr[0]; var low = arr[0] < arr[1] ? arr[0] : arr[1]; var range = []; for (i = low; i <= high; i += 1) { // create a range of numbers between high and low range.push(i); } range.reverse(); // make the highest number first var multiple = range[0]; var counter = 0; while (counter < range.length) { for (j = 0; j < range.length; j++) { if (range[j] % multiple === 0) { counter++; } } // for loop if (counter === range.length) { return multiple; } else { multiple += multiple; counter = 0; } } // while } smallestCommons([1,5]); Diego Mayer @Chrono79 May 10 2016 02:50 I would say yes, afaik Arjun Narayanan @anarayanan86 May 10 2016 02:50 awesome!!! thanks so much @Chrono79 you are the man CamperBot @camperbot May 10 2016 02:50 anarayanan86 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :cookie: 682 | @chrono79 |http://www.freecodecamp.com/chrono79 Arjun Narayanan @anarayanan86 May 10 2016 02:51 thanks a lot for the walkthrough! @micahbales im stuck on this one too, heh Diego Mayer @Chrono79 May 10 2016 02:51 @anarayanan86 no problem, if you want to polish your skills with regex I recommend hackerrank regex challenges, note that some of them don't work on javascript Micah Bales @micahbales May 10 2016 02:51 @anarayanan86 sucks to be us. :D Arjun Narayanan @anarayanan86 May 10 2016 02:52 will do! thanks again @Chrono79 CamperBot @camperbot May 10 2016 02:52 anarayanan86 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :warning: anarayanan86 already gave chrono79 points Arjun Narayanan @anarayanan86 May 10 2016 02:53 function spinalCase(str) { // "It's such a fine line between stupid, and clever." // --David St. Hubbins var regEx1 = /[\s_]/g; var regEx2 = /[A-Z]/g; return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(regEx1, "-").toLowerCase(); } spinalCase("ThisIsSpinalTap"); w00t solved that one thanks! onwards and upwards now onto the LCM challenge too lol Diego Mayer @Chrono79 May 10 2016 02:54 @micahbales it's a potential infinite loop because if counter is not incremented the while could loop forever Aryan @aryandua May 10 2016 02:54  // Setup var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { if(value!==""&&prop!=="tracks") { collection[id][prop]=value; } else if(value!==""&&prop==="tracks") { collection[tracks].push(value); } else if(value==="") { prop=""; } return collection; } // Alter values below to test your code updateRecords(5439, "artist", "ABBA"); thats the challege and thats my code what is wrong?? Diego Mayer @Chrono79 May 10 2016 02:55 @aryandua this collection[tracks].push(value); //and this prop=""; Aryan @aryandua May 10 2016 02:55 I have been trying for 2.5 hrs what @Chrono79 ? yeh what about it? Diego Mayer @Chrono79 May 10 2016 02:56 @aryandua in the first one, you're missing id Aryan @aryandua May 10 2016 02:56 oh oh o ok Diego Mayer @Chrono79 May 10 2016 02:56 in the second one you should use delete collection... Micah Bales @micahbales May 10 2016 02:56 @Chrono79 That I know, but why wouldn't it be incremented? Diego Mayer @Chrono79 May 10 2016 02:57 @micahbales the computer doesn't know that, after all your increment is inside an if Micah Bales @micahbales May 10 2016 02:57 so... i shouldn't worry about it and put in //noprotect? when i run the code in codepen, i do seem to get an infinite loop because my browser crashes Aryan @aryandua May 10 2016 02:58 delete collection delete collection; ?? Diego Mayer @Chrono79 May 10 2016 02:58 @micahbales I wouldn't go that far, I was just pointing out that's possible to get an infinite loop there Aryan @aryandua May 10 2016 02:58 it Gives me a warining Diego Mayer @Chrono79 May 10 2016 02:58 @aryandua not whole collection Aryan @aryandua May 10 2016 02:58 then? Diego Mayer @Chrono79 May 10 2016 02:59 what were you modifying before? Aryan @aryandua May 10 2016 02:59  else if(value==="") { delete id; } that Diego Mayer @Chrono79 May 10 2016 03:00 I meant when prop was not tracks and value was not empty, inside your first if Aryan @aryandua May 10 2016 03:01 if(value!==""&&prop==="tracks") { collection[id][prop]=value; } tht? Diego Mayer @Chrono79 May 10 2016 03:01 @aryandua yes, what would you have to delete then? Aryan @aryandua May 10 2016 03:01 nothing Diego Mayer @Chrono79 May 10 2016 03:02 @aryandua 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. <- what did you modified here? 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. <- it's the same you have to delete here Aryan @aryandua May 10 2016 03:02 you have to push value onto the end of the tracks array else if(value==="") { delete id; } thats that; Diego Mayer @Chrono79 May 10 2016 03:03 @aryandua no, id is just a value passed to your function ChloeHewitt @ChloeHewitt May 10 2016 03:03 Does anyone remember how they got past waypoint "Accessing Objects Properties with Variables"? Aryan @aryandua May 10 2016 03:03 i mean delet prop; Diego Mayer @Chrono79 May 10 2016 03:03 @aryandua no, prop is another value passed to your function Aryan @aryandua May 10 2016 03:04 then what??? Diego Mayer @Chrono79 May 10 2016 03:04 look at the comments I've added to the instructions above Aryan @aryandua May 10 2016 03:04 where? Diego Mayer @Chrono79 May 10 2016 03:04 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. <- what did you modified here? 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. <- it's the same you have to delete here you have to delete some property inside an object (that's inside another object) Aryan @aryandua May 10 2016 03:05 so to delete prop you do delete prop; right? Diego Mayer @Chrono79 May 10 2016 03:06 no Aryan @aryandua May 10 2016 03:06 then what? Diego Mayer @Chrono79 May 10 2016 03:06 look again at this part of your code if(value!==""&&prop==="tracks") { collection[id][prop]=value; } Aryan @aryandua May 10 2016 03:06 yeh Diego Mayer @Chrono79 May 10 2016 03:06 If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop. <- what did you modified here? when they say the prop, it's not prop alone Aryan @aryandua May 10 2016 03:07 oh "not tracks" Diego Mayer @Chrono79 May 10 2016 03:07 the prop is collection[id][prop] Aryan @aryandua May 10 2016 03:07 oh yeh Diego Mayer @Chrono79 May 10 2016 03:08 so, what are you going to delete? Aryan @aryandua May 10 2016 03:08  // Setup var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { if(value!==""&&prop!=="tracks") { collection[id][prop]=value; } else if(value!==""&&prop!=="tracks") { collection[tracks].push(value); } else if(value==="") { delete [id][prop]; } return collection; } // Alter values below to test your code updateRecords(5439, "artist", "ABBA"); thats my code and its still wrong Diego Mayer @Chrono79 May 10 2016 03:08 you're missing collection in the delete line also this isn't right collection[tracks] Aryan @aryandua May 10 2016 03:08 did that just now still wrong :( Diego Mayer @Chrono79 May 10 2016 03:09 it's collection[id].tracks.push(value) or collection[id][prop].push(value) or collection[id].["tracks"].push(value) and the if is also wrong, it should be else if(value!==""&&prop==="tracks") { Aryan @aryandua May 10 2016 03:11 so a else if without an if Diego Mayer @Chrono79 May 10 2016 03:12 paste your fixed code again Ken Haduch @khaduch May 10 2016 03:12 @ChloeHewitt - yes.... are you having trouble? Can you post your code? Aryan @aryandua May 10 2016 03:12  // Setup var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; // Keep a copy of the collection for tests var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { if(value!==""&&prop!=="tracks") { collection[id][prop]=value; } else if(value!==""&&prop!=="tracks") { collection[id].tracks.push(value); } else if(value==="") { delete [collection][id][prop]; } return collection; } // Alter values below to test your code updateRecords(5439, "artist", "ABBA"); ChloeHewitt @ChloeHewitt May 10 2016 03:13 @khaduch  // Setup var testObj = { 12: "Namath", 16: "Montana", 19: "Unitas" }; // Only change code below this line; var playerNumber = testObj.[16]; // Change this Line var player =; // Change this Line I really dont have anything haha I'm stuuumped Aryan @aryandua May 10 2016 03:14 what are you supposed to do @ChloeHewitt Diego Mayer @Chrono79 May 10 2016 03:14 @aryandua function updateRecords(id, prop, value) { if(value!==""&&prop!=="tracks") { collection[id][prop]=value; } else if(value!==""&&prop!=="tracks") { //this if condition is the same as the one above, this one should have prop==="tracks" collection[id].tracks.push(value); } else if(value==="") { delete [collection][id][prop]; // collection[id][prop] without the [] around collection } return collection; } Aryan @aryandua May 10 2016 03:14 ? ChloeHewitt @ChloeHewitt May 10 2016 03:14 Use the playerNumber variable to lookup player 16 in testObj using bracket notation. Ken Haduch @khaduch May 10 2016 03:15 @ChloeHewitt - okay... the instructions for this are...? Use the playerNumber variable to lookup player 16 in testObj using bracket notation. ChloeHewitt @ChloeHewitt May 10 2016 03:15 Yep! @khaduch So lost Diego Mayer @Chrono79 May 10 2016 03:15 @aryandua look at the comments and fix that Aryan @aryandua May 10 2016 03:16 I did Ken Haduch @khaduch May 10 2016 03:16 @ChloeHewitt - you want to put the player's number in the playerNumber variable. So change what you have there... just the number. Then... you that variable to reference the object, using bracket notation... Aryan @aryandua May 10 2016 03:16 No diff:( Diego Mayer @Chrono79 May 10 2016 03:16 paste it fixed again Aryan @aryandua May 10 2016 03:16 player=testObj[16] Diego Mayer @Chrono79 May 10 2016 03:16 just the function, no need for the whole challenge code Aryan @aryandua May 10 2016 03:17 var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { if(value!==""&&prop!=="tracks") { collection[id][prop]=value; } if(value!==""&&prop!=="tracks") { [collection][id].tracks.push(value); } else if(value==="") { delete [collection][id][prop]; } return collection; } Diego Mayer @Chrono79 May 10 2016 03:17 @aryandua collection shouldn't be between [], delete them and you didn't fixed the second if ChloeHewitt @ChloeHewitt May 10 2016 03:18 @khaduch i understand, thank you!! CamperBot @camperbot May 10 2016 03:18 chloehewitt sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1090 | @khaduch |http://www.freecodecamp.com/khaduch Aryan @aryandua May 10 2016 03:18 you said add them Diego Mayer @Chrono79 May 10 2016 03:18 delete [collection][id][prop]; // collection[id][prop] without the [] around collection Aryan @aryandua May 10 2016 03:18 did that function updateRecords(id, prop, value) { if(value!==""&&prop!=="tracks") { collection[id][prop]=value; } if(value!==""&&prop!=="tracks") { collection[id].tracks.push(value); } else if(value==="") { delete [collection][id][prop]; } return collection; } ;( nothing Ken Haduch @khaduch May 10 2016 03:20 @ChloeHewitt - I think that the examples are a little misleading, so I can see why you were trying what you were trying. One thing that I find to be helpful is to study the test conditions and what they are expecting - sometimes that helps to clarify the problem. Is your exercise working now? Diego Mayer @Chrono79 May 10 2016 03:20 @aryandua ok, you should have this if you had followed what I said: function updateRecords(id, prop, value) { if(value!==""&&prop!=="tracks") { collection[id][prop]=value; } else if(value!==""&&prop==="tracks") { // you didn't change this if condition, if it's the same as the previous if, it'll never enter here if it's nested collection[id].tracks.push(value); } else if(value==="") { delete collection[id][prop]; // like this } return collection; } Travis @dukenukethem May 10 2016 03:21 help make object properties private CamperBot @camperbot May 10 2016 03:21 ## :point_right: challenge make object properties private [wiki] Objects have their own attributes, called properties_, and their own functions, called _methods. You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope. var Bike = function() { var speed = 100; // private function addUnit(value) { // private return value + "KM/H"; } this.getSpeed = function () { // public return addUnit(speed); }; }; Another example: Aryan @aryandua May 10 2016 03:21 That is what i have @Chrono79 Diego Mayer @Chrono79 May 10 2016 03:22 are you sure?, take a good look because this code should work Aryan @aryandua May 10 2016 03:24 oh missing a semicolon so close i finally got it thank you so much @Chrono79 @Chrono79 CamperBot @camperbot May 10 2016 03:24 aryandua sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :cookie: 683 | @chrono79 |http://www.freecodecamp.com/chrono79 Aryan @aryandua May 10 2016 03:24 that was very helpful :) what a difference a ; can make!!!! Joseph @revisualize May 10 2016 03:26 Hello. Aryan @aryandua May 10 2016 03:27 hi Travis @dukenukethem May 10 2016 03:29  var Car = function() { // this is a private variable var speed = 10; // these are public methods this.accelerate = function(change) { speed += change; }; this.decelerate = function() { speed -= 5; }; this.getSpeed = function() { return speed; }; }; var Bike = function() { // Only change code below this line. var gear = 0; this.setGear = function(change) { gear += change; }; this.getGear = function() { return gear; }; }; var myCar = new Car(); var myBike = new Bike(); so for some reason this code will pass 4 of 6 tests but no the last 2 whats wrong here that i didnt notice in the past? Norvin Burrus @ndburrus May 10 2016 03:29 @dukenukethem which challenge is this? Travis @dukenukethem May 10 2016 03:29 wops Diego Mayer @Chrono79 May 10 2016 03:30 @dukenukethem setGear not incrementGear, so use = instead of += Travis @dukenukethem May 10 2016 03:30 oh sogear = change not gear += change rip; Ken Haduch @khaduch May 10 2016 03:32 @dukenukethem - basically, read the test conditions, look at what your code is doing, think about how to make the results as expected - if the value should be 3... then you have to get that value into the variable somehow. At least, I find that looking at the test conditions helps to clarify some things... Norvin Burrus @ndburrus May 10 2016 03:33 @dukenukethem correct, use the inpiut var/iable Travis @dukenukethem May 10 2016 03:33 I had already done the challenge previously :x just coming back to old challenges to see if it'll help me with my newest one Chris Cullen @123xylem May 10 2016 03:33 Could you give me a brief guide on how to implement the bottom code for geolocation here please... Do i need to define some of the variables in JS or something?  <div class ="container-fluid text-center "> <h1 class="mainheading "> Your Local Weather </h1> <div> <ul class ="navbar list-inline"> <li><a class="geofunction" id= "data" ></a>Location<li> <li><a class="weatherfunction" > </a>Weather<li> <li><a class="windfunction"></a>Wind<li> </ul> </div> <script> var x = document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { x.innerHTML = "Geolocation is not supported by this browser."; } } function showPosition(position) { x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script> </div> ^^ just want to know how ot make that script work Norvin Burrus @ndburrus May 10 2016 03:34 @dukenukethem commenting/(documenting your/the thought process) the code can also be useful... :) Travis @dukenukethem May 10 2016 03:34 I need to start doing that ! Diego Mayer @Chrono79 May 10 2016 03:35 @123xylem if you use codepen, put all that's inside <script> tags in javascript window Norvin Burrus @ndburrus May 10 2016 03:36 @dukenukethem :+1: Chris Cullen @123xylem May 10 2016 03:36 @Chrono79 including sctipt? Diego Mayer @Chrono79 May 10 2016 03:36 no only what's inside shaunski11 @shaunski11 May 10 2016 03:36 Good evening, I'm working on the Title Case a Sentence challenge and I'm wondering if someone could explain why I get this result, "I'm a lIttle tea pot". How is the i in little being changed to uppercase?  function titleCase(str) { var strArray; var newArray = []; str = str.toLowerCase(); strArray = str.split(""); for (var i = 0; i < strArray.length; i++) { var toUpper; if (strArray[i] == strArray[0]) { toUpper = strArray[i].toUpperCase(); newArray.push(toUpper); } //else if (strArray[i] === " ") { //newArray.push(strArray[i]); //toUpper = strArray[i + 1].toUpperCase(); //newArray.push(toUpper); else { newArray.push(strArray[i]); } } return newArray.join(""); } titleCase("I'm a little tea pot"); Diego Mayer @Chrono79 May 10 2016 03:37 @shaunski11 if (strArray[i] == strArray[0]) { the i in little and the i in I'm match Greg D @mosaic-greg May 10 2016 03:37 @shaunski11 the line that does it is toUpper = strArray[i].toUpperCase(); shaunski11 @shaunski11 May 10 2016 03:38 that makes sense. So what would I use if I wanted to compare the index of the array not the value of the index. Diego Mayer @Chrono79 May 10 2016 03:39 you may want to separate in words, not in letters, so split(" ") Chevon Phillip @phillicm May 10 2016 03:41 Hey everyone I need some help here please I am confuse to what I have to do in this problem. Never played the Mad Libs game before i seen it in life function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line // Your code above this line return result; } // Change the words here to test your function wordBlanks("dog", "big", "ran", "quickly"); Coy Sanders @coymeetsworld May 10 2016 03:42 @phillicm you basically need to make a sentence by concatenating those 4 variables together you at a minimum need to put spaces between the words but you can hardcode other words inside your result too Chris Cullen @123xylem May 10 2016 03:43 How do I print this in HTML? I have tried making$demo class in a <p> but that didnt work...

var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"Longitude: " + position.coords.longitude;
}
});
Diego Mayer
@Chrono79
May 10 2016 03:43
@phillicm @coymeetsworld it would make more sense with some connecting words
@123xylem demo is an id, not a class
Coy Sanders
@coymeetsworld
May 10 2016 03:44
yeah agreed @Chrono79
Chris Cullen
@123xylem
May 10 2016 03:45
@Chrono79 yea but you need to call that id in a Html class right?
eg <p class = "theID"
Diego Mayer
@Chrono79
May 10 2016 03:45
@123xylem you can write:
<p id="demo"></p>
Chevon Phillip
@phillicm
May 10 2016 03:45
@coymeetsworld I am still confuse do I have to use +=
Chris Cullen
@123xylem
May 10 2016 03:46
@Chrono79 Not class = demo?
Diego Mayer
@Chrono79
May 10 2016 03:46
@123xylem no
var x = document.getElementById("demo");
Chris Cullen
@123xylem
May 10 2016 03:46
ok I guess class is just for css then
shaunski11
@shaunski11
May 10 2016 03:47
If anyone is interested, I was able to move the logic in the first if statement and manually change the value of index 0 toUpperCase(). Works like a charm now.
function titleCase(str) {
var strArray;
var newArray = [];

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

newArray.push(strArray[0].toUpperCase());

for (var i = 1; i < strArray.length; i++) {
var toUpper;
if (strArray[i] === " ") {
newArray.push(strArray[i]);
toUpper = strArray[i + 1].toUpperCase();
newArray.push(toUpper);
i++;
} else {
newArray.push(strArray[i]);
}
}
return newArray.join("");
}

titleCase("I'm a little tea pot");
Coy Sanders
@coymeetsworld
May 10 2016 03:47
better to use just + @phillicm
like here's an example
var string = "This is " + " a concatenated String";
Diego Mayer
@Chrono79
May 10 2016 03:48
@123xylem you can access classes, but not with getElementById
Chris Cullen
@123xylem
May 10 2016 03:49
<div>
<ul class ="navbar list-inline">

<li><a id= "demo"  ></a>Location<li>  <li><a class="weatherfunction" > </a>Weather<li>
<li><a class="windfunction"></a>Wind<li>
</ul>
</div>
This is how im trying to implement the geocode function but it seems not to work. on the first li element I try to add demo id
@Chrono79 Ahhhhh that makes sense now...
Chevon Phillip
@phillicm
May 10 2016 03:52
btw how do you do the code block in here when you want share code snippets
Coy Sanders
@coymeetsworld
May 10 2016 03:53
help format
CamperBot
@camperbot
May 10 2016 03:53

## :point_right: code formatting [wiki]

### Multi line Code

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 ⏎]

### Single line Code

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

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

Diego Mayer
@Chrono79
May 10 2016 03:53
@123xylem review your html <a> are anchors and you're not closing your <li>
Chevon Phillip
@phillicm
May 10 2016 03:54

var result = "Hello " + newStr;
var newStr = "This is a " + myNoun + " he is very " + myAdjective + " he like to " + myVerb + " very " + myAdverb;
// Your code below this line

// Your code above this line
return result;
}

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

CamperBot
@camperbot
May 10 2016 03:54
:bulb: to format code use backticks!  more info
Norvin Burrus
@ndburrus
May 10 2016 03:54
@123xylem this may be useful: {ref: JavaScript Programmer's Reference, Valentine, Reid}
 The HTML5 DOM specification includes a robust
interface for managing classes: the classList property. When accessed directly, the classList property will return
an array-like object containing the classes applied to the element. (If no classes are applied to the element, the object
will be of length 0.) Each individual class can be accessed via indexes. In addition, the classList property exposes a
set of useful helper methods (seen in use in Listing 3-13):
•     classList.contains(classname): Returns true if classname is present in classList.
www.it-ebooks.info
ChapTer 3 ■ The DOM
69
•     classList.remove(classname): Removes class classname from classList.
•     classList.toggle(classname): If classname is present in classList, it is removed; otherwise
it is added.
Coy Sanders
@coymeetsworld
May 10 2016 03:55
good @phillicm but make that your result, not newStr
oh you can't reference a variable before you define it either
my result = "Hello " + myStr;
var myStr = "something";
won't work
Chevon Phillip
@phillicm
May 10 2016 03:56
This message was deleted
CamperBot
@camperbot
May 10 2016 03:56
:bulb: to format code use backticks!  more info
Chevon Phillip
@phillicm
May 10 2016 03:56
smh I don't know how to use this code thing lol
Coy Sanders
@coymeetsworld
May 10 2016 03:56
backticks, top left corner
and it needs to be on separate lines
help format
CamperBot
@camperbot
May 10 2016 03:56

## :point_right: code formatting [wiki]

### Multi line Code

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 ⏎]

### Single line Code

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

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

Chevon Phillip
@phillicm
May 10 2016 03:56
This message was deleted
Coy Sanders
@coymeetsworld
May 10 2016 03:57
needs to be on separate lines
Chevon Phillip
@phillicm
May 10 2016 03:57
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "Hello " + newStr;
var newStr = "This is a " + myNoun + " he is very " + myAdjective + " he like to " + myVerb + " very " + myAdverb;
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
there we go
lol
Coy Sanders
@coymeetsworld
May 10 2016 03:57
yeah, so back to what i was saying you can't reference newStr before defining it
Diego Mayer
@Chrono79
May 10 2016 03:58
@phillicm you can edit or delete a post too, right corner of the post, the ... that appears there
Chevon Phillip
@phillicm
May 10 2016 04:00
@coymeetsworld still confuse on this one think ill just skip it ...but maybe should figure it out.
Coy Sanders
@coymeetsworld
May 10 2016 04:00
don't skip it
its real simple you can't refer to a variable until you define it (i.e. use the var keyword)
Diego Mayer
@Chrono79
May 10 2016 04:01
good night
Coy Sanders
@coymeetsworld
May 10 2016 04:01
if you do var results = "Hello " + newStr; but newStr isn't defined yet, the code doesn't know what to give to results
Chris Cullen
@123xylem
May 10 2016 04:03
The ID is set on the JS.. ANd it corresponds to the HTML ID... I dont see why it doesnt show in HTML... I have changed the x.innerHTML to getelemebyID("demo") TO make sure that ID was always corresponding but that didnt help either....
http://codepen.io/123xylem/pen/WwPKrj?editors=1010
Chevon Phillip
@phillicm
May 10 2016 04:04
@coymeetsworld OMG I got it I figured out what you was saying I needed to think for a minute lol
thanks
Coy Sanders
@coymeetsworld
May 10 2016 04:05
yeah no problem @phillicm
but yeah in general try not to skip over lessons, since alot of them build on top of each other
Chevon Phillip
@phillicm
May 10 2016 04:05
@coymeetsworld I just had to change the order of my variable declaration
Yeah make sense thanks
Coy Sanders
@coymeetsworld
May 10 2016 04:06
yes correct
actually you don't even need to do it that way
Chevon Phillip
@phillicm
May 10 2016 04:06
hmm really?
Coy Sanders
@coymeetsworld
May 10 2016 04:06
you could just put all of that into the result variable, don't need a newStr
Chevon Phillip
@phillicm
May 10 2016 04:06
what was the better way doing it
oh i see
Mike Swartz
@mikeswartz
May 10 2016 04:07
anyone familiar with the palindrome JS section? I'm stuck dealing with the \ character parsing
Coy Sanders
@coymeetsworld
May 10 2016 04:07
could just do
var result = "Hello this is a " + myNoun + " he is very " + myAdjective + " he like to " + myVerb + " very " + myAdverb;
return result;
or, one step further, don't even declare the variable my result, just return that string:
return "Hello this is a " + myNoun + " he is very " + myAdjective + " he like to " + myVerb + " very " + myAdverb;
Chevon Phillip
@phillicm
May 10 2016 04:07
You know I was thinking about doing but I seen something about create additional strings so that why I did it that way
Coy Sanders
@coymeetsworld
May 10 2016 04:08
you could, but good idea when writing code is not to write more than you need
easier to troubleshoot and read that way
Chevon Phillip
@phillicm
May 10 2016 04:10
thanks for the advice don't want redundancy when writing my code. Got it.
Coy Sanders
@coymeetsworld
May 10 2016 04:10
no problem
Frank XC
@tenkdayz
May 10 2016 04:11
cant find a regex to match a set of digits at the end of a string that is not followed by anything and includes a dot. this is what the closest thing that I have /([.\d]+)(?!.*\d)/g
Coy Sanders
@coymeetsworld
May 10 2016 04:13
look at line anchors @tenkdayz
Aryan
@aryandua
May 10 2016 04:19
Hey guys i have a question
where can you get job as a front end developer?
Paul Borawski
@iAmNawa
May 10 2016 04:21
@aryandua Where do you live?
Aryan
@aryandua
May 10 2016 04:22
bay area
Fremont
Frank XC
@tenkdayz
May 10 2016 04:24
@coymeetsworld nevermind.. I found the answer.. I just haven had enough coffee today
Coy Sanders
@coymeetsworld
May 10 2016 04:24
ah there you go
@aryandua lol you are in Silicon Valley
you can throw a rock and find a place to work
Aryan
@aryandua
May 10 2016 04:25
yeh
haha!
is there an age limit?
Coy Sanders
@coymeetsworld
May 10 2016 04:25
getting hired, different story
Aryan
@aryandua
May 10 2016 04:25
so its hard to get hire?
hired?
Coy Sanders
@coymeetsworld
May 10 2016 04:26
most likely 18, even for internships but I'm sure there are exceptions to the rule
I don't know specifically since I'm not interviewing
Aryan
@aryandua
May 10 2016 04:26
so i have to wait 6 more years to get a job?
Coy Sanders
@coymeetsworld
May 10 2016 04:26
but from what ive read from people here trying to get jobs its tough, alot of people have problems w/ the interview process that companies run
Aryan
@aryandua
May 10 2016 04:27
i am opening a business then
Coy Sanders
@coymeetsworld
May 10 2016 04:27
you can do some research on it lol
Aryan
@aryandua
May 10 2016 04:27
:)
Kyle B.
@manbearkyle
May 10 2016 04:27
just wrapped up Algorithm: Truncate a String. My code seems pretty heavy. Does anyone have any pseudocode recommendations to lighten the load up a bit?

function truncateString(str, num) {

var newString = "";

if (num > 3) {
newString = str.slice(0, num - 3) + "...";
}

if (num <= 3) {
newString = str.slice(0, num) + "...";
}

else if (num >= str.length) {
newString = str.slice(0);
}

return newString;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Coy Sanders
@coymeetsworld
May 10 2016 04:27
if you're 12 aren't you going to school? that should be your full time job right now
Aryan
@aryandua
May 10 2016 04:27
i do go to school
Coy Sanders
@coymeetsworld
May 10 2016 04:27
This message was deleted
Aryan
@aryandua
May 10 2016 04:27
but i do free code camp when i come back
at night
Coy Sanders
@coymeetsworld
May 10 2016 04:28
well if you go to school you can't do a job, typically jobs are same hours especially for development
but I haven't done much looking for getting a job while still in middle/high school, as those situations no longer pertain to me.
Aryan
@aryandua
May 10 2016 04:29
Cant you drop school and go to work instead?
I am very close to finishing my front end
Coy Sanders
@coymeetsworld
May 10 2016 04:29
So I dont' want to say it's impossible, see if your school has any jobs perhaps
you should still at least graduate with a High School diploma or equivalent, plus you don't want to miss high school. You can work when you get older lol
Aryan
@aryandua
May 10 2016 04:30
ok
Coy Sanders
@coymeetsworld
May 10 2016 04:30
you could code on the side, do some consulting work or even work for non-profit like the curriculum is gearing you towards
you would build a nice portfolio and increase your chances of getting hired for sure
Aryan
@aryandua
May 10 2016 04:31
:)
if i cant get hired...
I'll make my own website and make money
Coy Sanders
@coymeetsworld
May 10 2016 04:34
exactly
important thing is to keep learning though, not just development but core studies too. It's important to be well rounded IMO. You may also want to go to college maybe get a Comp Sci degree too, that'll open up more doors for you also
Aryan
@aryandua
May 10 2016 04:38
yes
prithviraj m pillai
@prithviMP
May 10 2016 04:40

function golfScore(par, strokes) {
// Only change code below this line

if(strokes== 1){
return "Hole-in-one!";
}

else if(strokes <= par - 2){
return "Eagle";

}
else if(strokes== par - 1) {
return "Birdie";
}

else if(strokes == par){
return "par";
}
else if(strokes == par + 1){
return "Bogey";
}

else if(strokes==par + 2){
return "Double Bogey";
}

else if(strokes >= par + 3){
return "Go Home!";
}

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

not getting output for strokes == par
that is for golfScore(4,4) and golfscore(5,5)
Aryan
@aryandua
May 10 2016 04:42
try strokess===par
Coy Sanders
@coymeetsworld
May 10 2016 04:42
@prithviMP can you format your code? might be something wrong in your 1st else if statement not sure
help format
CamperBot
@camperbot
May 10 2016 04:42

## :point_right: code formatting [wiki]

### Multi line Code

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 ⏎]

### Single line Code

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

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

Norvin Burrus
@ndburrus
May 10 2016 04:43
@prithviMP review/check your strokes/par evaluations.... :)
prithviraj m pillai
@prithviMP
May 10 2016 04:43
ok sure
Aryan
@aryandua
May 10 2016 04:43
This message was deleted
thats the write code
Coy Sanders
@coymeetsworld
May 10 2016 04:43
@aryandua shouldn't just give the answers when trying to help
:)
Aryan
@aryandua
May 10 2016 04:44
ok sorry
prithviraj m pillai
@prithviMP
May 10 2016 04:44
lol
Aryan
@aryandua
May 10 2016 04:44
and i spelled right like "write"
:)
Coy Sanders
@coymeetsworld
May 10 2016 04:44
i didn't notice that haha
Norvin Burrus
@ndburrus
May 10 2016 04:45
@prithviMP else if(strokes == par){
return "par"; ?? what is happening here?
prithviraj m pillai
@prithviMP
May 10 2016 04:46
i have return the same thing@Norvin
Coy Sanders
@coymeetsworld
May 10 2016 04:46
oh its "Par" not "par"
prithviraj m pillai
@prithviMP
May 10 2016 04:46
ya
got it now
Aryan
@aryandua
May 10 2016 04:47
else if(strokes===par)
return Par;
prithviraj m pillai
@prithviMP
May 10 2016 04:47
ty @ndburrus and @coymeetsworld
CamperBot
@camperbot
May 10 2016 04:47
prithvimp sends brownie points to @ndburrus and @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 10 2016 04:47
yeah code looked ok to me, just that part of it was formatted and the other part wasn't, thought maybe there was an issue there like an extra line break or something
Norvin Burrus
@ndburrus
May 10 2016 04:47
@prithviMP kudos to you!! :+1:
prithviraj m pillai
@prithviMP
May 10 2016 04:47
i always do this silly mistaake
Coy Sanders
@coymeetsworld
May 10 2016 04:48
yeah, attention to detail important
prithviraj m pillai
@prithviMP
May 10 2016 04:48
and ty @aryandua
CamperBot
@camperbot
May 10 2016 04:48
prithvimp sends brownie points to @aryandua :sparkles: :thumbsup: :sparkles:
Aryan
@aryandua
May 10 2016 04:50
can someone tell what the "map" function is again?
Coy Sanders
@coymeetsworld
May 10 2016 04:50
for an array, it runs a function on each element of the array
prithviraj m pillai
@prithviMP
May 10 2016 04:50
@aryandua and it use key and value pair
uses*
Aryan
@aryandua
May 10 2016 04:51
oh yeh
prithviraj m pillai
@prithviMP
May 10 2016 04:51
i am a java guy so this makes sense
Aryan
@aryandua
May 10 2016 04:51
thx @coymeetsworld @prithviMP
CamperBot
@camperbot
May 10 2016 04:51
aryandua sends brownie points to @coymeetsworld and @prithvimp :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 10 2016 04:51
its not the same @prithviMP
prithviraj m pillai
@prithviMP
May 10 2016 04:52
okay didnt go to javascript map
learning it now @coymeetsworld
Reginald Holt
@Reggiereg83
May 10 2016 04:52
@coymeetsworld i need help finding a remainder in javaScript
Norvin Burrus
@ndburrus
May 10 2016 04:52
@aryandua "Array.prototype.map" {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map}
The map() method creates a new array with the results of calling a provided function on every element in this array.

SyntaxEDIT
arr.map(callback[, thisArg])
Parameters
callback
Function that produces an element of the new Array, taking three arguments:
currentValue
The current element being processed in the array.
index
The index of the current element being processed in the array.
array
The array map was called upon.
thisArg
Optional. Value to use as this when executing callback. Default value is the Window object
DescriptionEDIT
map calls a provided callback function once for each element in an array, in order, and constructs a new array from the results. callback is invoked only for indexes of the array which have assigned values, including undefined. It is not called for missing elements of the array (that is, indexes that have never been set, which have been deleted or which have never been assigned a value).
Coy Sanders
@coymeetsworld
May 10 2016 04:52
i think you're thinking of the datastructure ArrayaMap
Aryan
@aryandua
May 10 2016 04:53
yes thx @ndburrus
CamperBot
@camperbot
May 10 2016 04:53
aryandua sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 10 2016 04:53
Array.map() function in JavaScript is an example of functional programming
prithviraj m pillai
@prithviMP
May 10 2016 04:53
yaa i was thinking of map interface in collections of java
Coy Sanders
@coymeetsworld
May 10 2016 04:53
@Reggiereg83 the modulus of two numbers will return a remainder
yeah that's different
Reginald Holt
@Reggiereg83
May 10 2016 04:54
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Coy Sanders
@coymeetsworld
May 10 2016 04:54
Array.map isn't a data structure, its a function
yeah so instead of a divide symbol use the mod symbol
that will return the remainder
Norvin Burrus
@ndburrus
May 10 2016 04:54
This message was deleted
Aryan
@aryandua
May 10 2016 04:54
11%3 = 2
Coy Sanders
@coymeetsworld
May 10 2016 04:54
yeah like that
Aryan
@aryandua
May 10 2016 04:54
since 11/3 = 3 r 2
Reginald Holt
@Reggiereg83
May 10 2016 04:55
ok
Aryan
@aryandua
May 10 2016 04:55
i know because of C :)
Norvin Burrus
@ndburrus
May 10 2016 04:55
@aryandua Arithmetic operators: {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators}
Remainder (%)EDIT
The remainder operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend, not the divisor. It uses a built-in modulo function to produce the result, which is the integer remainder of dividing var1 by var2 — for example — var1 modulo var2. There is a proposal to get an actual modulo operator in a future version of ECMAScript, the difference being that the modulo operator result would take the sign of the divisor, not the dividend.

Syntax
Operator: var1 % var2
Examples
12 % 5 // 2
-1 % 2 // -1
NaN % 2 // NaN
1 % 2 // 1
2 % 3 // 2
-4 % 2 // -0
5.5 % 2 // 1.5
prithviraj m pillai
@prithviMP
May 10 2016 04:56
@coymeetsworld can i ask a question out the contxt?
Coy Sanders
@coymeetsworld
May 10 2016 04:56
shoot
prithviraj m pillai
@prithviMP
May 10 2016 04:56
i started working on spring and hibernate
as backend devloper
was wondering should i stick to the same
or learn any js framework
for backend
Aryan
@aryandua
May 10 2016 04:57
what does spring and hibernate mean?
prithviraj m pillai
@prithviMP
May 10 2016 04:57
like node.js
Coy Sanders
@coymeetsworld
May 10 2016 04:58
spring and hibernate are Java libraries, not JavaScript
prithviraj m pillai
@prithviMP
May 10 2016 04:58
they are frameworks of java
yeah
Aryan
@aryandua
May 10 2016 04:58
oh ok
like <include #stdio.h> in C
Reginald Holt
@Reggiereg83
May 10 2016 04:58
var remainder= 11 & 3; its saying its wrong
Rhjoo
@Rhjoo
May 10 2016 04:58
Hi, I'm stuck at Profile Lookup. Any advise, what I'm doing wrong here? 
prithviraj m pillai
@prithviMP
May 10 2016 04:58
i feel these tech are going to be outdated soon
Coy Sanders
@coymeetsworld
May 10 2016 04:58
i have programmed in Java but not familiar with anything outside of standard level
Rhjoo
@Rhjoo
May 10 2016 04:58
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
if (firstName == contacts[i].firstName) {
for (j = 0; j < contacts[i].length; j++) {
if (prop == contacts[i][j]) {
return contacts[i][j];
} else {
return "No such property";
}
}
} else {
return "No such contact";
}
}
// Only change code above this line
}
Coy Sanders
@coymeetsworld
May 10 2016 04:58
Java won't be outdated
Aryan
@aryandua
May 10 2016 04:59
is C outdated?
yet?
Coy Sanders
@coymeetsworld
May 10 2016 04:59
it may be less popular and new code may switch to other languages
prithviraj m pillai
@prithviMP
May 10 2016 04:59
okay
Coy Sanders
@coymeetsworld
May 10 2016 04:59
no C will never be outdated lol
that would be the last one to go I would say
Aryan
@aryandua
May 10 2016 04:59
know 14 different languages...
Coy Sanders
@coymeetsworld
May 10 2016 04:59
Java is written in a lot of places already, so there needs to be Java developers
Aryan
@aryandua
May 10 2016 04:59
C is my favorite
Coy Sanders
@coymeetsworld
May 10 2016 04:59
its too expensive for a company to go and rebuild their entire code base in a different language
as long as the language is still getting support, as Java and C both are, then its still fine to use.
prithviraj m pillai
@prithviMP
May 10 2016 05:00
i was targeting a startup as my next comapny
Coy Sanders
@coymeetsworld
May 10 2016 05:00
you'll see alot of languages and esp libraries can come and go over time.
prithviraj m pillai
@prithviMP
May 10 2016 05:00
company to work with
Norvin Burrus
@ndburrus
May 10 2016 05:00
@Rhjoo the code is iterating through all the records and returning what? prop == contacts? check/review the logic, imo... :)
Coy Sanders
@coymeetsworld
May 10 2016 05:00
turn of the century it was Java, then it was Ruby on Rails, now its JavaScript
but Java and RoR still used and still need developers, go check dice.com and search for jobs with those keywords
prithviraj m pillai
@prithviMP
May 10 2016 05:01
yeah
Aryan
@aryandua
May 10 2016 05:01
Java script is very similar to C and python
if else
for loops
while loops
arrays
lists
structure
pointer
Coy Sanders
@coymeetsworld
May 10 2016 05:02
javaScript continued to get popularity, thats why FCC recommends learning it
Reginald Holt
@Reggiereg83
May 10 2016 05:02
11 % 3 = 2 i should write it like this???? @coymeetsworld
Aryan
@aryandua
May 10 2016 05:02
pointers
Coy Sanders
@coymeetsworld
May 10 2016 05:02
yes @Reggiereg83 that how it works
Aryan
@aryandua
May 10 2016 05:02
are there pointers in java script? @coymeetsworld
Coy Sanders
@coymeetsworld
May 10 2016 05:02
no pointers
if there were pointers in JavaScript no one would learn it lol
Aryan
@aryandua
May 10 2016 05:02
why not?
prithviraj m pillai
@prithviMP
May 10 2016 05:02
if use it as condition use should writr 11%3==2
@Reggiereg83
Coy Sanders
@coymeetsworld
May 10 2016 05:03
its a tough concept to learn
Reginald Holt
@Reggiereg83
May 10 2016 05:03
Its saying it's wrong bad assignment @coymeetsworld
Aryan
@aryandua
May 10 2016 05:03
useful
no no @Reggiereg83
you dont srite 11%3=2
Coy Sanders
@coymeetsworld
May 10 2016 05:03
you wouldn't put that in the code, right
Aryan
@aryandua
May 10 2016 05:03
*write
Coy Sanders
@coymeetsworld
May 10 2016 05:03
thats just demonstrating how it works conceptually
Aryan
@aryandua
May 10 2016 05:04
the code will be like
Coy Sanders
@coymeetsworld
May 10 2016 05:04
whats the challenge name @Reggiereg83 ?
prithviraj m pillai
@prithviMP
May 10 2016 05:04
if youuse one = operator your assigning it
Aryan
@aryandua
May 10 2016 05:04
var a=11%3;
and a will be 2
Reginald Holt
@Reggiereg83
May 10 2016 05:04
finding a reminder in JavaScript
prithviraj m pillai
@prithviMP
May 10 2016 05:04
store it in a variable
Reginald Holt
@Reggiereg83
May 10 2016 05:04
150
prithviraj m pillai
@prithviMP
May 10 2016 05:05
as @aryandua said
Coy Sanders
@coymeetsworld
May 10 2016 05:05
150 isn't the number of the challenge, thats probably your brownie points
CamperBot
@camperbot
May 10 2016 05:05
Coy Sanders
@coymeetsworld
May 10 2016 05:05
or not hmm wonder where that 150 comes from
Rhjoo
@Rhjoo
May 10 2016 05:05
@ndburrus the function should return the value of the property of the matching contact. If no such property or contact exist, should return "No such property" or "No such contact"
Aryan
@aryandua
May 10 2016 05:05
var remainder=11%3;
Coy Sanders
@coymeetsworld
May 10 2016 05:05
well anyways yeah look what @aryandua wrote
you want to assign the variable remainder to the result of 11%3
Reginald Holt
@Reggiereg83
May 10 2016 05:06
Lets see if that works
Aryan
@aryandua
May 10 2016 05:06
again C is helping me with JS
it took me 3 seconds to complete that chalenge because I know C
Coy Sanders
@coymeetsworld
May 10 2016 05:07
yeah because JavaScript is C-like
Aryan
@aryandua
May 10 2016 05:07
and Python
Coy Sanders
@coymeetsworld
May 10 2016 05:07
so most of the basic syntax is similar
yeah and Java
Aryan
@aryandua
May 10 2016 05:07
For loops
Reginald Holt
@Reggiereg83
May 10 2016 05:07
@aryandua good job, i didn't know where to place my code, that's my biggest problem. @coymeetsworld
Coy Sanders
@coymeetsworld
May 10 2016 05:07
just has different nuances
Aryan
@aryandua
May 10 2016 05:07
While loops
if/else
structures
unions?? Maybe
Coy Sanders
@coymeetsworld
May 10 2016 05:08
theres no structures or unions
Aryan
@aryandua
May 10 2016 05:08
object
Same idea
Coy Sanders
@coymeetsworld
May 10 2016 05:08
everything in javascript is an object
even functions strange enough
Aryan
@aryandua
May 10 2016 05:08
arrays,
functions
and i can go on and on
its all on C
Norvin Burrus
@ndburrus
May 10 2016 05:09
@Rhjoo ...review/check your iteration/s value/s [i,j] ? :) ex.: " for (j = 0; j < contacts[i].length; j++) {
"
Rhjoo
@Rhjoo
May 10 2016 05:14
@ndburrus I'm not quite getting what you mean there.
Norvin Burrus
@ndburrus
May 10 2016 05:16
@Rhjoo it appears that an iteration is occurring in the following code (but the counter value is mismatched - i vs. j). oh wait, i see it j is less than... my mistake.
      for (j = 0; j < contacts[i].length; j++) {
@Rhjoo why not just return the contact property if the prop exist when the firstName is found? ...and set a condition/action for if the prop does not exist...
Markus Kiili
@Masd925
May 10 2016 05:21
@coymeetsworld Primitive values are not objects.
Rhjoo
@Rhjoo
May 10 2016 05:21
@ndburrus yeah, that's what I'm trying to do. I guess having two iterations (i and j) isn't the right way to go
Travis
@dukenukethem
May 10 2016 05:21
help caesars cipher
CamperBot
@camperbot
May 10 2016 05:21

## :point_right: algorithm caesars cipher [wiki]

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :memo:

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take a string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Coy Sanders
@coymeetsworld
May 10 2016 05:22
right @Masd925 my mistake
almost everything though
Norvin Burrus
@ndburrus
May 10 2016 05:22
@Rhjoo well, it would require a different decision structure.... :+1: does the psuedo code/suggestion sound sensible?
dheerajahuja000
@dheerajahuja000
May 10 2016 05:22
Hello everyone
Markus Kiili
@Masd925
May 10 2016 05:22
@coymeetsworld Yes, all except string, number, boolean, undefined and null.
Coy Sanders
@coymeetsworld
May 10 2016 05:23
and Symbol i guess for EMCA6
Markus Kiili
@Masd925
May 10 2016 05:23
@coymeetsworld Yes.
dheerajahuja000
@dheerajahuja000
May 10 2016 05:23
I am preparing a dynamic list in html with anchor tags (images) but i want that the click function should only work on that anchor tag and not on the whole list ..but if i click anywhere in the list, it gets called.
can someone help?
Frank XC
@tenkdayz
May 10 2016 05:25
when &#8730; is in a button.innerHTML it pushes the button up a few pixels
Norvin Burrus
@ndburrus
May 10 2016 05:26
@dheerajahuja000 "How to bind onclick event to dynamically created HTML elements in jQuery" {ref: http://www.tutorialrepublic.com/faq/how-to-bind-onclick-event-to-dynamically-added-elements-in-jquery.php}
If you try to do something with the elements that are dynamically added to DOM using the jQuery click() method it will not work, because it bind the click event only to the elements that exist at the time of binding. To bind the click event to all existing and future elements, use the jQuery on() method.
Frank XC
@tenkdayz
May 10 2016 05:26
how can I fix it?
Rhjoo
@Rhjoo
May 10 2016 05:33
@ndburrus Got it. I used the .hasOwnProperty instead of iterating with j inside iterating with i, haha. Also I realized I forgot to put "var" in front of "i" in the for loop setup. Thanks!
CamperBot
@camperbot
May 10 2016 05:33
rhjoo sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Aryan
@aryandua
May 10 2016 05:33
var total=1;
function factorialize(num) {
for(num=num;num>1;num--) {
total*=num;
}
}

factorialize(20);
Norvin Burrus
@ndburrus
May 10 2016 05:33
@Rhjoo woohoo!! You're on fire!! :fire: you're very welcome...:) ...good catch on var i!
Markus Kiili
@Masd925
May 10 2016 05:34
@aryandua FCC tests don't like global variables like total there.
Aryan
@aryandua
May 10 2016 05:34
what? @Masd925
so what do i do??
them?
*then
Markus Kiili
@Masd925
May 10 2016 05:35
@aryandua Put the variable declaration inside the function.
Aryan
@aryandua
May 10 2016 05:35
then every time the function runs total will reset to 1
wait i am not using recursion....
nm
you can use recursion to solve this
Markus Kiili
@Masd925
May 10 2016 05:37
@aryandua num=num does nothing.
Aryan
@aryandua
May 10 2016 05:37
yeh i couldve used a while loop
or i coulve used recursion
anyways...
thx @Masd925
CamperBot
@camperbot
May 10 2016 05:39
aryandua sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1448 | @masd925 |http://www.freecodecamp.com/masd925
Aryan
@aryandua
May 10 2016 05:39
and good night coders
I have school tommorow :worried:
Travis
@dukenukethem
May 10 2016 05:40
@aryandua good night :)
Sukhjinder Singh
@sssuk2
May 10 2016 05:42
Escape Sequences in Strings
myStr = "\"\" "\" "\"\r\" \"\n \"";// Change this line
I have to add backslash , tab , tab , carriage- return new- line
Dan Couper
@DanCouper
May 10 2016 05:44
I
Sukhjinder Singh
@sssuk2
May 10 2016 05:45
@DanCouper , sweet
can you check the whats wrong In my escaping @DanCouper ?
myStr = "\"\" "\" "\"\r\" \"\n \"";// Change this line
Coy Sanders
@coymeetsworld
May 10 2016 05:46
@sssuk2 you need to look at the table and convert each word into its appropriate escape sequence
for example tab would be \t
Sukhjinder Singh
@sssuk2
May 10 2016 05:47
I have give a look on the table @coymeetsworld
but I am not able to know where I have did the mistake here.?
myStr = "\"\" "\" "\"\r\" \"\n \"";// Change this line
@coymeetsworld In myStr
Coy Sanders
@coymeetsworld
May 10 2016 05:47
im not sure where all those symbols are coming from
but for example i don't see tab in there anywhere
take this:
myStr = "backslash tab tab carriage-return new-line"
and replace each word with the appropriate escape sequence
so replace tab with \t, so you got
myStr = "backslash \t \t carriage-return new-line"
does that make sense?
Ashwin
@ashwins93
May 10 2016 05:50
@sssuk2 you need double quotes only at the beginning and at the end of the string, i don't know why you have added so much double quotes inside the string
Travis
@dukenukethem
May 10 2016 05:52
I was so ready to give up on coding for a minute because of this stupid challenge :I
buiphuking
@buiphuking
May 10 2016 05:53
@dukenukethem what is wrong?
Travis
@dukenukethem
May 10 2016 05:53
Nothing now; I spent the better part of 24 hours trying to figure out how to do Caesars Cipher
ereinertsen
@ereinertsen
May 10 2016 05:53
I need some help with this lesson. I think my code is close but I'm struggling on one part
Travis
@dukenukethem
May 10 2016 05:53
Ashwin
@ashwins93
May 10 2016 05:53
@dukenukethem the first ingredient for being successful at coding is patience
Travis
@dukenukethem
May 10 2016 05:53
The challenges hadn't been too difficult up until that one
ereinertsen
@ereinertsen
May 10 2016 05:54
Ashwin
@ashwins93
May 10 2016 05:54
@dukenukethem at the very least you can hard code to do that challenge using a switch statement or a dictionary
Travis
@dukenukethem
May 10 2016 05:54
I got it with an if else statement
Ashwin
@ashwins93
May 10 2016 05:54
but the challenge really requires only a line or two of code to get it done
Travis
@dukenukethem
May 10 2016 05:54
took a lot of reading on ASCII
if/else if/
Ashwin
@ashwins93
May 10 2016 05:55
@dukenukethem you need to add a little arithmetical knowledge to that
circular arithmetic
buiphuking
@buiphuking
May 10 2016 05:55
@dukenukethem all string they give are uppercase , ascii is form 65 to 90
Coy Sanders
@coymeetsworld
May 10 2016 05:55
yeah need to learn ASCII on that challenge
Ashwin
@ashwins93
May 10 2016 05:55
@dukenukethem think of the alphabets being arranged on the circle so after XYZ then comes again ABC
Travis
@dukenukethem
May 10 2016 05:55
Yeh; I've got the challenge done now
Sukhjinder Singh
@sssuk2
May 10 2016 05:56
@coymeetsworld thanks for you suggestion but its still not working , i tried it thrice
CamperBot
@camperbot
May 10 2016 05:56
sssuk2 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Ashwin
@ashwins93
May 10 2016 05:56
@dukenukethem Modular Arithmetic
great!
Travis
@dukenukethem
May 10 2016 05:56
I think the hardest part was remembering to split my string into an array and mapping out each one
Coy Sanders
@coymeetsworld
May 10 2016 05:56
what do you have now @sssuk2?
ereinertsen
@ereinertsen
May 10 2016 05:56
Can anyone help me
Ashwin
@ashwins93
May 10 2016 05:56
@ereinertsen can you paste the code here instead of screen shots
ereinertsen
@ereinertsen
May 10 2016 05:56

function nextInLine(arr, item) {
testArr.push(10);
testArr.shift();
return arr[0]; // Change this line
}

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

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

Ashwin
@ashwins93
May 10 2016 05:57
@ereinertsen okay
Travis
@dukenukethem
May 10 2016 05:57
For the challenge you've got to do 65 to 95 though right? For spaces?
ereinertsen
@ereinertsen
May 10 2016 05:57
The part that isn't passing: nextInLine([], 1) should return 1
Ashwin
@ashwins93
May 10 2016 05:57
you need to return the first one in the queue
Travis
@dukenukethem
May 10 2016 05:57
or can I do x > 65 || x > 90 instead of 95?
Coy Sanders
@coymeetsworld
May 10 2016 05:57
@dukenukethem anything not a alphabetical letter you just return back
Ashwin
@ashwins93
May 10 2016 05:57
your testArr.shift() actually throws away the first item
Coy Sanders
@coymeetsworld
May 10 2016 05:57
only need to modify A-Z
Travis
@dukenukethem
May 10 2016 05:58
Oh; well alright then O:
Ashwin
@ashwins93
May 10 2016 05:58
plus you need to use the argument local variable arr instead of the global variable testArr
@ereinertsen
ereinertsen
@ereinertsen
May 10 2016 05:58
@ashwin I was doing that to achieve the last part, After nextInLine(testArr, 10), testArr4 should be 10
Travis
@dukenukethem
May 10 2016 05:58
That stinking challenge was the bane of my existence on this site
Sukhjinder Singh
@sssuk2
May 10 2016 05:58
@coymeetsworld
" \'\ \' \'\t' \'\t\' \'\r\' \'\n\' "
Coy Sanders
@coymeetsworld
May 10 2016 05:58
you don't need any quotes @sssuk2
just the double quotes at beginning and end
Ashwin
@ashwins93
May 10 2016 05:58
@dukenukethem to add thirteen it would be like (char+13)%26
Coy Sanders
@coymeetsworld
May 10 2016 05:58
you're making it more difficult than it is :)
buiphuking
@buiphuking
May 10 2016 05:59
@dukenukethem x <=77 && x>= 65 or use regexp
Coy Sanders
@coymeetsworld
May 10 2016 05:59
don't need regex for that challenge @buiphuking
but yeah you could use it, regex comes later in the curriculum though
Travis
@dukenukethem
May 10 2016 06:00
regex; from what ive been tampering with seems like it can shorten A LOT of code that i've written
Ashwin
@ashwins93
May 10 2016 06:00
@ereinertsen you should be pushing the item in the arguments, don't hard code values
Peter Svedman
@petersvedman
May 10 2016 06:00
regex is...clever but aNNNNNNNoying
buiphuking
@buiphuking
May 10 2016 06:00
/[A-Z]/
Sukhjinder Singh
@sssuk2
May 10 2016 06:00
Okay thanks @coymeetsworld and @ashwins93
CamperBot
@camperbot
May 10 2016 06:00
sssuk2 sends brownie points to @coymeetsworld and @ashwins93 :sparkles: :thumbsup: :sparkles:
:warning: sssuk2 already gave coymeetsworld points
waruwaruwaru
@waruwaruwaru
May 10 2016 06:00

Hello Campers,
I'm on the intermediate algorithm: "Everything be true". Can anyone explain why

truthCheck([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age") should return false.

should return false? All the element in the array has the property "age" and 0 is a number so that data type value is consistent with the other age values. Not sure where the false is coming from

Ashwin
@ashwins93
May 10 2016 06:00
@sssuk2 get rid of the quotes inside the string
Coy Sanders
@coymeetsworld
May 10 2016 06:00
regex could @dukenukethem but the idea also is to learn the functions its giving you in the challenge
also you need to get the character code anyways in order to encrypt it
so regex is superfluous to solve the problem
Peter Svedman
@petersvedman
May 10 2016 06:01
can solve it by making a dictionary
Travis
@dukenukethem
May 10 2016 06:01
  if ( x < 65 || x > 90) {
return String.fromCharCode(x);
}
else if (x < 78) {
return String.fromCharCode(x + 13);
}
return String.fromCharCode(x - 13);
}).join('');
}
Peter Svedman
@petersvedman
May 10 2016 06:01
map 'a' to ...
and so on
Travis
@dukenukethem
May 10 2016 06:02
this is my code - my array creating
Ashwin
@ashwins93
May 10 2016 06:03
@petersvedman yeah dictionary will work but that is technically hard coding but it gets the job done
Coy Sanders
@coymeetsworld
May 10 2016 06:03
don't know what the rest of the code is but looks ok
im guessing thats a map function
Travis
@dukenukethem
May 10 2016 06:03
yeah
I suppose I should have posted it;
Peter Svedman
@petersvedman
May 10 2016 06:04
Its not that hard, split the string into an array, walk through it and join up a new string
Coy Sanders
@coymeetsworld
May 10 2016 06:04
you didn't have to implement map although thats a more elegant way to solve it
you could've got by with a for loop
Travis
@dukenukethem
May 10 2016 06:04
whats another way I could have done it?
Coy Sanders
@coymeetsworld
May 10 2016 06:04
map is a more advanced topic but kudos for implementing it this early
at least i think it is, i forget if map was covered at that point or not
Travis
@dukenukethem
May 10 2016 06:05
map just takes what you have and does what the function tells it to do right?
Ashwin
@ashwins93
May 10 2016 06:05
@coymeetsworld i believe it was
buiphuking
@buiphuking
May 10 2016 06:05
@dukenukethem
mycode

function rot13(str) { // LBH QVQ VG!

return str.split("").map(act).join("");
function act(letter){
if(/[A-Z]/.test(letter)){
var num = letter.charCodeAt(0);
return num <= 77 ? String.fromCharCode(num + 13) : String.fromCharCode(num - 13);
}else{
return letter;
}
}
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Coy Sanders
@coymeetsworld
May 10 2016 06:05
Array.map() takes in a function, and that function runs on every element in the array
Travis
@dukenukethem
May 10 2016 06:05
I'm pretty sure it was gone over before hand
ereinertsen
@ereinertsen
May 10 2016 06:06
@ashwins93 In the previous lessons, we passed through push(). I understand not hardcoding values, but how do I push only the item?
Ashwin
@ashwins93
May 10 2016 06:06
@ereinertsen item is the argument passed to the function that must be pushed
qeurago
@qeurago
May 10 2016 06:06
can someone help me with 'using objects for lookups'? i must be missing something but i don't understand how to use a lookup table to lookup val and assign the associated string to the result variable. thanks
Peter Svedman
@petersvedman
May 10 2016 06:06
map is at the end of basic javascript, just did it
Coy Sanders
@coymeetsworld
May 10 2016 06:06
var arr = [1,2,3,4,5];

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

is the same as

arr = arr.map(function(element) { return element * element; }); //fixed typo
Travis
@dukenukethem
May 10 2016 06:06
@buiphuking I def need to go back and review a lot of what i've been learning. I could hardly read that.
Markus Kiili
@Masd925
May 10 2016 06:07
@qeurago Use syntax obj[key] to access the object and assign it to result variable. What is the object and where is the key?
ereinertsen
@ereinertsen
May 10 2016 06:07
@ashwins93 I get that part but I don't understand the syntax. So far it has been a value or ()
Ashwin
@ashwins93
May 10 2016 06:07
@ereinertsen you don't understand the syntax of push() function?
qeurago
@qeurago
May 10 2016 06:08
@Masd925 the object is lookup and i don't know what the key is
Norvin Burrus
@ndburrus
May 10 2016 06:08
@qeurago can you post what you've got so far?
qeurago
@qeurago
May 10 2016 06:08
how do i do the js markup thing in here
i forgot
Markus Kiili
@Masd925
May 10 2016 06:08
@qeurago It is passed into the function so use the function parameter as the key.
Ashwin
@ashwins93
May 10 2016 06:08
use three backticks


Norvin Burrus
@ndburrus
May 10 2016 06:08
help format
CamperBot
@camperbot
May 10 2016 06:08

## :point_right: code formatting [wiki]

### Multi line Code

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 ⏎]

### Single line Code

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

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

qeurago
@qeurago
May 10 2016 06:09

// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};

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

// Change this value to test
phoneticLookup("alpha");
Norvin Burrus
@ndburrus
May 10 2016 06:10
@ereinertsen "Array.prototype.push()" {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push}
The push() method adds one or more elements to the end of an array and returns the new length of the array.

SyntaxEDIT
arr.push(element1, ..., elementN)
Parameters
elementN
The elements to add to the end of the array.
Returns
The new length property of the object upon which the method was called.

DescriptionEDIT
The push method appends values to an array.
Ashwin
@ashwins93
May 10 2016 06:10
@qeurago here your object is the lookup and your key is the val in the argument
Norvin Burrus
@ndburrus
May 10 2016 06:12
@qeurago where is result updated from the initial value? :)
qeurago
@qeurago
May 10 2016 06:12
@ndburrus that's what i am trying to figure out how to do
Travis
@dukenukethem
May 10 2016 06:12
This message was deleted
Norvin Burrus
@ndburrus
May 10 2016 06:12
@qeurago ok, what needs to be defined? hint: what is returned?
qeurago
@qeurago
May 10 2016 06:13
@ndburrus the result is returned
Norvin Burrus
@ndburrus
May 10 2016 06:14
@qeurago great! ok, so how do we assign an updated value to return using the lookup key/value pairs? hint: we also need to use the inputted function (phoneticLookup) var/iable.
qeurago
@qeurago
May 10 2016 06:15
@ndburrus obj.prop?
Markus Kiili
@Masd925
May 10 2016 06:16
@qeurago The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
Norvin Burrus
@ndburrus
May 10 2016 06:16
@qeurago we're looking at the "using objects for lookups challenge"?
qeurago
@qeurago
May 10 2016 06:16
@ndburrus yes
Norvin Burrus
@ndburrus
May 10 2016 06:17
@qeurago ok, how do we use the lookup table to get the value/result we need??
qeurago
@qeurago
May 10 2016 06:17
@ndburrus i don't know
Travis
@dukenukethem
May 10 2016 06:18
So; after going through JSON APIs and Ajax should I know how to build a random quote generator?
Norvin Burrus
@ndburrus
May 10 2016 06:18
@qeurago let's review the given example:
var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"
qeurago
@qeurago
May 10 2016 06:19
ok
Norvin Burrus
@ndburrus
May 10 2016 06:20
@qeurago ...relax, and just follow the example... does it make sense?
qeurago
@qeurago
May 10 2016 06:20
oh i got it
Norvin Burrus
@ndburrus
May 10 2016 06:20
does it pass (parse/validate)?
qeurago
@qeurago
May 10 2016 06:20
i typed result=lookup[val];
Travis
@dukenukethem
May 10 2016 06:21
Good night all I need to rest my fried brain 8D
Ashwin
@ashwins93
May 10 2016 06:21
@qeurago bingo!
AbdHan
@abdhan
May 10 2016 06:21
@dukenukethem Yes. Find a random quote API. Use AJAX to get quotes.
Norvin Burrus
@ndburrus
May 10 2016 06:21
@qeurago You are on fire!! :fire:
Ashwin
@ashwins93
May 10 2016 06:22
Travis
@dukenukethem
May 10 2016 06:22
I googled "Random quote API" and was sent to a codepen that had a bunch of quotes pre written and it just chose from a list lmao
qeurago
@qeurago
May 10 2016 06:23
thanks for the help
Ashwin
@ashwins93
May 10 2016 06:23
all of these * marked challenges are somewhat beyond the scope covered in the lessons, it is to test your read-search-ask skills @dukenukethem
Norvin Burrus
@ndburrus
May 10 2016 06:23
@qeurago you're welcome :+1:
Travis
@dukenukethem
May 10 2016 06:23
Ah; well that makes sense.
Ashwin
@ashwins93
May 10 2016 06:24
try http://quotesondesign.com/ @dukenukethem
it has an API and it comes with an example
Travis
@dukenukethem
May 10 2016 06:25
what am I looking at here?
-is very tired-
Ashwin
@ashwins93
May 10 2016 06:27
@dukenukethem i'm yet to do the random quote generator myself, i can't find time to do it even though i know how to. May be we can pair up sometime
Travis
@dukenukethem
May 10 2016 06:27
I'd be down for that; send me a pm!
Gestur Björnsson
@GesturB
May 10 2016 06:27

Can anyone tell me what is wrong with this

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr = "Hello World";
myStr[0] = "H";

Ashwin
@ashwins93
May 10 2016 06:28
@dukenukethem sure
Norvin Burrus
@ndburrus
May 10 2016 06:28
@GesturB what challenge is this?
Ashwin
@ashwins93
May 10 2016 06:29
@ndburrus its the one that explains how strings are immutable
Gestur Björnsson
@GesturB
May 10 2016 06:29
@ndburrus Understand String Immutability
Coy Sanders
@coymeetsworld
May 10 2016 06:29
@GesturB you need to remove that last line
the idea is that you can't change a single character like that, the lesson is that Strings are immutable, meaning you can modify them
all you can do is reassign the variable to an entirely new string, like you did with myStr = "Hello World";
Gestur Björnsson
@GesturB
May 10 2016 06:30
@coymeetsworld Thank you :)
CamperBot
@camperbot
May 10 2016 06:30
gesturb sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
May 10 2016 06:30
no problem
May 10 2016 06:32
Anyone familiar with posting data from python directly to javascript ?
such as an array..
Ashwin
@ashwins93
May 10 2016 06:33
@affansadiq i guess python has support for JSON
May 10 2016 06:33
and then?
Markus Kiili
@Masd925
May 10 2016 06:34
@affansadiq Python objects transform easily to JSON and JSON into JS objects.
Ashwin
@ashwins93
May 10 2016 06:34
daniel akerley
@darkSkiesUniverse
May 10 2016 06:34

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

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

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

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

var Bike = function() {

// Only change code below this line.
var gear = 0;
this.setGear = function (change){
gear+= change;
};

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

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(4);
myBike.getGear();
function works fine but challenge isn't clearing off?
Ashwin
@ashwins93
May 10 2016 06:34
you just transform your objects in python to JSON and then from JS you can easily read JSON
Andres Romero
@And-Ro
May 10 2016 06:34
Hello I cannot make this lookup table works! Help please : ((
var lookup = {
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};
Norvin Burrus
@ndburrus
May 10 2016 06:35
@And-Ro which challenge is this?
Markus Kiili
@Masd925
May 10 2016 06:35
@And-Ro Use syntax obj[key] to access the object and assign it to result variable. What is the object and where is the key?
Andres Romero
@And-Ro
May 10 2016 06:36
Using Objects for Lookups
Norvin Burrus
@ndburrus
May 10 2016 06:36
@And-Ro can you post all the code, please? [there is a reason]
Andres Romero
@And-Ro
May 10 2016 06:37

var result = "";

// Only change code below this line
var lookup = {
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

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

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

Norvin Burrus
@ndburrus
May 10 2016 06:37
@And-Ro ok, where does the value of result get updated (from it's initialization "var result = "";")?
Andres Romero
@And-Ro
May 10 2016 06:37
I guess i need it initialize the lookup table but i don´t know how
i tried lookupval;
May 10 2016 06:38
First of all, i wanna prevent users from reading the .json data
Norvin Burrus
@ndburrus
May 10 2016 06:38
@And-Ro ok, let's review the example code (which illustrates how to use the lookup table to retieve a value): (does this help?)
var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"
Andres Romero
@And-Ro
May 10 2016 06:39
ok
yeah thanks !!! : )
i will keep on trying thanks so much !
Norvin Burrus
@ndburrus
May 10 2016 06:40
@And-Ro Kudos to you! :+1: You're very welcome.... look for any clues everywhere - in the instructions/code, etc... :)
Ashwin
@ashwins93
May 10 2016 06:42
May 10 2016 06:42
or any developers/hijackers
actually preventing it from google chrome dev tools
Ashwin
@ashwins93
May 10 2016 06:43
don't you mean hackers when you say hijackers?
Robin Versloot
@EvilDutchrebel
May 10 2016 06:43

Hey guys, I seem to be stuck on this one, anyone willing to help? :)

function caseInSwitch(val) {
// Only change code below this line
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
// Only change code above this line
}

// Change this value to test
caseInSwitch(1);

Norvin Burrus
@ndburrus
May 10 2016 06:45
@EvilDutchrebel which challenge is this?
Robin Versloot
@EvilDutchrebel
May 10 2016 06:45
@ndburrus Selecting from many options with Switch Statements
Norvin Burrus
@ndburrus
May 10 2016 06:47
@EvilDutchrebel ok, "Selecting from many (what?) Statements? :)
Robin Versloot
@EvilDutchrebel
May 10 2016 06:48

@ndburrus If you have many options to choose from, use a switch statement. A switch statement tests a value and can have many case statements which defines various possible values. Statements are executed from the first matched case value until a break is encountered.

Here is a pseudocode example:

switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
}
case values are tested with strict equality (===). The break tells JavaScript to stop executing statements. If the break is omitted, the next statement will be executed.

Instructions
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

Norvin Burrus
@ndburrus
May 10 2016 06:48
@EvilDutchrebel super! what type of statement is being used in the psuedo code?
Coy Sanders
@coymeetsworld
May 10 2016 06:48
@EvilDutchrebel when your code gets to a break, it leaves the function
Travis Stevenson
@travisxcode
May 10 2016 06:49

I'm having trouble accessing multidimensional arrays via index.

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

Norvin Burrus
@ndburrus
May 10 2016 06:49
@EvilDutchrebel ....alright, what is the first word in the psuedo code?
Travis Stevenson
@travisxcode
May 10 2016 06:49
How would I access the value of "8" and store it in myData?
Robin Versloot
@EvilDutchrebel
May 10 2016 06:49
Norvin Burrus
@ndburrus
May 10 2016 06:50
@EvilDutchrebel ok... now, let's follow the format of the example code..... :+1: your answer statements are fine.
Markus Kiili
@Masd925
May 10 2016 06:51
@coymeetsworld break leaves the switch statement, not the function.
Constantine Gauvoronsky
@ogkonstantin
May 10 2016 06:51

Hi there ! I can't understand this:
So, I have my var
Like this

var myStr; // Change this line

Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr

Coy Sanders
@coymeetsworld
May 10 2016 06:51
sorry that's what I meant @Masd925
but the problem is inside the switch statement
Norvin Burrus
@ndburrus
May 10 2016 06:52
@EvilDutchrebel ...look at the first word after the comment in the psuedo code, and compare it to the first word after the comment in your code...
Coy Sanders
@coymeetsworld
May 10 2016 06:52
when it gets to break, nothing else in the switch statement gets executed @EvilDutchrebel
Robin Versloot
@EvilDutchrebel
May 10 2016 06:54
@ndburrus I'm sorry, I really don't get this
Jonathan Schwob
@JonathanSchwob
May 10 2016 06:54
how do you guys quickly share your code environment?
is there a share button im missing
Norvin Burrus
@ndburrus
May 10 2016 06:54
@EvilDutchrebel what is the first word after the comment (" // Only change code below this line") in the example code?
Coy Sanders
@coymeetsworld
May 10 2016 06:55
@EvilDutchrebel you need to move variable declaration and return line outside of the switch statement
Robin Versloot
@EvilDutchrebel
May 10 2016 06:56
@ndburrus switch?
Coy Sanders
@coymeetsworld
May 10 2016 06:56
yes, what the break statement does is says you're leaving the switch, nothing below it gets executed, including the return statement
Norvin Burrus
@ndburrus
May 10 2016 06:56
@EvilDutchrebel do you have that word in your code?
Coy Sanders
@coymeetsworld
May 10 2016 06:56
only way return will run is if the case is not 1-4
May 10 2016 06:56
Ok easy to explain. I don't want anyone to see my JSON file/data when he turns on the dev-webtools in any browser..
Coy Sanders
@coymeetsworld
May 10 2016 06:57
but in those situations it will only return an empty string
Robin Versloot
@EvilDutchrebel
May 10 2016 06:57
@ndburrus so I should use switch instead of case?
Jonathan Schwob
@JonathanSchwob
May 10 2016 06:57

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

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);
hello could someone please help me figure out if i’m on the right track…i’m a bit confused with what else to write
Return Early Pattern for Functions level
Coy Sanders
@coymeetsworld
May 10 2016 06:58
oh I missed there is no switch statement @ndburrus, misread that
Markus Kiili
@Masd925
May 10 2016 06:59
@JonathanSchwob if (a || b < 0) is wrong. It should be like if (a < 0 || b < 0)
Norvin Burrus
@ndburrus
May 10 2016 06:59
@EvilDutchrebel ok - let's review the sample code: (there is an additional issue - closing curly brace - that we'' get to in a moment)
switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
}
cannelflow
@cannelflow
May 10 2016 06:59
@JonathanSchwob of (a is less then 0 or b is less then 0)
Jonathan Schwob
@JonathanSchwob
May 10 2016 06:59
oh ok thank you, about the rest of the code though
Norvin Burrus
@ndburrus
May 10 2016 06:59
@coymeetsworld :) you caught the missing closing curly.... :)
cannelflow
@cannelflow
May 10 2016 06:59
so do like @Masd925 said @JonathanSchwob
Jonathan Schwob
@JonathanSchwob
May 10 2016 07:00
oh ok
thank you
:)
Norvin Burrus
@ndburrus
May 10 2016 07:00
@EvilDutchrebel how are you doing?
Coy Sanders
@coymeetsworld
May 10 2016 07:01
yeah lol
Robin Versloot
@EvilDutchrebel
May 10 2016 07:01
@ndburrus I think I should read further into this because I'm at a complete loss