These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Mar 2017
Jason Luboff
@JLuboff
Mar 14 2017 00:00
Interesting... alright. Well have a good one :wave:
Pieter Stokkink
@forkerino
Mar 14 2017 00:00
@JLuboff and to you as well!
Seth Church
@iEnder
Mar 14 2017 00:01
@bjh2012 because coercion in javascript tried to compare 2 values to the same type so it converts that statement to what is 1 != 1 pretty much, to avoid running into these issues you can use the strict inequality operator !== which will prevent this coercion
Pieter Stokkink
@forkerino
Mar 14 2017 00:02
@bjh2012 1 can be converted to true and 0 can be converted to false. If you use != , it will try to match the types on both sides and if they're not the same, it'll try to coerce one type into the other. If you use !== instead, it won't do this coercion. 1 !== true is .... true
@pkmn9060 hahah
good one
Seth Church
@iEnder
Mar 14 2017 00:02
:b
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:02
:P :B
Pieter Stokkink
@forkerino
Mar 14 2017 00:02

ok. Time for bed. :b

Later!

Saboor Malik
@MathematicsCoding
Mar 14 2017 00:02
:b :p.
Joseph
@revisualize
Mar 14 2017 00:02
@TantienHime You do know that for that lesson you don't need to store the .shift()
jacob
@bjh2012
Mar 14 2017 00:02
thanks, guys.
Seth Church
@iEnder
Mar 14 2017 00:03
@forkerino o/
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:03
...
Seth Church
@iEnder
Mar 14 2017 00:03
ah yes the rest operator
one of es6's greater pieces
:b
Mike Bilyeu
@mbilyeu1
Mar 14 2017 00:04

@revisualize function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if ((contacts[i].firstName == firstName) && (contacts[i].hasOwnProperty(prop))) {
return contacts[i][prop];
}else if (contacts[i].firstName != firstName) {
return 'No such contact';
}else if (!(contacts[i].hasOwnProperty(prop))) {
return 'No such property';
}
}

// Only change code above this line
} //How do I check the individual objects in the array?

Seth Church
@iEnder
Mar 14 2017 00:04
use ``` before and after your code to format
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:05
Hey can someone help me with this shopping list....
Seth Church
@iEnder
Mar 14 2017 00:05
?
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:05
"There should be at least 5 sub-arrays in the list."
sub-array?
Seth Church
@iEnder
Mar 14 2017 00:06
nested arrays or 2D arrays are just arrays in arrays like [[], []]
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:06
Oh ok
```
var myList = [["Chocolate Bar", 15], ["Chips", 3]];
I added it but output frame doesnt have the spacing
How do I make them space?
Seth Church
@iEnder
Mar 14 2017 00:08
?
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:08
You know output at the left?
Seth Church
@iEnder
Mar 14 2017 00:08
yes
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:09
But it says like "Chocolate Bar", 15 not "Chocolate Bar", 15
Seth Church
@iEnder
Mar 14 2017 00:09
uhh
those are the same
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:09
Yeah...
But what if you want them to have the space?
" "?
Seth Church
@iEnder
Mar 14 2017 00:10
a space between Chocolate bar and 15?
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:10
Yeah i guess
Seth Church
@iEnder
Mar 14 2017 00:10
just add it between them id assume
are you printing out the array?
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:11
printing out the array?
Seth Church
@iEnder
Mar 14 2017 00:11
how are you displaying your info in the output
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:11
At the left
Seth Church
@iEnder
Mar 14 2017 00:11
looping though the array and loging them?
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:12
No...
I dont know loop yet
Seth Church
@iEnder
Mar 14 2017 00:12
which challenge is this
Saboor Malik
@MathematicsCoding
Mar 14 2017 00:12
Shopping list
I will be back soon brb
Seth Church
@iEnder
Mar 14 2017 00:12
Oh then you just put the space yourself in the actual array not that it should matter really
LuchooB
@LuchooB
Mar 14 2017 00:12
Can someone help me with the challenge Profile Lookup?
It's from basic JavaScript
Seth Church
@iEnder
Mar 14 2017 00:14
whats the issue?
LuchooB
@LuchooB
Mar 14 2017 00:14
for(var i=0; i<firstName.lenght; i++){
for(var j=0; j<prop.lenght; j++){
if(firstName===contacts.firstname){
return contacts[prop];
}else if(prop!=contacts.prop){
return "No such property";
}else{
return "No such contact";
}
}
}
I tried using that but it didn't work, I don't know why. I find it quite difficult because I started programming a few days ago :/
Seth Church
@iEnder
Mar 14 2017 00:16
your not actually checking the indexes first name rather the array itself for a property of firstname
also you spelled length wrong
LuchooB
@LuchooB
Mar 14 2017 00:18
it would be contacts.firstName.length?
Seth Church
@iEnder
Mar 14 2017 00:18
what are you looping over?
LuchooB
@LuchooB
Mar 14 2017 00:19
first over the length of the contacts array and then over the subarrays
Seth Church
@iEnder
Mar 14 2017 00:19
are they sub arrays?
LuchooB
@LuchooB
Mar 14 2017 00:19
I think
Seth Church
@iEnder
Mar 14 2017 00:19
or something else?
LuchooB
@LuchooB
Mar 14 2017 00:20
oooh I see
so I don't need to loop twice, right?
Seth Church
@iEnder
Mar 14 2017 00:20
correct! :D
LuchooB
@LuchooB
Mar 14 2017 00:20
Thanks!!
Jacoby Clarke
@Jacobycodes18
Mar 14 2017 00:20

var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line
var secondTree = [myPlants].type = "pine";
var secondTree = "pine";

Can't seem to figure this one out

LuchooB
@LuchooB
Mar 14 2017 00:21
I'll see if I can do it
Seth Church
@iEnder
Mar 14 2017 00:21
@Jacobycodes18 which challenge is this
Hernan Mendez
@hernanmendez
Mar 14 2017 00:23
hey what's wrong with this code on the challenge "Profile Lookup"

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i;i<contacts.length;i++){
if (firstname===contacts[i].firstname){
matchn=true;
if (contacts[i][prop]!==undefined){
return contacts[i][prop];}
}
else {
return "No such property";
}
return "No such contact";
}

// Only change code above this line
}

Shanta Nathwani
@TantienHime
Mar 14 2017 00:23
@revisualize Not so much store, as assign. Gotta get my terminology right.
Hernan Mendez
@hernanmendez
Mar 14 2017 00:24
but i=0
i fixed it
Joseph
@revisualize
Mar 14 2017 00:27
@TantienHime return arr.concat(item).shift();
toddylane
@toddylane
Mar 14 2017 00:28
can someone tell me if this is correct? it passes the lesson, but it should return a random number between 0 and 9 and everytime i run it i only get 0. its a whole number so it passes, but 0 returns everytime, no other random whole number.

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.
Math.floor(Math.random() * 10);
return Math.floor(Math.random());
}

Hernan Mendez
@hernanmendez
Mar 14 2017 00:29
i would help you but i'm too lazy to apply c++ or java logic to javascript logic
Johnny
@JohnnyBizzel
Mar 14 2017 00:30
@toddylane you are not using variables
Hernan Mendez
@hernanmendez
Mar 14 2017 00:30
yep
not even global ones
John Nunns
@johnnunns
Mar 14 2017 00:30
is there an easy fix to this or do i need to start over?
twlst
@twlst
Mar 14 2017 00:30
@toddylane You’re not actually returning Math.floor(Math.random() * 10).
Johnny
@JohnnyBizzel
Mar 14 2017 00:30
@hernanmendez Not that lazy ;)
John Nunns
@johnnunns
Mar 14 2017 00:30

function smallestCommons(arr) {
  var x =[];
  var y = []
  var num1=0;
  for(i=0;i<=25;i++){
    num1=arr[0]*i;
    x.push(num1);
  }
  //make an array of the numbers from the min to the max number with a for loop
  for(i=Math.min(...arr);i<=Math.max(...arr);i++){
    y.push(i);
  }
  return y;
  return x.filter(elem=>elem%y===0);
}


smallestCommons([1,5]);
so I know why my filter isn't working
I waasn't sure how to compare each elem to each elem in the array y i've created
Hernan Mendez
@hernanmendez
Mar 14 2017 00:31
@JohnnyBizzel But still... I'm lazy a*
Johnny
@JohnnyBizzel
Mar 14 2017 00:32
@hernanmendez If you were lazy, you would be in bed :zzz:
@johnnunns Are you asking or telling?
John Nunns
@johnnunns
Mar 14 2017 00:33
I'm asking for help but letting you know I do understand why it's currently not working
Johnny
@JohnnyBizzel
Mar 14 2017 00:34

@johnnunns I can't see this working:

  return y;
  return x.filter(elem=>elem%y===0);

How will you reach the 2nd return?

John Nunns
@johnnunns
Mar 14 2017 00:34
right
Hernan Mendez
@hernanmendez
Mar 14 2017 00:34
@JohnnyBizzel I am
toddylane
@toddylane
Mar 14 2017 00:34
@JohnnyBizzel im not sure what you mean about the variables... @twlst Thank you, that solved the problem, now i get a random whole number instead of just 0. i thought it would automatticaly reassign
CamperBot
@camperbot
Mar 14 2017 00:34
toddylane sends brownie points to @johnnybizzel and @twlst :sparkles: :thumbsup: :sparkles:
:star2: 1474 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:cookie: 346 | @twlst |http://www.freecodecamp.com/twlst
John Nunns
@johnnunns
Mar 14 2017 00:34
yeah, I should clarify that that's there more as what I'm trying to do. not as what I believe is the solution
@JohnnyBizzel
Hernan Mendez
@hernanmendez
Mar 14 2017 00:35
@toddylane just got to that challenge haha
Johnny
@JohnnyBizzel
Mar 14 2017 00:35
@toddylane Your first statement didn't do anything.
Math.floor(Math.random() * 10);
Do you know why it works if you add the return?
toddylane
@toddylane
Mar 14 2017 00:36
@JohnnyBizzel ahh, youre saying i dont need both statements? just that with return in front?
twlst
@twlst
Mar 14 2017 00:36
@toddylane Johnny meant that if you want to store the value of the Math.floor(Math.random() * 10), you have to use a variable. Ex: var num = Math.floor(Math.random() * 10).
Adam
@GoingAllTheWayUp
Mar 14 2017 00:36
@johnnunns why not putt your max and min inside variables?
aigamqa
@aigamqa
Mar 14 2017 00:36
Guys can you help me with this function?

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

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

// Change the inputs below to test your code
convertToF(30);

John Nunns
@johnnunns
Mar 14 2017 00:37
would be good practice, you're right. Not worried about that in terms of how to get the answer currently though. @GoingAllTheWayUp
toddylane
@toddylane
Mar 14 2017 00:37
@JohnnyBizzel @twlst ohh ok i see, i didnt need to store it though, just return it. thanks though, that clarifies things.
CamperBot
@camperbot
Mar 14 2017 00:37
toddylane sends brownie points to @johnnybizzel and @twlst :sparkles: :thumbsup: :sparkles:
:warning: toddylane already gave johnnybizzel points
:warning: toddylane already gave twlst points
Adam
@GoingAllTheWayUp
Mar 14 2017 00:37
I had learn what the euclidean algorithm for that one, included finding the greatest common denominator also @johnnunns
Johnny
@JohnnyBizzel
Mar 14 2017 00:38
@toddylane :+1:
Hernan Mendez
@hernanmendez
Mar 14 2017 00:38
@johnnunns i won't read all the mesagges but i think in that code a semicolon is missing...
Adam
@GoingAllTheWayUp
Mar 14 2017 00:38
@johnnunns but if you want to create the range first?
Hernan Mendez
@hernanmendez
Mar 14 2017 00:38
@johnnunns right?
John Nunns
@johnnunns
Mar 14 2017 00:39
@hernanmendez yeah you're right man.
Hernan Mendez
@hernanmendez
Mar 14 2017 00:39
@johnnunns ok! (send me Brownies haha)
John Nunns
@johnnunns
Mar 14 2017 00:39
@GoingAllTheWayUp I really didn't tamper with it yet because I felt so far off of the solution with what I currently have
@hernanmendez that's the wrong way to go about that bud :joy: and unfortunately my code will read the same with or without it. so there was really no help there man.
Adam
@GoingAllTheWayUp
Mar 14 2017 00:41
I found that after the euclidean algorithm was converted into javscript I had an easier time understanding the rest. here you can find my solution. The reason I made this is becuase its an obscure challenge and I liked it.
Joel
@MMK123
Mar 14 2017 00:42
var myStr FirstLine\nSecondLine\nThirdLine\;
hello can someone tell me what's wrong here
spencerjstewart
@spencerjstewart
Mar 14 2017 00:42
Hello :)
John Nunns
@johnnunns
Mar 14 2017 00:42
youtubing the euclidean method now. If i struggle afterwards I'll check your link out, thanks @GoingAllTheWayUp
CamperBot
@camperbot
Mar 14 2017 00:42
johnnunns sends brownie points to @goingallthewayup :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @goingallthewayup |http://www.freecodecamp.com/goingallthewayup
Adam
@GoingAllTheWayUp
Mar 14 2017 00:42
@johnnunns you can use logic and not the euclidean algorithm also
spencerjstewart
@spencerjstewart
Mar 14 2017 00:43
@MMK123 you need the assignment operator = ? after myStr
Johnny
@JohnnyBizzel
Mar 14 2017 00:43
@MMK123 slashes in the wrong place
John Nunns
@johnnunns
Mar 14 2017 00:43
I figure they probably made the algorithm for a reason haha probably the most effective way if it's been given that title
Adam
@GoingAllTheWayUp
Mar 14 2017 00:43
me to :)
LuchooB
@LuchooB
Mar 14 2017 00:44
how can I do to put a window for my program in the chat?
Stephen James
@sjames1958gm
Mar 14 2017 00:44
@LuchooB '''
CamperBot
@camperbot
Mar 14 2017 00:44
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Mar 14 2017 00:44
@LuchooB follow that more info link for posting code
Joel
@MMK123
Mar 14 2017 00:44
hmmm
cant figure it out
LuchooB
@LuchooB
Mar 14 2017 00:44
thanks
Ali Ahmad
@aliahmad-code
Mar 14 2017 00:44
Completely stumped at word blanks, anyone have any tips?
spencerjstewart
@spencerjstewart
Mar 14 2017 00:45
@MMK123 this works for me https://repl.it/GAOh/0
Joel
@MMK123
Mar 14 2017 00:45
var myStr = "FirstLine \nSecondLine\ \nThirdLine\";
Stephen James
@sjames1958gm
Mar 14 2017 00:45
@aliahmad-code https://www.freecodecamp.com/challenges/concatenating-strings-with-plus-operator
combine the values passed in into a single string
spencerjstewart
@spencerjstewart
Mar 14 2017 00:46
it looks like you have a couple of unnecessary backslashes
Stephen James
@sjames1958gm
Mar 14 2017 00:46
@MMK123 You should replace 4 key words with escape sequences - and remove spaces.
You missing one before SecondLine and \n is wrong after SecondLine
Ali Ahmad
@aliahmad-code
Mar 14 2017 00:46
@sjames1958gm do I have do define myNoun, myAdjective, myVerb, and myAdverb?
Stephen James
@sjames1958gm
Mar 14 2017 00:47
@aliahmad-code No they are passed into the function from the function call
LuchooB
@LuchooB
Mar 14 2017 00:47
'''
CamperBot
@camperbot
Mar 14 2017 00:47
:bulb: to format code use backticks! ``` more info
Joel
@MMK123
Mar 14 2017 00:47
interesting..
Ali Ahmad
@aliahmad-code
Mar 14 2017 00:47
@sjames1958gm thanks, I'll give it try!
CamperBot
@camperbot
Mar 14 2017 00:47
aliahmad-code sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6155 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 14 2017 00:47
@aliahmad-code :+1:
Joel
@MMK123
Mar 14 2017 00:47
replace four key words with escape sequences... ?
Stephen James
@sjames1958gm
Mar 14 2017 00:48
@MMK123 newline backslash backslash carriage-return
LuchooB
@LuchooB
Mar 14 2017 00:48
for(var i=0; i<contacts.length; i++){
    if(firstName===contacts[i].prop && prop===contacts[i].firstName){
      return contacts[prop];
    }if(firstName!=contacts[i].prop){
      return "No such contact";
    }
      return "No such property";
  }
thats the profile lookup challenge
I can't figure out why is wrong
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 00:49
Hey guys, I am in Javascript, How cam i Encode text with the proper escape sequences and no spacing???? Help please>
var myStr ='FirstLine\n\SecondLine\ThirdLine\r'; // Change this line
Stephen James
@sjames1958gm
Mar 14 2017 00:49
@LuchooB compare firstName to the property firstName (not prop)
Also, prop is a variable so you cannot use .prop
@AlejandroBarrera01 \r is out of place
Hernan Mendez
@hernanmendez
Mar 14 2017 00:49
@LuchooB and there is no contacs[prop]
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 00:50
where should it go? after ;?
Hernan Mendez
@hernanmendez
Mar 14 2017 00:50
@LuchooB prop is a "second level" element
Stephen James
@sjames1958gm
Mar 14 2017 00:50
@AlejandroBarrera01 Look at the instructions carriage-return is before ThirdLine
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 00:50
Thaks ubd,
budd,
LuchooB
@LuchooB
Mar 14 2017 00:51
what do you mean with second level?
Hernan Mendez
@hernanmendez
Mar 14 2017 00:52
@LuchooB that prop is an element inside of an element of the array.
LuchooB
@LuchooB
Mar 14 2017 00:53
so if I want the prop I use contacts[firstName]?
Hernan Mendez
@hernanmendez
Mar 14 2017 00:53
@LuchooB if you wan't it to be more confusing, prop is an element of an object that is inside o an array
LuchooB
@LuchooB
Mar 14 2017 00:53
contacts[i][firstName]*
Hernan Mendez
@hernanmendez
Mar 14 2017 00:53
[i][prop]
Stephen James
@sjames1958gm
Mar 14 2017 00:54
@LuchooB contacts[i].firstName first name is a property name (while prop contains a property name)
LuchooB
@LuchooB
Mar 14 2017 00:54
thanks
Hernan Mendez
@hernanmendez
Mar 14 2017 00:56
@sjames1958gm you would only get the name then... you use that to confirm that there is a object that has that name
@sjames1958gm and then you do NESTING MAGIC
Stephen James
@sjames1958gm
Mar 14 2017 00:56
@hernanmendez This is all true
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 01:03
No spaces between escape sequences or word? help
var myStr ='FirstLine\n/\SecondL
var myStr ='FirstLine\n/\SecondLine\ThirdLine\r/'; // Change this line
Stephen James
@sjames1958gm
Mar 14 2017 01:04
@AlejandroBarrera01 backslash is escaped with \\
@AlejandroBarrera01 All of the keywords and escape sequences are either side of SecondLine
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 01:05
okay
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:06
what am I doing wrong?
Capture1.PNG
Stephen James
@sjames1958gm
Mar 14 2017 01:07
@Giveback007 mispelled length
rsenter1993
@rsenter1993
Mar 14 2017 01:07
Hey all
Herman Fassett
@HermanFassett
Mar 14 2017 01:08
;)
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:08
ah score +1 to you
rsenter1993
@rsenter1993
Mar 14 2017 01:08
I'm having a bit of trouble with my lesson I'm working on.
var myStr = '\FirstLine\n SecondLine \r ThirdLine\';
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:08
thank you @sjames1958gm
CamperBot
@camperbot
Mar 14 2017 01:08
giveback007 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6156 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Hernan Mendez
@hernanmendez
Mar 14 2017 01:08
i feel like OOP in javascript is gonna be a lot different than it is on c++ and java
Stephen James
@sjames1958gm
Mar 14 2017 01:08
@rsenter1993 All the escape sequences go adjacent to SecondLine (before and after)
@hernanmendez Radically
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:08
I looked it over like 10 times, idk how I couldn't spot it
Stephen James
@sjames1958gm
Mar 14 2017 01:09
@Giveback007 Often you see what you think is there, that is why new eyes see it quickly
rsenter1993
@rsenter1993
Mar 14 2017 01:09
All of the \n should be in the verbiage?
Stephen James
@sjames1958gm
Mar 14 2017 01:09
@rsenter1993 Well it is \n \r and two \\
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:09
i wish I could run a spell check on code
rsenter1993
@rsenter1993
Mar 14 2017 01:10
Ahh line \n words\ \rwords\
*like
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 01:12
I am having trouble with that too mate @rsenter1993
I have this so far... var myStr ='FirstLine\n \SecondLine\ ThirdLine\r'; @rsenter1993
Let me know if you find it @rsenter1993
rsenter1993
@rsenter1993
Mar 14 2017 01:14
I have it in as var myStr = '\FirstLine \n SecondLine\ \r ThirdLine\'
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:14
so here's a question related to the same code:
why does
var lastLetterOfLastName = lastName[lastName.length - 1]; works
var lastLetterOfLastName = lastName.lenght - 1; doesn't work?
rsenter1993
@rsenter1993
Mar 14 2017 01:14
Have 75% of it right per the check list
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 01:14
same here.. i need the 1st check only..
rsenter1993
@rsenter1993
Mar 14 2017 01:15
Yeah
@Giveback007 was that for us?
Herman Fassett
@HermanFassett
Mar 14 2017 01:16
@Giveback007 well the second one would first be assigning a number to var instead of a character, and also length is misspelled.
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:17
sorry I keep slipping my fingers with the length
var lastLetterOfLastName = lastName[lastName.length - 1]; works
var lastLetterOfLastName = lastName.length - 1; doesn't work?
"find the last character in the lastName variable."
CamperBot
@camperbot
Mar 14 2017 01:18
find the last character in the lastname variable
nothing found
Herman Fassett
@HermanFassett
Mar 14 2017 01:19
lastName.length - 1 is a numeric value, while the first option you're accessing an index of a string, meaning the value is a character.
So you still get the right index with the second option, but you need to access that index in the string for the last letter
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:21
Just started java today and all these terms are confusing "index of a string"
Conrad Kay
@conradkay
Mar 14 2017 01:22
javascript or java?
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:22
aww fudge
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:23
@Giveback007
Fudge!
I want chocolate one
Joseph
@revisualize
Mar 14 2017 01:23
What is this called:
function name() {
    var y = x = 10;
}
name();
console.log(x); // Why can I access `x` outside of the function?
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:23
"Basic JavaSript" is what I'm working on
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:23
Same here
Herman Fassett
@HermanFassett
Mar 14 2017 01:23
Well maybe go back and reread some of the previous lessons, since they should explain index and string by that point.
@revisualize what ya mean? Global vars?
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:24
(sad face)
David Amanze
@GodKingShogun
Mar 14 2017 01:24
hello all :smile:
Joseph
@revisualize
Mar 14 2017 01:24
@HermanFassett I'm trying to figure out why I can set x as a global variable with that block of code.
Conrad Kay
@conradkay
Mar 14 2017 01:25
@revisualize that is called a function
David Amanze
@GodKingShogun
Mar 14 2017 01:25
anyone here that can help with the sum all prime challenge
Herman Fassett
@HermanFassett
Mar 14 2017 01:25
Is x really set global though?
rsenter1993
@rsenter1993
Mar 14 2017 01:25
Still having some trouble with this code.
var myStr ="\FirstLine\nSecondLine\\rThirdLine\";
Herman Fassett
@HermanFassett
Mar 14 2017 01:25
Doesn't create a global var for me in console
Conrad Kay
@conradkay
Mar 14 2017 01:25
x can be accessed outside of the function because javascript creators thought it would be usefull
rsenter1993
@rsenter1993
Mar 14 2017 01:26
Still indicating that I'm not encoding the text.
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:26
Finally
Conrad Kay
@conradkay
Mar 14 2017 01:26
^but i dont think you should be able to access it
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:26
Now learning about console.log
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:27
@rsenter1993 I was struggling with that one too, but I just did the instructions (with some help here) fallowing it up with the chart above the instructions and cracked it.
David Amanze
@GodKingShogun
Mar 14 2017 01:28
:cry ignored lol
:cry:
:cry:
lol
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:28
@rsenter1993 fallow the order of the instructions in a single line and use the chart above
David Amanze
@GodKingShogun
Mar 14 2017 01:29
can anyone see my emojis
i cant see them lol
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:29
I see it
David Amanze
@GodKingShogun
Mar 14 2017 01:29
weird it is blank for me
Dovydas Stirpeika
@Giveback007
Mar 14 2017 01:29
I will be sad with you friend
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:29
Hey
function reusableFunction() {
  console.log("Hi world");

}

reusableFunction();
"reusableFunction should output "Hi World" to the dev console"
Joseph
@revisualize
Mar 14 2017 01:30
@HermanFassett
function name() {
    var y = x = 10;
    console.log("inner x: " + x);
    console.log("inner y: " + y);
    return y / 2;
}
name();
console.log("Outer x: " + x); // How is x accessible here?
console.log("Outer y: " + y);
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:30
I dont understand
David Amanze
@GodKingShogun
Mar 14 2017 01:30
im going to post my sum all prime number challenge... dont freak out... it is returning an infinite loop at line six... help me please :cry:
function sumPrimes(num) {
 var counter=0;
 var primeNumbers= [2,3,5];
  var results=0;
  for (var i=7; i<=num; i++) {
    if (i%2===0){
      continue;
    } else if (i%2!==0){
      var k=i-1;
    while (k>=3){
        if (i%k===0) {
         counter+=1;
          k--;
        }
      }
       if (counter===0){
          primeNumbers.push(i);
       } else if (counter!==0) {
         counter=counter.defaultValue;
       }
    }
  }
  for (var j=0; j<primeNumbers.length; j++){
    results+=j;
  }
 return results; 
}
Herman Fassett
@HermanFassett
Mar 14 2017 01:31
@revisualize is that just because you don't have an implicit var, let, const before x so it's treated global?
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:31
oooh
I get it.... I typed world instead of World
Herman Fassett
@HermanFassett
Mar 14 2017 01:32
@GodKingShogun is num perhaps less than 7? that would be infinite loop
Joseph
@revisualize
Mar 14 2017 01:32
@HermanFassett I don't know. I'm trying to figure stuff out.
@GodKingShogun That looks a lot like my solution.
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:33
So what is console.log for?
David Amanze
@GodKingShogun
Mar 14 2017 01:33
@HermanFassett the only num that i have to pass is 100
maryamshoraka
@maryamshoraka
Mar 14 2017 01:33
Hi All, I have question in basic javaScript section challenge "Profile Lookup". Can anyone give me a hint on my code please?

function lookUpProfile(firstName, prop){
// Only change code below this line
var message;
for(var i =0; i < contacts.length; i++)
{
if(contacts[i].firstName === firstName){
if(contacts[i].hasOwnProperty(prop)){
switch (prop){
case 'lastName':
message = contacts[i].lastName;
break;
case 'number':
message = contacts[i].number;
break;
case 'likes':
message = contacts[i].likes;
break;
}
}
else
message ="No such property";
}
else
message = "No such contact";

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

David Amanze
@GodKingShogun
Mar 14 2017 01:34
@revisualize @HermanFassett i know the code works in a way to get the prime number and add them up but its just that infinite loop that is preventing me from moving on
Herman Fassett
@HermanFassett
Mar 14 2017 01:35
Sorry if I'm slow, been only using C++/C lately for school.
David Amanze
@GodKingShogun
Mar 14 2017 01:35
@maryamshoraka format your code in between ``` for easy readability
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:35
@HermanFassett are you a CS student?
maryamshoraka
@maryamshoraka
Mar 14 2017 01:35
@GodKingShogun : sure thank you
CamperBot
@camperbot
Mar 14 2017 01:35
maryamshoraka sends brownie points to @godkingshogun :sparkles: :thumbsup: :sparkles:
:cookie: 152 | @godkingshogun |http://www.freecodecamp.com/godkingshogun
Herman Fassett
@HermanFassett
Mar 14 2017 01:35
@MathematicsCoding yeah
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:35
I see
So do you know about console.log? what are they for?
David Amanze
@GodKingShogun
Mar 14 2017 01:36
@revisualize how did your code differ from mine lol
Herman Fassett
@HermanFassett
Mar 14 2017 01:37
@GodKingShogun I would check out the while (k>=3) loop. What happens if the first value of k does not divide into i?
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:39
@HermanFassett you didnt answer my question :(
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 01:39
@rsenter1993 you got it?
Herman Fassett
@HermanFassett
Mar 14 2017 01:39
@MathematicsCoding console.log is a way of logging info/variables to the console so you can see output
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:40
okay
David Amanze
@GodKingShogun
Mar 14 2017 01:40
@HermanFassett i want nothing to happen so i didn't write it... do i have to write the else part
Herman Fassett
@HermanFassett
Mar 14 2017 01:40
If you run JavaScript code that has console.log in it you should be able to see the result in your browser console (Ctrl+Shift+J in chrome)
Saboor Malik
@MathematicsCoding
Mar 14 2017 01:41
I see
Thanks and cya eating dinner
Herman Fassett
@HermanFassett
Mar 14 2017 01:41
@GodKingShogun what's happening is that i == 7 the first time it enters that loop while k == 6, so i % k !== 0 meaning that it will infinitely run that loop since it won't ever decrement k.
David Amanze
@GodKingShogun
Mar 14 2017 01:41
@HermanFassett i attached an else statement for good measures but the infinite loop is still persistent on line six
Sahil Khetarpal
@sahilkpal
Mar 14 2017 01:42
Hello
Need help understanding Word Blanks
Alejandro A Barrera
@AlejandroBarrera01
Mar 14 2017 01:42
@rsenter1993 try this... var myStr="FirstLine\n\\SecondLine\\rThirdLine";
David Amanze
@GodKingShogun
Mar 14 2017 01:43
@sahilkpal concat the variables you are giving so noun adjective and so forth to strings of your own
Stephen James
@sjames1958gm
Mar 14 2017 01:43
@maryamshoraka Since you don't return when you find the firstName you will return the result of the last contact.
Also the switch is not needed contacts[i][prop] is the value to return
@AlejandroBarrera01 You should have a total of six \
David Amanze
@GodKingShogun
Mar 14 2017 01:43
@HermanFassett i ended up telling my code to continue if i%k!==0 but still not moving on... the real issue is the infinite loop at line 6 :worried:
maryamshoraka
@maryamshoraka
Mar 14 2017 01:44
@sjames1958gm : much appreciated
Sahil Khetarpal
@sahilkpal
Mar 14 2017 01:45
result = "myNoun"; + "myadjective"; + "myVerb"; + "myadverb";
?
David Amanze
@GodKingShogun
Mar 14 2017 01:45
@HermanFassett i dont even understand why i am getting an infinite loop lol
Herman Fassett
@HermanFassett
Mar 14 2017 01:45
I don't see an infinite loop at line 6...
David Amanze
@GodKingShogun
Mar 14 2017 01:47
@HermanFassett thats what i am being told when i try to run my code... im depressed lol
Herman Fassett
@HermanFassett
Mar 14 2017 01:47
Lol where does it say that at
Stephen James
@sjames1958gm
Mar 14 2017 01:48
@sahilkpal You're variable names are inside quotes - so they won't be processed as variables - you need to remove all but the last ;
David Amanze
@GodKingShogun
Mar 14 2017 01:48
@HermanFassett the part on the left were you look at your return
Herman Fassett
@HermanFassett
Mar 14 2017 01:48
Personally what I did was have a separate function to check if a number is prime. It makes the coding process a lot cleaner.
Stephen James
@sjames1958gm
Mar 14 2017 01:48
@GodKingShogun What does your code look like now?
Sahil Khetarpal
@sahilkpal
Mar 14 2017 01:48
ok thanks, let me try
David Amanze
@GodKingShogun
Mar 14 2017 01:49
@sjames1958gm it looks like this
function sumPrimes(num) {
 var counter=0;
 var primeNumbers= [2,3,5];
  var results=0;
  for (var i=7; i<=num; i++) {
    if (i%2===0){
      continue;
    } else if (i%2!==0){
      var k=i-1;
    while (k>=3){
        if (i%k===0) {
         counter+=1;
          k--;
        } else if (i%k!==0){
          continue;
        }
      }
       if (counter===0){
          primeNumbers.push(i);
       } else if (counter!==0) {
         counter=counter.defaultValue;
       }
    }
  }
  for (var j=0; j<primeNumbers.length; j++){
    results+=j;
  }
 return results; 
}
Herman Fassett
@HermanFassett
Mar 14 2017 01:49
If you fix the while loop it shouldn't be infinite loop
That continue isn't going to help
Stephen James
@sjames1958gm
Mar 14 2017 01:49
@GodKingShogun You don't need a condition in your else that is the opposite of your if that is confusing.
David Amanze
@GodKingShogun
Mar 14 2017 01:50
@sjames1958gm it doesn't hurt either way does it
Stephen James
@sjames1958gm
Mar 14 2017 01:50
@GodKingShogun You need to k-- every time through the loop not just in the if part
@GodKingShogun Its poor style
Feelthewind
@Feelthewind
Mar 14 2017 01:51

function chunkArrayInGroups(arr, size) {
var newArr = [];
var loopNum = arr.length / size;
var remainingNum = arr.length % size;

for (var i=0; i<loopNum; i++) {
newArr.push(arr.slice(sizei, size(i+1)));
}

if (remainingNum !== 0) {
newArr.push(arr.slice(size*(i+1), arr.length));
}

return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);

Stephen James
@sjames1958gm
Mar 14 2017 01:51
@GodKingShogun remove the else if in the while loop and move the k-- outside of the if part
Feelthewind
@Feelthewind
Mar 14 2017 01:51
i don't understand why this code adds an empty array at last.

function chunkArrayInGroups(arr, size) {
var newArr = [];
var loopNum = arr.length / size;
var remainingNum = arr.length % size;

for (var i=0; i<loopNum; i++) {
newArr.push(arr.slice(sizei, size(i+1)));
}

if (remainingNum !== 0) {
newArr.push(arr.slice(size*(i+1), arr.length));
}

return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);

the result is [[0,1,2,3],[4,5],[]]
Herman Fassett
@HermanFassett
Mar 14 2017 01:52
@GodKingShogun personally I would use a for loop to check for primality, especially since you only need to check up to the number's square root to mathematically deduce primality.
David Amanze
@GodKingShogun
Mar 14 2017 01:52
@sjames1958gm okay i got you
Stephen James
@sjames1958gm
Mar 14 2017 01:53
@Feelthewind loopNum is not an integer so i goes past the last part of the array.
you don't need the if check after the loop at all
David Amanze
@GodKingShogun
Mar 14 2017 01:53
@HermanFassett why did you say the continue isn't going to help... i read that it moves the loop to the next iteration
Herman Fassett
@HermanFassett
Mar 14 2017 01:53
@GodKingShogun exactly, so it's still in the while loop
Skipping a decrement
maryamshoraka
@maryamshoraka
Mar 14 2017 01:54

@sjames1958gm : would you mind to have a quick look please ?
```function lookUpProfile(firstName, prop){
// Only change code below this line
var message;
for(var i =0; i < contacts.length; i++)
{
message="";
if(contacts[i].firstName === firstName){
if(contacts[i].hasOwnProperty(prop)){
message = contacts[i][prop];
}
else
message ="No such property";
}
else
message = "No such contact";

}
return message;
// Only change code above this line
}```

Stephen James
@sjames1958gm
Mar 14 2017 01:55
@maryamshoraka When you set message when you get the firstName match - you need to stop looping at that point. (use break to exit loop
maryamshoraka
@maryamshoraka
Mar 14 2017 01:55
@sjames1958gm : Oh ok i got it
Herman Fassett
@HermanFassett
Mar 14 2017 01:56
Sorry I haven't done these exercises in forever
I did primes one and a half years ago
David Amanze
@GodKingShogun
Mar 14 2017 01:56
@HermanFassett if i want the code to do nothing and move on to the next statement can i leave it blank like this
function sumPrimes(num) {
 var counter=0;
 var primeNumbers= [2,3,5];
  var results=0;
  for (var i=7; i<=num; i++) {
    if (i%2===0){

    } else {
      var k=i-1;
    while (k>=3){
        if (i%k===0) {
         counter+=1;

        } else if (i%k!==0){

        }
      k--;
      }
       if (counter===0){
          primeNumbers.push(i);
       } else {
         counter=counter.defaultValue;
       }
    }
  }
  for (var j=0; j<primeNumbers.length; j++){
    results+=j;
  }
 return results; 
}
Herman Fassett
@HermanFassett
Mar 14 2017 01:56
Should stop infinite loop as long as you have that k-- there outside of the if :thumbsup:
Adam
@GoingAllTheWayUp
Mar 14 2017 01:56
is this codePen for the calculator redundent? or could this be common practice?
Herman Fassett
@HermanFassett
Mar 14 2017 01:57
?
David Amanze
@GodKingShogun
Mar 14 2017 01:58
@HermanFassett but can i leave it blank if i want it to do nothing or do i have to write return or something else
Herman Fassett
@HermanFassett
Mar 14 2017 01:59
You should be able to leave it blank. At least now you don't have an infinite loop.
David Amanze
@GodKingShogun
Mar 14 2017 02:00
@HermanFassett true. can you look at my counter=counter.defaultValue... i looked that up when i was searching for how to reset a variable back to its original number... did i do that right
Sahil Khetarpal
@sahilkpal
Mar 14 2017 02:00
result = "myNoun" + "myadjective" + "myVerb" + "myadverb";
did not work
Waldo Lavaut
@w86compositor
Mar 14 2017 02:01
Hi, I have a simple javascript exercise from Mark Myers book "A smarter way to learn javascript" cuz I don't understand or don't agree with his correct answer compared with mine. Anybody willing to to help me find out what's wrong?
Stephen James
@sjames1958gm
Mar 14 2017 02:01
@sahilkpal Your variables names are still strings - not variables
Herman Fassett
@HermanFassett
Mar 14 2017 02:01
@GodKingShogun no, counter has no property defaultValue. You should probably just reassign 0 to it
David Amanze
@GodKingShogun
Mar 14 2017 02:01
@sahilkpal you have to add strings in between the variables
Stephen James
@sjames1958gm
Mar 14 2017 02:01
@sahilkpal result = myNoun + " " +
David Amanze
@GodKingShogun
Mar 14 2017 02:03
@HermanFassett so simple writing counter=0; should suffice
Herman Fassett
@HermanFassett
Mar 14 2017 02:03
That will do what you're trying to do, can't verify the solution will be right tho
David Amanze
@GodKingShogun
Mar 14 2017 02:08
@HermanFassett lol now my code is working for one value but not working for a higher number... it is saying infinite loop at line six again
Herman Fassett
@HermanFassett
Mar 14 2017 02:08
:/
David Amanze
@GodKingShogun
Mar 14 2017 02:12
@HermanFassett it works for all numbers until 660 :worried:
anything higher returns infinite loop
John Nunns
@johnnunns
Mar 14 2017 02:13
need some help understanding why this works
function smallestCommons(arr) {
  var max = Math.max(...arr);
  var min = Math.min(...arr);
  var candidate = max;

  var smallestCommon = function(low, high) {
    // inner function to use 'high' variable
    function scm(l, h) {
      if (h % l === 0) {
        return h;
      } else {
        return scm(l, h + high);
      }
    }
    return scm(low, high);
  };

  for (var i = min; i <= max; i ++) {
    candidate = smallestCommon(i, candidate);
  }

  return candidate;
}
David Amanze
@GodKingShogun
Mar 14 2017 02:13
I dont deserve to live :cry:
John Nunns
@johnnunns
Mar 14 2017 02:13
it's driving me crazy
Herman Fassett
@HermanFassett
Mar 14 2017 02:14
@GodKingShogun code?
David Amanze
@GodKingShogun
Mar 14 2017 02:14
@HermanFassett nvm i wrote noprotect on the top line and it worked :smile:
Herman Fassett
@HermanFassett
Mar 14 2017 02:15
x)
David Amanze
@GodKingShogun
Mar 14 2017 02:15
@HermanFassett thanks
CamperBot
@camperbot
Mar 14 2017 02:15
godkingshogun sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1666 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Mar 14 2017 02:15
Yep
Adam
@GoingAllTheWayUp
Mar 14 2017 02:15
@johnnunns where did you find this way?
Herman Fassett
@HermanFassett
Mar 14 2017 02:15
;)
HermanFassett @HermanFassett saw that
John Nunns
@johnnunns
Mar 14 2017 02:16
@GoingAllTheWayUp I checked your solution and struggled hard to figure it out man
this solution was on stacksoverflow
Adam
@GoingAllTheWayUp
Mar 14 2017 02:16
I would start by nameing your variables something with meaning
That why I am confused. i kinda gett what ists doning but the inert names are killing me
John Nunns
@johnnunns
Mar 14 2017 02:17
It's not my solution
what I'm trying to do is take the two numbers and follow them through this answer and see how it even works
Herman Fassett
@HermanFassett
Mar 14 2017 02:18
Are you familiar with recursion?
That's the basis of their answer kind of
Adam
@GoingAllTheWayUp
Mar 14 2017 02:18
I would name the variables better, imho
Herman Fassett
@HermanFassett
Mar 14 2017 02:18
Also a function in a function in a function xD
John Nunns
@johnnunns
Mar 14 2017 02:19
I acttually think I'm really slow with recursion right now
yeah it's driving me nuts man
oscar carrillo
@oscarrillo90
Mar 14 2017 02:19
can i get some help with this problem please
// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line
var processed = 2;

function processArg(num) {
  return (num + 3) / 5;
}
John Nunns
@johnnunns
Mar 14 2017 02:20
I'm reading the function, and then looking where it's called in another function, and having to piece it all together
Adam
@GoingAllTheWayUp
Mar 14 2017 02:20
yeah, in this case useing the elucidean would reqiure you to pass it through itself in this case. but thats just function of the math @johnnunns
John Nunns
@johnnunns
Mar 14 2017 02:20
ready to rip my hair out and be bald for a few months :joy:
Herman Fassett
@HermanFassett
Mar 14 2017 02:20
It'd be easier to understand if it was iteration
John Nunns
@johnnunns
Mar 14 2017 02:20
Adam I think where my disconnect is that you can't call your euclidian function and it bring the gcf by itself
oscar carrillo
@oscarrillo90
Mar 14 2017 02:20
the instructions say to: Call the processArg function with an argument of 7 and assign its return value to the variable processed.
Herman Fassett
@HermanFassett
Mar 14 2017 02:21
@oscarrillo90 so see the line changed = change(10);? It'll be a lot like that though changed will be processed, etc.
change( will be processArg(
Stephen James
@sjames1958gm
Mar 14 2017 02:22
@oscarrillo90 Don't redefined the function
Herman Fassett
@HermanFassett
Mar 14 2017 02:22
Yeah should be single line of code if I remember right
Adam
@GoingAllTheWayUp
Mar 14 2017 02:23
Its the case of the wheel or carriage what's that important to know and whats not. @johnnunns how far do you want to take it? I think its ok for now.
Shanta Nathwani
@TantienHime
Mar 14 2017 02:23
@revisualize concatenation? how does that fit in?
John Nunns
@johnnunns
Mar 14 2017 02:24
@GoingAllTheWayUp haha the problem is I literally copied and pasted that solution
Adam
@GoingAllTheWayUp
Mar 14 2017 02:24
I was familar with the idea before hand, seeing it again just opend me up a little more to constructing it in javascript
Its the case of the wheel and the carriage. for instence there is a video here on FCC about binary but not one on elucidean
John Nunns
@johnnunns
Mar 14 2017 02:26
var smallestCommon = function(low, high) {
    // inner function to use 'high' variable

      if (high % low === 0) {
        return high;
      } else {
        return smallestCommon(low, high + high);
      }

  };
so if I tweak the smallestCommon function to not have a function in it
which I see is doing vitually the same thing, I get maximum call stack error
Saboor Malik
@MathematicsCoding
Mar 14 2017 02:27
How can I test javascript? like trying create some code and test it
Stephen James
@sjames1958gm
Mar 14 2017 02:27
@MathematicsCoding I use jsbin.
John Nunns
@johnnunns
Mar 14 2017 02:27
I've read maximum call stack error more than I can count haha
Herman Fassett
@HermanFassett
Mar 14 2017 02:27
You could test it in your console, jsbin, or I sometimes use repl.it
Saboor Malik
@MathematicsCoding
Mar 14 2017 02:27
What about brackets?
Herman Fassett
@HermanFassett
Mar 14 2017 02:28
Yeah you could use brackets to edit code and then run it somewhere. Not sure if it has integrated haven't used it much.
Stephen James
@sjames1958gm
Mar 14 2017 02:28
@MathematicsCoding I don't know - it might depend on if you need some browser APIs
Adam
@GoingAllTheWayUp
Mar 14 2017 02:29
function euclidean (integerMax, integerLower) {
    if (integerLower === 0)
        return integerMax;
    else
        return euclidean(integerLower, integerMax%integerLower);
    }
Saboor Malik
@MathematicsCoding
Mar 14 2017 02:29
Nvm jsbin is better
Thanks
John Nunns
@johnnunns
Mar 14 2017 02:30
yeah adam that by itself will not return the greatest common denominator
Saboor Malik
@MathematicsCoding
Mar 14 2017 02:30
... jsbin output is different from output...
Stephen James
@sjames1958gm
Mar 14 2017 02:30
@MathematicsCoding output is the web page output - console is the console
Adam
@GoingAllTheWayUp
Mar 14 2017 02:31
I did this
var GreatestCommonDemoninator = euclidean(lestCommonMultiplyer, rangeLCM[j]);
Herman Fassett
@HermanFassett
Mar 14 2017 02:31
If I have quick stuff to test I do it right in the browser console
Adam
@GoingAllTheWayUp
Mar 14 2017 02:31
var lestCommonMultiplyer = rangeLCM[0];
inside a loop for j
oscar carrillo
@oscarrillo90
Mar 14 2017 02:32
@HermanFassett thanks bro
CamperBot
@camperbot
Mar 14 2017 02:32
oscarrillo90 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1667 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Ronald Johnson
@ronnieg1988
Mar 14 2017 02:32
function isLess(a, b) {
  // Fix this code
   return a === b; 


  }

// Change these values to test
isLess(10, 15);
how do i make this to return 10, 15 as true?
Stephen James
@sjames1958gm
Mar 14 2017 02:32
@ronnieg1988 You needed to keep the old comparison (it matches the name of the functoin)
Ronald Johnson
@ronnieg1988
Mar 14 2017 02:35
@sjames1958gm thank you
CamperBot
@camperbot
Mar 14 2017 02:35
ronnieg1988 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6157 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Alex G
@glazey132
Mar 14 2017 02:36
sorry to bring up destroyer again but i deleted my code to retry it. I'm pretty close but my code is returning an empty array. anyone know why?

function destroyer(arr) {
var args = arr.slice.call(arguments);
var destroyers = arr.slice(1, arr.length);

return arr.filter(function(val) {

if (destroyers.indexOf(val) === -1) {
return false;
}
else {
return false;
}
});
}

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

Stephen James
@sjames1958gm
Mar 14 2017 02:36
@glazey132 why are you always returning false?
John Nunns
@johnnunns
Mar 14 2017 02:40
alright what about this?

  smallestCommon = function(low, high) {


    if(high%low===0){
    return low;
  }else{
    return smallestCommon(low,high+5);
  }
}


smallestCommon([1,5]);
why on earth does thhis return max stacks?
the first if statement is true as well why would it even bother screwing up?
Alex G
@glazey132
Mar 14 2017 02:43
@sjames1958gm oops. I tried switching them around and forgot to put back to original. original code had return true in the if statement
still get an empty earray
David Shin
@datadaveshin
Mar 14 2017 02:44
@glazey132 yes, @sjames1958gm is right, your returned array from filter will always be empty if the only boolean value deciding the fate of each element is false
Alex G
@glazey132
Mar 14 2017 02:44
array*
@datadaveshin agreed and i see why but my original code had return true in the if statement.
oscar carrillo
@oscarrillo90
Mar 14 2017 02:46
function nextInLine(arr, item) {
  // Your code here

  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));
How do i 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.
Alex G
@glazey132
Mar 14 2017 02:46
i was trouble shooting and tried switching the returns around. forgot to change the first return back before pasting
Margaret
@Margaret2
Mar 14 2017 02:47
@oscarrillo90 do you remember which functions you can use to add or remove items from an array?
oscar carrillo
@oscarrillo90
Mar 14 2017 02:50
@Margaret2 not really
Margaret
@Margaret2
Mar 14 2017 02:51
oscar carrillo
@oscarrillo90
Mar 14 2017 02:52
@Margaret2 thank you
CamperBot
@camperbot
Mar 14 2017 02:52
oscarrillo90 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 2028 | @margaret2 |http://www.freecodecamp.com/margaret2
Saboor Malik
@MathematicsCoding
Mar 14 2017 02:52
to add = push and to remove either shift or pop but shift remove first element and pop remove last
Joel
@MMK123
Mar 14 2017 03:01
var code = "
whoops
can you guys help me with something?
can you tell me what's wrong here:
var myStr = "FirstLine\n\SecondLine\r\ThirdLine";
hello?
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:05
function fun1() {
  // Assign 5 to oopsGlobal Here

}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
Herman Fassett
@HermanFassett
Mar 14 2017 03:05
You need to escape the back sequences
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:05
I passed but I dont understand that code
Joel
@MMK123
Mar 14 2017 03:05
escape the back sequences... not sure what that means
Adam
@GoingAllTheWayUp
Mar 14 2017 03:06
is this Build a JavaScript Calculator too redundent or thick?
Herman Fassett
@HermanFassett
Mar 14 2017 03:07
@MMK123 to get a backslash to appear in a string you need to escape it... Did you thoroughly read the lesson? Should be like \\ to get a backslash in a string
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:14
How to add local variable?
Herman Fassett
@HermanFassett
Mar 14 2017 03:16
var globalvar;
...
{
    var localvar;
}
...
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:17
function myLocalScope() {
  'use strict';



}
myLocalScope(myVar);
Joel
@MMK123
Mar 14 2017 03:17
@HermanFassett thanks, that was it
CamperBot
@camperbot
Mar 14 2017 03:17
mmk123 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1668 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Mar 14 2017 03:18
@MathematicsCoding defining a var in a function means it is local to that function. That's all you need to do.
My pleasure @MMK123
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:19
Well how do I do that?
I mean it said "Add a local myVar variable"
with myVar?
Herman Fassett
@HermanFassett
Mar 14 2017 03:20
There should be an example of creating a local variable in the lesson text
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:20

function myTest() {
  var loc = "foo";
  console.log(loc);
}
myTest(); // "foo"
console.log(loc); // "undefined"

function myTest() {
  var myVar = "foo";
  console.log(myVar);
}
myTest(); // "foo"
console.log(myVar); // "undefined"
Like that?
Herman Fassett
@HermanFassett
Mar 14 2017 03:21
Yeah. Then I think you have to remove that last console.log to actually pass the lesson.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:21
Okay
function myLocalScope() {
  var myVar = "foo";
  console.log(myVar);
}
myTest();
Do I need to remove that myTest();
Herman Fassett
@HermanFassett
Mar 14 2017 03:23
myTest should be undefined in that scope, though you might be able to pass the exercise with it anyway.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:23
... it worked
why myTest?
oooh Because of that myTest();
Forgot to change :p
Herman Fassett
@HermanFassett
Mar 14 2017 03:24
;)
oscar carrillo
@oscarrillo90
Mar 14 2017 03:25
function nextInLine(arr, item) {
  // Your code here

  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));
How do i 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.
khaggag
@khaggag
Mar 14 2017 03:25
Hey, I am really stuck in the same thing as @oscarrillo90
Herman Fassett
@HermanFassett
Mar 14 2017 03:27
@oscarrillo90 and @khaggag you'll need to use the array functions push and shift.
Push will add an item/element to the end of an array and shift will remove the first element from an array as well as returning the removed element.
Usman Akram
@usmanakram1996
Mar 14 2017 03:28

hey there i have done the first two test cases how can i do the last https://www.freecodecamp.com/challenges/wherefore-art-thou

help plz

*last two
Herman Fassett
@HermanFassett
Mar 14 2017 03:30
@usmanakram1996 any code to share?
Joseph
@revisualize
Mar 14 2017 03:30

@oscarrillo90 Gist by revisualize / FreeCodeCamp - Stand in Line.js

// How do you add a number (item) to the end of an array (arr)? What does this method return?
// How do you remove the first element from an array (arr)? What does this method return?

You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

You just need to add a number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).
But, there is another part of this challenge. You need to know What the methods that do those two things return.

Usman Akram
@usmanakram1996
Mar 14 2017 03:31

@HermanFassett
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line

arr = collection.filter(function (items)
{
return(items.last === source.last);

});

return arr;
// Only change code above this line
//return source;
}

whatIsInAName(
// collection object

[{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

khaggag
@khaggag
Mar 14 2017 03:32
@HermanFassett would you please hint me to how to assign the testArr to nextInLine, because I attempted that and then used .push and .shift but still didn't work?
Herman Fassett
@HermanFassett
Mar 14 2017 03:34
@usmanakram1996 you need to check against all values in the second argument
Also you'll probably want to use hasOwnProperty to make this generic
@khaggag testArr is sent in through a function call. You shouldn't use its name explicitly in the function itself since it can be passed by value to the parameters
Do you have code you've tried?
khaggag
@khaggag
Mar 14 2017 03:36
yeah

function nextInLine(arr, item) {
var nextInLine=testArr;
item=nextInLine.push();

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

Joseph
@revisualize
Mar 14 2017 03:37
@khaggag Okay a few things. you shouldn't be using testArr inside of your function.
Herman Fassett
@HermanFassett
Mar 14 2017 03:37
@khaggag you should be doing everything on your arr argument. testArr is simply an array that is being passed by value to the function. These values will be held in the arr parameter. Might need to go back and make sure you understand how functions work.
Joseph
@revisualize
Mar 14 2017 03:38
@HermanFassett How's Yuki?
Herman Fassett
@HermanFassett
Mar 14 2017 03:39
?
Joseph
@revisualize
Mar 14 2017 03:39
Yuki-ma
Herman Fassett
@HermanFassett
Mar 14 2017 03:39
err
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:40
Joseph
@revisualize
Mar 14 2017 03:40
@HermanFassett My friend that used to live over there moved to Idaho and he messaged me about a job opening over where he's at now. I'm hoping I hear back from it.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:40
lol I dont remember which anime but I have heard the name "Yuki" before
Herman Fassett
@HermanFassett
Mar 14 2017 03:41
Lol I get it now...
Took me awhile to realize what you meant lol
Yeah, it's good. I'm looking at a few job options here, though I might end up in Seattle. Hoping to stay either in Yakima or tri-cities area though.
Joseph
@revisualize
Mar 14 2017 03:42
@HermanFassett I hear that there are a lot of options in Tri-Cities.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:42
Hey remember that actor from "Home-alone?"
Herman Fassett
@HermanFassett
Mar 14 2017 03:42
Yeah, I had an internship last summer in Tri-Cities. Really enjoyed it and the area.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:43
Ok... Don't mind me...
Herman Fassett
@HermanFassett
Mar 14 2017 03:43
x) which actor...
Joseph
@revisualize
Mar 14 2017 03:43
@HermanFassett Seattle is rough.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:43
:walking: :station:
@HermanFassett That boy..
Herman Fassett
@HermanFassett
Mar 14 2017 03:43
Yeah
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:43
And present that actor is addicted to heroin
I found an image saying he got 6 months to live not sure if it is true...
Herman Fassett
@HermanFassett
Mar 14 2017 03:44
@revisualize yep, looking hopeful for this area, so I probably won't do Seattle unless the pay is just that much better.
Joseph
@revisualize
Mar 14 2017 03:44
@HermanFassett I've been thinking about maybe getting a new job and I've been looking at the options out there. And I'm getting no where.
@HermanFassett Rents here in Seattle start at 1700.00 a month for most apartments.
Herman Fassett
@HermanFassett
Mar 14 2017 03:44
Yeah, most of my job options out here have been made through connecting with people.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:45
So seattle is expensive..
Herman Fassett
@HermanFassett
Mar 14 2017 03:45
Yeah ikr
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:45
1700 a month for apt.
Herman Fassett
@HermanFassett
Mar 14 2017 03:45
Maybe I could live with my Grandma lol, she lives somewhere over there.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:45
xD
Joseph
@revisualize
Mar 14 2017 03:45
@MathematicsCoding That's for a small apartment.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:45
Same thing..
Difference the size yeah...
have you read Of Sound Mind?
Herman Fassett
@HermanFassett
Mar 14 2017 03:46
I haven't
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:46
I see
Why did I bring that up? well I think i heard about seattle from that book something a girl moved to philiphia from seattle
Joseph
@revisualize
Mar 14 2017 03:47
@MathematicsCoding There is a 370sq ft studio open in the building next to me that is 1100.00 month
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:47
I wish this chat have spelling correct... autocorrect
Herman Fassett
@HermanFassett
Mar 14 2017 03:47
Lol, you heard about Seattle from a novel?
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:47
I dont think its a novel
Herman Fassett
@HermanFassett
Mar 14 2017 03:48
lol ok
book
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:48
Yeah
revisualize @revisualize goes afk.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:48
fiction one
..
How did you do that? with color
Herman Fassett
@HermanFassett
Mar 14 2017 03:48
/me doesn't know
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:49
@HermanFassett goes afk.
Herman Fassett
@HermanFassett
Mar 14 2017 03:49
xd
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:49
rip
HermanFassett @HermanFassett doesn't know
MathematicsCoding @MathematicsCoding help
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:49
I see
HermanFassett @HermanFassett nods
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:49
Huh
Liu, Kuichen
@Kuichen
Mar 14 2017 03:50
Hi there, could someone please explain to me what does this function do? I've never met these kind of statement syntax before.
function combine(current, fromMother, fromFather) {
var thisOneCounts = current != person && test(current);
return fromMother + fromFather + (thisOneCounts ? 1 : 0);
}
Herman Fassett
@HermanFassett
Mar 14 2017 03:50
Are you talking about the ternary operator - ? : stuff?
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:51
Jean Ferris
You know that woman? She is the one who wroted Of Sound Mind
Liu, Kuichen
@Kuichen
Mar 14 2017 03:51
yeah
Herman Fassett
@HermanFassett
Mar 14 2017 03:52
@Kuichen ?: acts kind of like an if else statement.
var a = 4;
var b = 6;
if (a == 4) {
    b = 5;
} else {
    b = 7;
}
// This is the same as writing:
b = (a == 4) ? 5 : 7;
It's called the ternary operator if I remember right, since it's the only operator with three inputs (as opposed to a unary operator such as ++ or a binary operator such as +)
Liu, Kuichen
@Kuichen
Mar 14 2017 03:54
oh I see. Thanks Herman. and how about this line: var thisOneCounts = current != person && test(current); is it another kind of ternary operator?
thanks @HermanFassett I will read the doc.
CamperBot
@camperbot
Mar 14 2017 03:55
kuichen sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1669 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Mar 14 2017 03:55
@Kuichen that's just assigning a boolean value to thisOneCounts. The result of current != person && test(current) will be either true or false.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:56
@HermanFassett have you created any app for iOS?
Herman Fassett
@HermanFassett
Mar 14 2017 03:56
Nope, shudders
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:56
:p
Herman Fassett
@HermanFassett
Mar 14 2017 03:56
x) I'm kidding (sort of) but I'm an Android guy
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:56
well you are learning C++ / C# right?
Liu, Kuichen
@Kuichen
Mar 14 2017 03:56
@HermanFassett got it, thanks again! :smile:
CamperBot
@camperbot
Mar 14 2017 03:56
kuichen sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:warning: kuichen already gave hermanfassett points
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:56
IOS is written by them
Herman Fassett
@HermanFassett
Mar 14 2017 03:57
@MathematicsCoding I've done a lot of C# in the past and I've been doing a lot of C/C++ currently
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:57
oh
Well what are the difference between them?
C/C++?
Herman Fassett
@HermanFassett
Mar 14 2017 03:58
Well C is a procedural language while C++ is Object Oriented (well technically a mix of the two)
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:58
Mind Blown
Herman Fassett
@HermanFassett
Mar 14 2017 03:58
So no classes or objects etc in C
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:58
Mind Recovered
I survived
Herman Fassett
@HermanFassett
Mar 14 2017 03:58
Oh good, thought I'd lost you for a moment.
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:59
Thanks
For paying the hospital bill'
Was recovering pretty quick
So... what was the cost? no offense
Herman Fassett
@HermanFassett
Mar 14 2017 03:59
Yeah almost called 1001-1-1
Saboor Malik
@MathematicsCoding
Mar 14 2017 03:59
999?
Herman Fassett
@HermanFassett
Mar 14 2017 04:00
911
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:00
oh
How does that equal 911?
Herman Fassett
@HermanFassett
Mar 14 2017 04:00
I wasn't treating it as subtraction
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:00
yea
Herman Fassett
@HermanFassett
Mar 14 2017 04:00
1001 is 9 in binary
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:01
oh
I see
Herman Fassett
@HermanFassett
Mar 14 2017 04:01
so 1001 - 1 - 1
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:01
911
Herman Fassett
@HermanFassett
Mar 14 2017 04:01
Yeah
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:01
So why is 1001 means 9 in binary?
Herman Fassett
@HermanFassett
Mar 14 2017 04:02
Uh, go learn binary xD
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:02
:p
Where did you learn them? which language?
Herman Fassett
@HermanFassett
Mar 14 2017 04:02
That's like machine level stuff lol
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:03
:p
Seth Church
@iEnder
Mar 14 2017 04:03
U mean you dont program in binary regularly? pff
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:03
Of course they teach them in CS
Herman Fassett
@HermanFassett
Mar 14 2017 04:03
What code is compiled into for the computer to interpret. I had to learn it for my Assembly language class.
Seth Church
@iEnder
Mar 14 2017 04:03
the only keyboard ill ever need http://i.imgur.com/0oOO3.jpg
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:04
LOL
Herman Fassett
@HermanFassett
Mar 14 2017 04:04
@pkmn9060 props
You're a better coder than I
x)
Seth Church
@iEnder
Mar 14 2017 04:04
:b:
Jim
@JLOSS1
Mar 14 2017 04:04
binary talk gives me anxiety.
Seth Church
@iEnder
Mar 14 2017 04:04
lmao
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:04
Disable all the keys except 1 and 0 well delete and enter too...
Herman Fassett
@HermanFassett
Mar 14 2017 04:04
naw 0 is delete, 1 is enter
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:05
Hm
Seth Church
@iEnder
Mar 14 2017 04:05
there is no backspace in binary programming obv if you screw up after 300000 digits you gotta start over
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:05
lol
1001101
Seth Church
@iEnder
Mar 14 2017 04:06
:O do you talk to your mother with those bits?
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:06
1001101?
Lmfao I got 18 tabs on now
Herman Fassett
@HermanFassett
Mar 14 2017 04:07
Byte me
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:08
Most of them are related to javascript and some stuff about programming
Researching... and some text editor
Oh yeah netflix
Herman Fassett
@HermanFassett
Mar 14 2017 04:08
I'm studying for my Operating Systems final tomorrow
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:08
...
Well study then lol
Herman Fassett
@HermanFassett
Mar 14 2017 04:08
No, I only come here if I have way more important things to do
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:08
oh
GL with OS final tomorrow
Herman Fassett
@HermanFassett
Mar 14 2017 04:09
TY
Seth Church
@iEnder
Mar 14 2017 04:09
OS final? sounds fun have you discovered the gospel that is windows ME
Herman Fassett
@HermanFassett
Mar 14 2017 04:10
xD studying memory management atm like virtual mem and paging etc. Haven't talked much about the gospel.
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:10
Cant wait for video challenges...
There is CS.... Coming Soon ugh
Seth Church
@iEnder
Mar 14 2017 04:11
theres early features on http://beta.freecodecamp.com/en/map kinda buggy with es6 though
const breaks everything
Jeremy
@JeremyAntonoff
Mar 14 2017 04:12
function factorialize(num) {
  x = 1;
  z = 1;
  while (x <= num) {
    y = x * (z + x);
    x++;
      }
  return y;
}

factorialize(5);
can someone help me
Saboor Malik
@MathematicsCoding
Mar 14 2017 04:12
LOL
Did anyone follow viral_tips on Instragam?
Well if someone doesnt and you should!'
Cya
Good Night guys
Herman Fassett
@HermanFassett
Mar 14 2017 04:15
gnight
:zzz:
@JToddFL so what is Z even doing?
Jim
@JLOSS1
Mar 14 2017 04:16
anyone got a second? I don't understand what's wrong with why i'm putting in...
var string = "Split me into an array";
var array = [];

// Only change code below this line.

var array = string.split(\s);
Herman Fassett
@HermanFassett
Mar 14 2017 04:16
Also, it's good practice to declare vars before using them, otherwise they're initialized as global.
@JLOSS1 well, you can't just have \s in the open like that!
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:17
Hello!
Herman Fassett
@HermanFassett
Mar 14 2017 04:17
Hi @WaffleTrapHouse
Jeremy
@JeremyAntonoff
Mar 14 2017 04:17
z is making it so its 1 2 then 2 3 then 3 * 4
etc
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:17
I need help with the challenge "Escaping Literal Quotes in Strings"
Jim
@JLOSS1
Mar 14 2017 04:17
@HermanFassett argh...
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:17
Anybody willing to offer help?
Herman Fassett
@HermanFassett
Mar 14 2017 04:17
@WaffleTrapHouse sure, post what you have.
@JToddFL well from what I see, Z is always 1 in your code
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:17
@HermanFassett var myStr = "I am a \"double quoted" string inside "double quotes"\"".";
Jim
@JLOSS1
Mar 14 2017 04:18
@HermanFassett I got it. haha thanks!
CamperBot
@camperbot
Mar 14 2017 04:18
jloss1 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1670 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Jeremy
@JeremyAntonoff
Mar 14 2017 04:18
yes but x changes
Herman Fassett
@HermanFassett
Mar 14 2017 04:18
Ooh @JToddFL Okay I see what you're trying to do
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:18
I need to make this occur: I am a "double quoted" string inside "double quotes".
Herman Fassett
@HermanFassett
Mar 14 2017 04:18
@WaffleTrapHouse are you escaping ALL the double quotes inside the double quotes?
Jeremy
@JeremyAntonoff
Mar 14 2017 04:18
@HermanFassett its prob the dumbest way ever lol but its all i could think of. Not that great with math
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:19
I wouldn't know due to my severe confusion @HermanFassett
Herman Fassett
@HermanFassett
Mar 14 2017 04:19
@JToddFL yeah I'd recommend just creating an x and y, incrementing x and multiplying it to y up to num...
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:19
I set up double quotes around the entire thing in order to make it into one big text
and the I planned to break down the insides so the internal double quotes would still show
Herman Fassett
@HermanFassett
Mar 14 2017 04:20
x := 1
y := 1
while x is less than num:
    x := x + 1
    y := x * y
ret y
@JToddFL some pseudocode you could try to follow
Jeremy
@JeremyAntonoff
Mar 14 2017 04:21
@HermanFassett ok thank you herman let me see if i can figure it out
CamperBot
@camperbot
Mar 14 2017 04:21
jtoddfl sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1671 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Mar 14 2017 04:21
@WaffleTrapHouse from what I saw it looks like you might have to many double quotes or missing some escape slashes
var exampleDoubleQuotes = "Here are some \"double\" quotes";
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:21
@HermanFassett That's what I figured but i can't find my mistakes
So my overlaying quotes are fine
As in the ones that surround the entire text, right?
Rob Tieffenbacher III
@Tiff32
Mar 14 2017 04:22

brain is just dead on this.

var myVar = 87;

// Only change code below this line
myVar = myVar + 1;

Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:23
OHHHH! I GET IT!
Herman Fassett
@HermanFassett
Mar 14 2017 04:23

With this:

var myStr = "I am a \"double quoted" string inside "double quotes"\"".";

the string will stop after the " after quoted, since it isn't escaped ...

Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:23
I did not learn that the 2nd slash goes before the double quote
Herman Fassett
@HermanFassett
Mar 14 2017 04:23
:)
Tejinder Mann
@TJTheRandomCoder
Mar 14 2017 04:23
Now I know!
Thanks a lot @HermanFassett
CamperBot
@camperbot
Mar 14 2017 04:23
waffletraphouse sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1672 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Mar 14 2017 04:23
@Tiff32 what are you supposed to do?
Yep!
Rob Tieffenbacher III
@Tiff32
Mar 14 2017 04:24
@HermanFassett Change the code to use the ++ operator on myVar
Herman Fassett
@HermanFassett
Mar 14 2017 04:24
@Tiff32 so do they give an example of the ++ operator in use? Just replace myVar = myVar + 1 with the given usage on myVar.
Rob Tieffenbacher III
@Tiff32
Mar 14 2017 04:25
@HermanFassett it just says that the entire line becomes i++:
Herman Fassett
@HermanFassett
Mar 14 2017 04:26
So if i is the variable used in the example, then replace i with myVar in your code
Rob Tieffenbacher III
@Tiff32
Mar 14 2017 04:27
so i doesn't mean anything other than an increment?
oh man overthought that one hard
Herman Fassett
@HermanFassett
Mar 14 2017 04:28
i++ is the same as writing i = i + 1 so it's the variable being incremented...
Rob Tieffenbacher III
@Tiff32
Mar 14 2017 04:28
ah. Brain fart. Thanks @HermanFassett
CamperBot
@camperbot
Mar 14 2017 04:28
tiff32 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1673 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Mar 14 2017 04:29
Yep
Joseph
@revisualize
Mar 14 2017 04:29
var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8
See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.
Herman Fassett
@HermanFassett
Mar 14 2017 04:29
:)
Now let's talk about ++i vs i++
x) jk I don't want to
Joseph
@revisualize
Mar 14 2017 04:37
I don't understand the point of ++i vs i++ for everything that I'm doing i++ is fine.
Herman Fassett
@HermanFassett
Mar 14 2017 04:38
I haven't come across a situation I've needed it in JS, but I've used it to reduce a few lines of code in C++/C
I've also heard claims that ++i can sometimes be faster system dependent but I dunno
Seth Church
@iEnder
Mar 14 2017 04:40
its like (function(){...})() vs (function(){...}()) just preference I guess though tbh I've never really heard of / used ++i
Herman Fassett
@HermanFassett
Mar 14 2017 04:40
It's different than preferences technically...
Seth Church
@iEnder
Mar 14 2017 04:40
o?
Herman Fassett
@HermanFassett
Mar 14 2017 04:40
I mean they do different things
I've used it mostly when I'm accessing an array index with a counter
Seth Church
@iEnder
Mar 14 2017 04:41
o ye ++i returns next number and i++ returns current
Herman Fassett
@HermanFassett
Mar 14 2017 04:41
like array[++i] vs array[i++]
cameron nicklaus
@camnicklaus
Mar 14 2017 04:45
anybody got tips for how to bring the keyboard into focus as soon as a page loads so that document.addEventListener('keydown', function() {}); will work before clicking on the screen?
Herman Fassett
@HermanFassett
Mar 14 2017 04:46
Maybe give a tab index or make sure your key function is inside an onload function? idk
cameron nicklaus
@camnicklaus
Mar 14 2017 04:47
@HermanFassett thanks, I'll give that a try
CamperBot
@camperbot
Mar 14 2017 04:47
camnicklaus sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 1674 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Joseph
@revisualize
Mar 14 2017 04:59
about @revisualize
CamperBot
@camperbot
Mar 14 2017 04:59
:star2: 3521 | @revisualize |http://www.freecodecamp.com/revisualize
Herman Fassett
@HermanFassett
Mar 14 2017 05:00
cool
xd
Jeremy
@JeremyAntonoff
Mar 14 2017 05:06
@HermanFassett can you help me with one more thing
Herman Fassett
@HermanFassett
Mar 14 2017 05:06
Sure
Vivian Chen
@chrysophyta
Mar 14 2017 05:07
hi I'm new here
I have a question for people who tried the javascript tutorials:
Is javascript tutorials in FreeCodeCamp using ES6?
Joseph
@revisualize
Mar 14 2017 05:07
@chrysophyta No
Herman Fassett
@HermanFassett
Mar 14 2017 05:07
@chrysophyta no not currently. There's some es6 stuff in development I believe
Joseph
@revisualize
Mar 14 2017 05:07
@chrysophyta Currently they are not. Everything is currently ES5.
@chrysophyta But, when the beta gets pushed to the site there is an ES6 section
@HermanFassett @chrysophyta http://beta.freecodecamp.com/map/
Jeremy
@JeremyAntonoff
Mar 14 2017 05:08
1 sec
Herman Fassett
@HermanFassett
Mar 14 2017 05:08
You can still do some es6 in the exercise space if you want tho
Vivian Chen
@chrysophyta
Mar 14 2017 05:09
okay thanks @revisualize and @HermanFassett
CamperBot
@camperbot
Mar 14 2017 05:09
chrysophyta sends brownie points to @revisualize and @hermanfassett :sparkles: :thumbsup: :sparkles:
:star2: 3522 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1676 | @hermanfassett |http://www.freecodecamp.com/hermanfassett
Vivian Chen
@chrysophyta
Mar 14 2017 05:10
i'm just browsing all the tutorials that i can find and I was wondering if I have to learn ES6 in separate tutorias
Jeremy
@JeremyAntonoff
Mar 14 2017 05:10
@HermanFassett you still there
Herman Fassett
@HermanFassett
Mar 14 2017 05:11
Yeah
Jeremy
@JeremyAntonoff
Mar 14 2017 05:11
@HermanFassett is there an easier way to filter out all the non alpha numeric characters plus punctuation then how i did this
function palindrome(str) {
  // Good luck!
  var array = str.split("");
  var reverseArray = array.reverse();
  reverseArray = reverseArray.filter(function(val) {
    return val !== ("_");
  });
  answer = reverseArray.join("");
  answer = answer.replace(/^[^A-Z0-9]+|[^A-Z0-9]+$/ig, '');
  answer = answer.replace(/\s/g, "");
  answer = answer.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"");
  str = str.replace(/\s/g, "");
  str = str.replace(/^[^A-Z0-9]+|[^A-Z0-9]+$/ig, '');
  str = str.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"");
  if (answer.toLowerCase() === str.toLowerCase()) {
    return true;
  }
  else {
    return false;
  }
}



palindrome("A man, a plan, a canal. Panama");
Joseph
@revisualize
Mar 14 2017 05:11
@chrysophyta You can use ES6 on FCC currently. You can even take the lessons on the beta. They just won't transfer over to the live site.
Herman Fassett
@HermanFassett
Mar 14 2017 05:11
@JToddFL yes
Joseph
@revisualize
Mar 14 2017 05:11
@JToddFL YES!
Herman Fassett
@HermanFassett
Mar 14 2017 05:11
like 1 line
Joseph
@revisualize
Mar 14 2017 05:11
\W_
Jeremy
@JeremyAntonoff
Mar 14 2017 05:12
just that are u serious
Herman Fassett
@HermanFassett
Mar 14 2017 05:12
\W|_
Jeremy
@JeremyAntonoff
Mar 14 2017 05:12
and then /gi, ""
?
Joseph
@revisualize
Mar 14 2017 05:12
You could have used ^A-Za-z0-9
Richard Belotte
@belotte
Mar 14 2017 05:12

Hello. So I am stuck on something that seems like it should be pretty elemental. Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.


function largestOfFour(arr) {
  var num = [];
  //var num2 = 0;
  // You can do this!
  for(var i = 0; i < arr.length; i++){
    //console.log(arr[i]);
    //return arr[i];
    for(var j = 0; j < arr[i].length; j++){
      num[i] = arr[i][j];
      console.log(num[i]);
    } 
  }
  //return arr;
}

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

I'm trying to figure out how to compare the array elements. Seems like I should be storing one and getting the next and comparing the 2 but I'm not sure how to store one and then get the next.

Joseph
@revisualize
Mar 14 2017 05:12
@JToddFL
function palindrome(str) {
  str = str.toLowerCase().replace(/[\W_]/g, ""); // also [^A-Za-z0-9]
  return str === str.split("").reverse().join("");
}
Herman Fassett
@HermanFassett
Mar 14 2017 05:13
xd
Jeremy
@JeremyAntonoff
Mar 14 2017 05:15
@HermanFassett i tried this and it doesnt pass
@joseph i mean

function palindrome(str) {
  // Good luck!
  var array = str.split("");
  var reverseArray = array.reverse();
  reverseArray = reverseArray.filter(function(val) {
    return val !== ("_");
  });
  answer = reverseArray.join("");
  answer = answer.replace(/[\W_]/, "");
  str = str.replace(/[\W_]/, "");
  if (answer.toLowerCase() === str.toLowerCase()) {
    return true;
  }
  else {
    return false;
  }
}



palindrome("A man, a plan, a canal. Panama");
Herman Fassett
@HermanFassett
Mar 14 2017 05:15
it should
oh that
Jeremy
@JeremyAntonoff
Mar 14 2017 05:16
nevermind
i forgot the gi
im an idiot
thank you!
Herman Fassett
@HermanFassett
Mar 14 2017 05:16
x)
Jeremy
@JeremyAntonoff
Mar 14 2017 05:16
@joseph thank you
CamperBot
@camperbot
Mar 14 2017 05:16
jtoddfl sends brownie points to @joseph :sparkles: :thumbsup: :sparkles:
:cookie: 43 | @joseph |http://www.freecodecamp.com/joseph
Jeremy
@JeremyAntonoff
Mar 14 2017 05:16
@HermanFassett thank you
CamperBot
@camperbot
Mar 14 2017 05:16
jtoddfl sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:warning: jtoddfl already gave hermanfassett points
Jeremy
@JeremyAntonoff
Mar 14 2017 05:16
appreciate it
Herman Fassett
@HermanFassett
Mar 14 2017 05:19
Well I've gtg now y'all
Joseph
@revisualize
Mar 14 2017 05:21
@JToddFL I'm @revisualize
jacob
@bjh2012
Mar 14 2017 05:28
Can anyone help with the Golf Code challenge. I figure it would be a series of if/else statements, but I was wrong.
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 05:29
my mind hurts . i didnt think it was possible but Javascript made it happen.
.>
jacob
@bjh2012
Mar 14 2017 05:30
The Logical And operator doesn't seem to be the key either
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:31
@bjh2012 you're to compare par with strokes...if am right
jacob
@bjh2012
Mar 14 2017 05:32
@Lumexralph and i'm assuming I will be using a numerical value in each comparison?
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:32
@bjh2012 depends on the condition you're checking
jacob
@bjh2012
Mar 14 2017 05:33
@Lumexralph which would then, of course, require a return statement
Richard Belotte
@belotte
Mar 14 2017 05:33
question... if I have an array, say [2, 6, 4, 3] and I am iterating through it with a for loop, I am starting at index 0 (in this case 2). how do I get the next index without running the next loop (index 1, in this case 6)?
would it be: arr[i + 1];?
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:34
@bjh2012 if it's required
@belotte yes....... but be careful when your iterator reaches the last index, i + 1 then will result to undefined
jacob
@bjh2012
Mar 14 2017 05:37
@Lumexralph using an operator for both par and strokes?
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:37
@bjh2012 yes... what're the instructions?
jacob
@bjh2012
Mar 14 2017 05:38
@Lumexralph Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):
@Lumexralph function golfScore(par,strokes)
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:38
@bjh2012 where's the table?
jacob
@bjh2012
Mar 14 2017 05:39

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

= par + 3
"Go Home!"

@Lumexralph sorry, it came out as a list
Richard Belotte
@belotte
Mar 14 2017 05:40

@Lumexralph so could I do it like this:

for(var j = 0; j < arr[i].length; j++){
      if(arr[i][j] > arr[i][j+1]){
        return "first num is bigger"
      }
    }

?

jacob
@bjh2012
Mar 14 2017 05:40
@Lumexralph the words in quotes are the return
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:41
@belotte you must declare variable i in the for loop conditions too
@bjh2012 is this the table?
Richard Belotte
@belotte
Mar 14 2017 05:42
@Lumexralph yeah, sorry. it's nested. it's actually this:
for(var i = 0; i < arr.length; i++){
    for(var j = 0; j < arr[i].length; j++){
      if(arr[i][j] > arr[i][j+1]){
        return "first num is bigger";
      }
    } 
  }
would that work?
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:43
@belotte are you working with a multi-dimensional array?
Richard Belotte
@belotte
Mar 14 2017 05:43
for a nested array? Something like [[4, 5, 1, 3], [13, 27, 18, 26]] @Lumexralph
jacob
@bjh2012
Mar 14 2017 05:43

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

= par + 3 "Go Home!"

Richard Belotte
@belotte
Mar 14 2017 05:44
@Lumexralph yes
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:44
@belotte so what are you trying to get from the array?
Richard Belotte
@belotte
Mar 14 2017 05:45
the largest number.
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:45
@bjh2012 can you give me a link to challenge on FCC?
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:45
@belotte largest number where? in each sub-array or the whole array?
Richard Belotte
@belotte
Mar 14 2017 05:46
I am suposed to return an array of the largest umbers from each sub array
Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.
the return I have is just for testing btw
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:48
@belotte okay..... you don't need to return the element in the inner loop, get an empty local to your function scope where you push each numbers to
Richard Belotte
@belotte
Mar 14 2017 05:48
yeah
that was just for testing
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:49
@belotte your loops will only populate the empty array for the largest numbers, and you return that array when your loops are done
Richard Belotte
@belotte
Mar 14 2017 05:49
Not sure I understand
I thought
I would store the first number
and compare it to the next in the array
if it's bigger it gets stored in a var
if not the other is
continue for the first sub array
the push the final result, and move on to the next sub array
but I can't seem to campare the first 2 numbers from the first sub array
that's what I am trying to do
@Lumexralph
Joseph
@revisualize
Mar 14 2017 05:52
Math.max();
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:54
@belotte you need to have a kind of starting value to compare each element in the sub-array to if(starting value < arr[ i ][ j ])......in the if statement block..... starting value = arr[i][j], which will be used for the next iteration and if you know @revisualize suggestion Math.max you can try that too, it'll return the largest number in the each sub-array which you can push into an empty array
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 05:55
im on this question also.. i know how ot do it with 2 loops but i really want to avoid doing that. any hints?
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:56
@kojodoesdesign use a loop with Math.max
Richard Belotte
@belotte
Mar 14 2017 05:56
@Lumexralph math.max would be good (didn't know about it), but I want to see if I can do it through loops and if statments.
Ogundele Olumide
@Lumexralph
Mar 14 2017 05:56
@belotte okay...try my suggestion then
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 05:57
@Lumexralph omg Ty
CamperBot
@camperbot
Mar 14 2017 05:57
:star2: 1303 | @lumexralph |http://www.freecodecamp.com/lumexralph
kojodoesdesign sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Richard Belotte
@belotte
Mar 14 2017 05:58
Not sure I understand.

@Lumexralph would this work:

for(var i = 0; i < arr.length; i++){
    for(var j = 0; j < arr[i].length; j++){
      var num1 = arr[i][j];
      var num2 = arr[i][j + 1];
      if(num1 > num 2) {
        numBig = num1;
      } else {
        numBig = Num2;
      }
    } 
  }

?

Ogundele Olumide
@Lumexralph
Mar 14 2017 06:01
@belotte
*have a starting value let's say largest initialize to 0
*have an empty array to hold largest value in each sub-array

for(var i = 0; i < arr.length; i++){
  //then you have to reset largest for each iteration of the sub-arrays
    for(var j = 0; j < arr[i].length; j++){
      if(arr[i][j] > largest]){
        largest = arr[ i ][ j ]  //largest becomes the next value to be compared and if no other value in the array is bigger
      }
    }
   push the largest value to the empty array 
  }
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 06:01
how do u guys get that code block to be formatted like that?
CamperBot
@camperbot
Mar 14 2017 06:02
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
Mar 14 2017 06:02
@kojodoesdesign follow that link by @camperbot
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 06:03
<p> I am code, hear me roar!</p>
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 06:03
yay!
Ogundele Olumide
@Lumexralph
Mar 14 2017 06:03
@belotte :point_up: March 14, 2017 7:01 AM
Jor
@joreyesl
Mar 14 2017 06:03
@belotte 1st loop iterates through each subarray. 2nd loop iterates through each element of the current subarray. You want to have a variable that keeps track of the current largest. Now before entering the 2nd loop, you want to set current largest to a really low value, like Number.MIN_SAFE_INTEGER or alternatively you can set it to the first value of the subarray arr[i][0]. Inside the 2nd loop then what you want to do is check if the current element is larger than current largest. If it is then you set that element equal to current largest. At the end of the loop current largest will be the largest number in that subarray, you can push it to an array that holds the largest from each subarray.
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 06:06
function largestOfFour(arr) {
  const payload = [];
  arr.forEach(function(value,iterator, array) {
    let comparer;
    if(value[0] > comparer) {
      comparer = value[0];
    }
    if(value[1] > comparer) {
      comparer = value[1];
    }
    if(value[2] > comparer) {
      comparer = value[2];
    }
    if(value[3] > comparer) {
      comparer = value[3];
    }

    payload.push(comparer);

  });

  return payload;
}
grantknaver
@grantknaver
Mar 14 2017 06:06
anyone free to give a bit of help
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 06:08
1 loop and uses if's
though im about to rewrite it to use math.max instead
Richard Belotte
@belotte
Mar 14 2017 06:10

@joreyesl OK, I'm going to have to think about this a bit more then.
@Lumexralph how do you compare a var before it's defined?

 if(arr[i][j] > largest]){
        largest = arr[ i ][ j ]  //largest becomes the next value to be compared and if no other value in the array is bigger
      }

?

oh, you'd be setting largest at the top... yes?
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 06:11
@belotte just like i did
:)
Jor
@joreyesl
Mar 14 2017 06:11
@belotte you declare it at the beginning of the function, and you initilize it right before you enter the 2nd loop. Remember you need to reset it before you enter the 2nd loop otherwise it will have the largest number from the previous subarray.
grantknaver
@grantknaver
Mar 14 2017 06:12
anyone
jacob
@bjh2012
Mar 14 2017 06:12
@Lumexralph I figured it out, but thanks for the help
CamperBot
@camperbot
Mar 14 2017 06:12
bjh2012 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1304 | @lumexralph |http://www.freecodecamp.com/lumexralph
Richard Belotte
@belotte
Mar 14 2017 06:13
@kojodoesdesign I don't know const and let yet.
grantknaver
@grantknaver
Mar 14 2017 06:13
if anyone has some time at some point I would love a smidge of help
here is the issue
Kwadwo Opoku-Debrah
@kojodoesdesign
Mar 14 2017 06:13
@belotte u can replace em with var; i just like using es6 so i remember it
grantknaver
@grantknaver
Mar 14 2017 06:13
I am trying to streamline my code
unction change(target) {
var referenceTime = new Date().getTime();
var countDownMinutes = $("#timerSetting").html() * 60000;
  if (savedMin === undefined) {
    target = referenceTime + countDownMinutes;
  console.log(target);
  } else {
    //target = savedDistance;// countDownMintues should be savedDistance need to establish var heirachary
  }
}

var func = function() {
    var countDownTime;
    change(countDownTime);
Im trying to use the function (func) to set the var countDownTime different ways depending ond savedMin, but once the code moves on past the function the var countDownTime is undefined...
HELP.
here is the rest of my code for context if anyone can help I would be much appreciated. Python hates the jquery I used so throwing it through there wont work.
Markus Kiili
@Masd925
Mar 14 2017 06:21
@grantknaver You declare var countDownTime; and then try to change its value with change(countDownTime); ?
Jor
@joreyesl
Mar 14 2017 06:22
@grantknaver you will need to return target from the function. JS doesnt have a pass by reference. So when you are assigning target in the function, it is not affecting countDownTime
grantknaver
@grantknaver
Mar 14 2017 06:23
@Masd925 yep
@joreyesl thanks
CamperBot
@camperbot
Mar 14 2017 06:24
grantknaver sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 595 | @joreyesl |http://www.freecodecamp.com/joreyesl
Markus Kiili
@Masd925
Mar 14 2017 06:24
@grantknaver Value of countDownTime is copied to parameter target so it doesn't work that way. You need to return from change function and do countDownTime = change(...)
Another way is to assign an object to countDownTime and then change it inside change.
grantknaver
@grantknaver
Mar 14 2017 06:26
@Masd925 thanks Im looking into it right now
I understand thank you both
your awesome
Richard Belotte
@belotte
Mar 14 2017 06:33
@joreyesl @Lumexralph TAHNK YOU BOTH!!! It took me a bit of thought (something I am not good at :worried: ) But, I went through what you guys wrote out and I wrote it out my self, and solved the challenge1
Jor
@joreyesl
Mar 14 2017 06:33
@belotte :thumbsup:
Richard Belotte
@belotte
Mar 14 2017 06:33
@joreyesl @Lumexralph :+1:
Tricia
@patricia07
Mar 14 2017 06:34
hey guys is this right?
// Only change code below this line.
var lastName = 8;
var lastName= "mesina";
"Mesina".length; // 8
lastNameLength = lastName;
i'm gonna find the length of a string
Joseph
@revisualize
Mar 14 2017 06:35
@patricia07 the variable lastNameLength should have the value of the lastName length applied to it