10th
Nov 2016
Aiden
Nov 10 2016 00:00
@gikwu1 So when I think about functions, I know that I am telling the computer what to do when I give it some type of variable. So in this instance, we want to give the computer a temperature in Celsius, and we want it to do some math and spit out what that equivalent temp in Fahrenheit will be. So in the function, we have to tell the computer where to input the temp in Celsius so that it can do the math and give us the temp in Fahrenheit. I can't give too much more in depth explanation without giving you the answer completely, lol.
Iqbal
@mibaldobaghi
Nov 10 2016 00:01
guys
im stuck with this
function permAlone(str) {
var permutations = [],
nextWord = [],
chars = [];
var regex = /(.)\1/g;
chars = str.split("");

function permutate(chars){
if (chars.length === 0){permutations.push(nextWord.join(""));}
for(var i =0;i < chars.length;i++){
chars.push(chars.shift());
nextWord.push(chars[0]);
permutate(chars.slice(1));
nextWord.pop();
}
}
permutate(chars);
return permutations.filter(function(element){
if(regex.test(element)){
return false;
}else{
return true;
}
});

}
permAlone('aabb');
Aiden
Nov 10 2016 00:01
But because the temp in Celsius is going to keep changing, we need to put a variable in it's place, not the number itself. So that way, we then can tell it what the variable is, and it will put that into the equation. @gikwu1
Iqbal
@mibaldobaghi
Nov 10 2016 00:02
the filter does not filter correctly. if I test return regex.test("abba") it returns true, but in the filter it returns false
anyone can explain why the regexp changes in a function?
ditorojuan
@ditorojuan
Nov 10 2016 00:07
Hello i have a problem with substr and variables can someone help me?
i saw the error ignore the above question
gabi
@gikwu1
Nov 10 2016 00:10
@AidenMead the issue is that i need to get all of the conversion in a list without ignorring the other
Aiden
Nov 10 2016 00:11
Right, that's why I was saying, don't hard code the Celsius temp in. You have to put a variable in it's place, so that way when you run the function, it will throw in whatever number is put in as the argument, and will do the correct math.
gabi
@gikwu1
Nov 10 2016 00:13
let me explain
Aiden
Nov 10 2016 00:13
So, say that I want to figure out a math problem where I need to always know that a number times 5 is... So instead of coding 15, 25, 35 and on, I write it once : x 5. Then when I call my function, I throw numbers in as the argument for x, and the computer will substitute and give me the right amount.
Ah, sorry, it did the math in the middle there. Instead of coding (1 5, 2 5, 3 * 5.....)
Arg, it's still doing the math, my bad. That's supposed to be 1 times 5, 2 times 5, 3 times 5
So in a function, that would look like this:
function timesFive (x) {
var result = "";
result = x * 5;
}
timesFive(5);//Which will result in 25.
gabi
@gikwu1
Nov 10 2016 00:18
i want to convert the following to fahrenheit "15, 10, and 21" respectively. However, if i convert 15c to F and get the answer. it is marked off as corect. but when i proceed to convert 10c to F and get the answer, it is marked off as correct but the answer from 15 is marked as not done
João Mhurilo Godoi da Silva
@ebak123
Nov 10 2016 00:22
Guys, _ is not a special char? Because is the only special char i cant remove using /\W+/g ...
Lucas
@lucas032689
Nov 10 2016 00:23

I'm having some issues with Word Blanks for Javascript, this is my code below, can someone help please?

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

Aiden
Nov 10 2016 00:31
@gikwu1 You have to fulfill them all at once, the only way to do that is, instead of actually coding "fahrenheit=15c*(9/5)+32", you need to give it a variable to tell the computer where to place those numbers, known as arguments.
Ogundele Olumide
@Lumexralph
Nov 10 2016 00:35
@ebak123 \w covers underscores
Aiden
Nov 10 2016 00:36
@gikwu1 In my example above x is a variable, then I passed 5 as an argument. In that situation, if I had 5, 6, 10 all as arguments, because I put in the X instead of coding in each argument, it actually satisfies all of the requirements because no matter what argument the computer puts in, I will get the correct answer. the way the exercises are set up is that when you click submit, the computer goes through and passes all of the arguments, and ticks off which ended correctly and which did not. So you need to write a function that in one shot can take any of those arguments and get the right answer. Which means you can't just hard code the arguments in.
EgeKaya
@EgeKaya
Nov 10 2016 00:38

I need help with linking a JSON file to HTML. I am at the Random Quote Machine challenge. Here is the code:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script>

$(function() { var people = [];$.getJSON('quotes/quotes.json', function(data) {
var entry = data[Math.floor(Math.random()*data.length)];
var par = "<p class='well'>" + entry + "</p>";

$(par).appendTo("#quotes_Main"); }); }); </script> <div id="quotes_Main"> </div> I really appreciate any help as I have been stuck on this for a long time... Carlin @crlycstl Nov 10 2016 00:38 so, i just did this for the profile lookup: function lookUpProfile(firstName, prop){ // Only change code below this line var x = ""; var i = 0; while(i < contacts.length){ if (firstName == contacts[i].firstName){ if(contacts[i].hasOwnProperty(prop)){ return contacts[i][prop]; }else{ return "No such property"; } }else{ x = "No such contact"; i++; } } return x; and it works, but I'm wondering if anybody knows a cleaner way to do this? Is this the best way? lettda @lettda Nov 10 2016 00:40 @lettda I'm working on my weather app and need to access the temperature data of the following line $(".message").append("<h4 id='tempData'>Current Temperature: "+data.main.temp+"&#8451</h4>");

is there a method I can use on the h4 to get just the numerical value of the temperature?

EgeKaya
@EgeKaya
Nov 10 2016 00:42

I need help with linking a JSON file to HTML. I am at the Random Quote Machine challenge. Here is the code:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>
<script>

$(function() { var people = [];$.getJSON('quotes/quotes.json', function(data) {
var entry = data[Math.floor(Math.random()*data.length)];
var par = "<p class='well'>" + entry + "</p>";

$(par).appendTo("#quotes_Main"); }); }); </script> <div id="quotes_Main"> </div> I really appreciate any help as I have been stuck on this for a long time... Stephen James @sjames1958gm Nov 10 2016 00:47 @EgeKaya quotes/quotes.json is on the local server? @lettda Seems better to store the data in js rather than in the DOM. EgeKaya @EgeKaya Nov 10 2016 00:49 @sjames1958gm Yes, I am running it on sublime text Stephen James @sjames1958gm Nov 10 2016 00:50 @EgeKaya Do you know that you are getting the data in the call back? Sometimes serving local files using getJSON doesn't work. @lettda Another choice would be to save the temp in a data attribute. https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes EgeKaya @EgeKaya Nov 10 2016 00:50 @sjames1958gm No, how do I check that? gabi @gikwu1 Nov 10 2016 00:50 sorry for wasting your time but i dont undderstand @AidenMead Stephen James @sjames1958gm Nov 10 2016 00:51 @EgeKaya You could put a console.log in the callback EgeKaya @EgeKaya Nov 10 2016 00:52 console.log(entry); Like that? Stephen James @sjames1958gm Nov 10 2016 00:52 @EgeKaya console.log(JSON.stringify(data)) would be what I would do then you can see the whole object Somia ♡ @somiajagadish Nov 10 2016 00:53 hi i need help var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>"; they want me to change the provided string from double to single quotes and remove the escaping. Stephen James @sjames1958gm Nov 10 2016 00:54 @somiajagadish Change the first and last " to ' and remove all the \ EgeKaya @EgeKaya Nov 10 2016 00:55 @sjames1958gm Where am I supposed to see the console? I am running it on sublimetext Somia ♡ @somiajagadish Nov 10 2016 00:55 hold on im going to fix it and send it to you :)) Stephen James @sjames1958gm Nov 10 2016 00:55 @EgeKaya There is a browser plugin in sublime? Or are you using a browser? Somia ♡ @somiajagadish Nov 10 2016 00:56 var myStr = "<a href='http://www.example.com' target='_blank\'>Link</a>"; Stephen James @sjames1958gm Nov 10 2016 00:56 @EgeKaya The browser should have developer tools (including a console Somia ♡ @somiajagadish Nov 10 2016 00:56 like this Stephen James @sjames1958gm Nov 10 2016 00:56 @somiajagadish 1. I said change the first and last " to ' and you did the opposite. 2. didn't remove all the \ Somia ♡ @somiajagadish Nov 10 2016 00:57 ohh thanks Stephen James @sjames1958gm Nov 10 2016 00:58 @somiajagadish :+1: Somia ♡ @somiajagadish Nov 10 2016 01:02 You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words. Here is the text with the escape sequences written out. "FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine" how am i supposed to do this :( lettda @lettda Nov 10 2016 01:03 @sjames1958gm this looks promising but how would I store the data in the html to access? @sjames1958gm should define the data-attr in the html and then set the value in my script? Stephen James @sjames1958gm Nov 10 2016 01:04 @lettda When you append you can do it there - similar to how you put it in the element. Somia ♡ @somiajagadish Nov 10 2016 01:05 hello? Stephen James @sjames1958gm Nov 10 2016 01:05 $(".message").append("<h4 id='tempData' data-temp='"+data.main.temp+"'>Current Temperature: "+data.main.temp+"&#8451</h4>");
@lettda something like ^^
Treylerp
@Treylerp
Nov 10 2016 01:06
could someone help me with reminders
Stephen James
@sjames1958gm
Nov 10 2016 01:06
@somiajagadish replace the 4 keywords with the corresponding values from the table
@Treylerp remainders?
Treylerp
@Treylerp
Nov 10 2016 01:06
The remainder operator % gives the remainder of the division of two numbers.
Im supposed to do this but cant figure it out Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Stephen James
@sjames1958gm
Nov 10 2016 01:07
@Treylerp What do you have?
Treylerp
@Treylerp
Nov 10 2016 01:08

// Only change code below this line

var remainder;

Stephen James
@sjames1958gm
Nov 10 2016 01:08
How would you assign the result of 11 divided by 3 to the variable?
Treylerp
@Treylerp
Nov 10 2016 01:08
var remainder = 11/3
Stephen James
@sjames1958gm
Nov 10 2016 01:08
@Treylerp Replace / with % and you're done
Treylerp
@Treylerp
Nov 10 2016 01:10
@sjames1958gm Thanks
CamperBot
@camperbot
Nov 10 2016 01:10
treylerp sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4275 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 10 2016 01:10
@Treylerp :+1:
estnimbus
@estnimbus
Nov 10 2016 01:10

function largestOfFour(arr) {
// You can do this!

var brr = [];
for (var i=0; i<arr.length;i++){
for (var j=0; j<arr[i].length; j++){
arr[i] = arr[i].sort( function(a,b){return (b-a);});
brr.push(arr[i][0]);

 }

return brr;

}

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);


kingsleychino
@kingsleychino
Nov 10 2016 01:11
please guys help me in this code
estnimbus
@estnimbus
Nov 10 2016 01:11
function largestOfFour(arr) {
// You can do this!

var brr = [];
for (var i=0; i<arr.length;i++){
for (var j=0; j<arr[i].length; j++){
arr[i] = arr[i].sort( function(a,b){return (b-a);});
brr.push(arr[i][0]);

}

return brr;
}

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stephen James
@sjames1958gm
Nov 10 2016 01:11
@estnimbus What's happening with your code?
Somia ♡
Nov 10 2016 01:11
var myStr = \n"FirstLine/n"/r"SecondLine/r"ThirdLine"; // Change this line
Whats wrong??
estnimbus
@estnimbus
Nov 10 2016 01:12
@sjames1958gm I am supposed to return an array with the highest number of each sub arrays entered
EgeKaya
@EgeKaya
Nov 10 2016 01:12
I need help with attaching a JSON file to HTML. Here is the code. I am running the code on sublime text.
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>

<script>
$(document).ready(function() {$(function() {

var people = [];

$.getJSON('quotes/quotes.json', function(data) { var entry = data[Math.floor(Math.random()*data.length)]; var par = "<p class='well'>" + entry + "</p>"; par.appendTo("#quotes_Main"); }); }); }); </script> Somia ♡ @somiajagadish Nov 10 2016 01:12 var myStr = \n"FirstLine/n"/r"SecondLine/r"ThirdLine"; // Change this line Help kingsleychino @kingsleychino Nov 10 2016 01:12 @somiajagadish please check this code for me Somia ♡ @somiajagadish Nov 10 2016 01:13 okay Stephen James @sjames1958gm Nov 10 2016 01:13 @somiajagadish Look at the sample string and the keywords and try again - its only one string so don't add a bunch of " @estnimbus And what is happening estnimbus @estnimbus Nov 10 2016 01:13 @sjames1958gm I think I got the part where you can find the largest number put I have difficulties putting them inserting them in an array Somia ♡ @somiajagadish Nov 10 2016 01:13 @kingsleychino do you have the code? kingsleychino @kingsleychino Nov 10 2016 01:13 @somiajagadish yes @somiajagadish function myTest(val) { var answer = ""; // Only change code below this line switch (val) { case 1: answer = "alpha"; break; case 2: answer = "beta"; break; case 3: answer = "gamma"; break; case 4: answer = "delta"; break; } // Only change code above this line return answer; } // Change this value to test myTest(2); Somia ♡ @somiajagadish Nov 10 2016 01:13 @kingsleychino okay Stephen James @sjames1958gm Nov 10 2016 01:14 @kingsleychino Is that the correct function name? kingsleychino @kingsleychino Nov 10 2016 01:14 @sjames1958gm yes but it is not working Somia ♡ @somiajagadish Nov 10 2016 01:14 I sorry but I'm still learing so I have no idea ask one of our more experienced people :) Stephen James @sjames1958gm Nov 10 2016 01:14 @estnimbus What is your code returning? @kingsleychino Challenge name? Somia ♡ @somiajagadish Nov 10 2016 01:14 @sjames1958gm whats wrong with my code var myStr = \n"FirstLine/n"/r"SecondLine/r"ThirdLine"; // Change this line EgeKaya @EgeKaya Nov 10 2016 01:15 I need help with attaching a JSON file to HTML. Here is the code. I am running the code on sublime text.  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script> </head> <script>$(document).ready(function() {

$(function() { var people = [];$.getJSON('quotes/quotes.json', function(data) {
var entry = data[Math.floor(Math.random()*data.length)];
var par = "<p class='well'>" + entry + "</p>";

par.appendTo("#quotes_Main");
});

});
});
</script>
Stephen James
@sjames1958gm
Nov 10 2016 01:15
@kingsleychino My challenge says the function name is caseInSwitch
estnimbus
@estnimbus
Nov 10 2016 01:15
@sjames1958gm the highest number of the first sub array times 5 so [5,5,5,5]
kingsleychino
@kingsleychino
Nov 10 2016 01:15
@sjames1958gm yes
estnimbus
@estnimbus
Nov 10 2016 01:15
@sjames1958gm times 4 I meant
Stephen James
@sjames1958gm
Nov 10 2016 01:16
@somiajagadish Look at the sample string and the keywords and try again - its only one string so don't add a bunch of "
Somia ♡
Nov 10 2016 01:16
Okay thanks
kingsleychino
@kingsleychino
Nov 10 2016 01:16
@sjames1958gm please check the code for me
Stephen James
@sjames1958gm
Nov 10 2016 01:17
@estnimbus Check where you are pushing and returning.
Steven
@Spokaroonie
Nov 10 2016 01:17

I have completed this exercise, but would someone be able to explain it in laymans terms for me to fully grasp it. It returns as 20. I just want to know why if I initialize i=1 why it returns as 18.
var myArr = [ 2, 3, 4, 5, 6];

var total = 0;

for (var i = 0; i < myArr.length; i++) {
total += myArr[i];

Somia ♡
Nov 10 2016 01:17
var myStr = \n"FirstLine/n"/r"SecondLine/r"ThirdLine";
Stephen James
@sjames1958gm
Nov 10 2016 01:17
@kingsleychino Your code looks fine. Can you copy one of the tests here
Somia ♡
Nov 10 2016 01:17
I seriousley have no clue
estnimbus
@estnimbus
Nov 10 2016 01:17
@sjames1958gm ok
Somia ♡
Nov 10 2016 01:18
:alien: :heartbeat:
Stephen James
@sjames1958gm
Nov 10 2016 01:18
@somiajagadish Look at the table - there are \r and \n -
kingsleychino
@kingsleychino
Nov 10 2016 01:18

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

// Change this value to test
myTest(2);

Stephen James
@sjames1958gm
Nov 10 2016 01:18
@kingsleychino Copy the text from one of the tests to here
Somia ♡
Nov 10 2016 01:18
@sjames1958gm I know
kingsleychino
@kingsleychino
Nov 10 2016 01:18
Stephen James
@sjames1958gm
Nov 10 2016 01:19
@kingsleychino is this one of the tests caseInSwitch(1) should have a value of "alpha"
@somiajagadish Copy the string from the instructions to the editor, putting "" around it then replace the 4 key words with the values from the table
kingsleychino
@kingsleychino
Nov 10 2016 01:19
@sjames1958gm how please show me example
Stephen James
@sjames1958gm
Nov 10 2016 01:20
@kingsleychino Is this one of the tests from the challenge? caseInSwitch(1) should have a value of "alpha"
EgeKaya
@EgeKaya
Nov 10 2016 01:20
I need help with attaching a JSON file to HTML. Here is the code. I am running the code on sublime text.
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script>

<script>
$(document).ready(function() {$(function() {

var people = [];

$.getJSON('quotes/quotes.json', function(data) { var entry = data[Math.floor(Math.random()*data.length)]; var par = "<p class='well'>" + entry + "</p>"; par.appendTo("#quotes_Main"); }); }); }); </script> Stephen James @sjames1958gm Nov 10 2016 01:21 @EgeKaya So sublime text has a browser built in? Walid Ashri @walidashri Nov 10 2016 01:22 @EgeKaya what error you get looks valid? estnimbus @estnimbus Nov 10 2016 01:22 @sjames1958gm function largestOfFour(arr) { // You can do this! var brr = []; for (var i=0; i<arr.length;i++){ for (var j=0; j<arr[i].length; j++){ arr[i] = arr[i].sort( function(a,b){return (b-a);}); brr.push(arr[i][0]); } return brr; } } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); Steven @Spokaroonie Nov 10 2016 01:22 var myArr = [ 2, 3, 4, 5, 6]; // Only change code below this line var total = 0; for (var i = 0; i < myArr.length; i++) { total += myArr[i]; estnimbus @estnimbus Nov 10 2016 01:22 @sjames1958gm Not seeing a solution kingsleychino @kingsleychino Nov 10 2016 01:23 @sjames1958gm not working Stephen James @sjames1958gm Nov 10 2016 01:23 @estnimbus If you are going to sort the values, why are there two loops? Also why are you returning inside the first loop? @kingsleychino Can you answer my question? EgeKaya @EgeKaya Nov 10 2016 01:23 @sjames1958gm I am coding it on sublime text, running the code on google chrome. Sorry about that graphetes @graphetes Nov 10 2016 01:23 good book recommendations on books to learn algorithms? kingsleychino @kingsleychino Nov 10 2016 01:23 @sjames1958gm what is the question Stephen James @sjames1958gm Nov 10 2016 01:23 @EgeKaya If you put a console.log inside your getJSON you should be able to see if that happens in the chrome devtools. @kingsleychino Is this one of the tests from the challenge? caseInSwitch(1) should have a value of "alpha" kingsleychino @kingsleychino Nov 10 2016 01:24 @sjames1958gm how do I fix it Stephen James @sjames1958gm Nov 10 2016 01:24 @Spokaroonie each pass through the loop will have a different value of i so a different value of myArr[i] which is summed to total. kingsleychino @kingsleychino Nov 10 2016 01:24 @sjames1958gm were do I fix it Stephen James @sjames1958gm Nov 10 2016 01:25 @kingsleychino Answer that question and I'll know. Adolfo Saenz @AdoSae1 Nov 10 2016 01:25 guys im having trouble with switch statements. EgeKaya @EgeKaya Nov 10 2016 01:25 @sjames1958gm file:///D:/Main/Personal/Programming/Projects/Websites/Random%20Quote%20Machine/js/bootstrap.min.js Failed to load resource: net::ERR_FILE_NOT_FOUND jquery.min.js:4 XMLHttpRequest cannot load file:///D:/Main/Personal/Programming/Projects/Websites/Random%20Quote%20Machine/quotes/quotes.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.send @ jquery.min.js:4 Adolfo Saenz @AdoSae1 Nov 10 2016 01:25 can anyone help me? Stephen James @sjames1958gm Nov 10 2016 01:25 @EgeKaya That was what I was afraid of - you cannot load local files like that without a web server. @AdoSae1 Probably Steven @Spokaroonie Nov 10 2016 01:26 @sjames1958gm Thanks for the clarification. My sleepy brain is being silly. kingsleychino @kingsleychino Nov 10 2016 01:26 @sjames1958gm working in it but not getting it right CamperBot @camperbot Nov 10 2016 01:26 spokaroonie sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: Adolfo Saenz @AdoSae1 Nov 10 2016 01:26 @sjames1958gm sweet! CamperBot @camperbot Nov 10 2016 01:26 :star2: 4276 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Adolfo Saenz @AdoSae1 Nov 10 2016 01:26 Write a switch statement which tests val and sets answer for the following conditions: 1 - "alpha" 2 - "beta" 3 - "gamma" 4 - "delta" is what its asking me Stephen James @sjames1958gm Nov 10 2016 01:26 @kingsleychino In my challenge the function name is caseInSwitch - try changing to that Adolfo Saenz @AdoSae1 Nov 10 2016 01:26 i got this this function caseInSwitch(val) { var answer = ""; // Only change code below this line switch(val){ case caseInSwitch(1): answer="alpha"; break; case caseInSwitch(2): answer="beta"; break; case caseInSwitch(3): answer="gamma"; break; case caseInSwitch(4): answer="delta"; break; } // Only change code above this line return answer; } // Change this value to test caseInSwitch(1); Stephen James @sjames1958gm Nov 10 2016 01:27 @AdoSae1 it should be case 1: not case caseInSwitch(1): - this is actually calling the function again. Maverink @Maverink Nov 10 2016 01:28 hi guys , anyone can help me with the caesars cipher exercise? EgeKaya @EgeKaya Nov 10 2016 01:28 @sjames1958gm What does that mean? How do I solve the issue? kingsleychino @kingsleychino Nov 10 2016 01:28 @sjames1958gm thank you so much for your help CamperBot @camperbot Nov 10 2016 01:28 kingsleychino sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: estnimbus @estnimbus Nov 10 2016 01:28 @sjames1958gm The second loop is so i can have access to the nested arrays within the original one and get the highest number Stephen James @sjames1958gm Nov 10 2016 01:29 @EgeKaya In order to do getJSON you have to have a webserver Adolfo Saenz @AdoSae1 Nov 10 2016 01:29 alright i get it now i was doing that before but wasnt doing answer="alpha"; @sjames1958gm thanks CamperBot @camperbot Nov 10 2016 01:29 adosae1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 4277 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Walid Ashri @walidashri Nov 10 2016 01:29 @sjames1958gm thanks I'll give up can't match your speed :) CamperBot @camperbot Nov 10 2016 01:29 walidashri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 4278 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm Nov 10 2016 01:29 @estnimbus But you sorted the value which puts the largest first so you don't have to loop again. estnimbus @estnimbus Nov 10 2016 01:29 I changed the place of the return statement outside of the for statement Stephen James @sjames1958gm Nov 10 2016 01:29 @walidashri Hey EgeKaya @EgeKaya Nov 10 2016 01:30 @sjames1958gm I am not too experienced. Can you give a more detailed answer please? Stephen James @sjames1958gm Nov 10 2016 01:33 @EgeKaya the getJSON function causes a requests to be sent to a server. But you are running out of a file, so the URL is file:// which is not allowed for this. Generally there is a remote web server or API that receives the requests over http:// Nicholas Vorraso @nickeyvee Nov 10 2016 01:34 ** i have a question about my pomodoro clock Stephen James @sjames1958gm Nov 10 2016 01:34 @estnimbus When you moved the return do you now get 4 copies of each of the largest values? @nickeyvee Best thing to do is just ask away and see who responds OwlNavigator @OwlNavigator Nov 10 2016 01:35 can anyone help me better understand a run method and why use it? Nicholas Vorraso @nickeyvee Nov 10 2016 01:35 @sjames1958gm haha ill go right ahead. Stephen James @sjames1958gm Nov 10 2016 01:35 @OwlNavigator "run" method? Maverink @Maverink Nov 10 2016 01:36 can someone help me function rot13(str) { var newString = str; var uncodedArray = newString.split(""); var codedArray = []; var currentCode = 0; var codeM = 77; for(i=0;i<= uncodedArray.length;i++){ if( newString.charCodeAt(i) <= codeM){  currentCode = newString.charCodeAt(i) + 13; codedArray.push(String.fromCharCode(currentCode)); }else if(newString.charCodeAt(i) >= codeM){ currentCode = newString.charCodeAt(i) - 13; codedArray.push(String.fromCharCode(currentCode)); } return codedArray; } } here please Stephen James @sjames1958gm Nov 10 2016 01:36 @Maverink Ask your question, someone should be able to OwlNavigator @OwlNavigator Nov 10 2016 01:37 yes the teach said include a run() method parisclinkscales @parisclinkscales Nov 10 2016 01:37 i keep getting TypeError: 2 is not a function function destroyer(arr) { var args = arguments[0]; var seeker = []; for (var i = 1; i < arr.length; i++){ seeker = args.filter(arguments[i]); } return seeker; } Nicholas Vorraso @nickeyvee Nov 10 2016 01:37 I'm trying to get my timer to pause when i press the start button to pause the clock, which works, but when I click it again to activate it, the function starts executing iterating down, at twice the speed, and the pattern seems to triple, and quadruple every time the clock is paused and and resumed. Stephen James @sjames1958gm Nov 10 2016 01:37 @Maverink You are not accounting for non-letters below A or above Z Nicholas Vorraso @nickeyvee Nov 10 2016 01:37 Stephen James @sjames1958gm Nov 10 2016 01:38 @parisclinkscales filter calls the passed in value as a function you are passing 2 to filter. OwlNavigator @OwlNavigator Nov 10 2016 01:39 yes the teacher said include a run() method @sjames1958gm Maverink @Maverink Nov 10 2016 01:39 i noticed that but in the loop, it doesnt keep adding the results into the array.. sorry im a beginner, im sure the problem is in the loop Stephen James @sjames1958gm Nov 10 2016 01:40 @nickeyvee Everytime you click you start another setInterval timer. parisclinkscales @parisclinkscales Nov 10 2016 01:40 @sjames1958gm oh i see it now. thanks! CamperBot @camperbot Nov 10 2016 01:40 parisclinkscales sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 4279 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Nicholas Vorraso @nickeyvee Nov 10 2016 01:40 @sjames1958gm it almost seemed like they are stacking Stephen James @sjames1958gm Nov 10 2016 01:41 @Maverink Your if check only checks < M you should check between A and M for +13 and N to Z for -13 and just pass through everything else - It is in the instructions, pass through spaces and puncutation @nickeyvee They are. A better strategy would be to start / cancel the setInterval when the button is clicked. Maverink @Maverink Nov 10 2016 01:42 @sjames1958gm got it tks!!! Stephen James @sjames1958gm Nov 10 2016 01:42 @OwlNavigator Are you doing java? or javascript? @Maverink :+1: @joehesse The instructions below don't saying anything about adding values. just assign as below. Recalling that assignment goes from right to left Assign the value 7 to variable a. Assign the contents of a to variable b. @joehesse you can just copy /paste your code here. estnimbus @estnimbus Nov 10 2016 01:45 @sjames1958gm yes I do @sjames1958gm And I am getting an error once I remove one of the for loop Emilie @Snipercatz Nov 10 2016 01:46 First of all, this help forum is just about the most asinine thing I've ever seen. Good flippin luck making sense out of it or trying to find help for an answer Stephen James @sjames1958gm Nov 10 2016 01:46 @estnimbus That is because you have an extra loop. The purpose of the sort is to avoid that second loop @estnimbus What does the code look like without the second loop? @Snipercatz Just wondering what's second of all? estnimbus @estnimbus Nov 10 2016 01:48 @sjames1958gm I maintained the second loop and moved my push line to the external loop and it worked Emilie @Snipercatz Nov 10 2016 01:48 I need help trying to figure out the convert celsius to fahrenheit problem. It'd be nice if they'd actually give us the celcius variable. I see someone else already asked this question but since the setup of this forum is so non-sensicle I can't find the full answer. Am I just supposed to imagine what this number is? estnimbus @estnimbus Nov 10 2016 01:48 @sjames1958gm I dont know but the second loop makes more sense to me Stephen James @sjames1958gm Nov 10 2016 01:48 @estnimbus ok, well that means that you sort it four times gabi @gikwu1 Nov 10 2016 01:49 hi everyone estnimbus @estnimbus Nov 10 2016 01:49  function largestOfFour(arr) { // You can do this! var brr = []; for (var i=0; i<arr.length;i++){ for (var j=0; j<arr[i].length; j++){ arr[i] = arr[i].sort( function(a,b){return (b-a);}); } brr.push(arr[i][0]); } return brr; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); Stephen James @sjames1958gm Nov 10 2016 01:49 @Snipercatz The value celsius is passed into the function - as can be seen at the function definition at the top. estnimbus @estnimbus Nov 10 2016 01:49 @sjames1958gm gabi @gikwu1 Nov 10 2016 01:49 i'm on the convert celcius to fahrenheit challenge and i'm stuck Emilie @Snipercatz Nov 10 2016 01:49 what is that value gabi @gikwu1 Nov 10 2016 01:49 can someone helo me?plsss Emilie @Snipercatz Nov 10 2016 01:49 ??? 10, 20 100, what? estnimbus @estnimbus Nov 10 2016 01:50 @sjames1958gm Does it make sense to you? Stephen James @sjames1958gm Nov 10 2016 01:50 @Snipercatz That is the variable that holds the value to be converted estnimbus @estnimbus Nov 10 2016 01:50 @sjames1958gm Thank you CamperBot @camperbot Nov 10 2016 01:50 estnimbus sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 4280 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Emilie @Snipercatz Nov 10 2016 01:50 how am i supposed to convert a number when i don't know what that number is? gabi @gikwu1 Nov 10 2016 01:50 @Snipercatz are u on the conversion challenge? Stephen James @sjames1958gm Nov 10 2016 01:50 @Snipercatz Well the formula is F = C * 9/5 + 32 - you don't have to know what the number is Emilie @Snipercatz Nov 10 2016 01:50 convert a number to another number but I don't know what the first number was to begin with yes @sjames1958gm Stephen James @sjames1958gm Nov 10 2016 01:51 @Snipercatz The function is designed so that you don't have to know Emilie @Snipercatz Nov 10 2016 01:51 literally makes zero sense Stephen James @sjames1958gm Nov 10 2016 01:51 @estnimbus It seems the second for loop is extraneous Manish Giri @Manish-Giri Nov 10 2016 01:52 @sjames1958gm a question for you Emilie @Snipercatz Nov 10 2016 01:52 yeah i know that formual. it gives it to you estnimbus @estnimbus Nov 10 2016 01:52 @sjames1958gm I would love to see how you do without gabi @gikwu1 Nov 10 2016 01:52 @sjames1958gm , can u explain how i can converrt more than 1 number at the same time?plss? Stephen James @sjames1958gm Nov 10 2016 01:52 @Snipercatz When the function is called with a number then celsius contains that number using the formula you can get the conversion estnimbus @estnimbus Nov 10 2016 01:52 @sjames1958gm In a private mess because i am about to live my desk Stephen James @sjames1958gm Nov 10 2016 01:52 @gikwu1 You only convert one number - you just use a variable and a formula estnimbus @estnimbus Nov 10 2016 01:52 @sjames1958gm Thanks CamperBot @camperbot Nov 10 2016 01:52 estnimbus sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :warning: estnimbus already gave sjames1958gm points Emilie @Snipercatz Nov 10 2016 01:53 i have no fucking clue. Stephen James @sjames1958gm Nov 10 2016 01:53 @Manish-Giri Sure ask away @Snipercatz so F = C * 9 / 5 + 32 - regardless of C? gabi @gikwu1 Nov 10 2016 01:54 the formula is C*9/5 +32=F right? @sjames1958gm Stephen James @sjames1958gm Nov 10 2016 01:54 @gikwu1 yes, I would use F = C * 9/5 + 32 because it maps to javascript better gabi @gikwu1 Nov 10 2016 01:55 ok, so how then do i convert different C's to F? Stephen James @sjames1958gm Nov 10 2016 01:55 @gikwu1 Inside the function you are given the variable celsius (which is the C in the formula) Manish Giri @Manish-Giri Nov 10 2016 01:56 @sjames1958gm so there’s this .done().fail() thing in jquery right? $.ajax({
url: "test.html",
context: document.body
}).done(function() {
$( this ).addClass( "done" ); }).fail(function() { blah; }); I need to rework my twitch app to use client headers and I need to convert my .getJSON to $.ajax() calls, so can I just continue with success() and error() instead of done and fail

$.ajax({ url: "test.html", success: function({}), error: function({}) }); tvithaya @tvithaya Nov 10 2016 01:56 Hey everyone, I'm having some trouble getting passed the Profile Lookup exercise and was wondering if someone can see what's wrong with the code. gabi @gikwu1 Nov 10 2016 01:56 @sjames1958gm , ok, i want to convert 15C to F, 12C to F, how do i go about it silmultaneaously? Stephen James @sjames1958gm Nov 10 2016 01:56 @gikwu1 var plus5 = x + 5 this a formula that converts any value of x to x + 5- the temp. conversion works the same wy tvithaya @tvithaya Nov 10 2016 01:56 function lookUpProfile(firstName, prop){ // Only change code below this line var i = 0; while (i<contacts.length) { // return contacts[i].firstName; if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) { return contacts[i][prop]; } else if (firstName !== contacts[i].firstName || contacts[i].hasOwnPropert(prop)){ return "No such property"; } else { return "not working!"; } i++; } // Only change code above this line } Stephen James @sjames1958gm Nov 10 2016 01:56 @gikwu1 Its not simultaneous. You don't call the function with more than one value. Emilie @Snipercatz Nov 10 2016 01:56 can you just tell me the code. i have absolutely zero clue what it is asking me or expects me to write. tvithaya @tvithaya Nov 10 2016 01:57 @Snipercatz , you referring to me? Stephen James @sjames1958gm Nov 10 2016 01:57 @Manish-Giri I believe so. gabi @gikwu1 Nov 10 2016 01:58 @sjames1958gm , obvipously myself and emile are stuck in the same place can u help explain well so we can move on pls> Stephen James @sjames1958gm Nov 10 2016 01:58 @Snipercatz fahrenheit = celsius * 9 / 5 + 32 Manish Giri @Manish-Giri Nov 10 2016 01:58 @sjames1958gm I’ve no idea when the success and fail in the docs got replaced with done and fail @sjames1958gm thanks CamperBot @camperbot Nov 10 2016 01:58 manish-giri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 4281 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm Nov 10 2016 01:58 @Manish-Giri done and fail are more of a promise type mechanism @coymeetsworld wrong person @coymeetsworld I am trying to explain Manish Giri @Manish-Giri Nov 10 2016 01:58 @sjames1958gm yeah, deferred objects, kinda similar to .then() in Promise in ES6 Stephen James @sjames1958gm Nov 10 2016 01:59 @Manish-Giri exactly @coymeetsworld np @gikwu1 Did you see the code. Manish Giri @Manish-Giri Nov 10 2016 01:59 damn Twitch Stephen James @sjames1958gm Nov 10 2016 01:59 @Manish-Giri :( Manish Giri @Manish-Giri Nov 10 2016 01:59 damn their client auth gabi @gikwu1 Nov 10 2016 01:59 @sjames1958gm , m problem is if i convert 12C fo F and i also have 5 more values of C to convert how do i do them so that i can get them clicked off as completed? Stephen James @sjames1958gm Nov 10 2016 02:00 @gikwu1 fahrenheit = celsius * 9 / 5 + 32 when the function is called celsius will have a different value each time and return the correct value. gabi @gikwu1 Nov 10 2016 02:00 @sjames1958gm , u mean, F=C*(9/5)+32? i get that @sjames1958gm Stephen James @sjames1958gm Nov 10 2016 02:01 @gikwu1 No - that is the line of code that goes in the function. gabi @gikwu1 Nov 10 2016 02:01 ? @sjames1958gm Stephen James @sjames1958gm Nov 10 2016 02:01 @gikwu1 That is how the function works. gabi @gikwu1 Nov 10 2016 02:02 @sjames1958gm , pls can i message u in a private window? Manish Giri @Manish-Giri Nov 10 2016 02:02 fuck it actually worked thx @sjames1958gm CamperBot @camperbot Nov 10 2016 02:02 manish-giri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :warning: manish-giri already gave sjames1958gm points Stephen James @sjames1958gm Nov 10 2016 02:02 @sjames1958gm convertToF(50) - when this happens celsius is set to 50 so the function returns 50 * 9/5 + 32 convertToF(0) - when this happens celsius is set to 0 so the function returns 0 * 9/5 + 32 davidericgillies @davidericgillies Nov 10 2016 02:07 I'm totally stuck on problem 96 "Nesting For Loops" Instructions: Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr Yong Lee @yonglee79 Nov 10 2016 02:09 does anyone know how to read elements or codes that are after </html> with jquery or javascript? Jeff Shapiro @Jeff-Shapiro Nov 10 2016 02:09 @davidericgillies for (of arr) { for (of arr[i] { } } oludotun dosunmu @ddosunmu Nov 10 2016 02:12 The run test returns an error with this attempt and I cannot figure out the problem. var Bike = function() { // Only change code below this line. var gear = 0; // these are public methods this.setGear = function(change) { gear += change; }; this.getGear = function() { return gear; }; }; //var myCar = new Car(); var myBike = new Bike(); myBike.setGear(4); // myBike.getGear(); console.log(myBike.getGear()); / myBike.setGear(3); //myBike.getGear(); console.log(myBike.getGear()); myBike.setGear(1); console.log(myBike.getGear()); //myBike.getGear(); / Stephen James @sjames1958gm Nov 10 2016 02:13 @ddosunmu set should only set not add gabi @gikwu1 Nov 10 2016 02:13 @ddosunmu have u done the conversion challenge? oludotun dosunmu @ddosunmu Nov 10 2016 02:14 ok. Aiden @AidenMead Nov 10 2016 02:14 @yongslee79 Do you have the code to post? Sheldon07 @Sheldon07 Nov 10 2016 02:15 hey there im new, how do I declare myName with the var keyword? Yong Lee @yonglee79 Nov 10 2016 02:15 no I was just curious if there is any way for that Walid Ashri @walidashri Nov 10 2016 02:15 @Sheldon07 var myName Sheldon07 @Sheldon07 Nov 10 2016 02:16 @walidashri I have written this and it doesnt say it is correct chunnali @chunnali Nov 10 2016 02:16 hey guys, i need help with a javascript problem. If I have an object from an api that says object{ loc: “xx,yy”,}. how do I get xx? Walid Ashri @walidashri Nov 10 2016 02:16 @yongslee79 I think no after html is closed nothing is readable Adolfo Saenz @AdoSae1 Nov 10 2016 02:17 @sjames1958gm Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined. my code is: function abTest(a, b) { // Only change code below this line if (a<0); if (b<0); // 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); Sheldon07 @Sheldon07 Nov 10 2016 02:18 how can i post pictures here? Adolfo Saenz @AdoSae1 Nov 10 2016 02:18 i have to return undefined Marcelo Henrique @Marcelosilva10 Nov 10 2016 02:19 help me CamperBot @camperbot Nov 10 2016 02:19 ## :point_right: readme [wiki] # Depecrated Wiki! This repo serves as an archive for the wiki and a place to report issues for our current wiki located in our forum! Our open source community's Wiki focuses on answering your questions about learning to code and getting a coding job. We also cover in detail our: • Curriculum • Other Programming Languages • Local Group Communities • Nonprofit Projects and much more Marcelo Henrique @Marcelosilva10 Nov 10 2016 02:19 function nextInLine(arr, item) { // Your code here nextInline([1],2); return item; // Change this line } // Test Setup var testArr = [1,2,3,4,5]; // Display Code console.log("Before: " + JSON.stringify(testArr)); console.log(nextInLine(testArr, 6)); // Modify this line to test console.log("After: " + JSON.stringify(testArr)); Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed. Cage Echarte @CageEcharte Nov 10 2016 02:20 I need some help here Sheldon07 @Sheldon07 Nov 10 2016 02:20 2 // Example 3 var ourName; 4 5 // Define myName below this line 6 var ourName; 7 don't know why this isnt working Aiden @AidenMead Nov 10 2016 02:21 you're defining "ourName" Marcelo Henrique @Marcelosilva10 Nov 10 2016 02:21 whats? Sheldon07 @Sheldon07 Nov 10 2016 02:21 what would I write? Marcelo Henrique @Marcelosilva10 Nov 10 2016 02:22 yes, i am with problem Aiden @AidenMead Nov 10 2016 02:22 Well, you have ourName defined but you need to define "myName" Marcelo Henrique @Marcelosilva10 Nov 10 2016 02:22 could help me Aiden @AidenMead Nov 10 2016 02:23 So if you switch it and define myName there, you'll be good Ken Haduch @khaduch Nov 10 2016 02:23 @chunnali :point_up: November 9, 2016 9:16 PM - you need to get xx from object{ loc: “xx,yy”,}. - you can do something like object.loc.split(',')[0]; I think that should do it? chunnali @chunnali Nov 10 2016 02:23 @khaduch okay ima try it right now! thanks! CamperBot @camperbot Nov 10 2016 02:23 chunnali sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1901 | @khaduch |http://www.freecodecamp.com/khaduch Cage Echarte @CageEcharte Nov 10 2016 02:24 I need some help Ken Haduch @khaduch Nov 10 2016 02:26 @CageEcharte - what do you need help with? chunnali @chunnali Nov 10 2016 02:26 @khaduch it worked!! i love you, thank you so much! ^^ CamperBot @camperbot Nov 10 2016 02:26 chunnali sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :warning: chunnali already gave khaduch points Cage Echarte @CageEcharte Nov 10 2016 02:27 Record Collection Ken Haduch @khaduch Nov 10 2016 02:27 @chunnali - you're welcome. Basically, you know what you did with that now, right? Just access the value from the object, and it is a string. Then it was split on the comma ,, which gives an array, and the [0] gives the first element in the array. [1] would give the second element, etc. Cage Echarte @CageEcharte Nov 10 2016 02:27 @khaduch Ken Haduch @khaduch Nov 10 2016 02:28 @CageEcharte - okay - what is your current status - code or link to check out? Or post your code here... chunnali @chunnali Nov 10 2016 02:28 @khaduch yes, got it^^ Cage Echarte @CageEcharte Nov 10 2016 02:29 here is the code i have so farfunction updateRecords(id, prop, value) { if (value === '') { delete collection[id][prop]; } else if (prop !== 'tracks') { collection[id][prop] = value; } else { collection[id][prop].push(value); } return collection; } Ken Haduch @khaduch Nov 10 2016 02:29 @CageEcharte - it looks like you are on the right track - how many tests are you passing? Cage Echarte @CageEcharte Nov 10 2016 02:30 I'm not passing one @khaduch Ken Haduch @khaduch Nov 10 2016 02:30 @CageEcharte - I see that you are passing most - that's great! The only one that you have to fix is the one where an object has no tracks property. @CageEcharte - the problem with that one is that you have to recognize that there isn't a tracks property, so you use .hasOwnProperty("tracks") and if it is not true, you add a tracks property, either with an empty array as a value, and you then push the value onto it, or you can add it all in one step with [value]. Does that help you? Try it and see if you need more help? Devin F. @defields923 Nov 10 2016 02:32 I am stuck on the manipulating complex objects challenge. var myMusic = [ { "artist": "Billy Joel", "title": "Piano Man", "release_year": 1973, "formats": [ "CS", "8T", "LP" ], "gold": true } ]; myMusic.push [ { "artist": "Michael Jackson", "title": "Thriller", "release_year": 1980, "formats": [ "LP", "Cassette", "8 track" ] } ]; Adolfo Saenz @AdoSae1 Nov 10 2016 02:33 @khaduch may i have some of your assistance? Devin F. @defields923 Nov 10 2016 02:33 var myMusic = [ { "artist": "Billy Joel", "title": "Piano Man", "release_year": 1973, "formats": [ "CS", "8T", "LP" ], "gold": true } ]; myMusic.push [ { "artist": "Michael Jackson", "title": "Thriller", "release_year": 1980, "formats": [ "LP", "Cassette", "8 track" ] } ]; Ken Haduch @khaduch Nov 10 2016 02:34 @defields923 - you are close - you just have an initial array with an object in it. You just want to add a second object within the array brackets - so don't to a push or antyhing, this is just to initialize the myMusic array with two objects. myMusic = [ { ...}, {...} ]; Devin F. @defields923 Nov 10 2016 02:34 I've tried multiple methods, but keep getting a "missing semicolon" or "expect ] from line x" rror Adolfo Saenz @AdoSae1 Nov 10 2016 02:34 Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined. my code is: // Setup function abTest(a, b) { // Only change code below this line console.log(a<0 && b<0); // 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); davidericgillies @davidericgillies Nov 10 2016 02:35 stuck on Nesting loops: function multiplyAll(arr) { var product = 1; // Only change code below this line // Only change code above this line return product; } // Modify values below to test your code multiplyAll([[1,2],[3,4],[5,6,7]]); gabi @gikwu1 Nov 10 2016 02:35 can anyone HELP ME GET OFF THIS CHALLANGE? Anush Reddy @anushreddy Nov 10 2016 02:35 can anyone help me with algorithm "Diff Two Arrays" davidericgillies @davidericgillies Nov 10 2016 02:35 Instructions Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr Ken Haduch @khaduch Nov 10 2016 02:36 @AdoSae1 - you actually have to put an if condition in there to test the values for the condition that they are specifying, and return if either one is less than zero - note that that means OR - using the || operator. console.log is not sufficient. Aiden @AidenMead Nov 10 2016 02:36 @AdoSae1 you were on the right track earlier with if statements, you just hadn't given the function what you wanted it to do if a<0 else if b<0 Devin F. @defields923 Nov 10 2016 02:36 var myMusic = [ { "artist": "Billy Joel", "title": "Piano Man", "release_year": 1973, "formats": [ "CS", "8T", "LP" ], "gold": true } { "artist": "Michael Jackson", "title": "Thriller", "release_year": 1980, "formats": [ "LP", "Cassette", "8 track" ] } ]; really dont know what Im missing Aiden @AidenMead Nov 10 2016 02:36 ^ or the ore operator, i like that too, always seem to forget about that Ken Haduch @khaduch Nov 10 2016 02:36 @defields923 - a comma... Devin F. @defields923 Nov 10 2016 02:37 where??? lol omg.... Thanks @khaduch I just needed that hint. lol CamperBot @camperbot Nov 10 2016 02:37 defields923 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1902 | @khaduch |http://www.freecodecamp.com/khaduch Ken Haduch @khaduch Nov 10 2016 02:37 @defields923 - separating the two objects in the array - just like you would write [1, 2, 3] - @defields923 - :+1: Devin F. @defields923 Nov 10 2016 02:38 I don't know why I didnt think to put a comma after curly braces, since the two are objects. Ken Haduch @khaduch Nov 10 2016 02:40 @davidericgillies - you have no code where you are supposed to change your code. So you need to have for loops - two of them, one inside the other. Since you have multiple arrays contained within the arr that is being passed in, you write for loops to iterate through the arrays in the outer loop, and the inner loop iterates through the sub-arrays... that might not be helpful enough? But you can start by writing that. Think about how you would write a loop that would output just the numbers in the order that they appear in the argument... Adolfo Saenz @AdoSae1 Nov 10 2016 02:41 @AidenMead thanks I understand and got it to work, cheers! CamperBot @camperbot Nov 10 2016 02:41 adosae1 sends brownie points to @aidenmead :sparkles: :thumbsup: :sparkles: :cookie: 269 | @aidenmead |http://www.freecodecamp.com/aidenmead Ken Haduch @khaduch Nov 10 2016 02:41 @defields923 - I think that's where the "complex" part comes in - just slightly more complex than an array of numbers or strings. Just enough to throw a curveball at you. Cage Echarte @CageEcharte Nov 10 2016 02:46 @khaduch okay now what? function updateRecords(id, prop, value) { if (value === '') { delete collection[id][prop]; } else if (prop.hasOwnProperty("tracks")) { collection[id][prop] = " "; } else { collection[id][prop].push(value); } return collectio Sheldon07 @Sheldon07 Nov 10 2016 02:47 how do I modify existing declarations so their names use camelCase? Nicholas Vorraso @nickeyvee Nov 10 2016 02:48 @sjames1958gm fixed it! thanks dude CamperBot @camperbot Nov 10 2016 02:48 nickeyvee sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 4282 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm Nov 10 2016 02:49 @nickeyvee :+1: Ken Haduch @khaduch Nov 10 2016 02:49 @CageEcharte - not quite right, you have to access the object for this test as you do with other object accesses in this problem collection[id] - that points you to an object, then you use collection[id].hasOwnProperty(prop) in your test. And you have to make sure that you are doing this only under the condition where you know that the property is tracks - you have a clearly laid out condition in your original code where you know that the property is "tracks"... davidericgillies @davidericgillies Nov 10 2016 02:51 I'm trying but clearly really confused... this is one of probably 10 different attempts (don't judge :-/ ) function multiplyAll(arr) { var product = 1; // Only change code below this line for (var i; i < arr[0].length; (ii)) { for (var j; j < arr[1].legnth; (j j)) { for (var k; k < arr[2].legnth; (kk)) { product = arr[0] [1]*[2]; } } } // Only change code above this line return product; } // Modify values below to test your code multiplyAll([[1,2],[3,4],[5,6,7]]); Alex @ajosephthompson Nov 10 2016 02:51 if someone can help me with this question......return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin......why does this code have to perform such as (ourMax - ourMin + 1)?? Ken Haduch @khaduch Nov 10 2016 02:52 @davidericgillies - no judgement - this is one of those "inflection points" on the learning curve, it seems. @davidericgillies - you need a loop that iterates over the element in the argument arr. So that would be something like this: for ( var i = 0; i < arr.length; i++ ) { // within this loop, you access arr[i], which gives you arr[0], which is an array [1,2]. } That is the first step - that outer loop. Diego Mayer @Chrono79 Nov 10 2016 02:54 @ajosephthompson 10-1 is 9, and math.random returns a number between 0 (can be 0) and 1 (can't be one) So, you add +1 and you can get at maximun, 9.99999 from that part, you then apply Math.floor and get 9 + the min value that's 1, you get 10 Alex @ajosephthompson Nov 10 2016 02:55 hmmm. Ken Haduch @khaduch Nov 10 2016 02:55 @davidericgillies - inside the inner loop, you then are working with the values in arr[i], which sequentially gives you the sub-arrays within the argument that is passed in. So within that inner loop, you have to use a different variable, as you are doing - the inner loop would look like this;  for ( var j = 0; j < arr[i].length; j++) { // in here, you access individual elements with arr[i][j] } Alex @ajosephthompson Nov 10 2016 02:55 so it has to do with order of operation @Chrono79 Diego Mayer @Chrono79 Nov 10 2016 02:56 @ajosephthompson it's there because you can't get 1 from Math.random. If Math.random could return 1, then it should be easier Cage Echarte @CageEcharte Nov 10 2016 02:56 @nickeyvee duuudddeeee!!!!!! Alex @ajosephthompson Nov 10 2016 02:57 i understand that but why cant it be (ourMax - ourMin + 2) @Chrono79 Ken Haduch @khaduch Nov 10 2016 02:57 @davidericgillies - see if you can put the two together, and access the individual elements of the array. Cage Echarte @CageEcharte Nov 10 2016 02:57 @khaduch now what? if (value === '') { delete collection[id][prop]; } else if (prop !== 'tracks') { collection[id].hasOwnProperty(prop); } else { collection[id][prop].push(value); } return collection; } Diego Mayer @Chrono79 Nov 10 2016 02:58 @ajosephthompson you'd get a value greater than ourMax then Your algorythm should return a number in the range ourMin and ourMax Stas Vitvitskiy @StasVitvitskiy Nov 10 2016 02:58 hey guys Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found". var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { if(myObj.hasOwnProperty("checkProp")) { return myObj.checkProp; } else { return "Not Found"; } return "Change Me!"; } checkObj("gift"); what am i doing wrong here? Alex @ajosephthompson Nov 10 2016 02:58 @Chrono79 hmm i think im catching on. so it can only be 1 since it cant go to high? Nicholas Vorraso @nickeyvee Nov 10 2016 02:59 @CageEcharte waaas happenin mane! Diego Mayer @Chrono79 Nov 10 2016 03:00 @ajosephthompson That's the idea, the plus 1 and Math.floor work together so you can get ourMax as the max value Alex @ajosephthompson Nov 10 2016 03:00 okay ill keep looking at it. @Chrono79 its a new thing for sure to me @Chrono79 Thank you CamperBot @camperbot Nov 10 2016 03:00 ajosephthompson sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 2475 | @chrono79 |http://www.freecodecamp.com/chrono79 Ken Haduch @khaduch Nov 10 2016 03:01 @CageEcharte - I want to go back to the original code that you posted... // Only change code below this line function updateRecords(id, prop, value) { if (value === '') { delete collection[id][prop]; // here you know that the value is blank } else if (prop !== 'tracks') { // here you know that the value is not blank collection[id][prop] = value; // here you know that the value is not blank and the prop is not "tracks" } else { // here you know that the prop is "tracks" and the value is not blank // this is a good place to do the tests on the "tracks" property within the object. collection[id][prop].push(value); } return collection; } I don't know if you lost that code state in making changes, but that is what I was referring to in my post to explain what you needed to do... gabi @gikwu1 Nov 10 2016 03:02 thanks @sjames1958gm CamperBot @camperbot Nov 10 2016 03:02 gikwu1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 4283 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Nivek @mydoan Nov 10 2016 03:02 Assign the following three lines of text into the single variable myStr using escape sequences. FirstLine \SecondLine\ ThirdLine var myStr="FirstLine \n \SecondLine\ \r ThirdLine"; // Change this line Alex @ajosephthompson Nov 10 2016 03:03 @Chrono79 i think i understand why it has to say (ourMax - ourMin + 1) instead of (ourMax) ........ is it because Math.random has to see that a number is there? Nivek @mydoan Nov 10 2016 03:04 I don't get new line or backslash or carriage-return despite using the code given? Can someone help me please Diego Mayer @Chrono79 Nov 10 2016 03:05 @ajosephthompson Math.random() returns a number between 0 and 1, what you do with it, has nothing to do with it The other code is for the "random" number you create to fall in the range ourMin, ourMax (both limits included) Cage Echarte @CageEcharte Nov 10 2016 03:08 @khaduch in the final else statement what should I test 'tracks' for? Ken Haduch @khaduch Nov 10 2016 03:09 @CageEcharte - use the .hasOwnProperty to see if there is a tracks property, and if there isn't create one with an empty array, which you can then use the .push method, as you are doing. So, basically, before you do the push, make sure you have a property that contains an array as a value. Bcrea @Bcrea Nov 10 2016 03:09 can someone review my code? omg this took me forever, i had paused FCC to read as much as i could about js and i finally got it right :smile:  function rot13(str) { // LBH QVQ VG! var array = str.split(""); var chars = array.map(function(x){return x.charCodeAt();}); var rot = chars.map(function(val) { if (val < 65) { return val; } if (val >= 65 && val <= 77) { return val += 13; } if (val >= 77 && val <= 90) { return val -= 13; } }); var result = rot.map(function(val){ return String.fromCharCode(val); }); return result.join(""); } // Change the inputs below to test rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK."); Alex @ajosephthompson Nov 10 2016 03:12 @Chrono79 yeah its tough to wrap my head around it. Devin F. @defields923 Nov 10 2016 03:12 @khaduch I'm also doing the record collection, and im watching your discussion but this is the first challenge that has me completely baffld I have no idea what's going on. Ken Haduch @khaduch Nov 10 2016 03:13 @defields923 - it's another one of those sticking points, it seems. So many people need help there... Cage Echarte @CageEcharte Nov 10 2016 03:16 @khaduch after I do the .hasOwnProperty do I need tp create another 'else' statement ? Ken Haduch @khaduch Nov 10 2016 03:17 @defields923 - basically, the record collection is an object with other objects contained in it - each representing a record album or CD, whatever the current relevant technology is... Stas Vitvitskiy @StasVitvitskiy Nov 10 2016 03:18 guys what am i doing wrong here Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found". Devin F. @defields923 Nov 10 2016 03:18 I get the concept of the objects within the collection, but I have no idea about all this instructions. Stas Vitvitskiy @StasVitvitskiy Nov 10 2016 03:18 var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { if(myObj.hasOwnProperty("checkProp")) { return myObj.checkProp; } else if(myObj.hasOwnProperty("checkProp"!==true)) { return "Not Found"; } return "Change Me!"; } // Test your code by modifying these values checkObj("gift"); Ken Haduch @khaduch Nov 10 2016 03:19 @CageEcharte - it depends on your approach. You can write the code without another else - you just need to test if ( ! collection[id].hasOwnProperty(prop)) - since you know the prop value is tracks, or you can write if ( ! collection[id].hasOwnProperty("tracks")). Note that I'm testing that it does not have the property. You can then put a code block in after that to set the property as an empty array, and then the following statement will push the value onto it. Alex @ajosephthompson Nov 10 2016 03:21 @Chrono79 figured it out!! Ken Haduch @khaduch Nov 10 2016 03:22 @defields923 - okay, back to your question... The arguments of the function are: • id - a numeric value that points to a particular record in the collection • prop - a string value that lists one of the properties or potential properties in a record • value - the desired value to store in that property, or if it is blank, if ( value === '' ) might be a test, you either store the property or delete the property from the given record in the collection. The "tracks" property is special in this object because it is an array, there is one record in the collection that is initialized without a "tracks" property, so you have to watch out for that one. Alex @ajosephthompson Nov 10 2016 03:22 because if it was 0,1 then it would round down to 0 right? @Chrono79 Ken Haduch @khaduch Nov 10 2016 03:26 @defields923 - the other important thing about this is the appropriate use of bracket or dot notation, and making sure that you are properly accessing record elements using the collection and id variables. Yixuan Li @YixuanFranco Nov 10 2016 03:26  function caseInSwitch(val) { var answer = ""; // Only change code below this line case 1: answer = "alpha"; break; case 2: answer = "beta"; break; case 3: answer = "gamma"; break; case 4: answer = "delta"; break; // Only change code above this line return answer; } Could anyone please tell me what's wrong with these code? Ken Haduch @khaduch Nov 10 2016 03:27 @YixuanFranco - you do not have the switch keyword and braces to surround all of the case statements... Devin F. @defields923 Nov 10 2016 03:28 @khaduch Since my head is still spinning as to what all this means, I decided to crack open the wiki entry for this problem. I will have to dissect the hints to get a grip on this one. Doesn't help that I've been up since 4AM after sleeping about as few hours as I've gotten any night this week. Ken Haduch @khaduch Nov 10 2016 03:30 @defields923 - I know where you're coming from about the sleep... the good thing is that you can put this aside and come back to it, it will still be here. If you spend a little more time getting a foundation in the basics of this problem, take a break and then come back. Sometimes you get new insight when you do that. Or else it is definitely a good thing to get away from it for a while! Yixuan Li @YixuanFranco Nov 10 2016 03:31 @khaduch thanks a loooooot, finally it works CamperBot @camperbot Nov 10 2016 03:31 yixuanfranco sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1903 | @khaduch |http://www.freecodecamp.com/khaduch Devin F. @defields923 Nov 10 2016 03:31 Wish I could, but I have to have the intro material complete by Friday. Diego Mayer @Chrono79 Nov 10 2016 03:31 @ajosephthompson The Math.floor() part would do that, yes, and you'll get ourMin Choz @chozzz Nov 10 2016 03:31 @Bcrea You're missing the lowercased character codes conditions.. Ken Haduch @khaduch Nov 10 2016 03:31 @defields923 - ah... a deadline. How much more do you have to do? Choz @chozzz Nov 10 2016 03:32 @Bcrea Something like this, function rot13(str) { // LBH QVQ VG! var array = str.split(""); var chars = array.map(function(x){return x.charCodeAt();}); var rot = chars.map(function(val) { if (val < 65) { return val; } else if ((val >= 65 && val <= 77) || (val >= 97 && val <= 109)) { return val + 13; } else if ((val >= 78 && val <= 90) || (val >= 110 && val <= 122)) { return val - 13; } }); var result = rot.map(function(val){ return String.fromCharCode(val); }); return result.join(""); } Devin F. @defields923 Nov 10 2016 03:32 @khaduch I have no idea. I'm on #95 Choz @chozzz Nov 10 2016 03:32 @Bcrea Or this for one liner.. rot13 = s => ((z = String.fromCharCode), s.split.map(v => (c = v.charCodeAt(), /[a-mA-M]/.test(v) ? z(c + 13) : /[n-zN-Z]/.test(v) ? z(c - 13) : v )).join ) Cole Maly @malycole Nov 10 2016 03:46 A quick question, I'm on the seek and destroy algorithm. what would the best practice be for iterating through the arguments not including [0]? Ken Haduch @khaduch Nov 10 2016 03:48 @malycole - start at 1... are you using Array.prototype.slice.call to convert your arguments to an array? Read about that in the documentation on the arguments object. Cole Maly @malycole Nov 10 2016 03:49 No I hadn't been, I thought arguments had enough properties such that you could utilize them without converting them to an array. perhaps I was wrong! Choz @chozzz Nov 10 2016 03:49 @malycole array filter and for loop would suffice lettda @lettda Nov 10 2016 03:50 How do I access and change the data-temp attribute?  var long; var lat;$.getJSON("https://crossorigin.me/http://ip-api.com/json", function(data2){ //access RESTFUL geo location API & set lattitude.longitude
lat=data2.lat;
long=data2.lon;

var api = "https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+long+"&appid=de61ccfbde0405f57d64dbb53323fccf&units=metric";
//Access weather API

$.getJSON(api, function(data){ var iconCode = data.weather[0].icon; //get Icon from API related to current weather conditions var iconUrl = "http://openweathermap.org/img/w/"+iconCode+".png"; var tempCel = data.main.temp;$(".heading").append("<h2>"+data.name+","+data.sys.country+"</h2>");
$(".message").append("<h4 id='tempData' data-temp='" + tempCel + "'>Current Temperature: "+tempCel+"&#8451</h4>");$(".message").append("<h4>Conditions: "+data.weather[0].main+"</h4>");
// $("#reveal").on('click', function(){ //click button // data.main.tempData //on click convert temperature to farenheight // });$(".message").append("<img id='conditions' src="+iconUrl+">");

$("#tempData").hover(function(){$(this).dataset.temp().fadeToggle('slow', function(){

});
});
console.log(data);
});
});
//$("#reveal").on("click", function(){ //}); }); Basically on hovering over the temperature fadeout the celcius and display the farenheight NoobsNoob @NoobsNoob Nov 10 2016 03:51 JS Seek and Destroy exercise - I've read the Arguments object article but still can't work out how to separate the starting array passed in from the other arguments. Can anyone direct to other resources that might assist? Jenky W. Nolasco @jenkynolasco11 Nov 10 2016 03:52 @lettda $('#tempData').data('temp') // returns tempCel value
$('#tempData').data('temp', newVal) // changes data-temp value to newVal Ken Haduch @khaduch Nov 10 2016 03:53 @NoobsNoob - when you do the Array.prototype.slice.call(arguments) call to convert the arguments to an array, you are using the Array.slice method - it has other arguments that you can provide. NoobsNoob @NoobsNoob Nov 10 2016 03:55 @khaduch Thanks for the pointer CamperBot @camperbot Nov 10 2016 03:55 noobsnoob sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1904 | @khaduch |http://www.freecodecamp.com/khaduch darisguo @darisguo Nov 10 2016 03:59 Could anyone tell me what's wrong with this code? I'm on record collection. function updateRecords(id, prop, value) { if (prop != "tracks" && value !=="") { collection[id][prop] = value; } else if (prop == "tracks" && collection[id].hasOwnProperty[prop] === false) { collection[id][prop] = []; collection[id][prop].push(value); } else if (prop == "tracks" && value !=="") { collection[id][prop].push(value); } else if (value ==="") delete collection[id][prop]; return collection; } Sorry first time using the forum. How can i send formatted code like other people do? Thanks Ken Haduch @khaduch Nov 10 2016 04:01 @darisguo - format code with the info in the following link ''' CamperBot @camperbot Nov 10 2016 04:01 :bulb: to format code use backticks!  more info Ken Haduch @khaduch Nov 10 2016 04:01 @darisguo - a couple things - the biggest one is that you are only doing the return collection; in your final conditional block. That might be the biggest thing? The only thing? Krishna Bhandari @krishna8723 Nov 10 2016 04:02 please help to solve this . wordBlanks("","","","") should return a string. wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib). wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib). 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"); darisguo @darisguo Nov 10 2016 04:04 @khaduch Thanks for the link! Am I not supposed to return collection? that's the default code. CamperBot @camperbot Nov 10 2016 04:04 darisguo sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1905 | @khaduch |http://www.freecodecamp.com/khaduch Ken Haduch @khaduch Nov 10 2016 04:04 @darisguo - there are other things - in this block of code: } else if (prop == "tracks" && collection[id].hasOwnProperty[prop] === false) {, you do not know the condition of the value variable. @darisguo - you are supposed to return collection, but you have to return it regardless of whether or not you are just doing that delete operation at the end there. In other words, it should be return collection; outside of that conditional block. OOPS my mistake -- I see that you do not have a conditional block there at the end - it is a one-line block and then the return... so that could work. Sorry! darisguo @darisguo Nov 10 2016 04:07 @khaduch my bad. let me send you a formatted version, might be easier to read function updateRecords(id, prop, value) { if (prop != "tracks" && value !=="") { collection[id][prop] = value; } else if (prop == "tracks" && collection[id].hasOwnProperty[prop] === false) { collection[id][prop] = []; collection[id][prop].push(value); } else if (prop == "tracks" && value !=="") { collection[id][prop].push(value); } else if (value ==="") { delete collection[id][prop]; } return collection; } Ken Haduch @khaduch Nov 10 2016 04:08 @darisguo - ok, the comment that I made just above in :point_up: November 9, 2016 11:04 PM is something that isn't correct in your code... I should revisit the code and make sure that I'm reading it all correctly. darisguo @darisguo Nov 10 2016 04:10 in that comment do you mean i need to check if value is ""? @khaduch pycraft @pycraft Nov 10 2016 04:10 how do i upload my code in this chat room? Ken Haduch @khaduch Nov 10 2016 04:10 @darisguo - it might be that if you changed your first test to if (value === "") it would fix everything? Because in that condition, you just want to delete, and then everything else will "know" that the value is not blank... OOPS again - my idea was change the first conditional test and do the delete there, then the rest of the code can use the fact that the value is not blank and act accordingly. @pycraft - look at this link in the next post ''' CamperBot @camperbot Nov 10 2016 04:11 :bulb: to format code use backticks!  more info darisguo @darisguo Nov 10 2016 04:12 @khaduch the only test i failed is this one: updateRecords(5439, "tracks", "Take a Chance on Me"). so i guess it's not about the value? Ken Haduch @khaduch Nov 10 2016 04:14 @darisguo - I'm not doing so well... the code collection[id].hasOwnProperty[prop] should have parentheses at the end, because it is a method and you need parens to call it... collection[id].hasOwnProperty(prop) is the correct syntax there. Aiden @AidenMead Nov 10 2016 04:16 I'm having an issue with my weather application. I'm getting geolocation properly and the API is sending the info, but accessing the nested values for display had left me scratching my head something fierce. Anyone willing to take a look? darisguo @darisguo Nov 10 2016 04:17 @khaduch finally got it right! Thank you so much! CamperBot @camperbot Nov 10 2016 04:17 darisguo sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :warning: darisguo already gave khaduch points Ken Haduch @khaduch Nov 10 2016 04:18 @darisguo - and with your code, there could be a case constructed where your code would generate an incorrect tracks property array - if arguments were passed in that pointed to an object without a tracks property, but with no value, you would generate the empty array and push a blank value onto it. They just do not have that test case and data installed there. But it's working with the current set of data and tests - so that's great! darisguo @darisguo Nov 10 2016 04:22 @khaduch i see, i should still move the last condition to be the first. Ken Haduch @khaduch Nov 10 2016 04:25 @darisguo - in fact, you can simplify your code a bit if you do that. if ( value === "" ) { // do the delete } else { // here you know that the value is not blank, so you // never have to test it again - just do that stuff for the "tracks" // and if it isn't "tracks", add or update the given property if ( prop === "tracks" ) { // handle the "tracks" cases } else { // update the property, because it isn't "tracks" } } Sheldon07 @Sheldon07 Nov 10 2016 04:31 I need help with the Fahrenheit question Ken Haduch @khaduch Nov 10 2016 04:31 @Sheldon07 - that's a hot one... :) What's your question about the Fahrenheit question? Sheldon07 @Sheldon07 Nov 10 2016 04:33 function convertToF(celsius) { var fahrenheit; // Only change code below this line var celsius = var fahrenheit // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(30); its asking me to use an algorithm of (celsius)(9/5)+32 to find fahrenheit Cole Maly @malycole Nov 10 2016 04:36 Still struggling with the seek and destroy challenge.  function destroyer(arr) { // Remove all the values var args = arr.slice.call(arguments); var destroyer = []; for (var i =1;i<args.length; i++){ destroyer.push(args[i]); } args[0].filter(function(val){ return val !== destroyer; }); // converts arguments into array and converts the destroyer indicies into a seperate array return args; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); I think I'm missing something on the implementation of array.filter but I'm not sure how exactly to word it Ken Haduch @khaduch Nov 10 2016 04:36 @Sheldon07 - you have a function that has a parameter celsius, which is going to be a variable with a value that is locally available within the function body. So you do not want to do a var celsius = anything within the body of the function. They create a var fahrenheit; so that is declared, you do not want to do another var fahrenheit; within the body of the function. You do want to calculate the value fahrenheit = and use the equation given to calculate the answer. Do you know how to translate that mathematical equation into a javascript calculation? Sheldon07 @Sheldon07 Nov 10 2016 04:37 @khaduch yes! i got it! thank you :) CamperBot @camperbot Nov 10 2016 04:37 sheldon07 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1906 | @khaduch |http://www.freecodecamp.com/khaduch Ken Haduch @khaduch Nov 10 2016 04:39 @malycole - you can get the list of the arguments that are the tail end of the values passed in the function args with this: var filters = Array.prototype.slice.call(arguments,1); - that will give you an array, for this example, it will have the value [2, 3]. @Sheldon07 :+1: Cole Maly @malycole Nov 10 2016 04:41 @khaduch I guess I have a more club-like approach to it, but I was able to sort that out nonetheless. my destroyer var does have [2, 3] as it's value when I pass it to the filter method Ken Haduch @khaduch Nov 10 2016 04:43 @malycole - okay, so then what do you think the comparison val != destroyer will do for you? I think val is a single number, and destroyer is an array? Emilie @Snipercatz Nov 10 2016 04:44 Can someone help with 'word blanks'? I don't even understand what it's asking me to do Ken Haduch @khaduch Nov 10 2016 04:44 @malycole - also, at the end, you are doing return args; - what is args at that point in time? @Snipercatz - do you know what that thing is they refer to in the description, "Mad Libs"? Joseph @revisualize Nov 10 2016 04:46 @Snipercatz I can. Emilie @Snipercatz Nov 10 2016 04:49 thanks @revisualize I'm just going to skip this one because I have no clue how to do it. I don't understand. I was just finding letters in a name, where the f did this come from? CamperBot @camperbot Nov 10 2016 04:49 snipercatz sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :star2: 2279 | @revisualize |http://www.freecodecamp.com/revisualize Joseph @revisualize Nov 10 2016 04:49 @Snipercatz OR ... You could just read what I wrote. Because it kind of explains EVERYTHING. Click the link and read. You need to understand this lesson to move forward to other lessons. Cole Maly @malycole Nov 10 2016 04:50 @khaduch so how can I manipulate the filter such that it will look through each index of the filters variable? Or is that out of the scope of filter? Ken Haduch @khaduch Nov 10 2016 04:51 @malycole - think of an array method that will search the array for a value. Or it could even be a for loop that you construct to check for an existing value in an array, but there are methods that do that for you. darisguo @darisguo Nov 10 2016 04:53 @khaduch thanks for going into such details! very helpful CamperBot @camperbot Nov 10 2016 04:53 darisguo sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :warning: darisguo already gave khaduch points Cole Maly @malycole Nov 10 2016 04:53 @khaduch indexOf would work. I'm just trying to figure out the most efficient way my (nurse) brain can devise so I'm trying to avoid the really simple long methods. Emilie @Snipercatz Nov 10 2016 04:54 @revisualize thx. i still don't get it but whatever. CamperBot @camperbot Nov 10 2016 04:54 snipercatz sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :warning: snipercatz already gave revisualize points Ken Haduch @khaduch Nov 10 2016 04:54 @malycole - .indexOf is what I used. I like that choice! :) Joseph @revisualize Nov 10 2016 04:55 @Snipercatz So, instead of getting help you're going to skip it? Okay. NoobsNoob @NoobsNoob Nov 10 2016 04:55 how to reference the current value when using array.map method? Cole Maly @malycole Nov 10 2016 04:56 @khaduch thank you! CamperBot @camperbot Nov 10 2016 04:56 malycole sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1907 | @khaduch |http://www.freecodecamp.com/khaduch NoobsNoob @NoobsNoob Nov 10 2016 04:56 Trying to chain the map and filter methods for Seek and Destroy Joseph @revisualize Nov 10 2016 04:57 Or just use .filter(). NoobsNoob @NoobsNoob Nov 10 2016 04:58 @revisualize I'm positive the mode I'm going with is not efficient but here is what I had in mind function destroyer(arr) { // Remove all the values var filters = Array.prototype.slice.call(arguments, 0); var search = filters.shift(0); var result = filters.map(search.filter(currentMapVal)); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); //Returns [1,2,3,1,2,4] as one array rather than separated such as input then return result Cole Maly @malycole Nov 10 2016 04:59 @khaduch  function destroyer(arr) { var args = arr.slice.call(arguments); var destroyer = Array.prototype.slice.call(arguments, 1); return args[0].filter(function(val){ return destroyer.indexOf(val) == -1; }); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); This is what I came up with. Annie @abvolatile Nov 10 2016 04:59 can someone tell me why array[i].shift(); won't work in my code? function titleCase(str) { var lower = str.toLowerCase(); var array = []; array = lower.split(" "); var newArray = []; for(var i=0; i<array.length; i++) { var firstCap = array[i][0].toUpperCase(); array[i].shift(); newArray.push(firstCap+array[i]); } return newArray; } titleCase("sHoRt AnD sToUt"); Cole Maly @malycole Nov 10 2016 04:59 function titleCase(str) { var lower = str.toLowerCase(); var array = []; array = lower.split(" "); var newArray = []; for(var i=0; i<array.length; i++) { var firstCap = array[i][0].toUpperCase(); array[i].shift(); newArray.push(firstCap+array[i]); } return newArray; } titleCase("sHoRt AnD sToUt"); Joseph @revisualize Nov 10 2016 05:00 Ken Haduch @khaduch Nov 10 2016 05:00 @abvolatile - strings in javascript are immutable - I think that's why that won't work. You are trying to eliminate the first character, right? You should use slice and splice or such things... Joseph @revisualize Nov 10 2016 05:00 @NoobsNoob [true, true, false, false, true, false, false, true, true].filter(function (x) { return x }); [23,1,6,12,17,3,2,5,19,86,87].filter(function (x) {return x % 2 === 0}); Annie @abvolatile Nov 10 2016 05:01 @khaduch Ok, I'll try it, thanks! CamperBot @camperbot Nov 10 2016 05:01 abvolatile sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1908 | @khaduch |http://www.freecodecamp.com/khaduch Ken Haduch @khaduch Nov 10 2016 05:02 @malycole - is it working? :point_up: November 9, 2016 11:59 PM Joseph @revisualize Nov 10 2016 05:02 Geez. Seattle is CRAZY right now. Sajeetharan @sajeetharan Nov 10 2016 05:02 any solution for this? Jax @jax11000 Nov 10 2016 05:03 can someone tell me whats wrong with my code for passing parameters? var Car = function(wheels, seats, engines) { //Change this constructor this.wheels = 4; this.seats = 5; this.engines = 1; }; //Try it out here var myCar = new Car(3,1,2); Sahebt Alezare @sahebt-alezar Nov 10 2016 05:06 what solution? a should be defined and have a value of 6 b should be defined and have a value of 15 c should not contain undefined and should have a value of "I am a String!" Do not change code below the line Jax @jax11000 Nov 10 2016 05:06 and im an idiot. disregard my last lol Ken Haduch @khaduch Nov 10 2016 05:08 @malycole - it looks like it passes, so that's great!. It could be just a little bit cleaner, but basically that's it! Good work... good luck. I'm checking out for the night... :) Cole Maly @malycole Nov 10 2016 05:08 @khaduch yes it is! sorry got wrapped up in the next challenge. thank you! CamperBot @camperbot Nov 10 2016 05:08 malycole sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :warning: malycole already gave khaduch points Utku Ören @orenutku Nov 10 2016 05:08 Hey! Having trouble understanding 'Assignment always goes from right to left. Everything to the right of the = operator is resolved before the value is assigned to the variable to the left of the operator.' and how it relates to the following:// Postfix var x = 3; y = x++; // y = 3, x = 4 // Prefix var a = 2; b = ++a; // a = 3, b = 3 Cole Maly @malycole Nov 10 2016 05:11 @orenutku so as I understand it, the text is saying that in y = x++, the "x++" will be performed before assigning it to that value on the left of the = NoobsNoob @NoobsNoob Nov 10 2016 05:13 @revisualize Forgive my ignorance but I'm having a bit of trouble translating that for the exercise :( Utku Ören @orenutku Nov 10 2016 05:13 @malycole that's right, but how come y ends up being 3 instead of 4 since x equals 3 and x++ is the increment of x? Joseph @revisualize Nov 10 2016 05:14 @NoobsNoob Filter requires a function and each element of the array gets passed into the function one at a time. Cole Maly @malycole Nov 10 2016 05:15 @orenutku so the difference is the ++. If it is on the right side of the x, the x is incremented AFTER y is assigned the value of x. its easier to visualize it this way var x = 3; y = x++; // y = 3, x = 4 var x = 3; y = ++x; //y = 4, x = 4 Utku Ören @orenutku Nov 10 2016 05:20 @malycole I see now. Thanks for the clarification! :) CamperBot @camperbot Nov 10 2016 05:20 orenutku sends brownie points to @malycole :sparkles: :thumbsup: :sparkles: :cookie: 264 | @malycole |http://www.freecodecamp.com/malycole Annie @abvolatile Nov 10 2016 05:22 @khaduch just FYI, I figured out how to do it with split. Not sure if it's the most efficient way, but it worked! function titleCase(str) { var lower = str.toLowerCase(); var array = []; array = lower.split(" "); var newArray = []; for(var i=0; i<array.length; i++) { var multiArray = []; multiArray = array[i].split(""); var firstCap = multiArray[0].toUpperCase(); multiArray.shift(); newArray.push(firstCap+multiArray.join("")); } return newArray.join(" "); } titleCase("sHoRt AnD sToUt"); Sahebt Alezare @sahebt-alezar Nov 10 2016 05:22 @sahebt-alezar i solve it as follows var a = 6; var b = 15; var c = c + "i am a string!"; Asadullah5600 @Asadullah5600 Nov 10 2016 05:22 hello world CamperBot @camperbot Nov 10 2016 05:22 ## welcome to FreeCodeCamp @Asadullah5600! Adolfo Saenz @AdoSae1 Nov 10 2016 05:23 ca someone explain "counting cards" to me the wording is really confusing me. Asadullah5600 @Asadullah5600 Nov 10 2016 05:23 i want to learn js from lynda is it right way? Ken Haduch @khaduch Nov 10 2016 05:25 @abvolatile - great! If it works, it's a good start. Good work! Thanks for the update! NoobsNoob @NoobsNoob Nov 10 2016 05:34 @malycole Your code is sort of what I was going for. I didn't want to use loops because they noted the filter methods in the links section. Thanks makes a lot of sense. Realise I was erroring by trying to find a way to iterate over the destroyer/predator array within the filter function. Simply checking if the predator array contains the current prey value is so much better. My bascially identical implementation; function destroyer(arr) { var prey = arguments [0]; var predator = Array.prototype.slice.call(arguments, 1); return prey.filter(function(val){ return predator.indexOf(val) == -1; }); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); CamperBot @camperbot Nov 10 2016 05:34 noobsnoob sends brownie points to @malycole :sparkles: :thumbsup: :sparkles: :cookie: 265 | @malycole |http://www.freecodecamp.com/malycole Adolfo Saenz @AdoSae1 Nov 10 2016 05:36 @khaduch for "counting Cards" im using if statements and not switches right? Joseph Beltrami @Aesirry Nov 10 2016 05:38 @AdoSae1 you can use both Adolfo Saenz @AdoSae1 Nov 10 2016 05:43 @Aesirry would it be: switch(card) { case 2: case 3: case 4: case 5: answer=""; break; ... } uxdash @uxdash Nov 10 2016 05:52 Hey guys I am having trouble with the Make Object Properties Private exercise. Can anyone help? 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(); Whoops sorry I figured it out uxdash @uxdash Nov 10 2016 05:57 Just changed gear+= change to gear = change andry91959 @andry91959 Nov 10 2016 06:04 hi can someone help me with my code function convertToF(celsius) { var fahrenheit; // Only change code below this line fahrenheit = celcius*(9/5)+32; // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(30); Im not sure what is wrong with it Adolfo Saenz @AdoSae1 Nov 10 2016 06:09 spelled celsius wrong Sam @Sambit153 Nov 10 2016 06:09 @andry91959 the spelling of celcius is wrong @andry91959 make it celsius and it will work fine Adolfo Saenz @AdoSae1 Nov 10 2016 06:10 @Sambit153 yo andry91959 @andry91959 Nov 10 2016 06:11 still not working wait its work thank you Adolfo Saenz @AdoSae1 Nov 10 2016 06:17 @Sambit153 hey man Sam @Sambit153 Nov 10 2016 06:18 Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr. function multiplyAll(arr) { var product = 1; // Only change code below this line for (var i=0; i < arr.length; i++){ for(var j = 0; j < arr[i].length; j++){ product = arr[i][j]; } } // Only change code above this line return product; } // Modify values below to test your code multiplyAll([[1,2],[3,4],[5,6,7]]); Markus Kiili @Masd925 Nov 10 2016 06:21 @Sambit153 You are not multiplying product inside the loop. Sam @Sambit153 Nov 10 2016 06:21 @Masd925 can you help me with the code? Chandrahas P @Chan11 Nov 10 2016 06:21 @Sambit153 product = arr[i][j]*product; Sam @Sambit153 Nov 10 2016 06:23 @Chan11 can you please me explain mathematically, what he wants us to do in the problem? @Chan11 and yes it provides the correct output. Thanks. CamperBot @camperbot Nov 10 2016 06:23 sambit153 sends brownie points to @chan11 :sparkles: :thumbsup: :sparkles: :cookie: 320 | @chan11 |http://www.freecodecamp.com/chan11 Markus Kiili @Masd925 Nov 10 2016 06:23 @Sambit153 Get the product of all the elements. Adolfo Saenz @AdoSae1 Nov 10 2016 06:24 You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space. my code is: function cc(card) { // Only change code below this line switch(card) { case 2: case 3: case 4: case 5: case 6: count++; break; case 10: case 'J': case 'Q': case 'K': case 'A': count--; break; } return "Change Me"; // Only change code above this line } // Add/remove calls to test your function. // Note: Only the last will display cc(2); cc(3); cc(7); cc('K'); cc('A'); Sam @Sambit153 Nov 10 2016 06:25 @Masd925 can you let me understand mathematically about what kind of multiplication it needs to do? Chandrahas P @Chan11 Nov 10 2016 06:25 @Sambit153 its very simple,as said by @Masd925 u're not multiplying product with array contents inside for loop. Markus Kiili @Masd925 Nov 10 2016 06:25 @Sambit153 Multiply all those elements: result = 1x2x3x4x5x6x7 Sam @Sambit153 Nov 10 2016 06:26 @AdoSae1 first of all write all the conditions and return bet or hold as a string along with count Markus Kiili @Masd925 Nov 10 2016 06:27 @AdoSae1 Test count after the switch and return accordingly. Adolfo Saenz @AdoSae1 Nov 10 2016 06:32 so lost Sam @Sambit153 Nov 10 2016 06:32 @Masd925 thanks for making me understand about what it needed. CamperBot @camperbot Nov 10 2016 06:32 sambit153 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2864 | @masd925 |http://www.freecodecamp.com/masd925 Adolfo Saenz @AdoSae1 Nov 10 2016 06:34 switch(card) { case 2: case 3: case 4: case 5: case 6: count++; count="Bet"; break; case 10: case 'J': case 'Q': case 'K': case 'A': count--; count="Hold"; break; @Sambit153 ??? Markus Kiili @Masd925 Nov 10 2016 06:35 @AdoSae1 Inside the switch you only increment count. After switch test count and return. andry91959 @andry91959 Nov 10 2016 06:35 hi what does this statement mean? "myStr should have encoded text with the proper escape sequences and no spacing." this is my code and I think i dont have space in it and I already have proper sequence var myStr="FirstLine\n\SecondLinebackslash\\rThirdLine"; shubhankarb180 @shubhankarb180 Nov 10 2016 06:37 how to execute this code : Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see: I am a "double quoted" string inside "double quotes". You should use two double quotes (") and four escaped double quotes (\"). Variable myStr should contain the string: I am a "double quoted" string inside Sam @Sambit153 Nov 10 2016 06:37 @AdoSae1 var count = 0; function cc(card) { // Only change code below this line switch(card) { case 2: case 3: case 4: case 5: case 6: count += 1; break; case 7: case 8: case 9: count += 0; break; case 10: case 'J': case 'Q': case 'K': case 'A': count -= 1; break; } return count; // Only change code above this line } // Add/remove calls to test your function. // Note: Only the last will display cc(2); cc(3); cc(7); cc('K'); cc('A'); try this andry91959 @andry91959 Nov 10 2016 06:37 @andry91959 hi what does this statement mean? "myStr should have encoded text with the proper escape sequences and no spacing." this is my code and I think i dont have space in it and I already have proper sequence var myStr="FirstLine\n\SecondLinebackslash\\rThirdLine"; Sam @Sambit153 Nov 10 2016 06:38 @AdoSae1 you will get the right count. @AdoSae1 you can also try this way : var count = 0; function cc(card) { // Only change code below this line if(card === 2 || card === 3 || card === 4 || card === 5 || card === 6) { count += 1; } else if(card === 7 || card === 8 || card === 9) { count += 0; } else if(card === 10 || card === 'J' || card === 'Q' || card === 'K' || card === 'A') { count -= 1; } if(count > 0) { return count+" Bet"; } else return count+" Hold"; // Only change code above this line } // Add/remove calls to test your function. // Note: Only the last will display cc(2); cc(3); cc(4); cc('K'); cc('A'); Markus Kiili @Masd925 Nov 10 2016 06:39 @AdoSae1 Using a lookup object is also a good possibility. Chandrahas P @Chan11 Nov 10 2016 06:41 @Sambit153 u can console.log to see whats happening inside for loop console.log("arr[i][j]*product:",arr[i][j],"*",product,"=",arr[i][j]*product); u can also see how product changes every loop console.log("product[before]:",product,"\t","prodcut[after]",arr[i][j]*product); shubhankarb180 @shubhankarb180 Nov 10 2016 06:44 Code : var myStr = "I am a \"\"double quoted\"\""; // Change this line Error: Variable myStr should contain the string: I am a "double quoted" All cases work here expect for one need help Sam @Sambit153 Nov 10 2016 06:45 @Chan11 it shows something like this. product[before]: 1 prodcut[after] 1 product[before]: 2 prodcut[after] 4 product[before]: 6 prodcut[after] 18 product[before]: 24 prodcut[after] 96 product[before]: 120 prodcut[after] 600 product[before]: 720 prodcut[after] 4320 product[before]: 5040 prodcut[after] 35280 shubhankarb180 @shubhankarb180 Nov 10 2016 06:47 Code : var myStr = "I am a \"\"double quoted\"\""; // Change this line Error: Variable myStr should contain the string: I am a "double quoted" Adolfo Saenz @AdoSae1 Nov 10 2016 06:50 @Sambit153 thanks i mean it passed but still 75% sure how it all works CamperBot @camperbot Nov 10 2016 06:50 adosae1 sends brownie points to @sambit153 :sparkles: :thumbsup: :sparkles: :cookie: 216 | @sambit153 |http://www.freecodecamp.com/sambit153 Sam @Sambit153 Nov 10 2016 06:51 @AdoSae1 what you didn't understood? Adolfo Saenz @AdoSae1 Nov 10 2016 06:51 @Sambit153 how did you learn it any pages or references you know of that can help? Sam @Sambit153 Nov 10 2016 06:51 @AdoSae1 learnt by solving problems. Asking people when any doubt. Adolfo Saenz @AdoSae1 Nov 10 2016 06:52 if(count > 0) { return count+" Bet"; } else return count+" Hold"; Chandrahas P @Chan11 Nov 10 2016 06:52 Adolfo Saenz @AdoSae1 Nov 10 2016 06:52 just this part damn i just got it! just by looking at it in chat :fire: :fire: :fire: Sam @Sambit153 Nov 10 2016 06:55 @AdoSae1 cool (y) Adolfo Saenz @AdoSae1 Nov 10 2016 06:55 thanks again and for being patient Sam @Sambit153 Nov 10 2016 06:56 @AdoSae1 I am also solving problems here. haha Adolfo Saenz @AdoSae1 Nov 10 2016 06:56 cheers! Quincy Koots @qkoots Nov 10 2016 07:12 Hello, Can anyone tell my why my code is not passing the test. 7 of the 8 test is passed by my code beside the one in the function call function diffArray(arr1, arr2) { var newArr = []; // Same, same; but different. var largerArr; var smallerArr; if (arr1.length >= arr2.length){ largerArr = arr1; smallerArr = arr2; }else{ largerArr = arr2; smallerArr = arr1; } for(var i = 0 ; i < largerArr.length -1; i++){ var elLargerArr = largerArr[i]; var elSmallerArr = smallerArr[i]; if(smallerArr.indexOf(elLargerArr) === -1){ newArr.push(elLargerArr); } if(largerArr.indexOf(elSmallerArr) === -1 ){ newArr.push(elSmallerArr); } if(largerArr.indexOf(elSmallerArr) === -1 && smallerArr.indexOf(elLargerArr) === -1) { newArr = largerArr.concat(smallerArr); } } return newArr; } diffArray( [1, "calf", 3, "piglet"], [1, "calf", 3, 4]); adilkara @adilkara Nov 10 2016 07:15 // Setup function abTest(a, b) { // Only change code below this line if (a<0 |b<0); // 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); please someone tell me what are the changes required to get output keyword undefined and not string "undefined"? Sam @Sambit153 Nov 10 2016 07:18 @adilkara what is the question? adilkara @adilkara Nov 10 2016 07:19 Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined. Hint Remember that undefined is a keyword, not a string. Sam @Sambit153 Nov 10 2016 07:23 @adilkara try this function abTest(a, b) { // Only change code below this line if (a < 0 || b < 0){ return undefined; } // Only change code above this line return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); } // Change values below to test your code abTest(2,2); @qkoots what is not passing? adilkara @adilkara Nov 10 2016 07:24 @Sambit153 you're a wizard , thank you CamperBot @camperbot Nov 10 2016 07:24 adilkara sends brownie points to @sambit153 :sparkles: :thumbsup: :sparkles: :cookie: 217 | @sambit153 |http://www.freecodecamp.com/sambit153 Quincy Koots @qkoots Nov 10 2016 07:26 @Sambit153 the funtion call is the only test of this challenge that will not turn to green so I can advanced to the next challenges.. I can’t figure out why Markus Kiili @Masd925 Nov 10 2016 07:27 @qkoots Using one loop to loop elements of two arrays is not a good idea. You should somehow loop the first array and keep those elements not found on the second, and then do it to the second array too. Concating the two arrays and using .filter() is a common solution here too. eroliver @eroliver Nov 10 2016 07:29 can someone help me w the phoneticLookup challenge I think I am misunderstanding instruction Sam @Sambit153 Nov 10 2016 07:31 @adilkara I am the most normal. haha Quincy Koots @qkoots Nov 10 2016 07:31 @Masd925 Oke thanks for the tip… I will start over again CamperBot @camperbot Nov 10 2016 07:31 :star2: 2865 | @masd925 |http://www.freecodecamp.com/masd925 qkoots sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: Sam @Sambit153 Nov 10 2016 07:32 @Masd925 The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact. If both are true, then return the "value" of that property. If firstName does not correspond to any contacts then return "No such contact" If prop does not correspond to any valid properties then return "No such property" Sending you the code. var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop){ // Only change code below this line if(firstName === contacts.firstName && prop === (contacts.lastName || contacts.number || contacts.likes)){ return contacts.prop; } if(firstName !== contacts.firstName && prop === contacts.prop){ return "No such contact"; } if(firstName === contacts.firstName && prop !== contacts.prop){ return "No such property"; } // Only change code above this line } // Change these values to test your function lookUpProfile("Akira", "likes"); Markus Kiili @Masd925 Nov 10 2016 07:34 @Sambit153 contacts is an array. It has no property key firstName contacts.firstName <- wrong You need to loop them contacts first. Then check. Sam @Sambit153 Nov 10 2016 07:37 So how to do it? @Masd925 so how to do it? Markus Kiili @Masd925 Nov 10 2016 07:37 @Sambit153 Remember how do you loop array indices. nhanly91 @nhanly91 Nov 10 2016 07:38 const data = [5, 5, 5, 2, 2, 2, 2, 2, 9, 4] function count(arr) { return arr.reduce((prev, curr) => (prev[curr] = ++prev[curr] || 1, prev), {}) } console.log(count(data)) I can't understand the function count(arr) anyone can explain to me, thanks! this function show array items with their occurrences Markus Kiili @Masd925 Nov 10 2016 07:41 @nhanly91 Are you familiar with how reduce works? nhanly91 @nhanly91 Nov 10 2016 07:43 @Masd925 I understand some simple reduce like summary all items or flat array Ming Yuan @ymmagic Nov 10 2016 07:44 How to solve this problem of Manipulating Complex Objects 216 who can give an exmaple juniorcito32 @juniorcito32 Nov 10 2016 07:47 How do I? Define a variable a with var and initialize it to a value of 9. Markus Kiili @Masd925 Nov 10 2016 07:47 @nhanly91 The accumulator is an empty object at first. The callback is run once with the accumulator and the element being iterated. The return value (prev, curr) => (prev[curr] = ++prev[curr] || 1, prev) uses the comma operator. The assignment there is executed but prev returned after that. The ++prev[curr] tries to increment the property value and return NaN if it does not exist. In that case 1 is assigned to the property (short circuit evaluation of logical OR). Otherwise the incremented value is assigned. That way each number increments corresponding property value and at the end the object is returned from reduce. juniorcito32 @juniorcito32 Nov 10 2016 07:50 Please Help Markus Kiili @Masd925 Nov 10 2016 07:51 @nhanly91 If you don't get it I can write it out in a more understandable form. @juniorcito32 You declare a variable by putting var before it. Initialization means assigning a value with = operator. = assigns from right side to left. juniorcito32 @juniorcito32 Nov 10 2016 07:54 Like var = 9 ? Markus Kiili @Masd925 Nov 10 2016 07:54 @juniorcito32 Put the variable name after var. nhanly91 @nhanly91 Nov 10 2016 07:56 @Masd925 hey I'm very glad if you can write it in a more understandable form, thanks alot :D CamperBot @camperbot Nov 10 2016 07:56 nhanly91 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2866 | @masd925 |http://www.freecodecamp.com/masd925 juniorcito32 @juniorcito32 Nov 10 2016 07:56 I don't get it Markus Kiili @Masd925 Nov 10 2016 08:00 @nhanly91 function count(arr) { return arr.reduce(function(acc,curr){ if (acc.hasOwnProperty(curr)) acc[curr]++; else acc[curr] = 1; return acc; },{}); } nhanly91 @nhanly91 Nov 10 2016 08:08 @Masd925 I got it, thank you! CamperBot @camperbot Nov 10 2016 08:08 :warning: nhanly91 already gave masd925 points nhanly91 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: Sam @Sambit153 Nov 10 2016 08:12 @Masd925 can you please help me with the solution of the problem? Markus Kiili @Masd925 Nov 10 2016 08:13 @Sambit153 Post the code you have done. Sam @Sambit153 Nov 10 2016 08:13 var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop){ // Only change code below this line if(firstName === contacts.firstName && prop === (contacts.lastName || contacts.number || contacts.likes)){ return contacts.prop; } if(firstName !== contacts.firstName && prop === contacts.prop){ return "No such contact"; } if(firstName === contacts.firstName && prop !== contacts.prop){ return "No such property"; } // Only change code above this line } // Change these values to test your function lookUpProfile("Akira", "likes"); Markus Kiili @Masd925 Nov 10 2016 08:15 @Sambit153 Where is the loop over contacts array elements? Johnny @JohnnyBizzel Nov 10 2016 08:23 @Masd925 contacts Markus Kiili @Masd925 Nov 10 2016 08:24 @JohnnyBizzel You started this typo business yesterday with functeon. I blame you ;) Johnny @JohnnyBizzel Nov 10 2016 08:27 :worried: it's not my fault!! I blame the keyboard Jax @jax11000 Nov 10 2016 08:29 anyone got a second to help with the palindrome algorithm? Markus Kiili @Masd925 Nov 10 2016 08:31 @jax11000 Sure. Jax @jax11000 Nov 10 2016 08:31 function palindrome(str) { str= str.replace(/\s+/g, ""); str = str.replace(/[^\w\s]|_/g, ""); str.toLowerCase(); if(str.split('').reverse().join('')!==str){ return false; } return true; } thats what i have so far and it works for all but two of them, and im not sure why exactly. Markus Kiili @Masd925 Nov 10 2016 08:32 @jax11000 .lowerCase returns a new string that you don't use there. Strings are immutable. Just do return str===str.split("").reverse().join(""); Jax @jax11000 Nov 10 2016 08:33 and boom goes the dynamite. i actually just added a str= str.toLowerCase and it worked. thanks @Masd925 CamperBot @camperbot Nov 10 2016 08:33 jax11000 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2867 | @masd925 |http://www.freecodecamp.com/masd925 Jax @jax11000 Nov 10 2016 08:33 its always the littlest thing that throws you off Markus Kiili @Masd925 Nov 10 2016 08:33 @jax11000 Remove the if because it is redundant. Yash Vardhan @blankyash Nov 10 2016 08:34 Can anyone help me this problem Accessing Objects Properties with Variables Sam @Sambit153 Nov 10 2016 08:34 @Masd925 didn't get you Johnny @JohnnyBizzel Nov 10 2016 08:34 @jax11000 Just do return str===str.split("").reverse().join(""); <- this refactors (improves) the code Yash Vardhan @blankyash Nov 10 2016 08:34 I run with this program // Setup var testObj = { 12: "Namath", 16: "Montana", 19: "Unitas" }; // Only change code below this line; var playerNumber = testObj.16; // Change this Line var player = testObj[playerNumber]; // Change this Line  // Setup var testObj = { 12: "Namath", 16: "Montana", 19: "Unitas" }; // Only change code below this line; var playerNumber = testObj.16; // Change this Line var player = testObj[playerNumber]; // Change this Line  Markus Kiili @Masd925 Nov 10 2016 08:35 @Sambit153 The first thing you need is a loop over contacts array. Johnny @JohnnyBizzel Nov 10 2016 08:35 @Sambit153 a for loop perhaps? Markus Kiili @Masd925 Nov 10 2016 08:35 @blankyash playerNumber should hold a number. Yash Vardhan @blankyash Nov 10 2016 08:35 the number is the identifier here How should I change the playernumber @Masd925 :) Johnny @JohnnyBizzel Nov 10 2016 08:36 @blankyash This doesn not return a number testObj.16 , this does 16. Markus Kiili @Masd925 Nov 10 2016 08:36 @blankyash Assign the number, not testObj.16 Also you cannot use anything starting with a number with dot notation. The key needs to be a valid JS identifier name. Yash Vardhan @blankyash Nov 10 2016 08:37 @Masd925 thanks :smile: CamperBot @camperbot Nov 10 2016 08:37 blankyash sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2868 | @masd925 |http://www.freecodecamp.com/masd925 juniorcito32 @juniorcito32 Nov 10 2016 08:37 can anybody help with Increment a Number with JavaScript Johnny @JohnnyBizzel Nov 10 2016 08:37 a++ @juniorcito32 Read this article http://www.punkchip.com/javascript-shorthand/ CampEvan @CampEvan Nov 10 2016 08:38 guys what's wrong with that? // Setup function phoneticLookup(val) { var result = ""; // Only change code below this line var lookup = { alpha: result = "Adams", bravo: result = "Boston", charlie: result = "Chicago", delta: result = "Denver", echo: result = "Easy", foxtrot: result = "Frank", " ": result = undefined }; // Only change code above this line return result; } // Change this value to test phoneticLookup("charlie"); Johnny @JohnnyBizzel Nov 10 2016 08:40 @CampEvan Don't change the lookup object. Assign result after Jacob Sidford @jacobsidford Nov 10 2016 08:40 Hey guys, just quick on the javascript string myStr should have encoded text with the proper escape sequences and no spacing. juniorcito32 @juniorcito32 Nov 10 2016 08:40 Thanks @JohnnyBizzel CamperBot @camperbot Nov 10 2016 08:40 juniorcito32 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles: :cookie: 783 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel Jacob Sidford @jacobsidford Nov 10 2016 08:40 code is var myStr ="FirstLine\n\\SecondLine\r\\ThirdLine"; CampEvan @CampEvan Nov 10 2016 08:40 @JohnnyBizzel how did i change the lookup? Jacob Sidford @jacobsidford Nov 10 2016 08:40 just got the double slash escapes in there because it requests them CampEvan @CampEvan Nov 10 2016 08:41 @jacobsidford no it shouldnt the displayer displays the code including your syntax @jacobsidford it actually doesnt apply the commands Johnny @JohnnyBizzel Nov 10 2016 08:41 @CampEvan  var lookup = { alpha: "Adams", bravo: "Boston", charlie: "Chicago", delta: "Denver", echo: "Easy", foxtrot: "Frank" }; It should be like this Jacob Sidford @jacobsidford Nov 10 2016 08:42 @CampEvan, sorry that was the request of the challenge I resubmitted it twice with the same code and it accepted so I am unsure what happened. Cheers though. CampEvan @CampEvan Nov 10 2016 08:42 @jacobsidford yeah the compiler bugs from time to time Johnny @JohnnyBizzel Nov 10 2016 08:42 @jacobsidford So near.. it should be like this FirstLine\n\\SecondLine\\\rThirdLine Read the instructions carefully. CampEvan @CampEvan Nov 10 2016 08:43 @JohnnyBizzel still it displays it as wrong damn Jacob Sidford @jacobsidford Nov 10 2016 08:44 @JohnnyBizzel Yea you're right. I resubmitted it and it worked fine, just bugged compiler like @EvanCarter said, thanks CamperBot @camperbot Nov 10 2016 08:44 jacobsidford sends brownie points to @johnnybizzel and @evancarter :sparkles: :thumbsup: :sparkles: :cookie: 784 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel :cookie: 121 | @evancarter |http://www.freecodecamp.com/evancarter CampEvan @CampEvan Nov 10 2016 08:44 @jacobsidford i said it ahahaha Johnny @JohnnyBizzel Nov 10 2016 08:44 @jacobsidford :+1: Jacob Sidford @jacobsidford Nov 10 2016 08:44 ahaha sorry. Thanks @CampEvan CamperBot @camperbot Nov 10 2016 08:44 jacobsidford sends brownie points to @campevan :sparkles: :thumbsup: :sparkles: :cookie: 203 | @campevan |http://www.freecodecamp.com/campevan CampEvan @CampEvan Nov 10 2016 08:44 @jacobsidford ahahaha np bro glad i could help Johnny @JohnnyBizzel Nov 10 2016 08:45 @CampEvan How is your lookup doing? CampEvan @CampEvan Nov 10 2016 08:45 not correct apparently Johnny @JohnnyBizzel Nov 10 2016 08:45 @CampEvan Do you know how to reference an object? CampEvan @CampEvan Nov 10 2016 08:45  Johnny @JohnnyBizzel Nov 10 2016 08:46 shift enter = single line break CampEvan @CampEvan Nov 10 2016 08:46 // Setup function phoneticLookup(val) { var result = ""; // Only change code below this line var lookup = { alpha: "Adams", bravo: "Boston", charlie: "Chicago", delta: "Denver", echo: "Easy", foxtrot: "Frank" }; // Only change code above this line return result; } // Change this value to test phoneticLookup("charlie"); @JohnnyBizzel Johnny @JohnnyBizzel Nov 10 2016 08:47 @CampEvan Assign the val passed in to result using the lookup . You need result = ..... Philipp Scholz @philipp32 Nov 10 2016 08:47 Hey. So I am supposed to filter out all the values which are smaller than 6. Why doesn't this work?  var oldArray = [1,2,3,4,5,6,7,8,9,10]; // Only change code below this line. oldArray = oldArray.filter(function(val){ return val < 6; }); Johnny @JohnnyBizzel Nov 10 2016 08:48 @philipp32 magic! :sparkle: Did you find any explanation of the filter() function? Philipp Scholz @philipp32 Nov 10 2016 08:48 *actually I changed it to val < 6; Johnny @JohnnyBizzel Nov 10 2016 08:50 @philipp32 My interpretation is... for each item of the array, test whether they pass the criteria in the function (callback). If they pass, keep them. If not, discard them. Return the result to a new array. lixchen @lixchen Nov 10 2016 08:51 大家好 问个问题 replace(这里要写逗号和空格应该怎么写,'') Johnny @JohnnyBizzel Nov 10 2016 08:51 lixchen @lixchen Nov 10 2016 08:52 replace(here i want write,and' ',"") what should i do Johnny @JohnnyBizzel Nov 10 2016 08:53 @lxccl myVar.replace(' ').replace("").replace(someOtherChar); Use chaining Philipp Scholz @philipp32 Nov 10 2016 08:55 @JohnnyBizzel solved it on my own. But thank you. :smile: CamperBot @camperbot Nov 10 2016 08:55 philipp32 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles: :cookie: 785 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel Johnny @JohnnyBizzel Nov 10 2016 08:56 @philipp32 Well done. Your code was fine. You asked what it did. Ausgeseitnett! lixchen @lixchen Nov 10 2016 08:56 str.replace(???,"") ???should be(" "and ",") but i don't know how to write @JohnnyBizzel mycol @Nepetrov Nov 10 2016 09:03 Hi everyone ! im stuck at very simple question - here is my code var myVar = 87; // Only change code below this line myVar = myVar + 1 ; myVar = myVar++ ; myVar should equal 88 myVar = myVar should be changed Use the ++ operator Do not change code above the line and here is my mission )) almost everything is done but how can i change myVar = myVar ? i dont understand what should i do hmm andry91959 @andry91959 Nov 10 2016 09:06 hi I need another pair of eyes , whats wrong with this var myStr= "This is the start. " + "This is the end "; Johnny @JohnnyBizzel Nov 10 2016 09:06 @lxccl Try this instead str = str.replace(',').replace(/ /g).replace(/[.]/g); andry91959 @andry91959 Nov 10 2016 09:06 I keep getting it wrong here myStr should have a value of This is the start. This is the end. Johnny @JohnnyBizzel Nov 10 2016 09:07 @andry91959 Looks fine to me mycol @Nepetrov Nov 10 2016 09:08 @JohnnyBizzel thank CamperBot @camperbot Nov 10 2016 09:08 nepetrov sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles: :cookie: 786 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel andry91959 @andry91959 Nov 10 2016 09:08 I dont get the last instruction right Johnny @JohnnyBizzel Nov 10 2016 09:08 @Nepetrov :+1: andry91959 @andry91959 Nov 10 2016 09:08 "myStr should have a value of This is the start. This is the end." Tony Miri @TonyMiri Nov 10 2016 09:08 So, why doesn't value.filter() work here. I get an error in the console that says it's not a function. I'm trying to put a filter in my filter so I can remove dupes while I remove dupes. function sym(args) { var newArray = Array.from(args); var noDupes = newArray.filter(function(value, index, array){ //For each array in the arguments return value.filter(function(val, ind, arr) { //For every value in that array return arr.indexOf(val) == ind; });//filter#2 });//filter console.log(noDupes); } sym([1, 2, 3], [5, 2, 1, 4]); Johnny @JohnnyBizzel Nov 10 2016 09:08 @andry91959 And what is your output? andry91959 @andry91959 Nov 10 2016 09:09 I got it now there was a space at the end and the pullstop Johnny @JohnnyBizzel Nov 10 2016 09:09 @andry91959 Though so ;) @FatTone225 Why have you done it like that? That code is very hard to follow. Tony Miri @TonyMiri Nov 10 2016 09:10 @JohnnyBizzel Mostly because I'm bad at programming lol Johnny @JohnnyBizzel Nov 10 2016 09:10 @fatTone225 The best idea here is to merge all the arrays into one, then filter Tony Miri @TonyMiri Nov 10 2016 09:11 I figured filter() is basically a for loop, and since I can nest for loops then I thought I'd be able to nest filters That doesn't work with the challenge though Combining them all at the beginning, I mean. That doesn't work. Removing duplicates is only step one Then I have to find the symmetric difference between arrays, but you have to do them in order Johnny @JohnnyBizzel Nov 10 2016 09:13 @FatTone225 map is also a similar loop but filter is designed to remove entries. Oh which challenge is it? Tony Miri @TonyMiri Nov 10 2016 09:13 Right. That's what I need to do It's the symmetric difference challenge. I think the second one in the advanced algo section Johnny @JohnnyBizzel Nov 10 2016 09:16 @FatTone225 Actually I used reduce for this one Tony Miri @TonyMiri Nov 10 2016 09:16 You only used reduce? Johnny @JohnnyBizzel Nov 10 2016 09:18 @FatTone225 reduce and filter and for loops. Lots of code! Tony Miri @TonyMiri Nov 10 2016 09:18 Right. I'll use reduce for the last part I'm sure. One leg at a time though. Johnny @JohnnyBizzel Nov 10 2016 09:22 @FatTone225 I need to remember how reduce works! Tony Miri @TonyMiri Nov 10 2016 09:23 Hmm? D O R C ¥ @Dorcy-ndg3 Nov 10 2016 09:24 guys am stuck, it says my button should have text  json.forEach(function(val) { var keys = Object.keys(val); html += "<div class = 'cat'>"; keys.forEach(function(key) { html += "<strong>" + "</strong>: " + val[key] + "<br>"; }); html += "</div><br>"; Johnny @JohnnyBizzel Nov 10 2016 09:27 @FatTone225 I remember .reduce( function( acc, cur ) { ... where acc is the accumulated total and cur is the current item. So this gets called until all items are processed. If that makes sense? Robert Purcea @RobertPurcea Nov 10 2016 09:27 function lookUpProfile(firstName, prop){ // Only change code below this line for(var i = 0; i < contacts.length; i++){ if (contacts[i].firstName == firstName){ if (contacts[i].hasOwnProperty(prop)){ return contacts[i][prop]; } else{ return "No such property"; } } else{ return "No such contact"; } } // Only change code above this line } what am i doing wrong I'm trying to solve the profile lookup exercice D O R C ¥ @Dorcy-ndg3 Nov 10 2016 09:29 @Robertb4 y do u have two else statements Robert Purcea @RobertPurcea Nov 10 2016 09:32 I solved it Merryl @MerrylArok Nov 10 2016 09:45 in a for loop does it matter if i use i++ or ++i Zabi @zabikadi Nov 10 2016 09:45 Hi Can someone help me with this code? // Setup function phoneticLookup(val) { var result = ""; // Only change code below this line var lookup = { aplha: "Adams", bravo: "Boston", charlie: "Chicago", delta: "Denver", echo: "Easy", foxtrot: "Frank" }; result = lookup[val]; // Only change code above this line return result; } // Change this value to test phoneticLookup("alpha"); Merryl @MerrylArok Nov 10 2016 09:47 shouldnt all strings be enclosed with ""? so "alpha":"Adams",... Zabi @zabikadi Nov 10 2016 09:48 Even the property names? Merryl @MerrylArok Nov 10 2016 09:48 yep Zabi @zabikadi Nov 10 2016 09:49 hmm interesting. I've read on other sources that it property names don't have to be strings. Thanks : ) argh still not working :/ smmathur @smmathur Nov 10 2016 09:52 please help with the Profile Lookup code @zabikadi check the spelling for "alpha" Markus Kiili @Masd925 Nov 10 2016 09:53 @MerrylArok On JS object literal there is a freedom to use or not to use quotes. Ghulam Shabir @ghulamshabir Nov 10 2016 09:53 @mibaldobaghi couldn't be answer.length ?? you are supposed to return a number not array Markus Kiili @Masd925 Nov 10 2016 09:54 @zabikadi All JS property keys are strings. @zabikadi If you something else on bracket notation, the engine coerces it to a string. Zabi @zabikadi Nov 10 2016 09:54 @smmathur haha thanks! CamperBot @camperbot Nov 10 2016 09:54 zabikadi sends brownie points to @smmathur :sparkles: :thumbsup: :sparkles: :warning: could not find receiver for smmathur Zabi @zabikadi Nov 10 2016 09:56 @Masd925 Yes, I agree now. Thanks. CamperBot @camperbot Nov 10 2016 09:56 zabikadi sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2869 | @masd925 |http://www.freecodecamp.com/masd925 smmathur @smmathur Nov 10 2016 09:57 has someone completed the Profile Lookup? Zabi @zabikadi Nov 10 2016 09:58 I'll be on it soon. Markus Kiili @Masd925 Nov 10 2016 09:59 @smmathur Yes. smmathur @smmathur Nov 10 2016 10:00 function lookUpProfile(firstName, prop){ // Only change code below this line var value = ""; for (var i = 0; i < contacts.length; i++) { console.log(contacts.length); if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty("prop") === true) { value = contacts[i][prop]; //console.log(contacts[i].firstName + " " + value); } if (contacts[i].hasOwnProperty("firstName") === false) { //console.log(contacts[i].hasOwnProperty("firstName")); value = "No such contact"; } if (contacts[i].hasOwnProperty("prop") === false) { //console.log(contacts[i].hasOwnProperty("prop")); value = "No such property"; } console.log(i + value + contacts[i][prop] + contacts[i].hasOwnProperty("prop")); return value; } //console.log(contacts.firstName); // Only change code above this line } // Change these values to test your function lookUpProfile("Kristian", "lastName"); Markus Kiili @Masd925 Nov 10 2016 10:01 @smmathur It is better to just return when you know the return value. smmathur @smmathur Nov 10 2016 10:01 so should i remove the 'value' variable and just return the value in 'if' blocks? Markus Kiili @Masd925 Nov 10 2016 10:01 Yes. The simplest structure that avoids repeating conditions is two nested if's for those two tests (first name and property existence tests). smmathur @smmathur Nov 10 2016 10:02 right, let me try a nested if function lookUpProfile(firstName, prop){ // Only change code below this line //var value = ""; for (var i = 0; i < contacts.length; i++) { console.log(contacts.length); if (contacts[i].firstName === firstName) { if (contacts[i].hasOwnProperty("prop") === true) { return contacts[i][prop];} //console.log(contacts[i].firstName + " " + value); } if (contacts[i].hasOwnProperty("firstName") === false) { //console.log(contacts[i].hasOwnProperty("firstName")); return "No such contact"; } if (contacts[i].hasOwnProperty("prop") === false) { //console.log(contacts[i].hasOwnProperty("prop")); return "No such property"; } //console.log(i + value + contacts[i][prop] + //contacts[i].hasOwnProperty("prop")); //return value; } // Only change code above this line } // Change these values to test your function lookUpProfile("Kristian", "lastName"); Markus Kiili @Masd925 Nov 10 2016 10:06 @smmathur You should be looking for the key stored in parameter prop, not the key "prop". You only need two if's and the returns. Yixuan Li @YixuanFranco Nov 10 2016 10:09 // 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(prop!=="tracks"&&value!==""){ collection.id.prop = value; } } // Alter values below to test your code updateRecords(5439, "artist", "ABBA"); why it show me : Cannot set property 'prop' of undefined? Markus Kiili @Masd925 Nov 10 2016 10:10 @YixuanFranco You need to use bracket notation when the key is stored in a variable. .id looks for property key "id". Yixuan Li @YixuanFranco Nov 10 2016 10:13 @Masd925 I don't really get it... you mean I should write like: collection.id[prop] or collection[id][prop]? I thought I should use bracket notation only if that is an array Markus Kiili @Masd925 Nov 10 2016 10:13 @YixuanFranco obj[id] looks for property key stored in variable id. Instead obj.id looks for property key "id". So dot notation uses the key written after the dot and bracket notation evaluates the expression written inside the brackets and coerces it to a string if needed. JS array is an object with numeric keys like "0" and "1". That is why it uses the same syntax. Some more explanation: 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. Yixuan Li @YixuanFranco Nov 10 2016 10:16 But the problem here is that it couldn't set property 'prop'....which is behind the id Markus Kiili @Masd925 Nov 10 2016 10:17 @YixuanFranco collection[id][prop]=... It uses as keys what is stored on those parameters id and prop. Yixuan Li @YixuanFranco Nov 10 2016 10:19 ha...I kinda get it now.. thx ^_^, I'll try to alter my code and see if it'll work @Masd925 thank you CamperBot @camperbot Nov 10 2016 10:19 yixuanfranco sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2870 | @masd925 |http://www.freecodecamp.com/masd925 Robert Purcea @RobertPurcea Nov 10 2016 10:27 Use split to create an array of words from string and assign it to array. array = string.split('\s'); what is wrong? Markus Kiili @Masd925 Nov 10 2016 10:30 @Robertb4 Those quotes mean it is a string and not a regexp object. Vijayanandkrishnan @Vijayanandkrishnan Nov 10 2016 10:32 hi , for profile lookup- i want to check If firstName does not correspond to any contacts then return "No such contact", why does this not work? for (var i=0; i<contacts.length; i++){ if (contacts[i].firstName !== firstName ){ return "No such contact"; } } Markus Kiili @Masd925 Nov 10 2016 10:33 @Vijayanandkrishnan You check the first contact on the list and then declare that there was no such contact. Seems wrong. Chandrahas P @Chan11 Nov 10 2016 10:33 @Vijayanandkrishnan fileName is variable,so u have to use contacts[i][firstName] Markus Kiili @Masd925 Nov 10 2016 10:34 @Chan11 No, there is actual "firstName" property key on the contact. Not to be confused with the firstName parameter. Chandrahas P @Chan11 Nov 10 2016 10:36 @Masd925 thanks for pointing out :) CamperBot @camperbot Nov 10 2016 10:36 chan11 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2871 | @masd925 |http://www.freecodecamp.com/masd925 Vijayanandkrishnan @Vijayanandkrishnan Nov 10 2016 10:38 @Masd925 @Chan11 trying to underestan @Masd925 i understand, how do i scan for each object before returning @Masd925 Thanks! CamperBot @camperbot Nov 10 2016 10:39 vijayanandkrishnan sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: Markus Kiili @Masd925 Nov 10 2016 10:40 @Vijayanandkrishnan You check each object for the correct first name and if it is correct, you also make a property existence test. Vijayanandkrishnan @Vijayanandkrishnan Nov 10 2016 10:41 @Masd925 yes, where to place the return so the loop goes till it finds fulfills i<contacts.length; Markus Kiili @Masd925 Nov 10 2016 10:43 If there is a contact with the correct first name, you return inside the loop. If not, after the loop block. chaoz4ngel @chaoz4ngel Nov 10 2016 10:44 Guys i cant undestand "Concatenating Strings with the Plus Equals Operator" I done this but didn't work var myStr = "This is the first sentence. "+= "This is the second sentence."; Vijayanandkrishnan @Vijayanandkrishnan Nov 10 2016 10:45 @Masd925 for (var i=0; i<contacts.length; i++){ if (contacts[i].firstName !== firstName ){ condition here } }return "No such contact"; Markus Kiili @Masd925 Nov 10 2016 10:45 @chaoz4ngel += is used on a variable, not a string literal. str += "cat"; chaoz4ngel @chaoz4ngel Nov 10 2016 10:46 Oh, i solved Markus Kiili @Masd925 Nov 10 2016 10:46 Use + to concat strings. Abhisek Pattnaik @abhisekp Nov 10 2016 10:46 "cat " + "mews" chaoz4ngel @chaoz4ngel Nov 10 2016 10:46 @Masd925 Yes yes, now i had undestrand how it work! thanks (: CamperBot @camperbot Nov 10 2016 10:46 chaoz4ngel sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 2872 | @masd925 |http://www.freecodecamp.com/masd925 Damnuel Coleman West @Dalton-West Nov 10 2016 10:46 Hi I need help understanding exactly what this code did for this project Iterate Through an Array with a For Loop  // Setup var myArr = [ 2, 3, 4, 5, 6]; // Only change code below this line var total = 0; for (var i=0; i < myArr.length; i++){ total += myArr[i]; //This Line Here I don't understand what exactly it did }  Chandrahas P @Chan11 Nov 10 2016 10:47 @Dalton-West total=total+myArr[i] Aamnah Akram @aamnah Nov 10 2016 10:47 i have this passing all but one condition: palindrome("1 eye for of 1 eye.") should return false. ideas?  str = str.toLowerCase().replace(/[,.\/\|:\d\s\-!@#$%^&*()_+=]/gi, '');

return str === str.split('').reverse().join('');
Abhisek Pattnaik
@abhisekp
Nov 10 2016 10:48
@Dalton-West where did you get the code from?
anyway, what does the instruction say?
Johnny
@JohnnyBizzel
Nov 10 2016 10:48
@Dalton-West It adds each item of the array to total
Stephen James
@sjames1958gm
Nov 10 2016 10:48
@Dalton-West myArr[i] will change for each loop being 2 then 3 then 4, etc. so total becomes 2, then 5, then 8, etc
Damnuel Coleman West
@Dalton-West
Nov 10 2016 10:48
I accomplished the task but how does it get to 20 when total is set to 0?
@sjames1958gm So will it keep repeating to lets say 26 and so on?
Stephen James
@sjames1958gm
Nov 10 2016 10:49
@Dalton-West Because each element of the array is summed into the total variable by using += which is the same as total = total +
@Dalton-West Well, 27 if you add 7 to the end of the array
@aamnah Why do you have \d in your regex?
Abhisek Pattnaik
@abhisekp
Nov 10 2016 10:50
. @aamnah because your function will always return true
Aamnah Akram
@aamnah
Nov 10 2016 10:50
@sjames1958gm because i want to remove the zeros. \d is for digits right?
Annika Williamson
@AnnikaKW
Nov 10 2016 10:51
Can anyone tell me why this code contains in infinite loop according to the test?
Stephen James
@sjames1958gm
Nov 10 2016 10:51
@aamnah You'll need to remove all non-alphanumeric characters from the instructions - keep numbers and letters
Annika Williamson
@AnnikaKW
Nov 10 2016 10:51
function factorialize(num) { for (var i = 1; i < num; i++) { num = num * (num + 1); } return num; }
Stephen James
@sjames1958gm
Nov 10 2016 10:51
@AnnikaKW If num keeps growing how will i ever reach it?
Aamnah Akram
@aamnah
Nov 10 2016 10:52
@sjames1958gm alpha-NUMERIC! got it, thank you!
CamperBot
@camperbot
Nov 10 2016 10:52
aamnah sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4284 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 10 2016 10:52
@aamnah :)
Annika Williamson
@AnnikaKW
Nov 10 2016 10:52
Ah I see. Thanks @sjames1958gm
Stephen James
@sjames1958gm
Nov 10 2016 10:52
@AnnikaKW :+1:
Damnuel Coleman West
@Dalton-West
Nov 10 2016 10:53
@sjames1958gm So since total is 0 and myArr is 2,3,4,5,6 and i=0 would it look like this in math
total = total +myArr[i]
0 = 0 + 2[0]
0 = 0+3[0]
Sorry im just a visual learner?
Stephen James
@sjames1958gm
Nov 10 2016 10:54
@Dalton-West total is
0 + myArr[0] or 2 -> 2
2 + myArr[1] or 3 -> 5
5 + myArr[2] or 4 -> 9
etc.
Damnuel Coleman West
@Dalton-West
Nov 10 2016 10:54
so 0=0+2[0] == 20 because of 2[0]?
Stephen James
@sjames1958gm
Nov 10 2016 10:54
@Dalton-West total is growing with each loop it is not zero after the first loop it is 2
Damnuel Coleman West
@Dalton-West
Nov 10 2016 10:55
O ok so total grows with each step in the array?
Is that it.
Stephen James
@sjames1958gm
Nov 10 2016 10:55
@Dalton-West Exactly as does i
Damnuel Coleman West
@Dalton-West
Nov 10 2016 10:55
@sjames1958gm Thanks man i appreciate the help!
CamperBot
@camperbot
Nov 10 2016 10:55
dalton-west sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Nov 10 2016 10:55
@Dalton-West Basically that is it.
CamperBot
@camperbot
Nov 10 2016 10:55
:star2: 4285 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 10 2016 10:55
@Dalton-West :+1:
Damnuel Coleman West
@Dalton-West
Nov 10 2016 10:56
Well back to work my Lunch is over :(
Johnny
@JohnnyBizzel
Nov 10 2016 10:57
@Dalton-West You can visualise this if you use a debugging tool like http://pythontutor.com/visualize.html#mode=edit
Annika Williamson
@AnnikaKW
Nov 10 2016 11:07
New try. I don't want to know a solution, just tell me where my logical error is in this:
function factorialize(num) {
var fact = 1;
for (var i = 1; i < num; i++) {
fact = fact * (fact + 1);
}
return fact;
}

factorialize(5);
Patkaa
@Patkaa
Nov 10 2016 11:07

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

// Only change code below this line
var lookup = {

"bravo": result = "Boston",

"charlie": result = "Chicago",

"delta": result = "Denver",

"echo": result = "Easy",

"foxtrot": result = "Frank",
};

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

// Change this value to test
phoneticLookup("charlie");
need help:(
Vagner Cazarotto
@vagnercazarotto
Nov 10 2016 11:11
@Patkaa whats the problem?
CampEvan
@CampEvan
Nov 10 2016 11:12
does anybody know how to correct this?


// 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("charlie");
Stephen James
@sjames1958gm
Nov 10 2016 11:13
@AnnikaKW You are multiply by the multiples so 1 * 2 * 2 * 4 * 8 and not 1 * 2 * 3 * 4
@CampEvan You need to use lookup and val together to set result. val is the property you are looking up
@Patkaa result = does not belong inside the object. You need to set result after the object literal
Annika Williamson
@AnnikaKW
Nov 10 2016 11:14
Thanks @sjames1958gm !
CamperBot
@camperbot
Nov 10 2016 11:14
:star2: 4286 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
annikakw sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: