These are chat archives for FreeCodeCamp/HelpJavaScript

12th
Apr 2017
Connor Yanz
@cmy235
Apr 12 2017 00:00
haha that did it @Manish-Giri
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 00:00
oh ok didnt even remember that challenge
SADickson
@SADickson
Apr 12 2017 00:00
I completed the exercise, but what does the "return" part mean?
Manish Giri
@Manish-Giri
Apr 12 2017 00:00
yeah the tests are quite strict
Connor Yanz
@cmy235
Apr 12 2017 00:01
I'm so confused. don't know how that was any different from mine! I just had a string/number in the first array, in addition to everything they asked for... but i guess it didn't want that
Manish Giri
@Manish-Giri
Apr 12 2017 00:01
dude
your first array wasn't an array at all.
var myList = ["first array", 10,["first sub", 1], ["second sub", 2], ["third sub", 3], ["fourth sub", 4],["fifth sub", 5],["sixth sub," 6]];
Moisés Man
@moigithub
Apr 12 2017 00:02
test requires 5 elements... all of those subarrays
urs have 7 elements @cmy235
1 string , 1 number and 5 subarrays
Connor Yanz
@cmy235
Apr 12 2017 00:03
why isn't that called an array? If the 5 sub arrays follow exact same format of ["string", #]?
Manish Giri
@Manish-Giri
Apr 12 2017 00:03
huh
an array is a collection of items in [ ]
Moisés Man
@moigithub
Apr 12 2017 00:03
brackets mean its an array [...]
if u wrap an array inside brackets, then u have an array containing another array.. a subarray [[...]]
Connor Yanz
@cmy235
Apr 12 2017 00:05
haha sorry to be annoying but then isn't this an array? ["first array", 10]
a string and #, enclosed in brackets was what I had...
stormfighter123
@stormfighter123
Apr 12 2017 00:05
hello
Manish Giri
@Manish-Giri
Apr 12 2017 00:06
where did you have the closing ]
stormfighter123
@stormfighter123
Apr 12 2017 00:06
can someone help me
Manish Giri
@Manish-Giri
Apr 12 2017 00:06
and the opening [
stormfighter123
@stormfighter123
Apr 12 2017 00:06
with the golf java script
Hello?
anyone here
can someone give me the answer
i got this

function golfScore(par, strokes) {
// Only change code below this line
if(strokes == 1){
return "Hole-in-one!";
}else if(strokes <= par - 2){
return "Eagle";
}else if(strokes == par - 1){
return "Birdie";
}else if(strokes == par){
return"par";
}else if(strokes == par +1){
return "Bogey";
}else if(strokes == par +2){
return "Double Boegy";
}else if(strokes >= par +3){
return "Go Home!";
}

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

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

HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 00:08
Double Bogey
@stormfighter123
and probably Par too
your strings need to be exaclt y what they want
only top left box working but coming along
SADickson
@SADickson
Apr 12 2017 00:16
Hey guys, what do the numbers in Arrays stand for?
greymistcube
@greymistcube
Apr 12 2017 00:18
@SADickson you mean the index?
like myArray[2]?
SADickson
@SADickson
Apr 12 2017 00:19
lets say var myArray =[Spencer, 25]
what exactly do the numbers represent
greymistcube
@greymistcube
Apr 12 2017 00:19
@SADickson it's just a value. 25 is in the "second slot".
myArray[0] // this is "Spencer"
SADickson
@SADickson
Apr 12 2017 00:20
hmm okay okay
greymistcube
@greymistcube
Apr 12 2017 00:20
myArray[1] // this is 25
SADickson
@SADickson
Apr 12 2017 00:20
so is it just assigning a value to the word?
greymistcube
@greymistcube
Apr 12 2017 00:21
in general, you wouldn't say 25 is assigned to "Spencer"
but if it is myArray variable you are referring to, then yes.
SADickson
@SADickson
Apr 12 2017 00:22
Okay, gotcha
Thanks @greymistcube
CamperBot
@camperbot
Apr 12 2017 00:22
sadickson sends brownie points to @greymistcube :sparkles: :thumbsup: :sparkles:
:cookie: 262 | @greymistcube |http://www.freecodecamp.com/greymistcube
greymistcube
@greymistcube
Apr 12 2017 00:22
also I'm assuming you forgot quotation marks around "Spencer"
Trakra
@trgme
Apr 12 2017 00:31
anyone use swagger api to build projects before?
Khubaib Abul Alla
@khu13aib
Apr 12 2017 00:32
help me with 155
hey
anyone there
??
Moisés Man
@moigithub
Apr 12 2017 00:34
challenges DO NOT have numbers.. those numbers are brownie points
if u wanna refer to a challenge use its name @khu13aib
Khubaib Abul Alla
@khu13aib
Apr 12 2017 00:39
Word Blanks
I dont know this mad lib game so cant really fig out what to do here @moigithub
:(
Moisés Man
@moigithub
Apr 12 2017 00:42
u have a function which accept words as values
those words are "mapped" to variables (function parameters)
ie: dog big ran quicky.. each of those words will be "saved" inside myNoun myVerb ... etc "variables"
@khu13aib
ur task is using string concatenation with variables (some previous exercise u ALREADY DID )
and form a phrase with those words, and extra words/fillers if needed
Khubaib Abul Alla
@khu13aib
Apr 12 2017 00:43
on it 3:) thanks yo @moigithub
CamperBot
@camperbot
Apr 12 2017 00:43
khu13aib sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3060 | @moigithub |http://www.freecodecamp.com/moigithub
Khubaib Abul Alla
@khu13aib
Apr 12 2017 00:45
how do I do that :P
Moisés Man
@moigithub
Apr 12 2017 00:45
ur task is using string concatenation with variables (some previous exercise u ALREADY DID )
if u dont remember.. then its time to go back and review that
Khubaib Abul Alla
@khu13aib
Apr 12 2017 00:46
I remember that man .. I was asking about send you thoese points
Moisés Man
@moigithub
Apr 12 2017 00:47
when some1 write thanks the bot register brownie points to whoever @ name u mention
thanks @khu13aib
CamperBot
@camperbot
Apr 12 2017 00:47
moigithub sends brownie points to @khu13aib :sparkles: :thumbsup: :sparkles:
:cookie: 156 | @khu13aib |http://www.freecodecamp.com/khu13aib
Khubaib Abul Alla
@khu13aib
Apr 12 2017 00:48
thanks @moigithub
CamperBot
@camperbot
Apr 12 2017 00:48
khu13aib sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: khu13aib already gave moigithub points
Khubaib Abul Alla
@khu13aib
Apr 12 2017 00:48
cool
@moigithub man how did you learn so much :(
Moisés Man
@moigithub
Apr 12 2017 00:49
...been here for 1.5 + year already
Ardigi
@Ardigi
Apr 12 2017 00:50

`var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
}][{
"artist": "Frank Sinatra",
"title": "Frank Sinatra Greatest Hits",
"release_year": 1969,
"formats" : [
"CD",
"Cassette",
"Vinyl"]

}// Add record here
];

David Amanze
@GodKingShogun
Apr 12 2017 00:50
anyone have any good recommendations of music for my simon game
Ardigi
@Ardigi
Apr 12 2017 00:50
what am I doing wrong? lol
I can't add an album
David Amanze
@GodKingShogun
Apr 12 2017 00:50
@Ardigi post your code in between ```
Joseph
@revisualize
Apr 12 2017 00:51
@Ardigi You need to make an array with two objects as elements.
Ardigi
@Ardigi
Apr 12 2017 00:51

` var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
}][{
"artist": "Frank Sinatra",
"title": "Frank Sinatra Greatest Hits",
"release_year": 1969,
"formats" : [
"CD",
"Cassette",
"Vinyl"]

}// Add record here
]; `

i have the backticks
it's not working lol
see
David Amanze
@GodKingShogun
Apr 12 2017 00:51
you have to use three`
Moisés Man
@moigithub
Apr 12 2017 00:51
3 on its own line... for multi line formatting
Joseph
@revisualize
Apr 12 2017 00:51
@Ardigi [ { ... } , { ... } ]
Ardigi
@Ardigi
Apr 12 2017 00:51
ohhh

``` var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
}][{
"artist": "Frank Sinatra",
"title": "Frank Sinatra Greatest Hits",
"release_year": 1969,
"formats" : [
"CD",
"Cassette",
"Vinyl"]

}// Add record here
];

ope
```
Joseph
@revisualize
Apr 12 2017 00:51
@Ardigi You have [ { ... } ] [ { ... } ]
Ardigi
@Ardigi
Apr 12 2017 00:51

``` var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,
}][{
"artist": "Frank Sinatra",
"title": "Frank Sinatra Greatest Hits",
"release_year": 1969,
"formats" : [
"CD",
"Cassette",
"Vinyl"]

}// Add record here
]; ```

David Amanze
@GodKingShogun
Apr 12 2017 00:51
lol. am i the only one that did not struggle with that
Ardigi
@Ardigi
Apr 12 2017 00:52
I've done it before
Moisés Man
@moigithub
Apr 12 2017 00:52
```
on its OWN LINE
like this
```
Ardigi
@Ardigi
Apr 12 2017 00:52
shift enter to get new line?
Moisés Man
@moigithub
Apr 12 2017 00:52
aye
Joseph
@revisualize
Apr 12 2017 00:52
@Ardigi the three ```s need to be on their own line.
Ardigi
@Ardigi
Apr 12 2017 00:52
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true,
  }][{
  "artist": "Frank Sinatra",
  "title": "Frank Sinatra Greatest Hits",
  "release_year": 1969,
  "formats" : [
     "CD",
     "Cassette",
     "Vinyl"]

   }// Add record here
];
Joseph
@revisualize
Apr 12 2017 00:52
However that doesn't change what I've said
Moisés Man
@moigithub
Apr 12 2017 00:52
:tada:
David Amanze
@GodKingShogun
Apr 12 2017 00:52
@Ardigi :+1:
Ardigi
@Ardigi
Apr 12 2017 00:52
lol
so wait , i've been fucking with brackets for 20 minutes
Joseph
@revisualize
Apr 12 2017 00:53
@Ardigi You need to make an array with two objects as elements.
@Ardigi [ { ... } , { ... } ]
@Ardigi You have [ { ... } ] [ { ... } ]
Ardigi
@Ardigi
Apr 12 2017 00:53
so why it not right? too many, too little?
David Amanze
@GodKingShogun
Apr 12 2017 00:53
@Ardigi get rid of the ][ in between your objects
Moisés Man
@moigithub
Apr 12 2017 00:53
[....] an array
{...} an object
[{...}] an object inside an array
[{...}, {...}] 2 objects inside an array
array elements MUST be separated by comma
Ardigi
@Ardigi
Apr 12 2017 00:54
oohhhh
Joseph
@revisualize
Apr 12 2017 00:54
@Ardigi Not correct. You don't add ][ between array elements.
David Amanze
@GodKingShogun
Apr 12 2017 00:54
@Ardigi and put a comma
Joseph
@revisualize
Apr 12 2017 00:56
damn my ribs are sore.
David Amanze
@GodKingShogun
Apr 12 2017 00:56
@revisualize icy-hot
Joseph
@revisualize
Apr 12 2017 00:57
I think I dislocated my .....
Costochondral Joint for Rib 7 or 8
At least, I know I popped it.. Kind of like how you pop a knuckle.
Ardigi
@Ardigi
Apr 12 2017 00:58
Thank you !
Joseph
@revisualize
Apr 12 2017 01:00
@moigithub Thanks
CamperBot
@camperbot
Apr 12 2017 01:00
revisualize sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3061 | @moigithub |http://www.freecodecamp.com/moigithub
Joseph
@revisualize
Apr 12 2017 01:01
cbot
CamperBot
@camperbot
Apr 12 2017 01:01
you called?
Joseph
@revisualize
Apr 12 2017 01:01
HA HA!
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:01

function palindrome(str) {
  // Good luck!
  if(str.replace(/[\W_]/g,"").toLowerCase===
     str.replace(/[\W_]/g,"").toLowerCase().split("").reverse().join("")){
  return true;  
  }

}



palindrome("eye");
can some tell me where i am wrong
Joseph
@revisualize
Apr 12 2017 01:02
@GodKingShogun thanks.
CamperBot
@camperbot
Apr 12 2017 01:02
revisualize sends brownie points to @godkingshogun :sparkles: :thumbsup: :sparkles:
:cookie: 185 | @godkingshogun |http://www.freecodecamp.com/godkingshogun
Joseph
@revisualize
Apr 12 2017 01:02
there we go.
@Ashish-Inamdar no return false?
Moisés Man
@moigithub
Apr 12 2017 01:02
free brownie points, thanks :) @revisualize @Ardigi @GodKingShogun @Ashish-Inamdar
CamperBot
@camperbot
Apr 12 2017 01:02
moigithub sends brownie points to @revisualize and @ardigi and @godkingshogun and @ashish-inamdar :sparkles: :thumbsup: :sparkles:
:cookie: 209 | @ardigi |http://www.freecodecamp.com/ardigi
:cookie: 186 | @godkingshogun |http://www.freecodecamp.com/godkingshogun
:cookie: 245 | @ashish-inamdar |http://www.freecodecamp.com/ashish-inamdar
:star2: 3717 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 12 2017 01:03
@Ashish-Inamdar your function returns true or ... undefined.
David Amanze
@GodKingShogun
Apr 12 2017 01:03
@moigithub thanks for the bronie points :smile:
CamperBot
@camperbot
Apr 12 2017 01:03
godkingshogun sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3062 | @moigithub |http://www.freecodecamp.com/moigithub
Joseph
@revisualize
Apr 12 2017 01:03
:busstop: :v:
Moisés Man
@moigithub
Apr 12 2017 01:04
also.. first toLowerCase missing () @Ashish-Inamdar
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:06
@revisualize Added the return false
@moigithub There is a toLowerCase

function palindrome(str) {
  // Good luck!
  if(str.replace(/[\W_]/g,"").toLowerCase===
     str.replace(/[\W_]/g,"").toLowerCase().split("").reverse().join("")){
  return true;  
  }
  return false;
}



palindrome("eye");
Moisés Man
@moigithub
Apr 12 2017 01:08
u NOT CALLING/executing the function
check ur second toLowerCase()
@Ashish-Inamdar
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:10
@moigithub Thanks man. Got it
CamperBot
@camperbot
Apr 12 2017 01:10
ashish-inamdar sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3063 | @moigithub |http://www.freecodecamp.com/moigithub
Joseph
@revisualize
Apr 12 2017 01:10
Why does one toLowerCase have a ()?
DJToners
@DJToners
Apr 12 2017 01:11

var myStr; // Change this line
Its the part about escaping with backslashes

You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Stephen James
@sjames1958gm
Apr 12 2017 01:18
@DJToners assign a string to myStr containing the provided string then replace the 4 keywords with the matching escape sequences from the table
DJToners
@DJToners
Apr 12 2017 01:20
I dont get it
@sjames1958gm
Mohamed Derhalli
@derhallim
Apr 12 2017 01:21

any idea what's wrong with this code?

    if (navigator.geolocation) {
             new Promise(function (resolve, reject) {
                navigator.geolocation.getCurrentPosition(resolve, reject);
            }).then(position => {
            url = url.concat(`&lat=${position.coords.latitude}&lon=${position.coords.longitude}`);
                                },
                            error =>
                                                     alert(error));
        }

why am I not able to see embed position.coords.latitude as part of the ` string? it's seeing it as a JS code instead of a string with red squiggly line under coords

Stephen James
@sjames1958gm
Apr 12 2017 01:21
@DJToners FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine assign
as string containing the above then repalce the four keyword newline backslash backslash and carriage-return with sequences from the table
Gulsvi
@gulsvi
Apr 12 2017 01:25
@derhallim
function getLocation() {
  return new Promise(function(resolve, reject) {
    navigator.geolocation.getCurrentPosition(resolve, reject);
  });
}

getLocation().then(function(position) {
  const urlCoords = `&lat=${position.coords.latitude}&lon=${position.coords.longitude}`
  console.log(urlCoords)
});
Mohamed Derhalli
@derhallim
Apr 12 2017 01:26
yea i had it in 2 functions
DJToners
@DJToners
Apr 12 2017 01:26

var myStr = FirstLine\nSecondLine\rThirdLine ; // Change this line
@sjames1958gm
Mohamed Derhalli
@derhallim
Apr 12 2017 01:26
but wanted to have it in 1 function all together
@SkyCoder01 why is it not working in 1 function?
Stephen James
@sjames1958gm
Apr 12 2017 01:27
@DJToners missing the escaped backslashes
Gulsvi
@gulsvi
Apr 12 2017 01:28
@derhallim You don't have to use a promise:
navigator.geolocation.getCurrentPosition(success, failure);

function success(position) {
  const urlCoords = `&lat=${position.coords.latitude}&lon=${position.coords.longitude}`
  console.log(urlCoords)
};

function failure(err) {
  console.log('navigator.geolocation failed')
}
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:28
Any ideas how to do the title case challenge?
Stephen James
@sjames1958gm
Apr 12 2017 01:29
@derhallim Is url already defined?
Mohamed Derhalli
@derhallim
Apr 12 2017 01:29
yep
@sjames1958gm
stevemax22
@stevemax22
Apr 12 2017 01:29
On the Word Blanks challenge. Sort of a MadLib thing. I'm not quite understanding the challenge entirely. Can someone help?
DJToners
@DJToners
Apr 12 2017 01:29
@sjames1958gm where do those go
Stephen James
@sjames1958gm
Apr 12 2017 01:30
@DJToners where the word backslash was twice
Gulsvi
@gulsvi
Apr 12 2017 01:30
@derhallim Or,
navigator.geolocation.getCurrentPosition(function(position) {
    const urlCoords = `&lat=${position.coords.latitude}&lon=${position.coords.longitude}`
    console.log(urlCoords)
  },
  function(err) {
    console.log('navigator.geolocation failed')
});
Mohamed Derhalli
@derhallim
Apr 12 2017 01:30
@SkyCoder01 am confused, I was using geo location, and my code continued to execute without waiting for the values to come back, i searched online, they said u need promises, such as jquery, but I found this code i have from a guy on github (I don't even now what the new Promise means )
Stephen James
@sjames1958gm
Apr 12 2017 01:30
@derhallim When I console.log url in the function it worked
Mohamed Derhalli
@derhallim
Apr 12 2017 01:30
ummm
Stephen James
@sjames1958gm
Apr 12 2017 01:31
@derhallim The promise doesn't stop the async nature of the code - it just makes it easier to reason about
Gulsvi
@gulsvi
Apr 12 2017 01:31
@derhallim The callback function will execute when the location comes back, so no need for a Promise there. Once you get the data, you can pass it off to another function.
navigator.geolocation.getCurrentPosition(success, failure);

function success(position) {
  getWeather(position);
};

function failure(err) {
  console.log('navigator.geolocation failed')
}

function getWeather(position) {
  // build your URL here
}
Mohamed Derhalli
@derhallim
Apr 12 2017 01:32
this is my complete code now, same thing:
    let url = 'http://api.openweathermap.org/data/2.5/forecast?id=524901&APPID=b39aafa2540986efcbfaed47e5aef571';
        if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(()=>{
                         url = url.concat(`&lat=${position.coords.latitude}&lon=${position.coords.longitude}`);
                }, 
                (err)=> alert(err));
         } //if
Gulsvi
@gulsvi
Apr 12 2017 01:32
That passes the position object off to another function getWeather()
Stephen James
@sjames1958gm
Apr 12 2017 01:32
@stevemax22 The function provided has 4 parameters, myNoun, etc.
those will contain the words to build the sentence when the functoin is called.
Your code inside the function will combine these 4 parameters and some string literals to make a sentence
@derhallim You have to process the url in the callback from getCurrentPosition or call a functoin to do that
Mohamed Derhalli
@derhallim
Apr 12 2017 01:33
sorry :( missed the position
Gulsvi
@gulsvi
Apr 12 2017 01:33
But yeah, promises make it really clean if you want to try and learn them. Lets you do stuff like:
getLocation()
  .then(buildWeatherUrl)
  .then(getWeather)
  .then(displayWeather)
  .catch(console.error);
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:33

function titleCase(str) {
  var a=[];
  a=str.split(" ");
  for(var i=0;i<a.length;i++){
    a[i].charAt(0).toUpperCase();
  }
  return a;
}

titleCase("I'm a little tea pot");
I have writte this code
Mohamed Derhalli
@derhallim
Apr 12 2017 01:34
@SkyCoder01 but is there promises native in JS?
Stephen James
@sjames1958gm
Apr 12 2017 01:34
@Ashish-Inamdar toUpperCase() returns a new value -
Mohamed Derhalli
@derhallim
Apr 12 2017 01:34
I know we have to use jQuery for that
Gulsvi
@gulsvi
Apr 12 2017 01:34
Yes, it's native JavaScript
Mohamed Derhalli
@derhallim
Apr 12 2017 01:34
ES6?
Gulsvi
@gulsvi
Apr 12 2017 01:34
In jQuery you create deferred objects with $.Deferred but it's the same thing
Stephen James
@sjames1958gm
Apr 12 2017 01:34
@derhallim promises are in most modern browsers
Gulsvi
@gulsvi
Apr 12 2017 01:35
I think it is ES6, yeah, but widely supported
Mohamed Derhalli
@derhallim
Apr 12 2017 01:35
why am I still using jQuery deferred in the code i did for the last project :joy:
Gulsvi
@gulsvi
Apr 12 2017 01:35
Because think of all the poor IE 11 users out there!
Mohamed Derhalli
@derhallim
Apr 12 2017 01:35
thanks guys @sjames1958gm @SkyCoder01
CamperBot
@camperbot
Apr 12 2017 01:35
derhallim sends brownie points to @sjames1958gm and @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1003 | @skycoder01 |http://www.freecodecamp.com/skycoder01
:star2: 6650 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
SADickson
@SADickson
Apr 12 2017 01:35
@SkyCoder01 sky are you able to explain multi-dimensional arryas
arrays*
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:36

function titleCase(str) {
  var a=[];
  var b=[];
  a=str.split(" ");
  for(var i=0;i<a.length;i++){
    b[i]=a[i].charAt(0).toUpperCase();
  }
  str=b.join("");
  return str;
}

titleCase("I'm a little tea pot");
Mohamed Derhalli
@derhallim
Apr 12 2017 01:36
Microsoft stopped supporting all IE < 11
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:36
now @sjames1958gm
Ryan
@Ryankennedy77
Apr 12 2017 01:36
hello, so im having a problem with testing objects for properties, anyone want to lend a hand?
Gulsvi
@gulsvi
Apr 12 2017 01:36
@SADickson I can try - do you have a specific question?
Stephen James
@sjames1958gm
Apr 12 2017 01:36
@Ashish-Inamdar So that gives you each first letter in uppercase?
SADickson
@SADickson
Apr 12 2017 01:36

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray

well
I'm trying to select an element that is equal to 8
Stephen James
@sjames1958gm
Apr 12 2017 01:36
@Ashish-Inamdar if you split with " " likely you will join with " "
SADickson
@SADickson
Apr 12 2017 01:36
but I really don't understand how i do that
Gulsvi
@gulsvi
Apr 12 2017 01:37
@SADickson Do you know what myArray[0] would return?
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:37
:wave:
SADickson
@SADickson
Apr 12 2017 01:37
1?
the example is extremely confusing
Gulsvi
@gulsvi
Apr 12 2017 01:38
Not quite - I'll write it in another way, that may help see it better, 1 sec
SADickson
@SADickson
Apr 12 2017 01:38
thank you
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:38
@sjames1958gm It only gives the first letter of all the words
:9
:(
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:38
var myArray = [0,1,2,3];
return myArray[0];
Gulsvi
@gulsvi
Apr 12 2017 01:38
var myArray = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
  [
    [10, 11, 12], 13, 14
  ]
];
@SADickson Sometimes it helps to look at it vertically
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:38
:)
Oh i see multiple arrays
Stephen James
@sjames1958gm
Apr 12 2017 01:39
@Ashish-Inamdar so maybe here
b[i]=a[i].charAt(0).toUpperCase(); you can think of a way to add back in the rest of a[i]?
SADickson
@SADickson
Apr 12 2017 01:39
ah okay
Gulsvi
@gulsvi
Apr 12 2017 01:39
With a 2D array like this, the first index of the array myArray[0] is an array. [1,2,3]
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:39
Yeah since computer start count at 0 instead of 1
like human
SADickson
@SADickson
Apr 12 2017 01:39
so 0 represents the first set of brackets?
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:39
0 means 1
Get it?
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:39
@sjames1958gm Ok let me try :)
SADickson
@SADickson
Apr 12 2017 01:39
yes I understand that
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:39
if its 1 then its 2
Stephen James
@sjames1958gm
Apr 12 2017 01:40
@Ashish-Inamdar :+1:
Gulsvi
@gulsvi
Apr 12 2017 01:40
Yes, the first element of the array. So let's say that myArray = [1,2,3], myArray[0] would be 1
Anica
@matosa
Apr 12 2017 01:40
Can someone help me with profile lookup?
DJToners
@DJToners
Apr 12 2017 01:40
@sjames1958gm I still havent gotten it
SADickson
@SADickson
Apr 12 2017 01:40
Okay I get that
Stephen James
@sjames1958gm
Apr 12 2017 01:40
@DJToners Show what you have.
SADickson
@SADickson
Apr 12 2017 01:40
so if I was to select an array = 8 how would I possible do that
Gulsvi
@gulsvi
Apr 12 2017 01:40
with a 2D array, we have to use 2 brackets.
var myArray = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
  [
    [10, 11, 12], 13, 14
  ]
];

myArray[0] // [1, 2, 3]
myArray[0][0] // 1
SADickson
@SADickson
Apr 12 2017 01:41
myArray[1][6]?
Gulsvi
@gulsvi
Apr 12 2017 01:41
If we wanted the number 3 it would be myArray[0][2]
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:41
No myArray[2][1]
Gulsvi
@gulsvi
Apr 12 2017 01:41
Yes, exactly
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:41
If you want to select 8
Gulsvi
@gulsvi
Apr 12 2017 01:42
Whoops, thought you were SADickson, Saboor :p
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:42
lol
SADickson
@SADickson
Apr 12 2017 01:42
how is [2][1] 8?
Gulsvi
@gulsvi
Apr 12 2017 01:42
Help them get to the answer
Don't give it out
SADickson
@SADickson
Apr 12 2017 01:42
hahaha
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:42
@SADickson see 2 means 3 right? like 3rd element
and other 1 meaning inside
SADickson
@SADickson
Apr 12 2017 01:42
all good, as long as I can understand how it works
Anica
@matosa
Apr 12 2017 01:42
I'm not sure how to refer to the array with the specified firstName property.

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  if (contacts.hasOwnProperty(firstName))
  {

    if(contacts[firstName].hasOwnProperty(prop))
    {
      return prop;
    }
    else
    {
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:42
1 = 2 and 8 is in 3rd element
DJToners
@DJToners
Apr 12 2017 01:42

var myStr = FirstLine\nSecondLine\rThirdLine ; // Change this line
SADickson
@SADickson
Apr 12 2017 01:42
ohhh okay
DJToners
@DJToners
Apr 12 2017 01:42
@sjames1958gm same as b4
SADickson
@SADickson
Apr 12 2017 01:42
so its the 3rd element, 2nd number
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:43
Yes
Gulsvi
@gulsvi
Apr 12 2017 01:43
@SADickson Here's another explanation:
var myArray = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
  [
    [10, 11, 12], 13, 14
  ]
];

myArray[0] // [1, 2, 3]
myArray[1] // [4, 5, 6]
myArray[2] // [7, 8, 9]
SADickson
@SADickson
Apr 12 2017 01:43
Okay I think I got it, so lets say I wanted to pick 5
it would be [1][1]?
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:43
Yep
Gulsvi
@gulsvi
Apr 12 2017 01:43
Perfect
SADickson
@SADickson
Apr 12 2017 01:44
Okay guys I got it, thanks @SkyCoder01 @MathematicsCoding
CamperBot
@camperbot
Apr 12 2017 01:44
sadickson sends brownie points to @skycoder01 and @mathematicscoding :sparkles: :thumbsup: :sparkles:
:star2: 1004 | @skycoder01 |http://www.freecodecamp.com/skycoder01
:cookie: 307 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:44
var array
@SADickson Wait hold on
SADickson
@SADickson
Apr 12 2017 01:44
okay i shall
Gulsvi
@gulsvi
Apr 12 2017 01:44
No problem, it gets really confusing when you get to 3 and 4d arrays
Stephen James
@sjames1958gm
Apr 12 2017 01:44
@DJToners Well for one you didn't make it a string.
FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
There are 4 keywords to replace you only replaced newline and carriage-return
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:44
var array = [1,2,3]
return array [1];
Gulsvi
@gulsvi
Apr 12 2017 01:44
sometimes, you just have to console.log() your way through it in codepen
SADickson
@SADickson
Apr 12 2017 01:44
Oh I'm sure I'll be back when I'm stuck on those
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:44
That would return 2 not entire element like 1,2,3
Just dont get confusing
Because there is only one element
SADickson
@SADickson
Apr 12 2017 01:45
so if there is only 1 element we only use 1 number right
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:45
Yes
SADickson
@SADickson
Apr 12 2017 01:46
Okay I got it that makes sense
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:46
@sjames1958gm What does slice function do. I was searching on Stack overflow and there they have used slice(1)
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:46
:+1:
Stephen James
@sjames1958gm
Apr 12 2017 01:46
@Ashish-Inamdar slice extracts a portion of the array/string slice(1) returns all but the first value
DJToners
@DJToners
Apr 12 2017 01:46
I forgot how to make its a string @sjames1958gm
Stephen James
@sjames1958gm
Apr 12 2017 01:47
@DJToners with "" or ''
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:47
" and '
or actually...
@SkyCoder01
Can you help?
Gulsvi
@gulsvi
Apr 12 2017 01:48
I can try :)
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:48
I dont know how to use reduce method
I tried but..
I know it need function in it
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 01:48
So should we write slice(0) to return all the values of array other than the first value or slice(1).Does slice follow indexing?
@sjames1958gm
Gulsvi
@gulsvi
Apr 12 2017 01:49
@MathematicsCoding what kind of challenges are you having with it?
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:49
Sum All Numbers in a Range
Stephen James
@sjames1958gm
Apr 12 2017 01:49
@Ashish-Inamdar slice(0) is all the array. slice(1) is all but first -
DJToners
@DJToners
Apr 12 2017 01:49
@sjames1958gm


var myStr = '\\FirstLinen\nSecondLine\rThirdLine\\' ; // Change this line
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:49
Linen
DJToners
@DJToners
Apr 12 2017 01:50
now the only one i need is myStr should have encoded text with the proper escape sequences and no spacing.
Stephen James
@sjames1958gm
Apr 12 2017 01:50
@DJToners you added an extra n and you put the \\ in the wrong place
Gulsvi
@gulsvi
Apr 12 2017 01:50
var sum = [0, 1, 2, 3].reduce(function (a, b) {
  return a + b;
}, 0);
// sum is 6
DJToners
@DJToners
Apr 12 2017 01:50
Damn
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:51
I see
Stephen James
@sjames1958gm
Apr 12 2017 01:51
@Ashish-Inamdar so if you use + and slice(1) you can add back in the rest of the word
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:51
But parameter already have an array...
DJToners
@DJToners
Apr 12 2017 01:51
I finally got it @sjames1958gm
Thanks @sjames1958gm
CamperBot
@camperbot
Apr 12 2017 01:51
djtoners sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6651 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Gulsvi
@gulsvi
Apr 12 2017 01:52
var myArray = [0, 1, 2, 3];
var sum = myArray.reduce(function (a, b) {
  return a + b;
}, 0);
// sum is 6
@MathematicsCoding Then you can do like above
Stephen James
@sjames1958gm
Apr 12 2017 01:52
@DJToners Great! :checkered_flag:
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:52
..
That is like an answer..
Gulsvi
@gulsvi
Apr 12 2017 01:52
It's exactly what I wrote earlier, but with "myArray" as a variable
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:53
}, 0);?
Gulsvi
@gulsvi
Apr 12 2017 01:53
That's the starting value
@MathematicsCoding If you change it to 4 you get:
var myArray = [0, 1, 2, 3];
var sum = myArray.reduce(function (a, b) {
  return a + b;
}, 4);
// sum is 10
Instead of 6
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:54
Oooh
Gulsvi
@gulsvi
Apr 12 2017 01:54
because we started by adding 4
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:54
Make sense..

function sumAll(arr) {
  var sum = arr.reduce(function(a,b) {
    return a + b;
  }

sumAll([1, 4]);
Gulsvi
@gulsvi
Apr 12 2017 01:55
That's going to give you 1 + 4 = 5
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:55
Yeah
But its not working
Stephen James
@sjames1958gm
Apr 12 2017 01:55
@MathematicsCoding but that is not going to work - because the array only has 1 and 4 so the result is 5 but the function is
supposed to sum from 1 to 4 - or 10
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 01:56
anyone wanna try give me a hand with some backendish kind of stuff
Gulsvi
@gulsvi
Apr 12 2017 01:56
Right, so you need to sum all the numbers from 1-4, [1,2,3,4]
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:56

function sumAll(arr) {
  var sum = arr.reduce(function(a,b) {
    return a + b;
  }, 0);
}
sumAll([1, 4]);
Oh I see but is that code fine for now?
Gulsvi
@gulsvi
Apr 12 2017 01:56
So, you have to change arr to [1,2,3,4] programmatically - more code needed
But yes, you are using .reduce() correctly to sum all the numbers in an array
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:57
So that would return 5 right?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 01:58
https://websocket-test-005.herokuapp.com/ i have this little app where everyone can draw on the page little colored circles, how would do you think i would go about saving the data thats already been inputed so that when a new person logs on they could see whats already been drawn
Gulsvi
@gulsvi
Apr 12 2017 01:58
Yes, it returns 5 now. Needs to return 10
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:58
I know but right now its not returning anything
Just blank
Anica
@matosa
Apr 12 2017 01:58
Does anyone here know about array lookup?
Gulsvi
@gulsvi
Apr 12 2017 01:58
Yeah, you have to return sum; at the end.
Anica
@matosa
Apr 12 2017 01:58
I'm still stuck and no one has responded
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 01:58
https://github.com/HeebieGeeBee/websockets-test here's the repo for the source code
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:59
Oh of course...

function sumAll(arr) {
  var sum = arr.reduce(function(a,b) {
    return a + b;
  }, 5);
  return sum;
}
sumAll([1, 4]);
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 01:59
would i be able to store all the data sent to the server?
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:59
I know just testing
Stephen James
@sjames1958gm
Apr 12 2017 01:59
@matosa What are you needing
Gulsvi
@gulsvi
Apr 12 2017 01:59
That's cheating :) but it will give you 10 @MathematicsCoding
Saboor Malik
@MathematicsCoding
Apr 12 2017 01:59
lol
Gulsvi
@gulsvi
Apr 12 2017 02:00
You could also just do return 10
:)
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:00
:0
I see just want to add another
Stephen James
@sjames1958gm
Apr 12 2017 02:01
@HeebieGeeBee yes your function that emits the data has access to the data and could store on the server
Mohamed Derhalli
@derhallim
Apr 12 2017 02:01
angular 2 is cool :D
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:02
@sjames1958gm so i could just write an array that i push all the data?
in the server.js file?
Anica
@matosa
Apr 12 2017 02:02
@sjames1958gm I need to go through an array of objects, check if the object with a particular firstName exists, and then check if that specific object has a specified property. I'm having trouble with the second part.

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  if (contacts.hasOwnProperty(firstName))
  {

    if(contacts.firstName.hasOwnProperty(prop))
    {
      return prop;
    }
    else
    {
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Stephen James
@sjames1958gm
Apr 12 2017 02:02
@matosa SInce you have an array of objects - then you need some sort of loop to access each contact
@HeebieGeeBee yes
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:03
@sjames1958gm ok thanks i'll give it try
CamperBot
@camperbot
Apr 12 2017 02:03
heebiegeebee sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6652 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Anica
@matosa
Apr 12 2017 02:03
@sjames1958gm I'll give that a try
Stephen James
@sjames1958gm
Apr 12 2017 02:03
@matosa You don't need to check hasOwnProperty on firstName you need to compare === to the parameter
@HeebieGeeBee If you want to write to a file you can use fs package
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:04
ooh
I think im figuring it out
Stephen James
@sjames1958gm
Apr 12 2017 02:04
@matosa The prop property is on contacts[i] not on contacts.firstName
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:04
@sjames1958gm fs package? that sounds familiar from the node lessons
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:04
Using max method for 4 and min for 1 then add them together to 5 then add it to return
Ashish Inamdar
@Ashish-Inamdar
Apr 12 2017 02:04
Done. Thanks @sjames1958gm
CamperBot
@camperbot
Apr 12 2017 02:04
ashish-inamdar sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6653 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:04
I guess..
Stephen James
@sjames1958gm
Apr 12 2017 02:04
@Ashish-Inamdar :+1:
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:05
but cant picture it at the moment
Edgar Pan
@edgaryp
Apr 12 2017 02:05
hello campers
Stephen James
@sjames1958gm
Apr 12 2017 02:05
@HeebieGeeBee Yes it is the files system package for writing/reading files
@edgaryp Hello
Edgar Pan
@edgaryp
Apr 12 2017 02:05
Hey I am hoping to find if static website (using Jekyll) can achieve "load more" feature for blog like photo attached?
Screen Shot 2017-04-12 at 12.00.09 pm.png
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:07

function sumAll(arr) {
  var sum = arr.reduce(function(a,b) {
    sum = Math.max(...sum);
    return a + b;
  }, 0);
  return sum;
} 

sumAll([5, 10]);
Danny Welstad
@GoonTwo
Apr 12 2017 02:08
Intermediate Algorithm Scripting "Spinal Tap Case" curious to know if there is a better way to do this (I'm sure there is). I'm pretty new to regexp

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

 str = str.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase().replace(/[\W_]/g,"-");

  return str;
}

spinalCase('The_Andy_Griffith_Show');
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:08
Can it return 25?
Because 5+10 = 15 then math.max = 10+15 = 25
Stephen James
@sjames1958gm
Apr 12 2017 02:09
@MathematicsCoding I don't think sum has any values yet when you are inside the reduce.
@GoonTwo I don't know that looks pretty good to me
Danny Welstad
@GoonTwo
Apr 12 2017 02:09
@sjames1958gm if you think so than I'll take it! :)
Gulsvi
@gulsvi
Apr 12 2017 02:09
@MathematicsCoding To use reduce, you'll have to make an array that has all the numbers to add
Danny Welstad
@GoonTwo
Apr 12 2017 02:10
@sjames1958gm thanks!
CamperBot
@camperbot
Apr 12 2017 02:10
goontwo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6654 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 12 2017 02:10
@GoonTwo :)
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:13
Ah
Im close

function sumAll(arr) {
  var sum = arr.reduce(function(a,b) {
    return a + b;
  }, 0);
  return Math.max.apply(null, arr)+sum;
} 

sumAll([5, 10]);
Gulsvi
@gulsvi
Apr 12 2017 02:15
@MathematicsCoding You need to figure out how to change [5,10] to [5,6,7,8,9,10]
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:16
...
Gulsvi
@gulsvi
Apr 12 2017 02:16
All that Math.max is going to do is tell you that 10 is the biggest number in the array
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:16
Yeah
Then I can add it

function sumAll(arr) {
  var sum = arr.reduce(function(a,b) {
    return a + b;
  }, 0);
  var sum1 = Math.max.apply(null, arr)+sum;
  return Math.min.apply(null,arr)+sum1;
} 

sumAll([5, 10]);
Gulsvi
@gulsvi
Apr 12 2017 02:16
But that won't work for other arrays...
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:16
...
Gulsvi
@gulsvi
Apr 12 2017 02:16
[5,100] for example
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:17
Oh... I thought challenge wanted me to add like first array then second then add math.max, math.min...
:(
So 5+6+7+8+9+10 is 45?
Gulsvi
@gulsvi
Apr 12 2017 02:17
I think so :)
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:18
Yeah it is
Anica
@matosa
Apr 12 2017 02:18
@sjames1958gm I got stuck again.

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


function lookUpProfile(firstName, prop){
// Only change code below this line

    for(var i = 0; i < contacts.length; i++)
    {
        if(contacts[i] === firstName)
        {
          for(var j = 0; j < contacts[i].length; j++)
          {
              if(contacts[i].hasOwnProperty(prop))
              {
                return contacts[i][j];
              }
              else
              {
                return "No such property";
              }
          }  
        }

        return "No such contact";

    }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:18
So why math.max and min?
Mohamed Derhalli
@derhallim
Apr 12 2017 02:18
@MathematicsCoding :v:
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:18
Why are they even there lol
@derhallim :wavae
:wave:
Stephen James
@sjames1958gm
Apr 12 2017 02:19
@matosa only one loop is needed.
contacts[i] is not an array so it has no contacts[i].length
contacts[i] === firstName this should use contacts[i].firstName === firstName
@MathematicsCoding because The lowest number will not always come first.
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:20
Hm
Gulsvi
@gulsvi
Apr 12 2017 02:22
@MathematicsCoding If you want to figure out all the numbers that go between two numbers you need to know where to start and where to end
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:22
Yeah
I guess that why i need these method
I dont even know how to turn them into 1,2,3,4...
Stephen James
@sjames1958gm
Apr 12 2017 02:26
@MathematicsCoding you could use a for loop and push the values
for (var i = min; i <=max; i++) newArr.push(i);
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:27
Ah..
My brain was not giving me any information..
"Maybe I need for loop for this but what am I supposed to do with it?"
:(
So for loop can I use parameter instead of var?
like var i to parameter
DJToners
@DJToners
Apr 12 2017 02:29


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Danny Welstad
@GoonTwo
Apr 12 2017 02:30
trying to create Fibonacci numbers up until var num. something is going wrong. thoughts?
function sumFibs(num) {
 var  arr = [1,1];
  while (arr[arr.length-1] < num) {
arr.push(arr[arr.length-1]+arr[arr.length-2]);  
  }
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:31

function sumAll(arr) {
  for (var i = Math.min.apply(null,arr); i<=Math.max.apply(null,arr);i++) {
return i;
} 
}
sumAll([5, 10]);
Jason Luboff
@JLuboff
Apr 12 2017 02:33
I can't see all the code since I'm on mobile but return stops all code execution your loop would only run once
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:33

function sumAll(arr) {
  for (var i = Math.min.apply(null,arr); i<=Math.max.apply(null,arr);i++) {
return i.reduce(function(a,b) {
  a + b;
}, 0);
}
}
sumAll([5, 10]);
Jason Luboff
@JLuboff
Apr 12 2017 02:34
...reduce is effectively a loop...and i is not an array...
Caleb
@calebxblackwell
Apr 12 2017 02:35
I am SO stuck on converting celsius to fahrenheit. I have revisited all of the algorithm challenges, and I'm still not sure where to begin. Can someone point me in the right direction?
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:35
@MathematicsCoding So change i to arr?

function sumAll(arr) {
  for (var i = Math.min.apply(null,arr); i<=Math.max.apply(null,arr);i++) {
var sum = arr.reduce(function(a,b) {
  var sum = a + b;
}, 0);
    return sum;
}
}
sumAll([5, 10]);
Brandon
@Minneanimal
Apr 12 2017 02:36
Hi friends, I'm stumped on the card counting function. I cannot figure out why a combination of values 7, 8, 9 are not returning the correct string.
Spoiler
Gulsvi
@gulsvi
Apr 12 2017 02:36
@MathematicsCoding
  1. Update arr to have all the numbers in it
  2. Use .reduce() to sum all the numbers
You are reducing it as your looping through it - one step at a time to get the problem
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:37
oh
Gulsvi
@gulsvi
Apr 12 2017 02:38
Now that you have .reduce() working, the next step is to figure out how to make that array have all the numbers you need. Set .reduce() aside for now
DJToners
@DJToners
Apr 12 2017 02:39
@calebxblackwell create a new line that sets fahrenheit = celsius *9/5 + 32
Gulsvi
@gulsvi
Apr 12 2017 02:39
@calebxblackwell Not sure if this will help... but It's like an algebra equation. ft = inches * 12
Caleb
@calebxblackwell
Apr 12 2017 02:39
@DJToners @SkyCoder01 Math coding is going to be really hard for me, I can tell! Haha thanks y'all.
CamperBot
@camperbot
Apr 12 2017 02:40
calebxblackwell sends brownie points to @djtoners and @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: @djtoners's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
:star2: 1005 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
Apr 12 2017 02:40
To give a parallel way of converting...
It will get easier though :)
DJToners
@DJToners
Apr 12 2017 02:40
np
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:40
@SkyCoder01 Congrats reaching 1k..
Brandon
@Minneanimal
Apr 12 2017 02:40
I can't figure out how to paste formatted code into the chat. I give up, lol.
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:40
Copy and paste
Gulsvi
@gulsvi
Apr 12 2017 02:40
Thanks, I'm looking forward to my trip to vegas now :) all you can eat buffet
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:40
'''
code
'''
click more info
CamperBot
@camperbot
Apr 12 2017 02:40
:bulb: to format code use backticks! ``` more info
DJToners
@DJToners
Apr 12 2017 02:41
@SkyCoder01 can u help me with this
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:41
@SkyCoder01 How did you get trip to vegas?
Gulsvi
@gulsvi
Apr 12 2017 02:41
I can try @DJToners
Brandon
@Minneanimal
Apr 12 2017 02:41
'''
CamperBot
@camperbot
Apr 12 2017 02:41
:bulb: to format code use backticks! ``` more info
DJToners
@DJToners
Apr 12 2017 02:41
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Gulsvi
@gulsvi
Apr 12 2017 02:41
@MathematicsCoding We all get a free trip to vegas when we get 1000 brownie points :p (not really)
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:41
...
So what happen if I did?
Gulsvi
@gulsvi
Apr 12 2017 02:42
@DJToners You'll need to create a sentence, like "My big dog ran quickly", dog is myNoun, big is myAdjective, etc.
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:43
lol listen to this comment from quora
"If video games are a waste of time, then so are books, movies, and pretty much any other form of entertainment"
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:44
im managing to store the data objects in an array server side, but having issues accessing from cliente side
Caleb
@calebxblackwell
Apr 12 2017 02:44
@SkyCoder01 once I have the line setting fahrenheit = celsius *9/5 +32, how do I apply that to my code? @DJToners
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:44
@sjames1958gm
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:44
@calebxblackwell That is the answer..
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:44
but might take a break for now
DJToners
@DJToners
Apr 12 2017 02:45
does it have a semicolon at the end? @calebxblackwell
Gulsvi
@gulsvi
Apr 12 2017 02:45
Always surprised to see you up so late @HeebieGeeBee
Brandon
@Minneanimal
Apr 12 2017 02:45

Hi friends, I can't seem to get values 7, 8, 9 to return 'count + " Hold"'. Does anyone have any tips?

testing code markup*

'var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count -= 1;
break;
default:
count += 0;
break;
}

if (card > 0) {
return count + " Bet";
}

return count + " Hold";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

'

Caleb
@calebxblackwell
Apr 12 2017 02:45
@DJToners yep!
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:46
@SkyCoder01 im a degenerate
DJToners
@DJToners
Apr 12 2017 02:46
Is it in between the lines it tells you to write in @calebxblackwell
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:46
@HeebieGeeBee So you are dying?
:(
Caleb
@calebxblackwell
Apr 12 2017 02:46
@DJToners yep!
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:46
lol thats not what degenerate means does it?
DJToners
@DJToners
Apr 12 2017 02:46
then just run it @calebxblackwell
Gulsvi
@gulsvi
Apr 12 2017 02:46
lol, nothing wrong with staying up late. Some people view it as hard work, dedication!
Caleb
@calebxblackwell
Apr 12 2017 02:47
@DJToners literally just got it. Thank you.
CamperBot
@camperbot
Apr 12 2017 02:47
calebxblackwell sends brownie points to @djtoners :sparkles: :thumbsup: :sparkles:
:warning: @djtoners's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Gulsvi
@gulsvi
Apr 12 2017 02:47
It can mean your health is in decline, I think
DJToners
@DJToners
Apr 12 2017 02:47
Np @calebxblackwell
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:47
@HeebieGeeBee No just saying xD
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:47
though i have just realised my computer my might be dying cus i have like 6 tabs open all console logging thousands of mouse coords
DJToners
@DJToners
Apr 12 2017 02:47

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result = "the myAdjective + my noun + myVerb + myAdverb" ;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:47
and colors
DJToners
@DJToners
Apr 12 2017 02:47
@SkyCoder01
AM i on the right track
Claudio Restifo
@Marmiz
Apr 12 2017 02:47
@Minneanimal why are you checking if the card > 0?
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:47
@DJToners my noun
Usman Akram
@usmanakram1996
Apr 12 2017 02:48

function spinalCase(str) {
  var newstr;
  var  re = new RegExp("/^[A-Z]*$/","g"); 
  for(i = 0 ; i < str.length;i++)
    {
      newstr = str.replace(re,'-');      
    }
  return newstr;
}

spinalCase('thisIsSpinalTap');
this code doesn't work right
Gulsvi
@gulsvi
Apr 12 2017 02:48
Almost @DJToners. The text needs to go in quotes, the variables do not go in quotes. For example:
var color = red;
var vehicle = truck;

var result = 'my ' + vehicle + ' is ' + color;
Usman Akram
@usmanakram1996
Apr 12 2017 02:48
any body help :point_up: April 12, 2017 7:48 AM
this challenge
Brandon
@Minneanimal
Apr 12 2017 02:48
@Marmiz to return count + " Bet" is the intent
CamperBot
@camperbot
Apr 12 2017 02:48
:bulb: to format code use backticks! ``` more info
Claudio Restifo
@Marmiz
Apr 12 2017 02:49
@Minneanimal yes but you're updating the count varaible right? And you use that to track the result of the card shown..
so doesn't make more sense to check if count is a certain value, then Bet or Hold?
DJToners
@DJToners
Apr 12 2017 02:50

@SkyCoder01


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result = "The " + myAdjective + myNoun + myVerb + myAdverb ;

  // Your code above this line
  return result;
}

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

Its coming out as a complete sentence but its not working

Usman Akram
@usmanakram1996
Apr 12 2017 02:51
David Amanze
@GodKingShogun
Apr 12 2017 02:51
@DJToners you need to add your own word in between each parameter
Usman Akram
@usmanakram1996
Apr 12 2017 02:51
:/
Jason Luboff
@JLuboff
Apr 12 2017 02:51
@SkyCoder01 I still think Bellagio has the best buffet in vegas. Can't go wrong with Planet Hollywood or The M either though
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:51
@SkyCoder01

function sumAll(arr) {
  for (var i = Math.min.apply(null,arr); i<=Math.max.apply(null,arr);i++) {
return arr;
}
}
sumAll([5, 10]);
Why cant I return 5,6,7,8,9,10
Danny Welstad
@GoonTwo
Apr 12 2017 02:51
Intermediate Algorithm Scripting "Add All Odd Fibonacci numbers": here is my solution. Anyone have thoughts on a cleaner way to do it or does this look good?

function sumFibs(num) {
 var  arr = [1,1];
  while (arr[arr.length-1] < num) {
arr.push(arr[arr.length-1]+arr[arr.length-2]);  
  }

var answer = arr.reduce(function(acc, val){
  if (val % 2 !== 0 && val <= num) {
    return acc + val;
  }
  return acc + 0;

});
 return answer;
}

sumFibs(75025);
Jason Luboff
@JLuboff
Apr 12 2017 02:52
@HeebieGeeBee still working on websockets?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:52
@JLuboff was playing around yeah
Jason Luboff
@JLuboff
Apr 12 2017 02:52
@MathematicsCoding I told you before...return stops all code execution
Brandon
@Minneanimal
Apr 12 2017 02:52
@Marmiz Eureka! Thank you!!!
CamperBot
@camperbot
Apr 12 2017 02:52
minneanimal sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 829 | @marmiz |http://www.freecodecamp.com/marmiz
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:52
havent been working on it all this time though
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:52
@JLuboff yeah but why..
Claudio Restifo
@Marmiz
Apr 12 2017 02:52
@Minneanimal :+1:
Gulsvi
@gulsvi
Apr 12 2017 02:52
@JLuboff :) I can't wait to try it
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:53
oh I have to return different place?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:53
@JLuboff https://websocket-test-005.herokuapp.com/ go make some pretty colors
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:53
If i return inside for loop it stops?
Gulsvi
@gulsvi
Apr 12 2017 02:54
@DJToners You have it correct now, even the spacing, but it seems it wants more words to pass the challenge... I just realized that I did the challenge incorrectly, but it still let me pass
Usman Akram
@usmanakram1996
Apr 12 2017 02:54
:point_up: April 12, 2017 7:48 AM :point_up: April 12, 2017 7:48 AM
@GodKingShogun plz help
DJToners
@DJToners
Apr 12 2017 02:54
@GodKingShogun Wut u mean?
Gulsvi
@gulsvi
Apr 12 2017 02:54
This was my solution:
/* jshint esversion: 6 */
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result = `The ${myAdjective} ${myNoun} ${myVerb} ${myAdverb}`;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Claudio Restifo
@Marmiz
Apr 12 2017 02:54
@GoonTwo In theory you can write a fibonacci using a recursive solution, but as long as your solution woks :)
Gulsvi
@gulsvi
Apr 12 2017 02:55
And it lets me pass because it thinks the extra spaces between the variables are extra words...
Bug in the challenge
David Amanze
@GodKingShogun
Apr 12 2017 02:55
@DJToners you already have created string. you need three more
Gulsvi
@gulsvi
Apr 12 2017 02:55
Or just do result = "The " + myAdjective + ' ' + myNoun + ' ' + myVerb + ' ' + myAdverb;
DJToners
@DJToners
Apr 12 2017 02:55
@SkyCoder01 Why do u have $
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:55
Seriously how do I return 5,6,7,8,9,10...
Danny Welstad
@GoonTwo
Apr 12 2017 02:55
@Marmiz i know... recursion just confuses me though lol :D
@Marmiz thanks
CamperBot
@camperbot
Apr 12 2017 02:56
goontwo sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 830 | @marmiz |http://www.freecodecamp.com/marmiz
Gulsvi
@gulsvi
Apr 12 2017 02:56
It's a template literal @DJToners an easier way to make strings and mix variables in: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
Jason Luboff
@JLuboff
Apr 12 2017 02:56
@HeebieGeeBee looking good. Hard to use on mobile though lol
Gulsvi
@gulsvi
Apr 12 2017 02:56
@MathematicsCoding How would you write code to log 5,6,7,8,9,10?
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:57
console.log?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:57
@JLuboff ahh right yeah
Gulsvi
@gulsvi
Apr 12 2017 02:57
Yes, but how would you get the numbers?
Conor Murphy
@cmurphy580
Apr 12 2017 02:57
anyone willing to help me work through this codewars problem? http://www.codewars.com/kata/power-bind/train/javascript
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:57
for loop..
But return stops them?
Gulsvi
@gulsvi
Apr 12 2017 02:57
correct, so instead of console.log() use .push() to add them to the array
Usman Akram
@usmanakram1996
Apr 12 2017 02:57
@GodKingShogun sir? kindly help me :point_up: April 12, 2017 7:54 AM
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:58
@JLuboff trying to figure out a way to store the image
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:58
arr.push(i)?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:58
so when someone just goes to the page all the stuff thats been drawn before is seen
DJToners
@DJToners
Apr 12 2017 02:58
@GodKingShogun @SkyCoder01

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result = "The " + myAdjective + "ugly "+ myNoun + "pooped and " + myVerb + "very " + myAdverb ;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:58
but its starting to hurt my brain now
Claudio Restifo
@Marmiz
Apr 12 2017 02:59
@HeebieGeeBee implement a JWT (JSON web token)
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:59
whats that?
Claudio Restifo
@Marmiz
Apr 12 2017 02:59
that's what you usually do with autentication
Saboor Malik
@MathematicsCoding
Apr 12 2017 02:59
@DJToners " Hey " + " There "
Jason Luboff
@JLuboff
Apr 12 2017 02:59
@HeebieGeeBee I imagine you need some sort of persistent state but I have no clue on that
Claudio Restifo
@Marmiz
Apr 12 2017 02:59
@HeebieGeeBee
https://jwt.io/
Gulsvi
@gulsvi
Apr 12 2017 02:59
@DJToners Close!! That outputs this:
"The bigugly dogpooped and ranvery quickly"
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 02:59
@Marmiz is that to stop my not secure message?
Gulsvi
@gulsvi
Apr 12 2017 02:59
Fix the spacing and you should have it I think
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:00
lol pooped
DJToners
@DJToners
Apr 12 2017 03:00
@SkyCoder01 I already added the spaces but i still cant pass
Usman Akram
@usmanakram1996
Apr 12 2017 03:00
what's the issue in this i am not getting it :/
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:00

function sumAll(arr) {
  for (var i = Math.min.apply(null,arr); i<=Math.max.apply(null,arr);i++) {
}
  return arr.push();
}
sumAll([5, 10]);
Usman Akram
@usmanakram1996
Apr 12 2017 03:00
blob
Gulsvi
@gulsvi
Apr 12 2017 03:00
@DJToners I copy/pasted yours into my challenge and added the spaces - it worked for me
Claudio Restifo
@Marmiz
Apr 12 2017 03:00
@HeebieGeeBee basically a hashed variable between a user browser and your server.
It's how (and not only limited to) a browser "remember" you're autenticated for a page
Usman Akram
@usmanakram1996
Apr 12 2017 03:01
blob
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:01
function sumAll(arr) {
for (var i = Math.min.apply(null,arr); i<=Math.max.apply(null,arr);i++) {
}
return Math.min.apply(null,arr).push(i);
}
sumAll([5, 10]);
Gulsvi
@gulsvi
Apr 12 2017 03:01
@MathematicsCoding If you return a .push() all you get is the length of the new array - and you have no code inside your for loop
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:01
Do I need that return with method..
DJToners
@DJToners
Apr 12 2017 03:01

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result = "The " + myAdjective + "ugly "+ myNoun + "pooped and " + myVerb + "very " + myAdverb ;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog ", "big ", "ran ", "quickly.");
@SkyCoder01 Is this whatu ended up with
Gulsvi
@gulsvi
Apr 12 2017 03:01
The only thing you're going to return in that function is the sum @MathematicsCoding
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:02
@Marmiz i just do the npm install?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:02
@SkyCoder01 But what do you want me to do with push method?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:02
is that it?
Danny Welstad
@GoonTwo
Apr 12 2017 03:02
@usmanakram1996 I just did that challenge and used these videos to learn RegExp. they were great, I def reccomend "https://www.youtube.com/watch?v=7DG3kCDx53c&list=PLRqwX-V7Uu6YEypLuls7iidwHMdCM6o2w&index=1"
Usman Akram
@usmanakram1996
Apr 12 2017 03:02
@GoonTwo thanks alot :) let me give a try ;)
CamperBot
@camperbot
Apr 12 2017 03:02
usmanakram1996 sends brownie points to @goontwo :sparkles: :thumbsup: :sparkles:
:warning: @goontwo's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Gulsvi
@gulsvi
Apr 12 2017 03:03
@DJToners I don't know why that isn't working... try this? result = "The " + myAdjective + " ugly "+ myNoun + " pooped and " + myVerb + " very " + myAdverb;
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:03
i also used shiffman in part for learning regex
Gulsvi
@gulsvi
Apr 12 2017 03:03
@DJToners Probably a bug in the exercise or something else... you seem to understand it more than enough...
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:03
@SkyCoder01 He didnt add the spaces...
So you just gave him the answer xD
Gulsvi
@gulsvi
Apr 12 2017 03:04
@MathematicsCoding He did, the second time
DJToners
@DJToners
Apr 12 2017 03:04
@SkyCoder01 That worked
Manish Giri
@Manish-Giri
Apr 12 2017 03:04
@HeebieGeeBee is our resident socket expert now
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:04
@SkyCoder01 End of string only..

```

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result = "The " + myAdjective + "ugly "+ myNoun + "pooped and " + myVerb + "very " + myAdverb ;

// Your code above this line
return result;
}

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

```

@SkyCoder01 Is this whatu ended up with

HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:04
@Manish-Giri i feel sorry for you all if im the expert on this matter
DJToners
@DJToners
Apr 12 2017 03:04
@SkyCoder01 thanks
CamperBot
@camperbot
Apr 12 2017 03:04
djtoners sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1006 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Claudio Restifo
@Marmiz
Apr 12 2017 03:04
@HeebieGeeBee unfortunately not. They are kind of a pain to implement.
you need your client to send one of this token to the server, and there you need to handle the data
Manish Giri
@Manish-Giri
Apr 12 2017 03:04
@Marmiz :wave:
Claudio Restifo
@Marmiz
Apr 12 2017 03:05
@Manish-Giri :sparkles:
Manish Giri
@Manish-Giri
Apr 12 2017 03:05
@SkyCoder01 congrats on the 1K! welcome to the starz :star:
Jason Luboff
@JLuboff
Apr 12 2017 03:05
@Manish-Giri good thing we got the resident DB expert here too! 😉
Gulsvi
@gulsvi
Apr 12 2017 03:05
Thanks @Manish-Giri :) another know it all lol
CamperBot
@camperbot
Apr 12 2017 03:05
skycoder01 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5120 | @manish-giri |http://www.freecodecamp.com/manish-giri
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:05
about @JLuboff
CamperBot
@camperbot
Apr 12 2017 03:05
:star2: 1473 | @jluboff |http://www.freecodecamp.com/jluboff
Manish Giri
@Manish-Giri
Apr 12 2017 03:05
@JLuboff :scream: :joy: :hear_no_evil: :see_no_evil:
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:06
@Marmiz i'll have to bookmark it and look it into it later
Manish Giri
@Manish-Giri
Apr 12 2017 03:06
says the mongo expert @JLuboff
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:06
just dealing with basics of websockets at moment
Manish Giri
@Manish-Giri
Apr 12 2017 03:06
@Marmiz got a question about heroky
Gulsvi
@gulsvi
Apr 12 2017 03:06
@MathematicsCoding Back to the basics for .push() -- how to add 5 to this array? var arr = [1,2,3,4]
Jason Luboff
@JLuboff
Apr 12 2017 03:06
@Manish-Giri 😂😂😂😂😂😂
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:06
arr.push(5)
Gulsvi
@gulsvi
Apr 12 2017 03:07
Right - no need for return
Claudio Restifo
@Marmiz
Apr 12 2017 03:07
@HeebieGeeBee :) sure thing.
Learning how to make one is a good thing tho. It's one of those stuff they ask to full-stackers ;)
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:07
oh...
Jason Luboff
@JLuboff
Apr 12 2017 03:07
The answer to all heroku questions....is...heroku is garbage 😁
Manish Giri
@Manish-Giri
Apr 12 2017 03:07
lol so true
Claudio Restifo
@Marmiz
Apr 12 2017 03:07
@Manish-Giri what about it?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:07
@Marmiz im watching the video but its not gonna get absorbed at th emoment
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:07
What what am I supposed to add to push method?
Claudio Restifo
@Marmiz
Apr 12 2017 03:07
I never used it besides hobby
Allan Pd
@ashish98054
Apr 12 2017 03:08
Multiply Two Decimals with JavaScript > Change the 0.0 so that product will equal 5.0. (help me here i'm stuck)
Manish Giri
@Manish-Giri
Apr 12 2017 03:08
Screenshot 2017-04-11 23.07.58.png
@Marmiz any idea here?
Gulsvi
@gulsvi
Apr 12 2017 03:08
var arr = [];
for (var i = 0, i < 5, i++) {
  arr.push(i);
}
console.log(arr) // [0, 1, 2, 3, 4]
@MathematicsCoding
Claudio Restifo
@Marmiz
Apr 12 2017 03:08
@HeebieGeeBee there is ofc an express middelware for that :)
https://github.com/auth0/express-jwt
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:08
That what i did but..
Gulsvi
@gulsvi
Apr 12 2017 03:08
That's how to make an array with .push() - but you have to figure out where to start and stop
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:08
Is it because of return?
Gulsvi
@gulsvi
Apr 12 2017 03:09
And because you have no code between { } in your for loop
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:09

function sumAll(arr) {
  for (var i = Math.min.apply(null,arr); i<=Math.max.apply(null,arr);i++) {
    arr = arr.push(i);
}
  return arr;
}
sumAll([5, 10]);
Allan Pd
@ashish98054
Apr 12 2017 03:10
Multiply Two Decimals with JavaScript > Change the 0.0 so that product will equal 5.0. (help me here i'm stuck)
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:10
@Marmiz thanks
CamperBot
@camperbot
Apr 12 2017 03:10
heebiegeebee sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 831 | @marmiz |http://www.freecodecamp.com/marmiz
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:10
oh cosolelog
console log*
Claudio Restifo
@Marmiz
Apr 12 2017 03:10
@Manish-Giri no Idea, what does the documentation said?
Manish Giri
@Manish-Giri
Apr 12 2017 03:10
nothing
Claudio Restifo
@Marmiz
Apr 12 2017 03:10
Is that the only error you got?
Manish Giri
@Manish-Giri
Apr 12 2017 03:10
it's gargabe, as @JLuboff mentioned
Gulsvi
@gulsvi
Apr 12 2017 03:10
@MathematicsCoding You don't need arr = that just sets arr to the length of the array because arr.push() returns the length after adding an element
Jason Luboff
@JLuboff
Apr 12 2017 03:10
@Manish-Giri I assume your package.json is all good?
Manish Giri
@Manish-Giri
Apr 12 2017 03:10
@JLuboff yeah
Gulsvi
@gulsvi
Apr 12 2017 03:11
@MathematicsCoding this is the Stand In Line challenge
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:11
...
Claudio Restifo
@Marmiz
Apr 12 2017 03:11
@Manish-Giri don't assign a default port on Heroku. That's a thing I remember NOT to do
Manish Giri
@Manish-Giri
Apr 12 2017 03:11
@Marmiz I have it as process.env.PORT || 3000
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:11
I did but it also add arr before for loops..
5,10.5,6,7,8,9,10
Manish Giri
@Manish-Giri
Apr 12 2017 03:12
lemme try sth real quick
David Amanze
@GodKingShogun
Apr 12 2017 03:12
@Manish-Giri i almost did not recognize you. :wave:
Gulsvi
@gulsvi
Apr 12 2017 03:12
@MathematicsCoding Maybe this helps explain better:
var arr = [];
for (var i = 0; i < 5; i++) {
  arr.push(i);
}
var arrayLength = arr.push(200);

console.log(arr) // [0, 1, 2, 3, 4, 200]
console.log(arrayLength) // 6
Manish Giri
@Manish-Giri
Apr 12 2017 03:12
@GodKingShogun hola :smile:
Jason Luboff
@JLuboff
Apr 12 2017 03:12
@Manish-Giri that port setup is good.
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:12
Yeah..
Jason Luboff
@JLuboff
Apr 12 2017 03:13
You have your start script in package.json all good?
Claudio Restifo
@Marmiz
Apr 12 2017 03:13
@Manish-Giri same goes for the start script?
Gulsvi
@gulsvi
Apr 12 2017 03:13
Sorry, some edits... but I think you got it
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:13
Yeah I got it
So now I just need to remove 5,10..
Gulsvi
@gulsvi
Apr 12 2017 03:14
@MathematicsCoding Yes, or start 1 higher and end one lower
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:15

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr); i>=Math.in.apply(null,arr);i++) {
    arr.push(i);
}
  return arr;
}
sumAll([5, 10]);
oops
in
The Great Cthulhu
@Ghoststorm34
Apr 12 2017 03:16
I'm having issues with the "Escape Sequences in Strings" challenge
I'm so confused
Claudio Restifo
@Marmiz
Apr 12 2017 03:16
@Manish-Giri make sure your package.json is at the root
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:16
ction sumAll(arr) {
  for (var i = Math.max.apply(null,arr); i<=Math.min.apply(null,arr);i++) {
    arr.push(i);
}
  return arr;
}
sumAll([5, 10]);
Claudio Restifo
@Marmiz
Apr 12 2017 03:17
@Ghoststorm34 the key is to "convert" the string from human to code :)
knowing that the " inside a string needs to be escaped
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:18
@SkyCoder01 Is that what you meant?
Gulsvi
@gulsvi
Apr 12 2017 03:18
@MathematicsCoding No, that gives you this for loop:
  for (var i = 10; i <= 5; i++) {
    arr.push(i);
  }
How can you start at 6 and end at 9?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:18
Yeah?
...
Moisés Man
@moigithub
Apr 12 2017 03:19
10 is NOT <=5 soo that wont loop
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:19
So > then...
But infinite loop?
Gulsvi
@gulsvi
Apr 12 2017 03:20
@MathematicsCoding What is this equal to? Math.max.apply(null,arr)
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:20
10
The Great Cthulhu
@Ghoststorm34
Apr 12 2017 03:20
This is what I have so far "var myStr="FirstLine \n \ SecondLine \ \r ThirdLine"; // Change this line"
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:21
ooh,,,
:(
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:21
@Ghoststorm34 no spaces
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:21
Forgot about it
Gulsvi
@gulsvi
Apr 12 2017 03:21
let him get it @moigithub so close :)
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:21
Yeah

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr); i>=Math.min.apply(null,arr);i--) {
    arr.push(i);
}
  return arr;
}
sumAll([5, 10]);
hanafiduck
@hanafiduck
Apr 12 2017 03:22
"Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
"Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
Gulsvi
@gulsvi
Apr 12 2017 03:22
...
hanafiduck
@hanafiduck
Apr 12 2017 03:22
...... need a help .....
function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while(i<contacts.length){
if(contacts[i]["firstName"]==firstName){
return contacts[i]["lastName"];
} else {
return "No such contact";
}
i++;
}
// Only change code above this line
}
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:22
@SkyCoder01 What did I do wrong..
5,10 again
Claudio Restifo
@Marmiz
Apr 12 2017 03:22
@Ghoststorm34 also remember that if I want to see a \ i need to escape it :)
Gulsvi
@gulsvi
Apr 12 2017 03:22
@MathematicsCoding Nothing, actually, I didn't see you switched to i--
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:23
lol
Gulsvi
@gulsvi
Apr 12 2017 03:23
Now, you need to be going from 9 to 6 though.
The Great Cthulhu
@Ghoststorm34
Apr 12 2017 03:23
and it worked
Gulsvi
@gulsvi
Apr 12 2017 03:23
how do you make Math.max.apply(null,arr) = to 9
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:23
@hanafiduck youre missing out a property check if the firstname matches
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:23
-1
The Great Cthulhu
@Ghoststorm34
Apr 12 2017 03:23
Thanks guys
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:23
and then when you make a return of that property dont hardcode the value like that @hanafiduck
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:24
I mean add -1 after it
Gulsvi
@gulsvi
Apr 12 2017 03:24
yes, correct
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:24

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr)-1; i>=Math.min.apply(null,arr)+1;i--) {
    arr.push(i);
}
  return arr;
}
sumAll([5, 10]);
Can I switch it..
max and min
hanafiduck
@hanafiduck
Apr 12 2017 03:25
@HeebieGeeBee i don't get it, could you please give me an example
Moisés Man
@moigithub
Apr 12 2017 03:25

@MathematicsCoding a general rule.. is .. u should NOT change the array u iterating.. cuz that can cause weird/hard to track behavior.. soo easier is create a new (array) variable

also... loop conditions is evaluated EVERYtime it loops i>=Math.min.apply(null,arr)
better move it above.. use another variable.. so it only gets evaluated once for better performace (at least on this case)

HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:26
@MathematicsCoding did this come challenge before writing the fibonacci algorithm ?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:26
Yes
Gulsvi
@gulsvi
Apr 12 2017 03:26
These are all optimizations, and they're important. One thing at a time though.
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:26
This is actually first challenge
hanafiduck
@hanafiduck
Apr 12 2017 03:26
@HeebieGeeBee i dont get it
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:26
@hanafiduck do youremember the challenge where you used .hasOwnPropery() to check an object for a particular property?
hanafiduck
@hanafiduck
Apr 12 2017 03:27
yup
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:27
well you have to do that in this challenge too
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:28
@SkyCoder01

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr)-1; i>=Math.min.apply(null,arr);i--) {
    arr.push(i);
}
  return arr;
}
sumAll([5, 10]);
Now it return 5,10 to 5
Can i use shift method?
Gulsvi
@gulsvi
Apr 12 2017 03:29
@MathematicsCoding What happened to your +1?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:29
To remove first 5..
Well..
Gulsvi
@gulsvi
Apr 12 2017 03:30
And why not just do > instead of >=?
Ryan Haire
@RyaanH
Apr 12 2017 03:30

`function mutation(arr) {
var word1 = arr[0].toLowerCase();
var word2 = arr[1].toLowerCase();

for(var i = 0; i < word2.length; i++){
var value = word1.indexOf(word2[i]);
return value === -1 ? false : true;
}

}

mutation(["hello", "hey"]);
`

Saboor Malik
@MathematicsCoding
Apr 12 2017 03:30
Then I would need 1+ for that
Ryan Haire
@RyaanH
Apr 12 2017 03:30
why does my code not work for this one test case but for the rest?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:30
@RyaanH you shouldnt return true and false within the loop
you'll only get one iteration
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:31
If i do > with 1+ then I cant get 6..
hanafiduck
@hanafiduck
Apr 12 2017 03:31
like this ?

function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while(i<contacts.length){
if(contacts[i]["firstName"]==firstName){
if(contacts[i].hasOwnProperty(prop)){

  }
} else {
   return "No such contact";
}
i++;

}
// Only change code above this line
}

HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:32
@hanafiduck yes now you need to sort out what and where your returns are and go
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:32
@SkyCoder01 well what about this?

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr)-1; i>Math.min.apply(null,arr)-1;i--) {
    arr.push(i);
}
  return arr;
}
sumAll([5, 10]);
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:32
@hanafiduck the one return you have at the moment is in the wrong place
Ryan Haire
@RyaanH
Apr 12 2017 03:32
@HeebieGeeBee i can't take the value of var value; out of the loop, i want to use ? : instead of if/else
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:33
@RyaanH why?
Ryan Haire
@RyaanH
Apr 12 2017 03:33
the console said the var value is private to the loop apparently
Gulsvi
@gulsvi
Apr 12 2017 03:33
@MathematicsCoding if you change to use > you don't need the -1
Ryan Haire
@RyaanH
Apr 12 2017 03:34
ill just make var value out of the loop instead
hanafiduck
@hanafiduck
Apr 12 2017 03:34
@HeebieGeeBee where the returns must be placed at?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:34
@RyaanH that wont help
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:34
Yeah recently deleted it
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:34
youre still making a return on the first iteration @RyaanH
Gulsvi
@gulsvi
Apr 12 2017 03:34
your code up there is the same as: for (var i = 9; i > 4; i--) {
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:34
which is the problem
Gulsvi
@gulsvi
Apr 12 2017 03:34
you want i = 9; i > 5
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:34
What about that +1?
never mind its -1
Go ahead
Ryan Haire
@RyaanH
Apr 12 2017 03:36

function mutation(arr) {
var word1 = arr[0].toLowerCase();
var word2 = arr[1].toLowerCase();
var value;
for(var i = 0; i < word2.length; i++){
value = word1.indexOf(word2[i]);
}
return value === -1 ? false : true;
}

mutation(["hello", "hey"]);

the test cases that are correct keep changing
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:36
@RyaanH now youre just re evaluating the value variable on each iteration
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:37
@SkyCoder01 What wrong?
oooh its done..
Ryan Haire
@RyaanH
Apr 12 2017 03:37
how do i make it so it iterates through them all?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:37
Now I just have to reduce..
order doesnt matter?
Gulsvi
@gulsvi
Apr 12 2017 03:37
@MathematicsCoding Show the update after getting rid of the second -1
Order doesn't matter in the reduce
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:38
@RyaanH well you only want to make a return false inside the loop if there is no index
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:38
Then..
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:38
then you can return true outside the loop
Ryan Haire
@RyaanH
Apr 12 2017 03:38
ahh ok
thanks @HeebieGeeBee i passed now
CamperBot
@camperbot
Apr 12 2017 03:39
ryaanh sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1270 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:39
cool well done
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:40

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr)-1; i>Math.min.apply(null,arr);i--) {
    arr.push(i);
}
 arr.reduce(function(a,b) {
    return a + b;
}, 0);
}
sumAll([5, 10]);
Gulsvi
@gulsvi
Apr 12 2017 03:40
@MathematicsCoding return the sum
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:41

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr)-1; i>Math.min.apply(null,arr);i--) {
    arr.push(i);
}
 var sum = arr.reduce(function(a,b) {
    return a + b;
}, 0);
}
sumAll([5, 10]);
Gulsvi
@gulsvi
Apr 12 2017 03:41
@MathematicsCoding return the sum :)
you've declared it, now return it
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:42
oh..
Yeah
Nothing
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:43
nothing?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:43
Yeah
Nothing happen
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:43
post the code
Gulsvi
@gulsvi
Apr 12 2017 03:43
function myFunc() {
  var sum = 10;
}
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:43
oh I didnt do a+b my bad
Gulsvi
@gulsvi
Apr 12 2017 03:43
How to return 10 from that function?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:43
return sum
Gulsvi
@gulsvi
Apr 12 2017 03:43
yes
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:44
But what about a+b?
Gulsvi
@gulsvi
Apr 12 2017 03:44
They are needed to get you the sum
once you get the sum, you return it
  var sum = arr.reduce(function(a,b) {
    return a + b;
}, 0);

  return sum;
That ^^
Is the same as:
return arr.reduce(function(a,b) {
    return a + b;
}, 0);
hanafiduck
@hanafiduck
Apr 12 2017 03:45
Your regular expression should find two occurrences of the word and.
Use regular expressions to find the word and in testString.
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:45
@SkyCoder01 I did it in first example
But nothing happens but 2ns worked
2nd*
Jeremy Seilhymer
@jseilhymer
Apr 12 2017 03:46
Hey all! I'm having an issue with 'Escape Sequences in Strings'.
Gulsvi
@gulsvi
Apr 12 2017 03:46
what is your code now?
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:46

function sumAll(arr) {
  for (var i = Math.max.apply(null,arr)-1; i>Math.min.apply(null,arr);i--) {
    arr.push(i);
}
 var sum = arr.reduce(function(a,b) {
    return a+b;
}, 0);
  return sum;
}
sumAll([5, 10]);
Thanks @SkyCoder01 :)
CamperBot
@camperbot
Apr 12 2017 03:47
mathematicscoding sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1007 | @skycoder01 |http://www.freecodecamp.com/skycoder01
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:47
@jseilhymer what issue?
Jeremy Seilhymer
@jseilhymer
Apr 12 2017 03:47
var myStr = "Your\nMom\Goes\\rToCollege";
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:47
lol
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:47
your mom does
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:47
Not my mom
Gulsvi
@gulsvi
Apr 12 2017 03:47
@MathematicsCoding Good job - now take some of that advice from @moigithub. Declare a min/max variable and use those in your for loop
  var min = Math.min.apply(null, arr);
  var max = Math.max.apply(null, arr);

  for (var i =  max - 1; i > min; i--) {
    arr.push(i);
  }
Jeremy Seilhymer
@jseilhymer
Apr 12 2017 03:47
It keeps saying it should have encoded text with the proper escape sequence
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:47
@SkyCoder01 Okay
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:48
im not sure thats the string they wanted you to use is it @jseilhymer
Jeremy Seilhymer
@jseilhymer
Apr 12 2017 03:48
Let me try the example they have. That might be it....
Gulsvi
@gulsvi
Apr 12 2017 03:48

This is my solution:

function sumAll(arr) {
  const min = Math.min(...arr),
        max = Math.max(...arr);

  return Array.from({length: max - min + 1}, (v, i) => i + min).reduce((a, b) => a + b);
}

sumAll([1, 4]);

To see other ways to do it

Saboor Malik
@MathematicsCoding
Apr 12 2017 03:49
Yeah with that ... thinhy
thingy* and it says its only available in ES6
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:49
spread operator
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:49
So const means two vars
?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:49
or think its called the rest too
Gulsvi
@gulsvi
Apr 12 2017 03:49
const means a var that can't be declared again
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:49
spread operator is correct
@SkyCoder01 I see
Jeremy Seilhymer
@jseilhymer
Apr 12 2017 03:50
@HeebieGeeBee Nailed it. Thank you my friend. I guess no one's mom is going to college :)
CamperBot
@camperbot
Apr 12 2017 03:50
jseilhymer sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1271 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:50
@jseilhymer My mom graduated from college..
My dad Have BS in Computer science
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:51
mine too
and my brother
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:51
I see
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:51
think my brother has actually something fancy
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:51
When my dad graduated had BS in CS and that time CS paying rate was too low..
CS salary
He said it was something like 40k+
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:52
thats not low is it
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:52
That was long time ago..
Like 30+ years ago maybe?
I dont know if it was low... but he didnt like it
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:53
thats what i mean 30 years ago that was a good wage wasnt it
well still kind of is
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:53
My dad used to work in best buy lol
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:54
not that i really know too much about it cus my mum and dad were seperated
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:54
Oh sorry to hear that
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:54
but my dad made nice money working in audi arabia in the naughties
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:54
You were in Asia?
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:54
@MathematicsCoding nothing to be sorry about
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:54
:)
Heathercoraje
@Heathercoraje
Apr 12 2017 03:54
Hi, I am stuck in stand in Line challenge.
HeebieGeeBee
@HeebieGeeBee
Apr 12 2017 03:55
@MathematicsCoding i wasnt living with him but i did go to saudi on a trip
Saboor Malik
@MathematicsCoding
Apr 12 2017 03:55
I see