These are chat archives for FreeCodeCamp/HelpJavaScript

26th
Apr 2017
Stephen James
@sjames1958gm
Apr 26 2017 00:00
@abhishek737 No I mean this FormData object - I think this code is using the fetch API
var form = new FormData();
form.append('client_id', config.APP_KEY);
form.append('redirect_url', config.REDIRECT_URL);
form.append('response_type', 'code');
iamjoshuacolon
@iamjoshuacolon
Apr 26 2017 00:04
This is my exercise: Escaping Literal Quotes in Strings - I need this result: I am a "double quoted" string inside "double quotes".
This is my code: var myStr = "I am a, \"double quoted\".";var myStr = "string inside \"double quotes\".";
Stephen James
@sjames1958gm
Apr 26 2017 00:05
@iamjoshuacolon Only one string
.";var myStr = " this part in the middle needs to go.
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 00:06
@cmccormack Sorry, walked away. If they did try and abstract it it didn't work with me. That's 2 execises in a row now where I had to be SHOWN the code. I feel like I cheated.
mrfleche
@mrfleche
Apr 26 2017 00:08
commenting in JavaScript Code starting // this is coment
Mostafa Hesham
@mhesham32
Apr 26 2017 00:08
sorry but i need help here

function rot13(str,key) { // LBH QVQ VG!
  var alphaNum={
    A:[1,27],B:[2,28],C:[3,29],D:[4,30],E:[5,31],F:[6,32],G:[7,33],
    H:[8,34],I:[9,35],J:[10,36],K:[11,37],L:[12,38],M:[13,39],N:[14,40],O:[15,41],P:[16,42],Q:[17,43],R:[18,44],S:[19,45],T:[20,46],
    U:[21,47],V:[22,48],W:[23,49],X:[24,50],Y:[25,51],Z:[26,52] };


var decodedLetter;
  var arr=[];



  for(var x in alphaNum){
  for(var i=0; i<str.length; i++){
    if(str[i]===x){
    decodedLetter=alphaNum[x][0]+key;}
    if(decodedLetter==alphaNum[x][1]){arr.push(x);}//this dosn't work 
    if( decodedLetter==alphaNum[x][0]){//it works Here
      arr.push(x);
    } 
  }
  }


return arr.join('') ;  //it should give N Is my logic right?
}

// Change the inputs below to test
rot13("A",13);
mrfleche
@mrfleche
Apr 26 2017 00:08
how do you close this
Stephen James
@sjames1958gm
Apr 26 2017 00:09

@mrfleche // are single line comments

/*
*/

are multiple lines

rajeshraj472
@rajeshraj472
Apr 26 2017 00:10
Hi Everyone, I am trying to removed the first element in the array using shift but for some reason it is not working.
mrfleche
@mrfleche
Apr 26 2017 00:10
2 types required
rajeshraj472
@rajeshraj472
Apr 26 2017 00:10

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

arr+=arr.push(item);
var removed = arr.shift();
return removed;
}
console.log(nextInLine([1,2,3], 4));
// 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));

Stephen James
@sjames1958gm
Apr 26 2017 00:10
@mhesham32 How is this supposed to work? How does A get to be N
@rajeshraj472 arr.push returns the new length (a number - don't overwrite the arr variable with it)
Mostafa Hesham
@mhesham32
Apr 26 2017 00:12
@sjames1958gm it works A gives N But N doesn't give A
rajeshraj472
@rajeshraj472
Apr 26 2017 00:12
@sjames1958gm got it. Thanks
CamperBot
@camperbot
Apr 26 2017 00:12
rajeshraj472 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6971 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 26 2017 00:14
@mhesham32 What are the numbers in the array A:[1, 27]
Mostafa Hesham
@mhesham32
Apr 26 2017 00:15
A=1, 1+13=14=N /N=14, 14+13=27=A @sjames1958gm
Stephen James
@sjames1958gm
Apr 26 2017 00:18
@mhesham32 But you never look back at A after N so N cannot get to A
Long Nguyen
@longnt80
Apr 26 2017 00:18

Hi @sjames1958gm
I'm doing the Seek and Destroy challenge. I'm using a filter method within a for loop like this:

function destroyer(arr) {

  var numberOfCase = arguments.length -1;

  var firstArg = arguments[0];  

  // Start the loop
  for (var i = 1; i <= numberOfCase; i++) {
    givenNum = arguments[i];
    result = firstArg.filter(function(val){
      return val !== givenNum;
    });  

    firstArg = result;
  }


  console.log(result);
  return result;
}

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

However, FCC said "Don't make functions within a loop". How can I avoid it?

Stephen James
@sjames1958gm
Apr 26 2017 00:20
@longnt80 You could put var givenNum and name the function, passing the named function to the filter.
Christopher McCormack
@cmccormack
Apr 26 2017 00:20
@longnt80 there is an anonymous function within your filter, you can move that function outside of your for loop and pass the name ( no ()'s ) of the outside function to filter
Stephen James
@sjames1958gm
Apr 26 2017 00:20
@mhesham32 You could just get the character code for A and add 13 then change back to a number
Mostafa Hesham
@mhesham32
Apr 26 2017 00:20
@sjames1958gm You mean x should relooped?
Fernando J Soares
@biofscode
Apr 26 2017 00:21
Hi everybody, I simply can't figure why my nested for loops are not looping at all. Would anybody care to look, please?
Christopher McCormack
@cmccormack
Apr 26 2017 00:21
@biofscode sure can you paste your code, surrounded by ```?
Stephen James
@sjames1958gm
Apr 26 2017 00:21
@mhesham32 Possibly. Seems overly complex
Fernando J Soares
@biofscode
Apr 26 2017 00:21
in a sec...

'''function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.lenght; i++) {
for (var j=0; j < arr[i].lenght; j++) {
product = (arr[i][j]) * (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]]);
'''

CamperBot
@camperbot
Apr 26 2017 00:22
:bulb: to format code use backticks! ``` more info
Christopher McCormack
@cmccormack
Apr 26 2017 00:22
backticks, under the tilde ~ key
Stephen James
@sjames1958gm
Apr 26 2017 00:23
@biofscode You are just resetting product to a new value each time - you need to accumulate the product
Mostafa Hesham
@mhesham32
Apr 26 2017 00:23
@sjames1958gm yeah :smile:
Stephen James
@sjames1958gm
Apr 26 2017 00:23
@biofscode Also typo - lenght
Fernando J Soares
@biofscode
Apr 26 2017 00:23
Cheers!!
RonnyNovik
@RonnyNovik
Apr 26 2017 00:24
@RonnyNovik
Hey can somebody help me out here?Why all of the pictures are going down at the same time?
http://codepen.io/roninovik/pen/jmVBOg
Long Nguyen
@longnt80
Apr 26 2017 00:24
@sjames1958gm @cmccormack thanks guys, I got it, no more warning from FCC
CamperBot
@camperbot
Apr 26 2017 00:24
longnt80 sends brownie points to @sjames1958gm and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 420 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 6972 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 26 2017 00:24
@longnt80 :+1:
iamjoshuacolon
@iamjoshuacolon
Apr 26 2017 00:26
Escape Sequences in Strings - this is my code: var myStr = "FirstLine\\nSecondLine\\rThirdLine";
This is my error message: myStr should have encoded text with the proper escape sequences and no spacing.
What did I miss?
ThePineal
@ThePineal
Apr 26 2017 00:27
im trying to do switch statements but im getting told one of my case values is undefined

switch (val) {
case "a":
answer = "apple";
break;
case "b":
answer = "bird";
break;
case "c":
answer = "cat";
break;
default:
answer = "stuff";

}

any ideas?
Christopher McCormack
@cmccormack
Apr 26 2017 00:28
@RonnyNovik animate is asynchronous, so all are actually called at around the same time. check this video for help https://www.youtube.com/watch?v=82CqnUhTFLo
I believe near the end he does a very similar example to what you're trying to do
Long Nguyen
@longnt80
Apr 26 2017 00:29
@ThePineal copy all your code into the backticks like this:
alt
ThePineal
@ThePineal
Apr 26 2017 00:30

```switch (val) {
case "a":
answer = "apple";
break;
case "b":
answer = "bird";
break;
case "c":
answer = "cat";
break;
default:
answer = "stuff";

}

im confused
Christopher McCormack
@cmccormack
Apr 26 2017 00:31
@ThePineal what is the goal? Are you supposed to return answer?
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 00:31
@cmccormack BTW, Thanks for your help!
ThePineal
@ThePineal
Apr 26 2017 00:31
yeah
CamperBot
@camperbot
Apr 26 2017 00:31
tincan-assassin sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 421 | @cmccormack |http://www.freecodecamp.com/cmccormack
Stephen James
@sjames1958gm
Apr 26 2017 00:31
@iamjoshuacolon Did you get the correct order - newline - backslash - backslash - carriage-return?
Christopher McCormack
@cmccormack
Apr 26 2017 00:31
@TinCan-Assassin np
Long Nguyen
@longnt80
Apr 26 2017 00:31
@ThePineal copy everything in here
ThePineal
@ThePineal
Apr 26 2017 00:31

function switchOfStuff(val) {
var answer = "";
// Only change code below this line

switch (val) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";

}

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

Stephen James
@sjames1958gm
Apr 26 2017 00:31
This message was deleted
ThePineal
@ThePineal
Apr 26 2017 00:32
i get "referenceError: a is not defined"
Christopher McCormack
@cmccormack
Apr 26 2017 00:32
ah
just use 'a' instead :)
surround your strings in quotes
ThePineal
@ThePineal
Apr 26 2017 00:32
gets the same answer
tried that already
Stephen James
@sjames1958gm
Apr 26 2017 00:32
@ThePineal Make sure your call to switchOfStuff is also using "a"
at the bottom.
@ThePineal They should both be strings.
RonnyNovik
@RonnyNovik
Apr 26 2017 00:33
@cmccormack Didn't work..
Stephen James
@sjames1958gm
Apr 26 2017 00:33
@ThePineal switchOfStuff("a");
ThePineal
@ThePineal
Apr 26 2017 00:33
@sjames1958gm that worked
why though?
RonnyNovik
@RonnyNovik
Apr 26 2017 00:33
Hey can somebody help me out here?Why all of the pictures are going down at the same time?
http://codepen.io/roninovik/pen/jmVBOg
Christopher McCormack
@cmccormack
Apr 26 2017 00:33
@RonnyNovik what didn't work? Setinterval?
Stephen James
@sjames1958gm
Apr 26 2017 00:33
@ThePineal because a by itself is a variable that was not defined - so it got an error
RonnyNovik
@RonnyNovik
Apr 26 2017 00:34
@cmccormack he didn't do set interval
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 00:34
I'm out for tonight. See ya'll.
Christopher McCormack
@cmccormack
Apr 26 2017 00:34
@RonnyNovik watch the whole video so you can understand asynch calls, then you can figure out the solution yourself
@TinCan-Assassin see ya
ThePineal
@ThePineal
Apr 26 2017 00:34
@sjames1958gm ty
CamperBot
@camperbot
Apr 26 2017 00:34
thepineal sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6973 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
iamjoshuacolon
@iamjoshuacolon
Apr 26 2017 00:35
@sjames1958gm Got it man, thanks!
CamperBot
@camperbot
Apr 26 2017 00:35
iamjoshuacolon sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6974 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Enric Llopis Fabra
@qiqete
Apr 26 2017 00:35
Hello! Can I have Help with the TileCaseASentence?
I have this code, but everything finish as starts :S
Stephen James
@sjames1958gm
Apr 26 2017 00:35
@ThePineal :+1:
@iamjoshuacolon :checkered_flag:
Enric Llopis Fabra
@qiqete
Apr 26 2017 00:35

Here is my code
function titleCase(str) {
var arr = [];
arr = str.split(' ');

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

arr[i].charAt(0).toUpperCase();

}
str = arr.join(' ');
return str;
}

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

Long Nguyen
@longnt80
Apr 26 2017 00:36
@sjames1958gm
where are all these emoticons?
Stephen James
@sjames1958gm
Apr 26 2017 00:36
@qiqete strings are immutable - so all string functions return values -
arr[i].charAt(0).toUpperCase();
this returns a value which you do nothing with
@longnt80 Start with a \:
Long Nguyen
@longnt80
Apr 26 2017 00:36
\:
ok I see them now, haha
thanks @sjames1958gm
CamperBot
@camperbot
Apr 26 2017 00:37
longnt80 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: longnt80 already gave sjames1958gm points
Jamal Uddin
@jamal-pb95
Apr 26 2017 00:37
Please tell whats wrong in my code:
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

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

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

var total = 0;
for(var i = 2; i < myArr.lenght; i++) {
  total += myArr[i];
}
Enric Llopis Fabra
@qiqete
Apr 26 2017 00:37
@sjames1958gm okay, any idea how to set it?
Stephen James
@sjames1958gm
Apr 26 2017 00:38
@qiqete You have to rebuild the word from the first letter and rest of the string.
You can put this word back into arr[i]
@jamal-pb95 lenght is mispelled
Enric Llopis Fabra
@qiqete
Apr 26 2017 00:38
length
@sjames1958gm Okay, thanks :D
CamperBot
@camperbot
Apr 26 2017 00:39
qiqete sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6975 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jamal Uddin
@jamal-pb95
Apr 26 2017 00:39
@qiqete Thanks
CamperBot
@camperbot
Apr 26 2017 00:39
jamal-pb95 sends brownie points to @qiqete :sparkles: :thumbsup: :sparkles:
:cookie: 144 | @qiqete |http://www.freecodecamp.com/qiqete
Jamal Uddin
@jamal-pb95
Apr 26 2017 00:40
@sjames1958gm Thanks
CamperBot
@camperbot
Apr 26 2017 00:40
jamal-pb95 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6976 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 26 2017 00:40
@qiqete :+1:
@jamal-pb95 :shipit: yw
anderson
@anderson2825
Apr 26 2017 00:40
function mutation(arr) {
   if(arr[1].indexOf(arr[0])!==-1){
       return false; 
    }else {
       return true;
    } 

}

mutation(["hello", "hey"]);
why is wrong?? i need help!
arrindexof26083915.png
Manish Giri
@Manish-Giri
Apr 26 2017 00:41
@anderson2825 what about the rest of the letters?
Stephen James
@sjames1958gm
Apr 26 2017 00:41
@anderson2825 1) you're search is backwards. 2) you need to look for each letter of arr[1] separately not as whole string
Oscar Lopez Guzman
@olopezg
Apr 26 2017 00:42
Hi guys!
Christopher McCormack
@cmccormack
Apr 26 2017 00:42
@olopezg hello
Enric Llopis Fabra
@qiqete
Apr 26 2017 00:42
@olopezg hi
Stephen James
@sjames1958gm
Apr 26 2017 00:42
@olopezg Hola
Oscar Lopez Guzman
@olopezg
Apr 26 2017 00:42
I'm stuck in Weather App challenge.
anderson
@anderson2825
Apr 26 2017 00:43
@olopezg hello morning!
Oscar Lopez Guzman
@olopezg
Apr 26 2017 00:44
I need https to use "navigator.gelocation" but api.openweathermap.org does not support https.
Christopher McCormack
@cmccormack
Apr 26 2017 00:44
use darksky @olopezg
anderson
@anderson2825
Apr 26 2017 00:44
@sjames1958gm @Manish-Giri okay, thanks!
CamperBot
@camperbot
Apr 26 2017 00:44
anderson2825 sends brownie points to @sjames1958gm and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5293 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 6977 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Oscar Lopez Guzman
@olopezg
Apr 26 2017 00:44
So im getting this error...
Christopher McCormack
@cmccormack
Apr 26 2017 00:44
I moved my personal domain to https recently and that was a pain moving the weather app over without changing apis
Long Nguyen
@longnt80
Apr 26 2017 00:44
@anderson2825
.indexOf only search for the first result it can find, it won't search for all identical values
you need to use a loop to cycle through the values
Oscar Lopez Guzman
@olopezg
Apr 26 2017 00:44
blob
Christopher McCormack
@cmccormack
Apr 26 2017 00:45
@olopezg you can either use a weather api that supports https, or switch your geolocator to something that supports http
@olopezg http://ipinfo.io/json supports http if you need one
but I believe you also have to ensure codepen is using http and not https as well if you're using codepen
Oscar Lopez Guzman
@olopezg
Apr 26 2017 00:46
@cmccormack it is free, right?
Christopher McCormack
@cmccormack
Apr 26 2017 00:46
yup
Nigel Haslam
@motioncircus
Apr 26 2017 00:46
any suggestions for styling my first, vanilla javascript, web app? Seems there's a lot of CSS options, wondering what's the current best/easiest option
Christopher McCormack
@cmccormack
Apr 26 2017 00:46
I found darksky to be easier to use anyhow
anderson
@anderson2825
Apr 26 2017 00:47
@longnt80 okay! Thanks for your advice!
CamperBot
@camperbot
Apr 26 2017 00:47
:cookie: 186 | @longnt80 |http://www.freecodecamp.com/longnt80
anderson2825 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
Apr 26 2017 00:47
@motioncircus you could use pure bootstrap if you want, but if you're going to heavily customize it I might not suggest using it
RonnyNovik
@RonnyNovik
Apr 26 2017 00:48
@cmccormack @cmccormack Can you give me a brief ? how to deal with such thing?
Nigel Haslam
@motioncircus
Apr 26 2017 00:49
@cmccormack thanks, will take a peek at bootstrap... I'm not a fussy pixel pusher, so will probably be happy with the out of the box bits and bobs.
CamperBot
@camperbot
Apr 26 2017 00:49
motioncircus sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 422 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Apr 26 2017 00:49
@RonnyNovik I'm not even certain what you're trying to do. Are you trying to do one animation at a time, iterating from left to right?
RonnyNovik
@RonnyNovik
Apr 26 2017 00:50
@cmccormack Exactly
I want them to slide down its delayed a bit from the previous
Christopher McCormack
@cmccormack
Apr 26 2017 00:50
@RonnyNovik in that video he does almost exactly that same exercise, check it out at around 15 min https://youtu.be/82CqnUhTFLo?t=887
but I do recommend watching the whole video to get a good understanding of the different ways to do asynchronous calls and the pitfalls you can learn to avoid
@motioncircus it's great for out of the box, but if you need to say customize the navbar, it can be a pain if it's more than maybe just some color changes
Ryan Park
@ryanpark1
Apr 26 2017 00:53
Can somebody help me out how how to get right code on Understanding Case Sensitivity in Variables?
Christopher McCormack
@cmccormack
Apr 26 2017 00:53
@ryanpark1 what issues are you having?
Ryan Park
@ryanpark1
Apr 26 2017 00:53
the problem is here
studlyCapVar is defined and has a value of 10
properCamelCase is defined and has a value of "A String"
titleCaseOver is defined and has a value of 9000
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
Christopher McCormack
@cmccormack
Apr 26 2017 00:55
@ryanpark1 gotta read the instructions, it basically walks you through how to do it with examples
@ryanpark1 do you have code so far or just the default?
Ryan Park
@ryanpark1
Apr 26 2017 00:56
I have code
// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;
titleCaseOver = 9000;
// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;
studlyCapVar = 10;
properCamelCase = "A String";
like this
Christopher McCormack
@cmccormack
Apr 26 2017 00:57
you need to use camel case
Write variable names in Javascript in camelCase. In camelCase, multi-word variable names have the first word in lowercase and the first letter of each subsequent word is capitalized.
Ryan Park
@ryanpark1
Apr 26 2017 00:57
got it
thank you :+1:
Christopher McCormack
@cmccormack
Apr 26 2017 00:57
you have different casing for the same variables too, make sure it's all camel case and the variables match
np!
Haylycon
@Haylycon
Apr 26 2017 00:59
I'm stuck on the converting celsius to farenheit.
I have literally no clue what I should be doing.
Any ideas?
RonnyNovik
@RonnyNovik
Apr 26 2017 00:59
@cmccormack http://codepen.io/roninovik/pen/jmVBOg i did the same thing he shows yet it doesn't work
Christopher McCormack
@cmccormack
Apr 26 2017 00:59
@Haylycon read the instructions again, then again, then paste your code after you've considered the instructions
Christopher McCormack
@cmccormack
Apr 26 2017 01:05
@RonnyNovik I think it may have to do with the animate function, let me take a look
Joseph
@revisualize
Apr 26 2017 01:07

@Haylycon There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32

hekri-d
@hekri-d
Apr 26 2017 01:08
it kinda surprises me why a great deal of people find this Fahrenheit to Celsius challenge hard?
Christopher McCormack
@cmccormack
Apr 26 2017 01:08
@RonnyNovik yeah I think what's happening is when one of the boxes animates down, the margin at the top is increased, and that applies to all of the boxes. Play with that and see if it helps. I have to run for a few
Joseph
@revisualize
Apr 26 2017 01:08
It is one of the key times that they need to use a parameter.
Nigel Haslam
@motioncircus
Apr 26 2017 01:08
@cmccormack looking at bootstrap opened up the pandoras box of "sorting out my development environment".
I've got Node.js installed from a previous bout of tutorials but when I tried to get it to serve my current project I got a heap of errors that I couldn't resolve quickly.
I'd love a locally hosted, preferably 'live updating' web server to save me half a dozen clicks every time I want to see the result of my coding. Any suggestions, other than reading up on Node?
hekri-d
@hekri-d
Apr 26 2017 01:09
@revisualize could be. To be hones never thought about it that way.
Dean Pierrot
@dapierrot21
Apr 26 2017 01:10

So I'm being ask to 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. Here is my ```
function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift([0]);
return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
What am i doing wrong? Thanks in advance!!!

Joseph
@revisualize
Apr 26 2017 01:10
@dapierrot21 you are still returning item
You need to return the removed element.
Also, .shift() doesnt take an argument.
hekri-d
@hekri-d
Apr 26 2017 01:11
@dapierrot21 to format your code add a carriage return (enter button) before and after the 'ticks'. And add three 'ticks' at the end of your piece of code.
Dean Pierrot
@dapierrot21
Apr 26 2017 01:12
is the removed element arr?
Joseph
@revisualize
Apr 26 2017 01:12

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

The shift() method removes the first element from an array and returns that element.

hekri-d
@hekri-d
Apr 26 2017 01:12
Adding to @revisualize even if shift took any arguments it likely wouldn't be an array with a single element set to zero
Joseph
@revisualize
Apr 26 2017 01:13
@dapierrot21 no. arr is a whole array. An element is a value in the array.
Stephen James
@sjames1958gm
Apr 26 2017 01:13
@hekri-d Its because they don't understand functions and that celsius will have different values, in my experience
@ryanpark1 Make sure that you just edit the variables given, don't add any new lines,
Joseph
@revisualize
Apr 26 2017 01:16
@dapierrot21 solve it?
Dean Pierrot
@dapierrot21
Apr 26 2017 01:18
ok so i removed the argument from .shift(). I'm assuming i got the arr.push(item) right correct? I know its staring me right in the face but where will i find the removed element?
Joseph
@revisualize
Apr 26 2017 01:18
Your push is correct.
hekri-d
@hekri-d
Apr 26 2017 01:18
@sjames1958gm this shows how easy it is to forget what we were like and what we though when we started out. When I first got introduced to a programming language I had a pretty good idea what a function is so I didn't have a hard time grasping functions. A lot of people here are probably not that familiar with mathematical functions either so that could be a reason.
@dapierrot21 the removed argument is 'removed' from the array... you just have to 'catch' it.
Joseph
@revisualize
Apr 26 2017 01:19
@dapierrot21 what does the .shift() method do?
Stephen James
@sjames1958gm
Apr 26 2017 01:19
@hekri-d Yes, I would agree, i don't think objects and functions are taught/communicated well enough.
Joseph
@revisualize
Apr 26 2017 01:20
I agree
Nahuel Ovejero
@NahuelOvejero
Apr 26 2017 01:21
Hello! Does someone know about Virtual Memory and memory pages? I need a bit of help. Could not find help in other chats
Dean Pierrot
@dapierrot21
Apr 26 2017 01:22
it removes the first element from an array and returns that element.
Joseph
@revisualize
Apr 26 2017 01:22
Oh. I like that and part
@dapierrot21 so should you.
Dean Pierrot
@dapierrot21
Apr 26 2017 01:23
so should i want?
Joseph
@revisualize
Apr 26 2017 01:23
So, if .shift() returns the element removed. Could you just return what is returned from the shift?
@dapierrot21 Need an example?
Dean Pierrot
@dapierrot21
Apr 26 2017 01:26
yes please lol
Joseph
@revisualize
Apr 26 2017 01:26

@dapierrot21

function getName() { return "Happy Feet"; }
var name = getName();
console.log(name);

What do you think is output to the console when you log the variable name?
Why do you think that is?

Dean Pierrot
@dapierrot21
Apr 26 2017 01:27
happy feet
Joseph
@revisualize
Apr 26 2017 01:28
@dapierrot21 Well, it's actually "Happy Feet" but, I really want the why.
Dean Pierrot
@dapierrot21
Apr 26 2017 01:30
Because getName function returns "Happy Feet" and var name stores that function
Joseph
@revisualize
Apr 26 2017 01:30

@dapierrot21 Then my next question will be.. What happens if we just cut out the middle man and remove name variable.

function getName() { return "Happy Feet"; }
console.log( getName() );

Does the answer change? Are you still logging to the console "Happy Feet"? This goes back to that why.

@dapierrot21 The same holds true for the method .shift() it returns the value of the element that it removed from the array.
rmattr
@rmattr
Apr 26 2017 01:31
how are you guys posting your code?
Joseph
@revisualize
Apr 26 2017 01:31
@dapierrot21 So, you can just return the .shift() method call because your function would then be returning what is returned from .shift()
hekri-d
@hekri-d
Apr 26 2017 01:32
@revisualize you paste your code inside ```
Joseph
@revisualize
Apr 26 2017 01:32

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

...
@dapierrot21 Confused?
amr ibrahem
@amrIbrahem
Apr 26 2017 01:33
hi i need help does any one know course or ducumentation to learn algorithm
rmattr
@rmattr
Apr 26 2017 01:33
Thanks! and yeah, a little bit haha.
Nahuel Ovejero
@NahuelOvejero
Apr 26 2017 01:34
@amrIbrahem check the "map" navigation in the FreeCodeCamp, there are few excercises
Joseph
@revisualize
Apr 26 2017 01:34
@amrIbrahem What Algorithm?
@amrIbrahem An algorithm is just a set of instructions to complete a task.
amr ibrahem
@amrIbrahem
Apr 26 2017 01:35
yes but i need course this is look as a test i need something to learn me then will take it on freeCodeCamp @NahuelOvejero
Joseph
@revisualize
Apr 26 2017 01:35
@amrIbrahem
al·go·rithm
ˈalɡəˌriT͟Həm/
noun
a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.
amr ibrahem
@amrIbrahem
Apr 26 2017 01:36
@revisualize i don't know yet i need to start
Joseph
@revisualize
Apr 26 2017 01:36
@amrIbrahem I need more information.
Al
@fingrlicknchickn
Apr 26 2017 01:37
``````
check this
Dean Pierrot
@dapierrot21
Apr 26 2017 01:38
The answer will still Be Happy Feet because the function is being called with the return Happy Feet. I'm Still confused because i can't see what was removed
Joseph
@revisualize
Apr 26 2017 01:38
@amrIbrahem Do you know of a course or documentation to teach me to build an automobile?
What kind of a car. A Yugo or a Ferrari?
@amrIbrahem You just read and click next.
hekri-d
@hekri-d
Apr 26 2017 01:38
@revisualize you know Yugo? XD
Joseph
@revisualize
Apr 26 2017 01:39
@hekri-d Yugo. I-go. Wego?
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:39
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; i++){
      product *= arr[i];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
hekri-d
@hekri-d
Apr 26 2017 01:39
@dapierrot21 there's nothing fancy going on. Shift removes one element from the array and 'gives' it to you. You can do anything you like with it. You just need to catch it first. You can do that with a variable. Not that complicated.
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:40
I got a question in regards to this problem.
Joseph
@revisualize
Apr 26 2017 01:40
@codebusiness2014 What's j for?
hekri-d
@hekri-d
Apr 26 2017 01:40
@revisualize LOL. Yeah. Got elected the worst car ever recently. XD
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:40
It keeps saying undefined .length
I was told once I shouldn't use the same i when using nested arrays as the computer will get confused.
anderson
@anderson2825
Apr 26 2017 01:41
function mutation(arr) {
   for(var i=0;i<arr[1].length;i++){
     if(arr[0].indexOf(arr[1][i])!=-1){
         return true;
     }else{
      return false;
      }
   }

}

mutation(["hello", "hey"]);
@sjames1958gm please help me check it! Why is it wrong?
indexOfaa.png
rmattr
@rmattr
Apr 26 2017 01:41
  var myArray = [];
cool
amr ibrahem
@amrIbrahem
Apr 26 2017 01:41
@revisualize do you know any course?
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:41
So j is used in order to grab what is within the array. Second part I mean since first for loop grabs the first array and second forloop loops through that array
Joseph
@revisualize
Apr 26 2017 01:41
@codebusiness2014 for(var j = 0; j < arr[i].length; i++) ... Why i++ here.
flansolo
@flansolo
Apr 26 2017 01:41
@forkerino did you set up mongodb local?
Joseph
@revisualize
Apr 26 2017 01:41
@amrIbrahem I have no idea what you are actually asking.
@amrIbrahem freeCodeCamp has a set of algorithm challenges.
Stephen James
@sjames1958gm
Apr 26 2017 01:42
@anderson2825 you should only return false within the loop so you are sure to check all the letters
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:42
@revisualize oh you got a point. I didn't realize I had that as i instead of j. Really use to seeing i when looking.
Joseph
@revisualize
Apr 26 2017 01:43
@dapierrot21 Still here.
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:43
@revisualize but now I'm getting a null ><
flansolo
@flansolo
Apr 26 2017 01:43
@sjames1958gm what about you? setup mongodb local or something like mlab?
Stephen James
@sjames1958gm
Apr 26 2017 01:43
@flansolo I did the setup on cloud9 and mlab
Joseph
@revisualize
Apr 26 2017 01:43
@codebusiness2014 Why are you making the j variable?
flansolo
@flansolo
Apr 26 2017 01:43
okay cool ty @sjames1958gm
CamperBot
@camperbot
Apr 26 2017 01:43
flansolo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6978 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Apr 26 2017 01:43
@codebusiness2014 Why are you making that whole loop?
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:44
@revisualize Am I not understanding nesting. First for-loop used to look through each array we have in the object then second for-loop is used to check the elements in the array we grabbed?
anderson
@anderson2825
Apr 26 2017 01:44
what should i do ?? @sjames1958gm
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:44
@revisualize Need to it iterate through multiplyAll([[1,2],[3,4],[5,6,7]])
Joseph
@revisualize
Apr 26 2017 01:44
@codebusiness2014 If you have an array [[1,2],[3,4],[5,6,7]] and i is 0. What is the value of arr[0]?
hekri-d
@hekri-d
Apr 26 2017 01:44
@amrIbrahem you won't find any specific lessons on the algorithm challenges. You just have to learn javascript as much as you can and based on what you've learned get back to the algorithms challenges and find solutions for them.
Stephen James
@sjames1958gm
Apr 26 2017 01:44
@anderson2825 Check for failed test === -1 inside the loop and return true after the loop if you never fail
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:44
it'll be [1, 2]
@revisualize it'll be [1, 2]
Joseph
@revisualize
Apr 26 2017 01:45
@codebusiness2014 How do you access the value 1?
Dean Pierrot
@dapierrot21
Apr 26 2017 01:45
yes i am sorry. I got it to pass. I don't know why i didn't get it before with using a variable.
flansolo
@flansolo
Apr 26 2017 01:45
cloud9 good @sjames1958gm ? i see its recommended in regular fcc but not beta
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:45
@revisualize hm I'm guessing by looping through that one once we have access to it by arr[o]
Joseph
@revisualize
Apr 26 2017 01:45
@dapierrot21 You don't need to use a variable. But grats.
@codebusiness2014 Simple question.
Stephen James
@sjames1958gm
Apr 26 2017 01:46
@flansolo Recently they required Credit card for an account - may be why
Joseph
@revisualize
Apr 26 2017 01:46
@codebusiness2014 arr = [[1,2],[3,4],[5,6,7]] how do you access the value 1?
flansolo
@flansolo
Apr 26 2017 01:46
ahhh i see
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:46
@revisualize arr[0][1]
sorry
Joseph
@revisualize
Apr 26 2017 01:46
@codebusiness2014 product *= arr[i]; .. Is something missing?
Dean Pierrot
@dapierrot21
Apr 26 2017 01:46
@revisualize what else can i use then?
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:46
@revisualize arr[0][0]
Joseph
@revisualize
Apr 26 2017 01:46
@dapierrot21 Just return arr.shift()
anderson
@anderson2825
Apr 26 2017 01:46
okay! i try it! @sjames1958gm !
flansolo
@flansolo
Apr 26 2017 01:46
not a big deal i guess as long as they aren't charging, i got the same from heroku
and digitalocean for that matter
rmattr
@rmattr
Apr 26 2017 01:47
guys, i'm trying to complete the second algorithm challenge but my code returns nothing. I cannot figure out why as it looks like it would work.
 function factorialize(num) {


  var myArray = []; 
  var i = 1;
  while (i <= num) {
    myArray.push(i);
    i++;
  } 





   myArray.reduce(function(previousVal, currentVal) {
         return previousVal + currentVal;




  });



}

 factorialize(5);
Joseph
@revisualize
Apr 26 2017 01:47
@codebusiness2014 When i is 0. and you're doing product *= arr[i]; .. You're trying to multiply a number by an array.
rmattr
@rmattr
Apr 26 2017 01:47
any ideas?
Stephen James
@sjames1958gm
Apr 26 2017 01:47
@rmattr please remove blanks lines when posting.
Joseph
@revisualize
Apr 26 2017 01:47
@codebusiness2014 You're not actually multiplying by the numeric value.
rmattr
@rmattr
Apr 26 2017 01:48
okay, sorry about that
Stephen James
@sjames1958gm
Apr 26 2017 01:48
@rmattr You have to return the result of reduce
flansolo
@flansolo
Apr 26 2017 01:48
^^^
Stephen James
@sjames1958gm
Apr 26 2017 01:48
@rmattr FYI factorial is multiplication
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:48
@revisualize I see.
@revisualize so we would want something like arr[i][j]
rmattr
@rmattr
Apr 26 2017 01:49
right, that was a leftover from some testing
Dean Pierrot
@dapierrot21
Apr 26 2017 01:49
if it was a snake i would have been dead at the beginning of this all. Thanks guys for being patience
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:49
@revisualize since that is similar to arr[0][0] then arr[0][1]
flansolo
@flansolo
Apr 26 2017 01:49
ty @revisualize and @sjames1958gm you are the shiznit lol
CamperBot
@camperbot
Apr 26 2017 01:49
flansolo sends brownie points to @revisualize and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: flansolo already gave sjames1958gm points
:star2: 3832 | @revisualize |http://www.freecodecamp.com/revisualize
Stephen James
@sjames1958gm
Apr 26 2017 01:49
@flansolo YW
Joseph
@revisualize
Apr 26 2017 01:50
@codebusiness2014 Did it work?
flansolo
@flansolo
Apr 26 2017 01:50
:)
Steven Ossorio
@steven-ossorio
Apr 26 2017 01:50
@revisualize Yup :) thank you for getting me there. Can't believe I didn't think of that
CamperBot
@camperbot
Apr 26 2017 01:50
codebusiness2014 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3833 | @revisualize |http://www.freecodecamp.com/revisualize
Dean Pierrot
@dapierrot21
Apr 26 2017 01:50
I was getting confused with the word play of the instructions. It seems like there were 3 steps but only 2 really @revisualize
Joseph
@revisualize
Apr 26 2017 01:51
@dapierrot21 It's a learning process.
@codebusiness2014 Grats.
Dean Pierrot
@dapierrot21
Apr 26 2017 01:51
learning def took place here. At its simplest form lol
Joseph
@revisualize
Apr 26 2017 01:51
@dapierrot21 @codebusiness2014 @flansolo Now you need to go answer my question over here. :point_up: April 25, 2017 1:47 PM
HEHEHE
flansolo
@flansolo
Apr 26 2017 01:52
sold :)
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 01:56
Has anyone tried out fcc beta? Is it prepare you better for the challenges?
rmattr
@rmattr
Apr 26 2017 01:57
@sjames1958gm is the result of reduce not the multiplication of the parameters?
   myArray.reduce(function(previousVal, currentVal) {
      return previousVal * currentVal;
Vignettes
@Vignettes
Apr 26 2017 01:57
Can someone help explain a concept to me?
Stephen James
@sjames1958gm
Apr 26 2017 01:57
@rmattr Yes. But if you don't assign it to a variable or return it, it is lost
Joseph
@revisualize
Apr 26 2017 01:57
@TinCan-Assassin I think they are really trying to change the curriculum for the better. I think it still needs some improvements.
Stephen James
@sjames1958gm
Apr 26 2017 01:57
@Vignettes What concept?
Joseph
@revisualize
Apr 26 2017 01:58
@sjames1958gm Did you see the link to my non-technical question?
Vignettes
@Vignettes
Apr 26 2017 01:58
function largestOfFour(arr) {
  // You can do this!
  var results = [];
  for (var n = 0; n < arr.length; n++) {
   var largestNumber = 0;
    for (var sb = 0; sb < arr[n].length; sb++) {
      if (arr[n][sb] > largestNumber) {
largestNumber = arr[n][sb];
      }
    }
  results[n] = largestNumber; 
  }
  return results;
}


largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 01:58
@revisualize +1
Vignettes
@Vignettes
Apr 26 2017 01:58
Not as much of a concept as a point I guess
@sjames1958gm I don't understand the point of "results[n] = largestNumber;
Joseph
@revisualize
Apr 26 2017 01:59
@Vignettes That's assigning results[0] to a value.
Then results[1]
Stephen James
@sjames1958gm
Apr 26 2017 01:59
@Vignettes You want to save the largestNumber of the current subarray to the output array,
Joseph
@revisualize
Apr 26 2017 01:59
It should maybe be a .push() instead.
Vignettes
@Vignettes
Apr 26 2017 01:59
OH damn it...
It didn't make sense before but I kind of see it now
Stephen James
@sjames1958gm
Apr 26 2017 02:00
@revisualize Are you interested in the question?
Vignettes
@Vignettes
Apr 26 2017 02:00
so we are pulling the largest number from the "largestNumber var for results
Stephen James
@sjames1958gm
Apr 26 2017 02:00
@Vignettes Yes. storing it for later return
Vignettes
@Vignettes
Apr 26 2017 02:00
Thank you, Stephen!
Joseph
@revisualize
Apr 26 2017 02:02
@sjames1958gm I don't think so. I just think it is an interesting thought process.
flansolo
@flansolo
Apr 26 2017 02:02
@TinCan-Assassin i've done most of my work in the beta
Stephen James
@sjames1958gm
Apr 26 2017 02:02
@revisualize I see.
flansolo
@flansolo
Apr 26 2017 02:03
almost finished with api projects and moving on to the info security/quality assurance before contributing
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 02:03
@flansolo Cool, what do you think?
Danny Welstad
@GoonTwo
Apr 26 2017 02:03
im trying to use this function to return who won in a game of tic tac toe, but I'm no always getting the right result. Anyone see what I'm doing wrong?
 var human = 1;
  var computer = -1;  
  var winningCases = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]; //left to right - top to bottom
  var board = [1,1,-1,-1,1,1,-1,-1,1]; //starting at example board for testing [0,0,0,0,0,0,0,0,0];
  var myTurn;

  function winner(){
    for (var i = 0; i < winningCases.length; i++){
      if(winningCases[i].every(function(val){
        return board[val] === human;
      })){
        return 1;
      } else if(winningCases[i].every(function(val){
        return board[val] === computer;
      })){
        return -1;
      } else if (board.every(function(val){
        return val !== 0;
      })){
        return 0;
      }
    }
  }
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 02:04
Did bete prepare you better?
flansolo
@flansolo
Apr 26 2017 02:04
it is how freecodecamp should be structured, relative to what we should be learning now
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 02:04
*beta
🖒
flansolo
@flansolo
Apr 26 2017 02:05
while by the time we finish, some things will be outdated, its so useful for progressing your learning from there on
i highly recommend it, though just be sure to save all challenges with asterisk(*)
and of course your projects will be on codepen or glitch/gomix whatever
so all is good there
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 02:07
I'll remember that. Did you go from the beginning (html) or start with JS?
FlashHero
@FlashHero
Apr 26 2017 02:07
var obj={
  name:'unknown'
}
var anotherObj={
  age:10
}
Object.setPrototypeOf(obj,anotherObj);
console.log(obj.__proto__);
console.log(anotherObj.prototype);
I understand the proto part, but I don't get why the second console.log is saying undefined please help
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 02:08
How do you save with an asterisk? Normally I'd just click the button.
flansolo
@flansolo
Apr 26 2017 02:09
you'll see an asterisk at the end of a challenge name
copy paste it in some file locally, and or put in a github/gist repository
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 02:10
Got it.
rmattr
@rmattr
Apr 26 2017 02:10
I must still be missing something @sjames1958gm I believe i'm returning the result but still the function outputs nothing
 function factorialize(num) {
  var myArray = []; 
  var i = 1;
  while (i <= num) {
    myArray.push(i);
    i++;
  } 
   myArray.reduce(function(previousVal, currentVal) {
   return  previousVal * currentVal;
    });
  }
factorialize(5);
Stephen James
@sjames1958gm
Apr 26 2017 02:11
@rmattr return myArray.reduce(
flansolo
@flansolo
Apr 26 2017 02:12
^^^ want to return the array that reduce returns in the function
TinCan-Assassin
@TinCan-Assassin
Apr 26 2017 02:12
Night y'all.
Christopher McCormack
@cmccormack
Apr 26 2017 02:12
@TinCan-Assassin see ya
flansolo
@flansolo
Apr 26 2017 02:12
evening lol, night @TinCan-Assassin
Jedifan200
@Jedifan200
Apr 26 2017 02:14
does anyone have complete list of the lower case alphabet in unicode?
Vamp
@the-vampiire
Apr 26 2017 02:15
“abcdefghijklmnopqrstuvwxyz"
@Jedifan200
Jedifan200
@Jedifan200
Apr 26 2017 02:16
why thank you @the-vampiire
CamperBot
@camperbot
Apr 26 2017 02:16
jedifan200 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
rmattr
@rmattr
Apr 26 2017 02:16
 function factorialize(num) {


  var myArray = []; 
  var i = 1;
  while (i <= num) {
    myArray.push(i);
    i++;
  } 
    return myArray.reduce(function(previousVal, currentVal){
      previousVal * currentVal;
    });
      }
factorialize(5);
this is what I have now, but it still doesn't work
Vamp
@the-vampiire
Apr 26 2017 02:17
Screen Shot 2017-04-25 at 10.16.46 PM.png
easiest brownie points I ever got lol @Jedifan200
Christopher McCormack
@cmccormack
Apr 26 2017 02:18
haha
@rmattr you have to return the value within the reduce anonymous function
return previousVal * currentVal;
rmattr
@rmattr
Apr 26 2017 02:25
thanks for your response @cmccormack that's what I had, but it wouldn't output anything.
CamperBot
@camperbot
Apr 26 2017 02:25
:cookie: 423 | @cmccormack |http://www.freecodecamp.com/cmccormack
rmattr sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
Apr 26 2017 02:26
well you won't get an output unless you're doing it in the console or wrap your function call in a console.log statement
Steven Ossorio
@steven-ossorio
Apr 26 2017 02:29
I'm having a bit of a problem regarding the profile loopup problem in the JavaScript section.
function lookUpProfile(firstName, prop){
// Only change code below this line
  if(contacts.hasOwnProperty(prop) && contacts[firstName]){
    return contacts[prop];
  }
// Only change code above this line
}
This is what I've written so far and the question says
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
Am I on the right track or am I drifting in the wrong direction?
Ken Haduch
@khaduch
Apr 26 2017 02:30
@rmattr - I agree with @cmccormack - add that return and it should be better.
@rmattr - and you need an initial value, it seems?
Christopher McCormack
@cmccormack
Apr 26 2017 02:32
@codebusiness2014 you're going to want to check all of the contacts, so you'll probably want to use a loop. also your first conditional isn't going to work properly as contacts is an array of objects
Ken Haduch
@khaduch
Apr 26 2017 02:32

@rmattr - this passes:

  return myArray.reduce(function (previousVal, currentVal) {
    return previousVal * currentVal;
  },1);

The problem is that you are generating an empty array for the factorialize(0) and that is giving a TypeError...

Steven Ossorio
@steven-ossorio
Apr 26 2017 02:33
@cmccormack Thanks for your input :) I'll go try again in what you've advice
CamperBot
@camperbot
Apr 26 2017 02:33
codebusiness2014 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 424 | @cmccormack |http://www.freecodecamp.com/cmccormack
FlashHero
@FlashHero
Apr 26 2017 02:33
var obj={
  name:'unknown'
}
var anotherObj={
  age:10
}
Object.setPrototypeOf(obj,anotherObj);
console.log(obj.__proto__);
console.log(anotherObj.prototype);
Why does anotherObj.prototype return undefined ?
rmattr
@rmattr
Apr 26 2017 02:36
@khaduch thanks. How does that 1 come into play though?
CamperBot
@camperbot
Apr 26 2017 02:36
rmattr sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2794 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 26 2017 02:36
@rmattr - I think that if you input an initial value, it will use that if the array is empty? I haven't encountered that before now. Checking the docs...

@rmattr - from the docs:

initialValue
[Optional] Value to use as the first argument to the first call of the callback. If no initial value is supplied, the first element in the array will be used. Calling reduce on an empty array without an initial value is an error.
...
If the array is empty and no initialValue is provided, TypeError will be thrown. If the array has only one element (regardless of position) and no initialValue is provided, or if initialValue is provided but the array is empty, the solo value will be returned without calling callback.

so that case covers the factorialize(0) for your solution.
rmattr
@rmattr
Apr 26 2017 02:40
Okay, I believe I understand now.
Ken Haduch
@khaduch
Apr 26 2017 02:41
I learned something (or re-learned something), too...
Christopher McCormack
@cmccormack
Apr 26 2017 02:44
@FlashHero try
var anotherObj = function() {
  this.age = 10
}
FlashHero
@FlashHero
Apr 26 2017 02:47
@cmccormack I'm trying to understand the difference between proto and prototype
Christopher McCormack
@cmccormack
Apr 26 2017 02:51
@FlashHero I believe every object gets a __proto__ function, but only functions that are constructors have prototypes
@FlashHero Here's what I'm playing with if it helps:
var a = {}
console.log(a.prototype) // undefined
a.prototype = new Object();
console.log( a.prototype ); // Object {}
var b = function() {};
console.log(b.prototype); // Object {constructor: function}
1GCKM1
@1GCKM1
Apr 26 2017 03:02
Screenshot from 2017-04-26 10-00-07.png
guys, i want to know how can i replace the %d in that alert by a number as i do in c program??
Christopher McCormack
@cmccormack
Apr 26 2017 03:04
Tried the String.replace() method?
why even put the %d in the alert? what does your code look like for that section?
1GCKM1
@1GCKM1
Apr 26 2017 03:06
@cmccormack I'm trying replacing a text by some variables, look like i can't do this like C :)
Moisés Man
@moigithub
Apr 26 2017 03:06
u can use es6 string templates
LeSean Johnson
@leseanbiz
Apr 26 2017 03:07
can any one tell me where im going wrong with the C to F on click for the weather app?
This message was deleted
1GCKM1
@1GCKM1
Apr 26 2017 03:07
many thanks, i should try it now :)
LeSean Johnson
@leseanbiz
Apr 26 2017 03:07
This message was deleted
hekri-d
@hekri-d
Apr 26 2017 03:08
@leseanbiz add a carriage return (enter) after your 'ticks'.
LeSean Johnson
@leseanbiz
Apr 26 2017 03:08
    $("#temp").on("click", function(temp){
          if (temp == json.main.temp.toFixed(0)){
        temp = (json.main.temp.toFixed(0) * 1.8) + 32;
        $("#temp").html(temp /*+ variable for C or F*/);
      }else{
        temp = json.main.temp.toFixed(0);
        $("#temp").html(temp /*+ variable for C or F*/);
      }     
});
thnx
Adam
@Kloppers
Apr 26 2017 03:08
Hey all, I'm having trouble with the lesson: Using Objects for Lookups. The explanation is pretty scant in the lesson, and not sure what I am doing wrong
CharlieAguilera090
@CharlieAguilera090
Apr 26 2017 03:09
what is the best site to learn javascript
hekri-d
@hekri-d
Apr 26 2017 03:09
@leseanbiz what's the error?
@CharlieAguilera090 freecodecamp
Moisés Man
@moigithub
Apr 26 2017 03:10
@leseanbiz do u know how to use console.log and check on devtools ?
Christopher McCormack
@cmccormack
Apr 26 2017 03:10
@leseanbiz why the conditional? What are you checking for?
LeSean Johnson
@leseanbiz
Apr 26 2017 03:10
the value isnt changing but if i sub the if with just a change html then it works
the conditional is incase it is on C then it will go back to F
if value displayed == imperial input then change to C
Moisés Man
@moigithub
Apr 26 2017 03:11
@leseanbiz do u know how to use console.log and check on devtools ?
LeSean Johnson
@leseanbiz
Apr 26 2017 03:11
yes
Moisés Man
@moigithub
Apr 26 2017 03:11
...n("click", function(temp){ <-- what is temp ?
Ken Haduch
@khaduch
Apr 26 2017 03:11
@FlashHero @cmccormack - http://stackoverflow.com/questions/9959727/proto-vs-prototype-in-javascript - the top question that came up in stackoverflow
Moisés Man
@moigithub
Apr 26 2017 03:11
add console.log(temp) and check on devtools
LeSean Johnson
@leseanbiz
Apr 26 2017 03:12
temp is the variableble that holds the temperatur from the API
Joshua Humphrey
@Humphreyj
Apr 26 2017 03:12
Hey folks, I'm working on the Twitch API and cant get my data to prepend. Can anyone take a look?
https://codepen.io/humphreyJ/pen/bqwGvo?editors=1010
Jean-Paul Sauve
@jp-sauve
Apr 26 2017 03:12
@moigithub it's the variable name that you will use in that function to refer to whatever is passed to it as an argument when it's called.
LeSean Johnson
@leseanbiz
Apr 26 2017 03:12
its is also the id of the <p> that displays it
Christopher McCormack
@cmccormack
Apr 26 2017 03:12
@sevensixtwo762 he's trying to help @leseanbiz :)
Roxroy
@roxroy
Apr 26 2017 03:12
@Kloppers , did you make any progress with the challenge.
Jean-Paul Sauve
@jp-sauve
Apr 26 2017 03:12
oh ok
theres the whole thing
but everything works aside from that conditional
ignore the css please
Jean-Paul Sauve
@jp-sauve
Apr 26 2017 03:14
@leseanbiz sorry, which conditional doesn't work'
Adam
@Kloppers
Apr 26 2017 03:14
@roxroy I have made an object: var lookup = {
"alpha" :"Adams",
"bravo" :"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank",
};
But the thing is so vague as to what a Lookup is, not sure if i did it right
LeSean Johnson
@leseanbiz
Apr 26 2017 03:14
everything i posted under the .on(“click)
the if/else
Moisés Man
@moigithub
Apr 26 2017 03:15
@leseanbiz ARE you SURE??.. again.. add console.log(temp)
LeSean Johnson
@leseanbiz
Apr 26 2017 03:15
VM6781 console_runner-079c09a….js:1 Portland
VM6781 console_runner-079c09a….js:1 OR
VM6781 console_runner-079c09a….js:1 temp is: 53.08, ID id: 5,0,0
VM6781 console_runner-079c09a….js:1 ["2", "0", "0"]
the temperature is displaying in the page'
Moisés Man
@moigithub
Apr 26 2017 03:16
lem m e repost ur code
.... to check temp
    $("#temp").on("click", function(temp){

console.log(temp);  ///<<<<<<<<<<<<<

          if (temp == json.main.temp.toFixed(0)){
        temp = (json.main.temp.toFixed(0) * 1.8) + 32;
        $("#temp").html(temp /*+ variable for C or F*/);
      }else{
        temp = json.main.temp.toFixed(0);
        $("#temp").html(temp /*+ variable for C or F*/);
      }     
});
Ken Haduch
@khaduch
Apr 26 2017 03:16
@Kloppers - did you get the idea of what the switch statement was doing? You pass in a value like charlie and it will return "Chicago"... now just look at the same way you would achieve this using an object - a property coming in, like charlie and you want to get the same return value "Chicago" - you lookup the property in an object to get the value.
LeSean Johnson
@leseanbiz
Apr 26 2017 03:16
ok, fair point @moigithub
lemme check
Roxroy
@roxroy
Apr 26 2017 03:17
@Kloppers , see the example on the left , var value = 2; alpha[value]; // "Y"
Well in your case you are using phonetic and val.
LeSean Johnson
@leseanbiz
Apr 26 2017 03:17
@moigithub ok, i think this is the same trouble i had with .filter
Austin Wiggins
@austinwiggins
Apr 26 2017 03:18
Can anyone give me kind of a walkthrough on the algorithm challenge 'return largest numbers in arrays'? Any help would be very much appreciated.
LeSean Johnson
@leseanbiz
Apr 26 2017 03:18
how do i pass the temp variable into that function?
Christopher McCormack
@cmccormack
Apr 26 2017 03:18
you dont
LeSean Johnson
@leseanbiz
Apr 26 2017 03:18
ok
Adam
@Kloppers
Apr 26 2017 03:18
@khaduch @roxroy I'll have a look. I don't get it because I basically did just copy the example code for this one :P
Christopher McCormack
@cmccormack
Apr 26 2017 03:18
function(temp) is a callback to the .on method
LeSean Johnson
@leseanbiz
Apr 26 2017 03:18
DAMNIT!!!! now it workws lol
Vicky Lai
@vickylai
Apr 26 2017 03:18
Hellooo coders
Christopher McCormack
@cmccormack
Apr 26 2017 03:19
@vickylaixy hello
Joshua Humphrey
@Humphreyj
Apr 26 2017 03:19
hi
LeSean Johnson
@leseanbiz
Apr 26 2017 03:19
@cmccormack @moigithub thanks!
CamperBot
@camperbot
Apr 26 2017 03:19
leseanbiz sends brownie points to @cmccormack and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 3160 | @moigithub |http://www.freecodecamp.com/moigithub
LeSean Johnson
@leseanbiz
Apr 26 2017 03:19
@cmccormack can you explain how it gets the temp variable with out passing it in?
Christopher McCormack
@cmccormack
Apr 26 2017 03:19
did you set it somewhere else?
oh forgot you had a codepen one sec
LeSean Johnson
@leseanbiz
Apr 26 2017 03:20
here ill update
Ken Haduch
@khaduch
Apr 26 2017 03:20
@austinwiggins - what is your biggest hurdle with this?
LeSean Johnson
@leseanbiz
Apr 26 2017 03:20
again, please ignore the css issues
Vicky Lai
@vickylai
Apr 26 2017 03:21
Instant cup noodles and FCC today.
Roxroy
@roxroy
Apr 26 2017 03:21
@Kloppers , you are going to use val to lookup the value in the phonetic list, and assign the value to the result.
Christopher McCormack
@cmccormack
Apr 26 2017 03:21
you set temp above, when you removed it from the callback, temp is now referring to the temp you delcared in the outer scope
Austin Wiggins
@austinwiggins
Apr 26 2017 03:22
@khaduch mainly understanding how to do the challenge; I kind of have a basic idea, but how to do it fully I do not know.
Ken Haduch
@khaduch
Apr 26 2017 03:22
@vickylaixy - that sounds good, except for the noodles. Or the FCC, or both... ;)
Christopher McCormack
@cmccormack
Apr 26 2017 03:22
function(json) {
        var temp = json.main.temp.toFixed(0);
Ken Haduch
@khaduch
Apr 26 2017 03:22
@austinwiggins - this is the one with multiple arrays and you have to return one array that has the largest value in each of the sub-arrays, right?
LeSean Johnson
@leseanbiz
Apr 26 2017 03:22
ohhhhh, ok, instead of trying to use it as an undefined/?
Liu Bo
@Axis-dot
Apr 26 2017 03:23

var ourDecimal = 5.7;

// Only change code below this line

Austin Wiggins
@austinwiggins
Apr 26 2017 03:23
@khaduch correct
LeSean Johnson
@leseanbiz
Apr 26 2017 03:23
it seems to trip me up to think that function call can reach out and get thatvariable
Christopher McCormack
@cmccormack
Apr 26 2017 03:23
I believe temp would have been a DOM object if you left it in the function parameter
or an event
I'd have to test
probably an event
Ken Haduch
@khaduch
Apr 26 2017 03:25
@austinwiggins - okay, the first thing to understand is how to find the largest number in an array. How do you think you would do that - just a single array? There are a couple different methods.
LeSean Johnson
@leseanbiz
Apr 26 2017 03:25
i also now see my error in the calculation.
Vicky Lai
@vickylai
Apr 26 2017 03:26
@khaduch Cup noodles rock, and so does FCC!
My internet's not so great however.
Ken Haduch
@khaduch
Apr 26 2017 03:27
@vickylaixy :+1: and :(
Austin Wiggins
@austinwiggins
Apr 26 2017 03:27
@khaduch I don't know, maybe somehow with a for loop
Christopher McCormack
@cmccormack
Apr 26 2017 03:27
Too bad they don't sell Cup o' WiFi
Ken Haduch
@khaduch
Apr 26 2017 03:27
@austinwiggins - good - that's a fine way to do it. Can you write a for loop that will just output all of the values in an array (still talking about the single array) and use console.log to do it?
LeSean Johnson
@leseanbiz
Apr 26 2017 03:27
you guys are the best, thanks again!
Christopher McCormack
@cmccormack
Apr 26 2017 03:28
@leseanbiz :thumbsup:
Vicky Lai
@vickylai
Apr 26 2017 03:28
What I wouldn't give for personal worldwide high speed internet!
Though I hear Google Fi is good.
Ah crap. Totally thought I was in the General channel. Sorry yall. Didn't mean to spam!
Christopher McCormack
@cmccormack
Apr 26 2017 03:29
np kind of quiet tonight
Austin Wiggins
@austinwiggins
Apr 26 2017 03:30
@khaduch possibly, maybe by doing something like for(var i = 0; i<length.arr; i++) { console.log(i)} ?
Adam
@Kloppers
Apr 26 2017 03:30
@roxroy nope, completely stumped
Aaron Massey
@aaronmassey45
Apr 26 2017 03:31
has anyone ran into the issue with their code being right and different test variables give proper values but it still won't accept it?
Christopher McCormack
@cmccormack
Apr 26 2017 03:31
yes but it was always my fault in the end :)
Aaron Massey
@aaronmassey45
Apr 26 2017 03:32
all tests return the right values but it won't take
var factorial = 1;
function factorialize(num) {
for (var i = num; i>0; i--) {
factorial *= i;
}
return factorial;
}
Adam
@Kloppers
Apr 26 2017 03:33

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

Christopher McCormack
@cmccormack
Apr 26 2017 03:34
@aaronmassey45 try moving your variable declaration inside your function
Ken Haduch
@khaduch
Apr 26 2017 03:34

@austinwiggins - yes - that would do it. Well, almost - if your array is the variable arr, you would have to use arr.length for your loop control, and arr[i] to access the element.

So - working with that loop:

var arr = [4, 2, 5, 1, 3];
for ( var i = 0; i < arr.length; i++) {
    console.log(arr[i]);
}

What would you do to select the largest value in the array arr?

Manny
@Alloffices
Apr 26 2017 03:35
@khaduch console.log(arr[4]); ?
Austin Wiggins
@austinwiggins
Apr 26 2017 03:35
@khaduch I have no clue...
Aaron Massey
@aaronmassey45
Apr 26 2017 03:36
@Kloppers you didn't set result equal to the lookup value
Gabe Rotberg
@grotberg
Apr 26 2017 03:36
@Kloppers You're nearly there. Your lookup object looks good, but now you just need to access it. You have the "val" from the test function ("charlie", in that example) and need to actually USE it to look up the answer and store it in the "result" variable.
Roxroy
@roxroy
Apr 26 2017 03:36
@Kloppers , use val to lookup the phonetic, you do it using phonetic[val];. Then assign it to the result variable
Austin Wiggins
@austinwiggins
Apr 26 2017 03:37
@khaduch maybe create a variable inside another for loop and check to see if it is greater than that and if it is make the variable equal to that?
Gabe Rotberg
@grotberg
Apr 26 2017 03:38
@khaduch you'll have to do a comparison inside the loop. save the largest value so far in a new variable, and compare it in each loop. If the new value is greater, replace it.
Aaron Massey
@aaronmassey45
Apr 26 2017 03:39
@cmccormack that worked, thanks!
CamperBot
@camperbot
Apr 26 2017 03:39
aaronmassey45 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 426 | @cmccormack |http://www.freecodecamp.com/cmccormack
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:39
hey guys, what am I doing wrong here?

function largestOfFour(arr) {
  // You can do this!
  var largestOfFour = 0;

  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++){
      if (arr[i][j] < largestOfFour){
        largestOfFour = arr[i][j];
      }
    }
  }
  return largestOfFour;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Ken Haduch
@khaduch
Apr 26 2017 03:39
@austinwiggins - on the right track - you need to start with an initialized variable that is smaller than anything in the array, and as you get access to each value, using arr[i], you can check it with > the current largest value, and set the largest value accordingly.
Christopher McCormack
@cmccormack
Apr 26 2017 03:39
@aaronmassey45 np
Austin Wiggins
@austinwiggins
Apr 26 2017 03:40
@khaduch OK, I'll try that...
Ken Haduch
@khaduch
Apr 26 2017 03:40
@Rafewey - you have to generate an array of the largest value in each of the subarrays... so you need to push something somewhere.
Gabe Rotberg
@grotberg
Apr 26 2017 03:41
@Rafewey Yeah, right now your code is finding the largest single value in all of the arrays, but what you want your result to be is an array of the largest values - one for each of the input arrays.
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:41
@grotberg @khaduch Ill try it
It doesnt work

function largestOfFour(arr) {
  // You can do this!
  var largestOfFour = [];

  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++){
      if (arr[i][j] < largestOfFour){
        largestOfFour.push(arr[i][j]);
      }
    }
  }
  return largestOfFour;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Christopher McCormack
@cmccormack
Apr 26 2017 03:44
@Rafewey you may want to keep a running max for each inner array and only push to the largestOfFour when you have the largest of all four
Ken Haduch
@khaduch
Apr 26 2017 03:44
@Rafewey - well, your function is largestOfFour... you cannot really push onto that - is it giving you an error? You need a separate array variable within the function, and push to that.
then return that array
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:44
@khaduch No, it i just giving me an empty array "[]"
There is no error
Duy khanh
@buiduykhanh
Apr 26 2017 03:45

hi everyone , i dont know what did im wrong so i cant pass this challenge anyone can help ?


// 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) {
  for(var k in collection){
    for(var a in collection[k]){
      if(prop !=="tracks"&& value!==""){
        collection[k][prop] = value;
      }
      else if(prop =="tracks" && collection[k].hasOwnProperty(prop) !==true){
        collection[k][prop] =[];
      }
      else if(prop =="tracks"&& value !==""){
        collection[k].tracks.push(value);
      }
      else if(collection[k].hasOwnProperty(prop) === true && value ===""){
        delete collection[k][prop];
      }
    }
  }

  return collection;
}

// Alter values below to test your code
updateRecords(1245, "tracks", "Addicted to Love");

thanks you so much

Ken Haduch
@khaduch
Apr 26 2017 03:45
@Rafewey - try a different name for that array
Gabe Rotberg
@grotberg
Apr 26 2017 03:45
@Rafewey Error or not, it is generally good practice to distinguish your variables from your functions (in terms of naming convention).
Austin Wiggins
@austinwiggins
Apr 26 2017 03:46

@khaduch So here is what I have, it says there is a potential infinite loop at line five and it doesn't work; what did I write wrong and/or leave out? function largestOfFour(arr) {
var numberinarr = 0;
for(var i=0; i<arr.length; i++){ for(var j = 0; j<arr[i].length; j++) { if(arr[i][j]>numberinarr) {
numberinarr=arr[i][j];
}
}
arr.push(numberinarr);
}
return arr;
}

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

Christopher McCormack
@cmccormack
Apr 26 2017 03:46
@Rafewey your conditional is also comparing a number with an array
Gabe Rotberg
@grotberg
Apr 26 2017 03:46
@Rafewey But that said, your code still won't work. If you look at it, it will push each individual "highest" value into your array, but that won't end up with a single value for each original array, which is what you need.
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:47
@grotberg Yeah I see
Gabe Rotberg
@grotberg
Apr 26 2017 03:47
@Rafewey IE, if you test 4 first, and it is the highest, it will push it. Then you test 5 next, and it pushes that too, even if it is the same array.
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:47
@grotberg Yeah I see that now
Gabe Rotberg
@grotberg
Apr 26 2017 03:48
@Rafewey Try maintaining the final array in the outer of the two loops, and keeping track of the highest value for each internal array in the inside loop.
Ken Haduch
@khaduch
Apr 26 2017 03:52

@austinwiggins - well, for your current code, if we're still doing the single array example, you do not need an inner for loop, because you can access all of the array values in a single array in one for loop ( you'll need an inner loop for the "array of arrays" case). So if you take your code and make a slight modification:

var numberinarr = 0;
for (var i = 0; i < arr.length; i++) {
     if (arr[i] > numberinarr) {
      numberinarr = arr[i];
    }
  }
return numberinarr;
}

Even though it isn't really a function at this point, that loop will store the largest number in a single array in the variable numberinarr...

So then you can think about the nested arrays problem.

Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:53
Got it.

function largestOfFour(arr) {
  // You can do this!
  var largestOfFourArray = [];

  for (var i = 0; i < arr.length; i++){
    var highestNumber = Math.max.apply(Math, arr[i]);
    largestOfFourArray.push(highestNumber);
  }
  return largestOfFourArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Christopher McCormack
@cmccormack
Apr 26 2017 03:54
@Rafewey that works too
Gabe Rotberg
@grotberg
Apr 26 2017 03:54
@Rafewey Nice! Did it work?
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:55
@grotberg Yeah. I just found that Math.max method and applied it to my code.
Austin Wiggins
@austinwiggins
Apr 26 2017 03:55
OK, thanks @khaduch
CamperBot
@camperbot
Apr 26 2017 03:55
austinwiggins sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2795 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 26 2017 03:55
@buiduykhanh - you are being passed an id value as a function argument - you are not using that in your code?
Gabe Rotberg
@grotberg
Apr 26 2017 03:55
@Rafewey Neat. I've not actually need Math.max.apply(Math, arr[i]); in action, but that probably ended up being slicker than my solution!
Not actually seen, rather.
Ken Haduch
@khaduch
Apr 26 2017 03:56
@buiduykhanh - so you can use that id value to directly access one of the objects in collection - nofor ... in` required.
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 03:57
@grotberg Yeah I am looking at the medium post on this challenge. I am looking at what other ways I could have solved it.
My first method of solving it was fine, but I messed up on one thing.
This would have worked if I changed this:
```

function largestOfFour(arr) {
  // You can do this!
  var largestOfFour = 0;

  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++){
      if (arr[i][j] < largestOfFour){
        largestOfFour = arr[i][j];
      }
    }
  }
  return largestOfFour;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
```
Christopher McCormack
@cmccormack
Apr 26 2017 03:59
It still would not have worked as you would have only returned a single number
Ken Haduch
@khaduch
Apr 26 2017 04:00
@buiduykhanh - in fact, you do not need any for ... in loops for this problem at all - it is all working directly with the property values that are passed in - id is the id of a collection item. prop is the name of a property, which either exists or not, and value is either a value to set in the given property, or indicates that you should delete a property.
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 04:00
inside the if statement, I needed to change largestOfFour to an array, then I needed, inside the if statement, have arr[i] = arr[i][j];
Christopher McCormack
@cmccormack
Apr 26 2017 04:00
@Rafewey prove it to yourself, solve it without reading the answers
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 04:01
@cmccormack I did.
@cmccormack I solved it on my own, but now that I solved it, I am looking at how I could have solved it using other methods
intcreate
@intcreate
Apr 26 2017 04:01

function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  testArr.pop(item);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(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.
can any1 help me with this plz
Christopher McCormack
@cmccormack
Apr 26 2017 04:02
@Rafewey don't just state that your original way would have worked if you did X, try and actually make it work.
there's a lot of logic wrapped up in Math.max.apply(), can you do it without that function?
Ken Haduch
@khaduch
Apr 26 2017 04:02
@intcreate - you do not want to reference testArr within the body of the function. There is a function argument arr which is the array that you should be working with. That's the first thing to correct. The next thing is that you have to return the item that is removed from the beginning of the array.
Mathew Gellner-Garcia
@Rafewey
Apr 26 2017 04:03
@cmccormack I mean now I can that I already looked up how to do it in a foor loop.
for*
heroiczero
@heroiczero
Apr 26 2017 04:04
@intcreate need to use the parameters of the function which are (arr,item) to push and shift
Ken Haduch
@khaduch
Apr 26 2017 04:04
@intcreate - note that .pop() removes an item from the end of the array - you need to use a different method to get the first element
intcreate
@intcreate
Apr 26 2017 04:05
how would i use the arr variable
nextInLine(arr.push(item)); ?
Ken Haduch
@khaduch
Apr 26 2017 04:06
@intcreate - no, use it in place of the testArr that you have in the body of your function. The function arguments are available within the function body.
In other words, arr.push(item);
Austin Wiggins
@austinwiggins
Apr 26 2017 04:08

@khaduch It still says that this is a potential infinite loop, yet I can't find how to fix it... I think if I can get the potential infinite loop cleared up it will be able to work. Do you know what I can do to fix this? function largestOfFour(arr) {
var numberinarr = 0;
for(var i = 0; i<arr.length; i++){ for(var j = 0; j<arr[i].length; j++) { if(arr[i][j]>numberinarr) {
numberinarr=arr[i][j];
}
}
arr.push(numberinarr);
}
return arr;
}

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

intcreate
@intcreate
Apr 26 2017 04:09
okay
i got it
but these are still needed
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
this is what i have so far

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift(item);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
heroiczero
@heroiczero
Apr 26 2017 04:10
@intcreate return the shifted element
intcreate
@intcreate
Apr 26 2017 04:10
i have the return item
line
Ken Haduch
@khaduch
Apr 26 2017 04:10
@intcreate - you have to return the value that is removed when you arr.shift() - you dn't need item in the parens, and you are losing the "shifted" value.
heroiczero
@heroiczero
Apr 26 2017 04:10
@intcreate return "shifted" element
intcreate
@intcreate
Apr 26 2017 04:11
return arr.shift(item);
Christopher McCormack
@cmccormack
Apr 26 2017 04:11
@austinwiggins try to use ``` tags around your code when you paste it here so it's easier to follow
heroiczero
@heroiczero
Apr 26 2017 04:12
@intcreate :+1:
Gabe Rotberg
@grotberg
Apr 26 2017 04:13
@austinwiggins yeah, I honestly don't see any problems with your code, but it is a bit difficult to read. It is also good practice to put each of those for and if statements on their own line - it will make it easier to read your code and identify any problems.
intcreate
@intcreate
Apr 26 2017 04:13
when i do that
everything gets unchecked , incorrect
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10),
Ken Haduch
@khaduch
Apr 26 2017 04:14
@austinwiggins - the problem is that you are doing arr.push() which is adding elements to your arr, which is the function argument. That would make it continue to grow with each loop of your for (var i = 0 loop. You want to make a separate empty array within your function, right after the function largestOfFour line, and then push into that array, and return that array. Also, you have to make sure to initialize your variable numberinarr inside of the first for loop.
heroiczero
@heroiczero
Apr 26 2017 04:15
@intcreate lets see your new code
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:15
@intcreate you don't need to pass argument to your shift method
Ken Haduch
@khaduch
Apr 26 2017 04:15
@intcreate - can you please post your code again with the latest change?
intcreate
@intcreate
Apr 26 2017 04:15

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift(item);
  return arr.shift(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));
Ken Haduch
@khaduch
Apr 26 2017 04:15
@intcreate - you are shifting two times...
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:15
@intcreate you're shifting twice
Austin Wiggins
@austinwiggins
Apr 26 2017 04:15
@khaduch @grotberg Thanks, I will try it and see how it goes. @cmccormack I'll try that next time
CamperBot
@camperbot
Apr 26 2017 04:15
austinwiggins sends brownie points to @khaduch and @grotberg and @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: austinwiggins already gave khaduch points
:cookie: 267 | @grotberg |http://www.freecodecamp.com/grotberg
:cookie: 427 | @cmccormack |http://www.freecodecamp.com/cmccormack
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:15
@intcreate and shift doesn't require an argument
intcreate
@intcreate
Apr 26 2017 04:16
oh ok
how would i return the shift value
shifted value
Ken Haduch
@khaduch
Apr 26 2017 04:16
@intcreate - take away your first .shift and that should do it.
Christopher McCormack
@cmccormack
Apr 26 2017 04:16
I believe shift does return the value removed, just assign it to a variable
codeasasin
@codeasasin
Apr 26 2017 04:16
@MohammadHasham India
Adam
@Kloppers
Apr 26 2017 04:17
@aaronmassey45 @grotberg @roxroy Thank you, got it working,still doesn't quite make sense in the context of the lesson as they didn't have result at all in the sample code...
CamperBot
@camperbot
Apr 26 2017 04:17
kloppers sends brownie points to @aaronmassey45 and @grotberg and @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @grotberg |http://www.freecodecamp.com/grotberg
:warning: @aaronmassey45's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
:cookie: 764 | @roxroy |http://www.freecodecamp.com/roxroy
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:17
@intcreate shift has a value it removed from the array you need to return
Adam
@Kloppers
Apr 26 2017 04:17
with "result = lookup[val];"
intcreate
@intcreate
Apr 26 2017 04:17
its still not correct

function nextInLine(arr, item) {
  // Your code here
  arr.push();
  arr.shift();
  return arr;  // 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));
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:17
@Kloppers should that be a string?
Ken Haduch
@khaduch
Apr 26 2017 04:17
@intcreate - in other words, just do this:
  arr.push(item);
  return arr.shift();  // Change this line
Austin Wiggins
@austinwiggins
Apr 26 2017 04:17
@khaduch How do I initialize numberinarr inside of the first for loop?
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:18
@intcreate return arr.shift();
intcreate
@intcreate
Apr 26 2017 04:18
ok thanks @khaduch @Lumexralph it works
CamperBot
@camperbot
Apr 26 2017 04:18
intcreate sends brownie points to @khaduch and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 2796 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 26 2017 04:18
@austinwiggins - like this:
for ( var i = 0; i < arr.length; i++) {
    var numberinarr = 0;
    for ( var j = 0; .... etc.)
CamperBot
@camperbot
Apr 26 2017 04:18
:star2: 1585 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:19
@intcreate :+1:
Adam
@Kloppers
Apr 26 2017 04:19
@Lumexralph sorry what?
Austin Wiggins
@austinwiggins
Apr 26 2017 04:19
@khaduch Thanks so much! That was the last step, now it's complete. :D
CamperBot
@camperbot
Apr 26 2017 04:19
austinwiggins sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: austinwiggins already gave khaduch points
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:19
@Kloppers thought you're asking a question or did i get it mixed up ?
Ken Haduch
@khaduch
Apr 26 2017 04:20
@austinwiggins - and actually, making it var numberinarr = arr[i][0]; would be better, because then you would have an actual array value, in case they slipped in an array of all negative numbers. But if they only have all positive numbers, then 0 is fine.
Adam
@Kloppers
Apr 26 2017 04:20
@Lumexralph Oh yeah I was just quoting what i used to get my code to work :)
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:20
@Kloppers okay :wink:
khaduch @khaduch - good night all & happy coding.
Adam
@Kloppers
Apr 26 2017 04:21
Haha gotta be careful when mixing code and chat I guess :p
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:21
@khaduch good night
Austin Wiggins
@austinwiggins
Apr 26 2017 04:22
@khaduch thanks for those tips as will; what is the purpose of putting numberinarr inside of the first for loop?
CamperBot
@camperbot
Apr 26 2017 04:22
austinwiggins sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: austinwiggins already gave khaduch points
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:22
@austinwiggins you mean initializing it with a variable?
Austin Wiggins
@austinwiggins
Apr 26 2017 04:23
Yes
Why does it need to be initialized inside of the first for loop and not outside of the function?
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:23
@austinwiggins loop is just a way of doing a repeated task, you need to keep track of how long you or how many times you want your loop to iterate
Austin Wiggins
@austinwiggins
Apr 26 2017 04:24
OK, thanks @Lumexralph ;)
CamperBot
@camperbot
Apr 26 2017 04:24
austinwiggins sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1586 | @lumexralph |http://www.freecodecamp.com/lumexralph
intcreate
@intcreate
Apr 26 2017 04:26
function trueOrFalse(wasThatTrue) {

  // Only change code below this line.
  if (true) {
    return "Yes, that was true";
  } 
  return "No, that was false";



  // Only change code above this line.

}
trueOrFalse(false) should return "No, that was false"
i have the line but its not going through
the thing says its incorrect
David Bartle
@captin411
Apr 26 2017 04:27
If(wasThatTrue)...
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:27
@intcreate because if condition will always run on true
intcreate
@intcreate
Apr 26 2017 04:27
thanks @captin411
CamperBot
@camperbot
Apr 26 2017 04:27
intcreate sends brownie points to @captin411 :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @captin411 |http://www.freecodecamp.com/captin411
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:27
and because return exits the function too @intcreate
intcreate
@intcreate
Apr 26 2017 04:27
oh i just changed
the true to wasThatTrue
Ken Haduch
@khaduch
Apr 26 2017 04:29
@austinwiggins - you need to initialize it to have a new start for each subarray, otherwise you would get the largest value across all of the arrays, or subarrays.
David Bartle
@captin411
Apr 26 2017 04:29
Yeah just changing that will work since return in the true block causes the function to exit.. skipping subsequent lines
Austin Wiggins
@austinwiggins
Apr 26 2017 04:31
@khaduch That makes sense, thank you for answering my continuous questions. I really appreciate it as it definitely helped me understand it much more than I would have on my own.
CamperBot
@camperbot
Apr 26 2017 04:31
austinwiggins sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: austinwiggins already gave khaduch points
codeasasin
@codeasasin
Apr 26 2017 04:32
In 'Make Object Properties Private' I am not able to understand the motivation behind that , can anyone explain to me ?
Austin Wiggins
@austinwiggins
Apr 26 2017 04:33
Good night and happy coding all
Christopher McCormack
@cmccormack
Apr 26 2017 04:33
@austinwiggins see ya
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:34
@codeasasin in OOP, there're class variables and instance variables, in JS they're public/instance property or private/ class property or variables
codeasasin
@codeasasin
Apr 26 2017 04:35
@Lumexralph I am not familiar with OOPs I get nightmares when I hear "OOPs", because of historical reasons
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:35
@codeasasin private variables in the class is shared by all instances of the class while public variable or instance variable is unique for each of the instances created by the constructor
@codeasasin using object concepts in your code..... Object Oriented Programming
codeasasin
@codeasasin
Apr 26 2017 04:38
@Lumexralph ok thats fine about the above statement, I got that. But last line has gone above my head
@Lumexralph "while public variable or instance variable is unique for each of the instances created by the constructor" - this line
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:39
@codeasasin remember a constructor?
codeasasin
@codeasasin
Apr 26 2017 04:39
@Lumexralph yes
@Lumexralph Actually to much technical words are confusing me
@Lumexralph Instance means that - when a new variable uses the contructor function, to make object of the type according to contructor function prototype??
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:43
@codeasasin when you create an instance of that constructor using new, the property with this.property in the constructor is an instance property , it's unique for every instance of that constructor created
codeasasin
@codeasasin
Apr 26 2017 04:45
@Lumexralph ok got that,
@Lumexralph now I am continuing with my problem , hope it gets solved
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:47
@codeasasin cool
Sandeep Bandi
@bsandyy
Apr 26 2017 04:52

@Lumexralph I guess the below two lines are doing what you suggested. Aren't they ?

var re = /[a-zA-Z0-9]/g; var newStr = str.match(re);

Ogundele Olumide
@Lumexralph
Apr 26 2017 04:53
@bsandyy what're you trying to do?
intcreate
@intcreate
Apr 26 2017 04:54

function testLogicalAnd(val) {
  // Only change code below this line

  if (val <= 24 && val >= 51) {
    if (val >= 25 && val <= 50) {
      return "Yes";
    }
  }

  // Only change code above this line
  return "No";
}

// Change this value to test
testLogicalAnd(10);
testLogicalAnd(25) should return "Yes"
testLogicalAnd(30) should return "Yes"
testLogicalAnd(50) should return "Yes"
can any1 help me with this 1
some reason im getting these wrong
Christopher McCormack
@cmccormack
Apr 26 2017 04:54
try changing the first && to ||
no number will ever be both lte 24 AND gte 51
Ogundele Olumide
@Lumexralph
Apr 26 2017 04:56
@intcreate use ||...... && will run if both conditions are true
@intcreate if(val > 24 || val < 51)
Christopher McCormack
@cmccormack
Apr 26 2017 04:57
@intcreate you'll need to seperate those if statements as well
intcreate
@intcreate
Apr 26 2017 04:58
these are the insructions

You should use the && operator once
You should only have one if statement
testLogicalAnd(0) should return "No"
testLogicalAnd(24) should return "No"
testLogicalAnd(25) should return "Yes"
testLogicalAnd(30) should return "Yes"
testLogicalAnd(50) should return "Yes"
testLogicalAnd(51) should return "No"
testLogicalAnd(75) should return "No"
testLogicalAnd(80) should return "No"

i have everything right except
testLogicalAnd(25) should return "Yes"
testLogicalAnd(30) should return "Yes"
testLogicalAnd(50) should return "Yes"

Christopher McCormack
@cmccormack
Apr 26 2017 04:59
@intcreate in that case, you're not following instructions. It says use the && operator once, you have it twice, it says use one if statement, you have two
@intcreate all you should really have to do is check one thing - is the number between these two values? If so, return "Yes", else return "No"
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:01
@intcreate then your condition should be if(val > 24 && val < 51) {return "Yes"} then you return No for the rememaining values
@intcreate remember that return gives a value on it's right and exits the function
intcreate
@intcreate
Apr 26 2017 05:03
this is the original code

function testLogicalAnd(val) {
  // Only change code below this line

  if (val) {
    if (val) {
      return "Yes";
    }
  }

  // Only change code above this line
  return "No";
}

// Change this value to test
testLogicalAnd(10);
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:04
@intcreate i have illustrated all you need to do, you just need an if statement with the condition i showed you
Christopher McCormack
@cmccormack
Apr 26 2017 05:04
yup, and it says you need to change it
Darth Skywalker
@adityaparab
Apr 26 2017 05:05
function testLogicalAnd(val) {
  return val > 24 && val < 51 ? 'Yes' : 'No';
}

// Change this value to test
testLogicalAnd(51); // No
You don't really need an if
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:06
@adityaparab not sure he's required to use ternary operator
Darth Skywalker
@adityaparab
Apr 26 2017 05:06
@Lumexralph : Whether to use ternary or if/else construct is a matter of choice...
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:07
@adityaparab according to instructions though..... the code will perfectly work
codeasasin
@codeasasin
Apr 26 2017 05:07
@Lumexralph Problem solved!!!!!!
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:07
@adityaparab no doubt, FCC can be very cranky :wink:
Darth Skywalker
@adityaparab
Apr 26 2017 05:07
:D
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:07
@codeasasin cool
codeasasin
@codeasasin
Apr 26 2017 05:08
@Lumexralph though still problem with understanding technical words like instances you mention above
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:08
@adityaparab that's why I'm thinking if the FCC test will pass the code if it's ternary operator
@codeasasin you should try knowing more and make yourself comfy with it
codeasasin
@codeasasin
Apr 26 2017 05:09
I am having a problem with the word instance , help me understand it
Darth Skywalker
@adityaparab
Apr 26 2017 05:09
@Lumexralph I don't think any test framework looks at code. Tests are performed on the results produced.. :)
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:09
@adityaparab who knows...... shrugs
Darth Skywalker
@adityaparab
Apr 26 2017 05:09
@codeasasin : instance and similar jargons make you feel important!
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:09
@adityaparab :laughing:
codeasasin
@codeasasin
Apr 26 2017 05:12
@adityaparab :smile:
Darth Skywalker
@adityaparab
Apr 26 2017 05:17

@codeasasin

I am having a problem with the word instance , help me understand it

Assuming you're referring to instance in the context of OOP, there are two things...
Classes and Objects.

Class is just template. And they say object is an instance of a class.
Which means, an object has physical existence. Class doesn't. Class is just a rule based on which you create object.
If you instantiate a class, you get an object that uses the structure defined by the said class.

When you instantiate a class, the object you get is an instance of that class.

codeasasin
@codeasasin
Apr 26 2017 05:21
@adityaparab wow man first three lines made my day, that was the thing that I needed, I am new to OOPs , I just have C background :smile:
Darth Skywalker
@adityaparab
Apr 26 2017 05:22
@codeasasin : Class are struct are almost the same ;)
codeasasin
@codeasasin
Apr 26 2017 05:22
@adityaparab bhai kaha se ho , your name sounds like an Indian
Darth Skywalker
@adityaparab
Apr 26 2017 05:22
You won't have difficulty understanding classes if you understand struct...
I am Indian... Pune
codeasasin
@codeasasin
Apr 26 2017 05:22
@adityaparab Delhi
devpaaji
@devpaaji
Apr 26 2017 05:23
@Lumexralph morning friend how are you
@adityaparab morning Darth
how are you
Darth Skywalker
@adityaparab
Apr 26 2017 05:23
@codeasasin : If you want to have sex with someone you don't know.... please... always always always... ASK!
@devpaaji : GM!
all good.. how are you?
Markus Kiili
@Masd925
Apr 26 2017 05:23
Morning.
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:23
@devpaaji Morning Bro!
devpaaji
@devpaaji
Apr 26 2017 05:23
@Masd925 morning
codeasasin
@codeasasin
Apr 26 2017 05:23
@adityaparab You mean gay sex ? sorry I am straight :)
devpaaji
@devpaaji
Apr 26 2017 05:23
how are you
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:23
@Masd925 Morning
@adityaparab ask for what? :smile:
Darth Skywalker
@adityaparab
Apr 26 2017 05:24
@codeasasin : Delhi guys need to be told that! :D
Erol Aliyev
@erolaliyev
Apr 26 2017 05:24
hi guys!
codeasasin
@codeasasin
Apr 26 2017 05:24
:)
Darth Skywalker
@adityaparab
Apr 26 2017 05:24
Just pulling your leg mate!! JK

@adityaparab ask for what? :smile:

NVM... that's a delhi thing...

codeasasin
@codeasasin
Apr 26 2017 05:24
I know it :)
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:24
:laughing:
@erolaliyev Hello
Darth Skywalker
@adityaparab
Apr 26 2017 05:25
Man! My kids are gonna have nigerian names!
Look at @Lumexralph
Markus Kiili
@Masd925
Apr 26 2017 05:25
@adityaparab If you pull someones protuberance, always ask first.
Erol Aliyev
@erolaliyev
Apr 26 2017 05:25

can anyone help me?
i should should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
if(contacts.firstName == firstName && contacts.hasOwnProperty(prop) === true) {
return contacts.firstName.prop ;
}
else if(contacts.firstName != firstName) {
return "No such contact";
}
else if(contacts.hasOwnProperty(prop) === false) {
return "No such property";
}
// Only change code above this line
}

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

Ogundele Olumide
@Lumexralph
Apr 26 2017 05:25

Man! My kids are gonna have nigerian names!

:smirk:

Darth Skywalker
@adityaparab
Apr 26 2017 05:26
@Masd925 lmao! But he's from Delhi... He's used to either having his protuberance pulled or doing that to someone else...
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:26
@erolaliyev
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
codeasasin
@codeasasin
Apr 26 2017 05:27
@adityaparab yea , just got lost in technical words
Erol Aliyev
@erolaliyev
Apr 26 2017 05:27
@Lumexralph thank you i got it in completely wrong way
CamperBot
@camperbot
Apr 26 2017 05:27
erolaliyev sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1587 | @lumexralph |http://www.freecodecamp.com/lumexralph
Darth Skywalker
@adityaparab
Apr 26 2017 05:27
@codeasasin :+1:
Erol Aliyev
@erolaliyev
Apr 26 2017 05:28
@Lumexralph how can i get this tips if i get stuck again?
codeasasin
@codeasasin
Apr 26 2017 05:29
@adityaparab Its not a Delhi thing, mainly outsiders are involved, due to influx of large people from other states
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:29
@erolaliyev I really can't say..... there should be a way to jump to a time in the chat, right @Masd925 ?
@erolaliyev you can copy and paste it somewhere on your computer too, maybe a notepad
Markus Kiili
@Masd925
Apr 26 2017 05:32
@Lumexralph Would be nice.
Erol Aliyev
@erolaliyev
Apr 26 2017 05:33
@Lumexralph no problem :)
rugano
@rugano
Apr 26 2017 05:33
Return the factorial of the provided integer. What is wrong with my code?
function factorialize(num){
var factorial = num;

5! = 1 * 2 * 3 * 4 * 5;
return num;
}
factorize(5);
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:37
@rugano what's 5! ?
codeasasin
@codeasasin
Apr 26 2017 05:38
@Lumexralph 5! = 5x4x3x2x1
rugano
@rugano
Apr 26 2017 05:39
@Lumexralph it is the number to be factorized
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:40
@rugano how do you perform a repeated task in JS?
codeasasin
@codeasasin
Apr 26 2017 05:40
@Lumexralph n! = nX(n-1) X (n-2) X (n-3) X (n-4) X .............X3 X2X1
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:40
@rugano you can use loop or recursion
rugano
@rugano
Apr 26 2017 05:40
@Lumexralph by use of a loop
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:41
@rugano you'll need a loop then to accumulate the product of the numbers as you've written them in your code
rugano
@rugano
Apr 26 2017 05:42
@Lumexralph let me do that now Sir
Ogundele Olumide
@Lumexralph
Apr 26 2017 05:43
@rugano ignore the Sir.... :wink:
Darth Skywalker
@adityaparab
Apr 26 2017 05:47
Let's get a little fancy with factorial
Array.prototype.spread = function(){
  var arr = [];
  var start, end;
  if(arguments.length === 2){
    start = arguments[0];
    end = arguments[1];
  } else {
    start = 1;
    end = arguments[0];
  }

  for(var i=start;i<=end;i++){
    arr.push(i);
  }

  return arr;
}

function factorialize(num){
  return Array.prototype.spread(num).reduce( (f, c) => f * c, 1);
}

factorialize(5); //120
Abhishek Saini
@sainiabhi
Apr 26 2017 05:52
//Constructor Function

    function Person(name, street){
        this.name = name;
        this.street = street;

        this.info = function(){
            return "My name is " + this.name + " and I live on " + this.street;
        }
    }

    var bobSmith = new Person("Bob Smith", "1234 St. Mary");

    document.write(bobSmith.info() + "<br/>");   

    document.write( "Bob is a Person " +  (bobSmith instanceOf Person)  + "<br/>" );
If you guys see the last line (bobSmith instanceOf Person) should return true but it's giving an error which I'm not getting. Please help
Darth Skywalker
@adityaparab
Apr 26 2017 05:53
Now let's call anonymous function recursively to calculate factorial
function factorialize(num){
  return (function(){
    return num >= 0 ? this.call(this, num) : new Error('Negative number cannot have a factorial');
  }).bind(function(n){
    return n > 0 ? n * this.call(this, --n) : 1;
  })(num);
}

factorialize(5); // 120
devpaaji
@devpaaji
Apr 26 2017 05:56
@sainiabhi
function C() {}
function D() {}

var o = new C();

// true, because: Object.getPrototypeOf(o) === C.prototype
o instanceof C;
what is the error you are getting
Markus Kiili
@Masd925
Apr 26 2017 05:57
@sainiabhi instanceof
Darth Skywalker
@adityaparab
Apr 26 2017 05:57
@sainiabhi instanceOf should be instanceof
Abhishek Saini
@sainiabhi
Apr 26 2017 06:01
oh :O thanks @Masd925 @adityaparab
CamperBot
@camperbot
Apr 26 2017 06:01
sainiabhi sends brownie points to @masd925 and @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1025 | @adityaparab |http://www.freecodecamp.com/adityaparab
:star2: 3935 | @masd925 |http://www.freecodecamp.com/masd925
Abhishek Saini
@sainiabhi
Apr 26 2017 06:03
@devpaaji paaji syntax galat si :) thanks for the example
CamperBot
@camperbot
Apr 26 2017 06:03
sainiabhi sends brownie points to @devpaaji :sparkles: :thumbsup: :sparkles:
:cookie: 236 | @devpaaji |http://www.freecodecamp.com/devpaaji
devpaaji
@devpaaji
Apr 26 2017 06:03
@sainiabhi np
thats fine
rugano
@rugano
Apr 26 2017 06:20
@Lumexralph Thanks,it worked
CamperBot
@camperbot
Apr 26 2017 06:20
rugano sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1588 | @lumexralph |http://www.freecodecamp.com/lumexralph
intcreate
@intcreate
Apr 26 2017 06:28

function golfScore(par, strokes) {
  // Only change code below this line
  if(par < 5 && strokes < 2) {
    return "Hole-in-one!";
  } else if(par < 6 && strokes === 2) {
    return "Eagle";
  } else if(par < 5 && strokes === 3) {
    return "Birdie";
  } else if(par === 4 || 5 && strokes === 4 || 5) {
    return "Par";
  } else if(par === 4 && strokes === 5) {
    return "Bogey";
  } else if(par === 4 && strokes === 6) {
    return "Double Bogey";
  } else if(par === 4 && strokes === 7) {
    return "Go Home!";
  }

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

// Change these values to test
golfScore(5, 4);
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
golfScore(4, 7) should return "Go Home!"
can any1 help me with this one these 3 are incorrect
Markus Kiili
@Masd925
Apr 26 2017 06:29
@intcreate You didn't understand it correctly. For example if strokes===par, you should return Par etc.
It is about how much over or under par the strokes are.
intcreate
@intcreate
Apr 26 2017 06:31
they had this

1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"

but i created my own thing and didnt use it
what do u mean?
Markus Kiili
@Masd925
Apr 26 2017 06:32
@intcreate Yes, for example if(strokes===par-1) return "Birdie"; etc
intcreate
@intcreate
Apr 26 2017 06:33
dang
devpaaji
@devpaaji
Apr 26 2017 06:43
alert(Array.isArray({})); // false

alert(Array.isArray([])); // true
@Masd925
alert(typeof {}); // object
alert(typeof []); //  object
that is a JS behavior
often unnoticed
where as everything in JS works like objects]
Markus Kiili
@Masd925
Apr 26 2017 06:45
@devpaaji There is only one Object type in JS. Only objects typeof specifies from the rest is functions.
Naveen Raju Mudhunuri
@naveenrajum
Apr 26 2017 06:46
function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
In this exercise how I access the arguments i.e.,2 , 3
when I return the arr it was returning the given array only.
somrat1998
@somrat1998
Apr 26 2017 06:48
i need help.... can anyone tell me where the prob is???
var myStr='FirstLine\n\SecondLine\\rThirdline';
Markus Kiili
@Masd925
Apr 26 2017 06:48
@9aveen Use the arguments object.
somrat1998
@somrat1998
Apr 26 2017 06:48

Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine

Naveen Raju Mudhunuri
@naveenrajum
Apr 26 2017 06:49
arr.filter(arguments);
Does it remove all the occurrences of the arguments in the array?
@Masd925
ravi-kolla
@ravi-kolla
Apr 26 2017 06:50
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
if(myObj.hasOwnProperty(checkProp)){
return myObj.checkProp;
}else{
return "Not Found";
}
}
checkObj("gift");
check obj is not returning pony in this case
Markus Kiili
@Masd925
Apr 26 2017 06:51
@9aveen You need to pass a function to filter that tells filter which elements to keep. Look at simple examples on MDN filter page.
ravi-kolla
@ravi-kolla
Apr 26 2017 06:55
var x = "FirstLine \n \ SecondLine\ \n ThirdLine" @somrat1998 once try this
\ should be repeated two times before and after "SecondLine" @somrat1998
Riley
@Riley1435
Apr 26 2017 06:58
for the life of me, cannot figure this out.
pei4inbolt
@pei4inbolt
Apr 26 2017 06:58

Hi. I have a problem with this one. Pls help.

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++ ){
if(contacts[i].hasOwnProperty(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
}

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

Riley
@Riley1435
Apr 26 2017 06:58

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

Parth-g
@Parth-g
Apr 26 2017 06:58
Then give myCar a nickname property with a string value.
what is nickname property
Abhi
@abhishek737
Apr 26 2017 06:59
hello guys
Abhishek Tiwari
@fillopfy
Apr 26 2017 06:59
var myStr = "<a href=http:'//www.example.com' 'target=_blank'>Link</a>";
what is wrong with this code