These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Mar 2017
Andrew Robida
@arobida
Mar 09 2017 00:00
omg I need help
Manish Giri
@Manish-Giri
Mar 09 2017 00:00
@arobida with?
Jason Luboff
@JLuboff
Mar 09 2017 00:00
@Missposhtee To format your code, use three backticks ``` then shift+enter paste your code then shift+ enter and three more backticks
Andrew Robida
@arobida
Mar 09 2017 00:00
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  var result=checkProp.this;
   if (myObj.hasOwnProperty(checkProp)===true) {
     return result;
    } else    
    return "Not Found";
  }  

// Test your code by modifying these values
checkObj("gift");
it only returns "Not Found"
Jason Luboff
@JLuboff
Mar 09 2017 00:01
@arobida checkProp.this isn't going to work... you need to tell it to search the object for checkProp
Adam VanZuiden
@adamvz
Mar 09 2017 00:01
@arobida becuase you are only returning "Not Found"
Manish Giri
@Manish-Giri
Mar 09 2017 00:01
@arobida what is this? var result=checkProp.this;
Andrew Robida
@arobida
Mar 09 2017 00:01
do I need a for loop
Adam VanZuiden
@adamvz
Mar 09 2017 00:02
@arobida whoops my mistake I misread your code. Second time in a row.
Andrew Robida
@arobida
Mar 09 2017 00:02
that is me storing a property value in a variable
Manish Giri
@Manish-Giri
Mar 09 2017 00:02
do you know what the keyword this is?
Jason Luboff
@JLuboff
Mar 09 2017 00:03
@arobida you're storing undefined. checkProp.this would be undefined..
review this lesson
Andrew Robida
@arobida
Mar 09 2017 00:04
@Manish-Giri I somewhat understand its contextual
john94
@lpy1994
Mar 09 2017 00:04
@joreyesl don’t know why there are some can’t pass through
Yakubu El-Rufai Mahatma
@snaps23
Mar 09 2017 00:04
hey guys
john94
@lpy1994
Mar 09 2017 00:05
@joreyesl I am thinking about using indexOf on that
Jor
@joreyesl
Mar 09 2017 00:05
@lpy1994 what is your current code?
Yakubu El-Rufai Mahatma
@snaps23
Mar 09 2017 00:05
need help on json requests
john94
@lpy1994
Mar 09 2017 00:05
I used your suggestion, don’t know why it won’t work
Missposhtee
@Missposhtee
Mar 09 2017 00:05
@JLuboff didnt get that
john94
@lpy1994
Mar 09 2017 00:06
@joreyesl now I am trying to use IndexOf
Jor
@joreyesl
Mar 09 2017 00:06
@lpy1994 that can work as well
Jason Luboff
@JLuboff
Mar 09 2017 00:06
```
shift + enter to go to a new line
```
@Missposhtee
Yakubu El-Rufai Mahatma
@snaps23
Mar 09 2017 00:06
https://www.freecodecamp.com/challenges/convert-json-data-to-html#?solution=%0Afccss%0A%20%20%24(document).ready(function()%20%7B%0A%0A%20%20%20%20%24(%22%23getMessage%22).on(%22click%22%2C%20function()%20%7B%0A%E2%80%89%E2%80%89%20%20%20%20%24.getJSON(%22%2Fjson%2Fcats.json%22%2C%20function(json)%20%7B%0A%0A%20%20%20%20%20%20%20%20var%20html%20%3D%20%22%22%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20Only%20change%20code%20below%20this%20line.%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%2F%2F%20Only%20change%20code%20above%20this%20line.%0A%0A%E2%80%89%E2%80%89%E2%80%89%E2%80%89%20%20%20%20%24(%22.message%22).html(html)%3B%0A%0A%E2%80%89%E2%80%89%20%20%20%20%7D)%3B%0A%20%20%20%20%7D)%3B%0A%20%20%7D)%3B%0Afcces%0A%0A%3Cdiv%20class%3D%22container-fluid%22%3E%0A%20%20%3Cdiv%20class%20%3D%20%22row%20text-center%22%3E%0A%20%20%20%20%3Ch2%3ECat%20Photo%20Finder%3C%2Fh2%3E%0A%20%20%3C%2Fdiv%3E%0A%20%20%3Cdiv%20class%20%3D%20%22row%20text-center%22%3E%0A%20%20%20%20%3Cdiv%20class%20%3D%20%22col-xs-12%20well%20message%22%3E%0A%20%20%20%20%20%20The%20message%20will%20go%20here%0A%20%20%20%3C%2Fdiv%3E%0A%20%20%3C%2Fdiv%3E%0A%20%20%3Cdiv%20class%20%3D%20%22row%20text-center%22%3E%0A%20%20%20%20%3Cdiv%20class%20%3D%20%22col-xs-12%22%3E%0A%20%20%20%20%20%20%3Cbutton%20id%20%3D%20%22getMessage%22%20class%20%3D%20%22btn%20btn-primary%22%3E%0A%20%20%20%20%20%20%20%20Get%20Message%0A%20%20%20%20%20%20%3C%2Fbutton%3E%0A%20%20%20%20%3C%2Fdiv%3E%0A%20%20%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A i dont understand a bit of that . need help
john94
@lpy1994
Mar 09 2017 00:07
@joreyesl I like yours, it more simple. but Can’t get it done.
Andrew Robida
@arobida
Mar 09 2017 00:07
@Manish-Giri I know I could store every property as variables but i am trying to let it accept anything
that lesson just shows that you can store properties in variables
Missposhtee
@Missposhtee
Mar 09 2017 00:08
@JLuboff oh sorry wasnt talking about going to a new line....was wondering ow to copy my code neatly on her with the black background
Joel
@MMK123
Mar 09 2017 00:09

// Setup
var a = 7;
var b = var a;

// Only change code below this line

see anything wrong with this?
I'm confused
instruction are to assign the value 7 to variable a
and assign the contents of a to variable b
Missposhtee
@Missposhtee
Mar 09 2017 00:10

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

Adam VanZuiden
@adamvz
Mar 09 2017 00:11
@MMK123 don't use the var keyword when assigning content of variables
@MMK123 only use var when declaring the variable. If you want the contents of that variable afterwards just use the name you gave it.
Jason Luboff
@JLuboff
Mar 09 2017 00:12
@Missposhtee What I described is how to do that
Here is formatted code between backticks
Adam VanZuiden
@adamvz
Mar 09 2017 00:13
'''
CamperBot
@camperbot
Mar 09 2017 00:13
:bulb: to format code use backticks! ``` more info
Adam VanZuiden
@adamvz
Mar 09 2017 00:13
@Missposhtee click on that camperbot link
Joel
@MMK123
Mar 09 2017 00:13
thank you adam
JenimDacket
@JenimDacket
Mar 09 2017 00:15
@joreyesl Thank you so much man
CamperBot
@camperbot
Mar 09 2017 00:15
jenimdacket sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 574 | @joreyesl |http://www.freecodecamp.com/joreyesl
Adam VanZuiden
@adamvz
Mar 09 2017 00:16
@MMK123 no problem!
JenimDacket
@JenimDacket
Mar 09 2017 00:16
And thank you to everyone else. Sorry. I was losing my mind not being able to understand this.
Dennis
@denskiz
Mar 09 2017 00:16

Has anyone completed: ES6: Use getters and setters to Control Access to an Object?

I'm stuck on this one

JenimDacket
@JenimDacket
Mar 09 2017 00:17

Question: function trueOrFalse(wasThatTrue){ if(wasThatTrue){return "Yes, that was true";}
{return "No, that was false";}}

Will the first assigned value always be teh "true" value and the second always the "false"?

"Replace assigned value" with "return"
Andrew Robida
@arobida
Mar 09 2017 00:19
@JLuboff Do you know how I can store the arguments property in a variable?
Jason Luboff
@JLuboff
Mar 09 2017 00:20
@JenimDacket Yes. the if condition (whats inside the parenthesis) tests if the value is true. If, and only if, its true will it return whats inside it's curly brackets. If its false, it will move on
curiousNoob
@curiousNoob
Mar 09 2017 00:20
@arobida this.argumentName=argumentName
Jason Luboff
@JLuboff
Mar 09 2017 00:20
@arobida var myVar = arguments[0]
@arobida That would be just for the first argument though
JenimDacket
@JenimDacket
Mar 09 2017 00:21
@JLuboff I was reading something online about if....else.... so the else is not necessary?
Jason Luboff
@JLuboff
Mar 09 2017 00:22
@JenimDacket Not always
Adam VanZuiden
@adamvz
Mar 09 2017 00:22
@JenimDacket in an if statement everything between the parethensis is checking to see if it's true.
Andrew Robida
@arobida
Mar 09 2017 00:23
@curiousNoob Huh/
?
Adam VanZuiden
@adamvz
Mar 09 2017 00:24
@JenimDacket in that example you used wasThatTrue will be a boolean passed in the arugment. So it will either be true or false
James
@jamesns
Mar 09 2017 00:24
ugh.. still can't get the Profile Lookup thing right :( can I post my code?
curiousNoob
@curiousNoob
Mar 09 2017 00:26
@arobida refer to @JLuboff answer
var myVar = arguments
Gulsvi
@gulsvi
Mar 09 2017 00:27
@jamesns Yes, you can post your code
James
@jamesns
Mar 09 2017 00:27
function lookUpProfile(firstName, prop){
  var i = 0;
  while (i < contacts.length) {
    if (contacts[i][firstName] == firstName) {
        if (contacts.hasOwnProperty(prop)) {
          return prop;
        } else {
          return "No such property";
        }
    } else {
      i++;
    }    
  }
  return "No such contact";
}
am I too far from the answer?
Missposhtee
@Missposhtee
Mar 09 2017 00:28

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

wats wrong in here pls
Jason Luboff
@JLuboff
Mar 09 2017 00:29
@Missposhtee You need to use the parameters myNoun myAdjective ,etc They will provide the values from the function call.
Jor
@joreyesl
Mar 09 2017 00:29
@jamesns contacts.hasOwnProperty you are missing [i]
return prop; how do you return the property of an object? here you are only return the prop key
Manish Giri
@Manish-Giri
Mar 09 2017 00:31
@Missposhtee you need to form a string, and assign it to result, using string concatenation (+). The string has to be formed by concatenating the four parameters in your function - myNoun, myAdjective, etc, along with spaces and (optionally) some words of your own - to form a coherent sentence.
Missposhtee
@Missposhtee
Mar 09 2017 00:31
@Missposhtee were does that come in please
James
@jamesns
Mar 09 2017 00:34
@joreyesl ok, so I changed those 2 lines, so now they look like this:
        if (contacts[i].hasOwnProperty(prop)) {
          return contacts[prop];
is that what you meant?
Missposhtee
@Missposhtee
Mar 09 2017 00:35
@Manish-Giri oh kk...but were does the cat little hit slowly comes in?
Jor
@joreyesl
Mar 09 2017 00:36
@jamesns yep, remember you need the [i] whenever you are referring to the current object, so the return needs it also. remember contacts is the entire list, contacts[i] is one object.
Seth
@sethdcd
Mar 09 2017 00:36

hi all how can i use this same loop

        for ( var i = 0; i < 10; i++ ) {
          console.log(data.query.search[i].title);
        }

but with a jquery each loop?

$.each(data, function( i, value) {
          console.log(value.query.search[i].title);
        });

this is what i tried but no dice

Manish Giri
@Manish-Giri
Mar 09 2017 00:36
@Missposhtee when you call the function
Missposhtee
@Missposhtee
Mar 09 2017 00:37
@Manish-Giri am not getting that pls
Manish Giri
@Manish-Giri
Mar 09 2017 00:37
the words cat, little, etc, replace the parameters in your function like myNoun, myAdjective, etc
@Missposhtee
James
@jamesns
Mar 09 2017 00:38
@joreyesl right. well, it still doesn't work :( I don't know what else I'm missing here
Manish Giri
@Manish-Giri
Mar 09 2017 00:38
function add(num1,num2)  {
return num1 + num2;
}

add(5,10);
@Missposhtee see here
Missposhtee
@Missposhtee
Mar 09 2017 00:38
@Manish-Giri i used the big dog ran quickly already....do i have to clear that off?
Manish Giri
@Manish-Giri
Mar 09 2017 00:38
when you call add(5,10), those numbers replace num1 and num2
@Missposhtee yes
john94
@lpy1994
Mar 09 2017 00:39
guys, how to use ?, : in js?
Joseph
@revisualize
Mar 09 2017 00:39
cbot
CamperBot
@camperbot
Mar 09 2017 00:39
you called?
Joseph
@revisualize
Mar 09 2017 00:39
@jamesns If you post your code just post the function . Not the large array.
Manish Giri
@Manish-Giri
Mar 09 2017 00:39
@lpy1994 var a = 2 > 4 ? true : false;
Manish Giri
@Manish-Giri
Mar 09 2017 00:39
@lpy1994 try to go through that and see what it does.
Jor
@joreyesl
Mar 09 2017 00:39
@jamesns the logic in your code looked correct. Post the updated changes?
Joseph
@revisualize
Mar 09 2017 00:40
Am I not connected?
john94
@lpy1994
Mar 09 2017 00:40
@Manish-Giri @eyesore- thx!
CamperBot
@camperbot
Mar 09 2017 00:40
lpy1994 sends brownie points to @manish-giri and @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 78 | @eyesore- |http://www.freecodecamp.com/eyesore-
:star2: 4657 | @manish-giri |http://www.freecodecamp.com/manish-giri
James
@jamesns
Mar 09 2017 00:40
@joreyesl sure:
function lookUpProfile(firstName, prop){
  var i = 0;
  while (i < contacts.length) {
    if (contacts[i][firstName] == firstName) {
        if (contacts[i].hasOwnProperty(prop)) {
          return contacts[i][prop];
        } else {
          return "No such property";
        }
    } else {
      i++;
    }    
  }
  return "No such contact";
}
Joseph
@revisualize
Mar 09 2017 00:40
@lpy1994 Let me show you.
eyesore-
@eyesore-
Mar 09 2017 00:40
No problem
Joseph
@revisualize
Mar 09 2017 00:40
ACK!
cbot
CamperBot
@camperbot
Mar 09 2017 00:41
you called?
Joseph
@revisualize
Mar 09 2017 00:41
Can you see me now?
Conrad Kay
@conradkay
Mar 09 2017 00:41
var answer = "";
// Only change code below this line
switch(val) {
case 1:
answer = "apple";
break;
case 2:
answer = "bird";
break;
case 3:
answer = "cat";
break;
default:
answer = "stuff";
}
Seth
@sethdcd
Mar 09 2017 00:41

hi all how can i use this same loop

        for ( var i = 0; i < 10; i++ ) {
          console.log(data.query.search[i].title);
        }

but with a jquery each loop?

$.each(data, function( i, value) {
          console.log(value.query.search[i].title);
        });

this is what i tried but no dice, ideally i want the foreach loop so i can iterate through an undetermined amount of objects

Conrad Kay
@conradkay
Mar 09 2017 00:41
failing this one
Joseph
@revisualize
Mar 09 2017 00:41
damn it. I really need to reboot my comptuer.
Missposhtee
@Missposhtee
Mar 09 2017 00:42

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

// Your code above this line
return result;
}

// Change the words here to test your functi

i removed that and added this.....and everything went wrong
Jason Luboff
@JLuboff
Mar 09 2017 00:43
@sethdcd have you tried console.log(value.title)?
Manish Giri
@Manish-Giri
Mar 09 2017 00:43
@Missposhtee remove the quotes
and you need spaces between the words
Missposhtee
@Missposhtee
Mar 09 2017 00:44
ok
Jor
@joreyesl
Mar 09 2017 00:44
@jamesns here, try if (contacts[i].firstName instead of if(contacts[i][firstName]
Seth
@sethdcd
Mar 09 2017 00:44
@JLuboff i haven't, this is for the wiki viewer, and the json kinda nests it deep
@JLuboff let me try
Jason Luboff
@JLuboff
Mar 09 2017 00:45
@sethdcd Actually... try value.query.search.title
James
@jamesns
Mar 09 2017 00:45
@joreyesl perfect!! worked like a charm :) thank you so much :+1:
CamperBot
@camperbot
Mar 09 2017 00:45
jamesns sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 575 | @joreyesl |http://www.freecodecamp.com/joreyesl
Joseph
@revisualize
Mar 09 2017 00:45
hey.
cbot
CamperBot
@camperbot
Mar 09 2017 00:45
you called?
James
@jamesns
Mar 09 2017 00:45
it was driving me crazy lol
Joseph
@revisualize
Mar 09 2017 00:46
I'm back!
Seth
@sethdcd
Mar 09 2017 00:46
@JLuboff TypeError: value.query is undefined
Joseph
@revisualize
Mar 09 2017 00:46
@Missposhtee You have a string
Jason Luboff
@JLuboff
Mar 09 2017 00:46
@sethdcd Ya try value.query.search.title
Joseph
@revisualize
Mar 09 2017 00:46
I"M BACK!
stupid computer.
Seth
@sethdcd
Mar 09 2017 00:46
console.log(value.query.search.title); i did @JLuboff
Jason Luboff
@JLuboff
Mar 09 2017 00:46
But Joseph...you never left..
@sethdcd Do you have it in codepen?
Joseph
@revisualize
Mar 09 2017 00:47
@JLuboff No no.. I did. I had to crash Chrome and reboot.
Jor
@joreyesl
Mar 09 2017 00:47
@jamesns yea, its one of those where you have to understand whether to use bracket or dot notation. In this case, you want to get the property "firstName" not the property key represented by firstName, Because if they pass in firstName = "Kristian", then you are checking if(contacts[i]["Kristian"], i.e. you are retreiving the "Kristian" property which does not exist.
Seth
@sethdcd
Mar 09 2017 00:47
@JLuboff i just put in the i value
James
@jamesns
Mar 09 2017 00:48
@JLuboff I thank you as well, the link you sent me before got me on the right path :+1:
CamperBot
@camperbot
Mar 09 2017 00:48
jamesns sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1078 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Mar 09 2017 00:48
@sethdcd Ya I'm looking
Michael Grienauer
@mgrienauer
Mar 09 2017 00:49
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  var sourceKeys = Object.keys(source);
  // Only change code below this lin
  for (var i=0; i<collection.length;i++){
    for(var key in collection[i]){
      if (key in sourceKeys && source.hasOwnProperty(collection[i][key])){
          arr.push(collection[i]);
      }
    }
  }
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet"});
James
@jamesns
Mar 09 2017 00:49
@joreyesl got it. thanks for the explanation!
CamperBot
@camperbot
Mar 09 2017 00:49
jamesns sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: jamesns already gave joreyesl points
Michael Grienauer
@mgrienauer
Mar 09 2017 00:49
wondering why this isnt working for the wherefore art thou challenge
i think its messing up on the last if statement but not sure why
Adam
@GoingAllTheWayUp
Mar 09 2017 00:51

https://www.freecodecamp.com/challenges/drop-it

function dropElements(theArray, theFunction) {
  // Drop them elements.
  while ( theArray.length > 0 && !theFunction(theArray[0])){ // while both the Array is not empty and and the 0th array item fails the function only
    theArray.shift(); // Remove the first item "theArray[0]" and shift the next value to position "theArray[0]".
  }
  return theArray; // return final result.
}

dropElements([1, 2, 3], function(n) {return n < 3; });

This code pass this challenge but its flawed becuase it stops running at the first sight of a true response from the function, so something like

dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) // should return [3, 9, 2].

pass fine, so does

dropElements([1, 2, 3, 9, 2,1,1,2], function(n) {return n > 2;}) // but returns [3, 9, 2,1,1,2]

Yet in spite of these vauge limitations set on the FCC solution, I still see a solution as being more complex then required. My imagination is greater then required here, and what is in fact required is a some what water down version of the real thing. Have you noticed?
I have noticed this flaw in the game.

Michael Grienauer
@mgrienauer
Mar 09 2017 00:51
any ideas?
Jor
@joreyesl
Mar 09 2017 00:51
@mike93og93 you need to check that they key exists, but also that the values stored in those keys match.
Seth
@sethdcd
Mar 09 2017 00:51
@JLuboff ohh i think i got it, there is no query, it goes straight to it now so i do value.search
Joseph
@revisualize
Mar 09 2017 00:51

@mike93og93 ....

      if (key in sourceKeys && source.hasOwnProperty(collection[i][key])){
          arr.push(collection[i]);
      }

Is that correct?

Michael Grienauer
@mgrienauer
Mar 09 2017 00:51
@joreyesl i did check and they seem to be working before the if statement
Joseph
@revisualize
Mar 09 2017 00:51
I don't think you can do an if in.
Michael Grienauer
@mgrienauer
Mar 09 2017 00:52
@revisualize can i do hasOwnProperty() ?
Jason Luboff
@JLuboff
Mar 09 2017 00:52
@sethdcd Alright good luck :+1:
Michael Grienauer
@mgrienauer
Mar 09 2017 00:52
sourceKeys.hasOwnProperty(key)
Jor
@joreyesl
Mar 09 2017 00:53
@mike93og93 also you dont want to push from just 1 test, remember the object has to have all properties/values of source.
Michael Grienauer
@mgrienauer
Mar 09 2017 00:53
no that doesnt work either
if (sourceKeys.hasOwnProperty(key) && source.hasOwnProperty(collection[i][key])){
          arr.push(collection[i]);
@joreyesl isnt this checking if sourceKeys has a property of the key AND the key has a matching value?
Dennis
@denskiz
Mar 09 2017 00:54

Has anyone completed: ES6: Use getters and setters to Control Access to an Object?

I'm stuck on this one

Michael Grienauer
@mgrienauer
Mar 09 2017 00:56
i think ive got it 1 sec
Adam
@GoingAllTheWayUp
Mar 09 2017 00:57

https://www.freecodecamp.com/challenges/drop-it

function dropElements(theArray, theFunction) {
  // Drop them elements.
  while ( theArray.length > 0 && !theFunction(theArray[0])){ // while both the Array is not empty and and the 0th array item fails the function only
    theArray.shift(); // Remove the first item "theArray[0]" and shift the next value to position "theArray[0]".
  }
  return theArray; // return final result.
}

dropElements([1, 2, 3], function(n) {return n < 3; });

This code pass this challenge but its flawed becuase it stops running at the first sight of a true response from the function, so something like

dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) // should return [3, 9, 2].

Yet in spite of these vauge limitations set by the FCC solution, I saw the solution as being more complex then required. My imagination was greater then needed here, and in fact required me to dumb down a better version of the solution.
I have noticed this flaw in the game.

Jor
@joreyesl
Mar 09 2017 00:57

@mike93og93 nope, if you want to compare values, you have to use object[i][key] === source[key]. Anything you pass to hasOwnProperty is checking to see if that property exists.

Also you dont want to iterate the keys of object[i] but the keys of source and check if object[i] has that key and the values match.

Adam
@GoingAllTheWayUp
Mar 09 2017 00:59
I think some of the challenges here at FCC are dumb down real world problems, but they hurt us becuase they actualy require odd solutions
Umesi Obusor Ezekiel
@obusorezekiel
Mar 09 2017 00:59
PLease some help with the WORD blank problem in Number 154
john94
@lpy1994
Mar 09 2017 01:03
can Conditional (ternary) Operator apply to else if ?
David Fraser
@DavidFraserBHS
Mar 09 2017 01:04

how can i seperate this with "non word characters"? - function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result = (myAdjective + myNoun + myVerb + myAdverb);
// Your code above this line
return result;
}

Jor
@joreyesl
Mar 09 2017 01:06
@lpy1994 you mean can you do an if else if using a ternary? You can nest ternary operation to accomplish something similar.
_xiaotian
@xiaotiandada
Mar 09 2017 01:08
blob
I Will not
Testing Objects for Properties
Julien Cauwet
@juliencauwet
Mar 09 2017 01:09
Hi guys, can sb pls tell how to copy lines here because I need to show you my code so that you can tell me what is wrong?
Jor
@joreyesl
Mar 09 2017 01:09
@juliencauwet Paste code between set of 3 backticks ```, look at more info for example.
CamperBot
@camperbot
Mar 09 2017 01:09
:bulb: to format code use backticks! ``` more info
Dennis
@denskiz
Mar 09 2017 01:09

Has anyone completed: ES6: Use getters and setters to Control Access to an Object?

I'm stuck on this one

Hopper Kremer
@hopperkremer
Mar 09 2017 01:11
Hi everybody! I can't figure out what's triggering "Unexpected token ILLEGAL" on my codepen. Here it is:
https://codepen.io/hopperkremer/pen/PpWZyO?editors=0010
Julien Cauwet
@juliencauwet
Mar 09 2017 01:11

function lookUpProfile(firstName, prop) {

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

   if (contacts[i].firstName==firstName)                    {

                  if (contacts[i].hasOwnProperty(prop))                      
                  { return contacts[i][prop];}

                  else  {return "No such property"; }

     else {return "No such contact";}

          }
          }

// Only change code above this line
} '''

CamperBot
@camperbot
Mar 09 2017 01:11
:bulb: to format code use backticks! ``` more info
Julien Cauwet
@juliencauwet
Mar 09 2017 01:12
@camperbot thanks
CamperBot
@camperbot
Mar 09 2017 01:12
juliencauwet sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3077 | @camperbot |http://www.freecodecamp.com/camperbot
Julien Cauwet
@juliencauwet
Mar 09 2017 01:12
@joreyesl thanks
CamperBot
@camperbot
Mar 09 2017 01:12
juliencauwet sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 576 | @joreyesl |http://www.freecodecamp.com/joreyesl
Adam VanZuiden
@adamvz
Mar 09 2017 01:12
@hop7d5 put #temp in quotes
@hop7d5 all selectors should be in quotes unless it's variable
Julien Cauwet
@juliencauwet
Mar 09 2017 01:13

'''
function lookUpProfile(firstName, prop) {

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

   if (contacts[i].firstName==firstName)                    {

                  if (contacts[i].hasOwnProperty(prop))                      
                  { return contacts[i][prop];}

                  else  {return "No such property"; }

     else {return "No such contact";}

          }
          }

// Only change code above this line
} '''

CamperBot
@camperbot
Mar 09 2017 01:13
:bulb: to format code use backticks! ``` more info
Jor
@joreyesl
Mar 09 2017 01:14
@juliencauwet you are using ''', the backtick ` is right above the tab
CamperBot
@camperbot
Mar 09 2017 01:14
:bulb: to format code use backticks! ``` more info
Julien Cauwet
@juliencauwet
Mar 09 2017 01:14

```
function lookUpProfile(firstName, prop) {

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

   if (contacts[i].firstName==firstName)                    {

                  if (contacts[i].hasOwnProperty(prop))                      
                  { return contacts[i][prop];}

                  else  {return "No such property"; }

     else {return "No such contact";}

          }
          }

// Only change code above this line
}

function lookUpProfile(firstName, prop)                    {


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

       if (contacts[i].firstName==firstName)                    {

                      if (contacts[i].hasOwnProperty(prop))                      
                      { return contacts[i][prop];}

                      else  {return "No such property"; }

         else {return "No such contact";}

              }
              }

// Only change code above this line
       }
@camperbot ok i think i got it
Hopper Kremer
@hopperkremer
Mar 09 2017 01:15
@adamvz Wow, thanks! Shows just how much I've been struggling today that I would overlook such an unbelievably fundamental detail. I'm calling it quits for the day.
CamperBot
@camperbot
Mar 09 2017 01:15
:cookie: 278 | @adamvz |http://www.freecodecamp.com/adamvz
hop7d5 sends brownie points to @adamvz :sparkles: :thumbsup: :sparkles:
Adam VanZuiden
@adamvz
Mar 09 2017 01:16
@hop7d5 no problem. I had malformed JSON i made a couple days ago I was banging my head against the wall trying to figure out why it wasn't working.
Julien Cauwet
@juliencauwet
Mar 09 2017 01:16
Could you pls help on the code below. It does not accept the 2nd "else
function lookUpProfile(firstName, prop)                    {


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

       if (contacts[i].firstName==firstName)                    {

                      if (contacts[i].hasOwnProperty(prop))                      
                      { return contacts[i][prop];}

                      else  {return "No such property"; }

         else {return "No such contact";}

              }
              }

// Only change code above this line
       }
Manish Giri
@Manish-Giri
Mar 09 2017 01:17
@juliencauwet how do you have two elses?
AJ
@DracIdea
Mar 09 2017 01:17
Hi guys, I'm was wondering if anyone would clarify how to use String.prototype.replace(). I'm working on the Check for Palindromes challenge.
Julien Cauwet
@juliencauwet
Mar 09 2017 01:17
@Manish-Giri there are 2 if
Manish Giri
@Manish-Giri
Mar 09 2017 01:18
@DracIdea you can use .replace() to remove all the special characters..
Julien Cauwet
@juliencauwet
Mar 09 2017 01:18
one if is inside the other
Jor
@joreyesl
Mar 09 2017 01:18
@juliencauwet you are missing the closing } for the first if
Manish Giri
@Manish-Giri
Mar 09 2017 01:18
@juliencauwet but isn't the if-else-else nested in the outer if?
Seth
@sethdcd
Mar 09 2017 01:19

hi all, i'm trying to parse through some json data to display in the wikipedia viewer, and i'm using a $.each loop. for some reason this works

        $.each(data, function(i, value) {
          console.log(value.search);
        });

but if i try to narrow it down to

        $.each(data, function(i, value) {
          console.log(value.search.title);
        });

i'm getting the error value.search is undefined which makes no sense because 1) when i call it on just value.search it works, and 2) there is definitely a title item within search

here is the codepen, please ignore the commented out stuff https://codepen.io/sethdcd/pen/NpRKJR?editors=1010

JenimDacket
@JenimDacket
Mar 09 2017 01:19
1 != 2 // true
1 != "1" // false
1 != '1' // false
1 != true // false
0 != false // false
This is confusing to me.. How does "!=" assign validity to the last two? And since "1" is a value data-type, and not a number data-type, shouldn't that be false?
Julien Cauwet
@juliencauwet
Mar 09 2017 01:20
@joreyesl i counted but it is not the problem
Manish Giri
@Manish-Giri
Mar 09 2017 01:20
@sethdcd search is an array
AJ
@DracIdea
Mar 09 2017 01:20
@Manish-Giri That's kinda what I thought, but I've read through the info the link in the exercise points me to and I still can't grasp how to do it. What would I put in the ()?
Jor
@joreyesl
Mar 09 2017 01:20
@juliencauwet i'm looking matching { and } and right now the 2nd else is inside the first if statement
Michael Grienauer
@mgrienauer
Mar 09 2017 01:21
@joreyesl Ok i've reworked it but it's only passing half the tests
Julien Cauwet
@juliencauwet
Mar 09 2017 01:21
@joreyesl ok i'm checking
Michael Grienauer
@mgrienauer
Mar 09 2017 01:21
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  var sourceKeys = Object.keys(source);
  //return source[sourceKeys];
  // Only change code below this lin
  for(var k=0;k<sourceKeys.length;k++){
    for (var i=0; i<collection.length;i++){
      for(var key in collection[i]){
        if (source.hasOwnProperty(key) && collection[i][key] === source[key]){
            arr.push(collection[i]);
        }
      }
    }
  }
  // Only change code above this line
  return arr;
}

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Julien Cauwet
@juliencauwet
Mar 09 2017 01:23
@joreyesl thanks i've been trying for hours :clap:
CamperBot
@camperbot
Mar 09 2017 01:23
juliencauwet sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: juliencauwet already gave joreyesl points
Moisés Man
@moigithub
Mar 09 2017 01:23
@mike93og93 u pushing too soon
u need to check if EVERY key:value property match before push
not on any match
Michael Grienauer
@mgrienauer
Mar 09 2017 01:25
oooo ok i see, thanks @moigithub
CamperBot
@camperbot
Mar 09 2017 01:25
mike93og93 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2819 | @moigithub |http://www.freecodecamp.com/moigithub
Michael Grienauer
@mgrienauer
Mar 09 2017 01:25
i misread the instructios
Adam VanZuiden
@adamvz
Mar 09 2017 01:25
@JenimDacket in javascript 0 -0 or NaN are equal to false, and every other number is equal to true
@JenimDacket it's just a quirk or method inside of javascript
Jor
@joreyesl
Mar 09 2017 01:26
@JenimDacket you are using loose equality and JS converts both values to a common type before comparing them.
That is why 1 != "1" is false. The "1" gets converted to a number so 1 != 1 is false.
JenimDacket
@JenimDacket
Mar 09 2017 01:27
Ooooookay... so it looks at "1" as its .length?
Seth
@sethdcd
Mar 09 2017 01:27
@Manish-Giri i tried value.search[i].title and that didn't work either though :/
JenimDacket
@JenimDacket
Mar 09 2017 01:27
Oh, it just turns string-ed numbers into numbers?
Dennis
@denskiz
Mar 09 2017 01:28

Has anyone completed: ES6: Use getters and setters to Control Access to an Object?

I'm stuck on this one

Adam VanZuiden
@adamvz
Mar 09 2017 01:29
@JenimDacket yes... when you use loose equality, if you had 1 !== "1" then that would be true
Jor
@joreyesl
Mar 09 2017 01:29
@JenimDacket yes, look at the link and you will see a chart of how the conversion occurs. In this case because the first operand is a number, then the "1" gets coerced to a number type then compared. But if you use strict equality, 1 !== "1" then they are compared without conversion.
Manish Giri
@Manish-Giri
Mar 09 2017 01:30

@sethdcd this is what I did

       $.each(data.query.search, function(i, value) {
          console.log(value.title);
        });

it worked for me

232.png
Seth
@sethdcd
Mar 09 2017 01:30
interesting, i think i tried that but maybe i didnt/was wrong
Manish Giri
@Manish-Giri
Mar 09 2017 01:30
you're not passing/fetching the right things
JenimDacket
@JenimDacket
Mar 09 2017 01:31
@adamvz @joreyesl Thanks guys! I get it
CamperBot
@camperbot
Mar 09 2017 01:31
jenimdacket sends brownie points to @adamvz and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @adamvz |http://www.freecodecamp.com/adamvz
:cookie: 577 | @joreyesl |http://www.freecodecamp.com/joreyesl
Seth
@sethdcd
Mar 09 2017 01:31
@Manish-Giri im getting undefined
ohhh because im not doing data.query.search
Manish Giri
@Manish-Giri
Mar 09 2017 01:32
you're not passing/fetching the right things
Seth
@sethdcd
Mar 09 2017 01:32
interesting, thanks @Manish-Giri
CamperBot
@camperbot
Mar 09 2017 01:32
sethdcd sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4658 | @manish-giri |http://www.freecodecamp.com/manish-giri
CliffSmith25
@CliffSmith25
Mar 09 2017 01:33
Anyone know why my challenges are showing failed tests but I can test them in codepen and they work?
Adam VanZuiden
@adamvz
Mar 09 2017 01:34
@Stolz25 post your code
Jor
@joreyesl
Mar 09 2017 01:36
@Stolz25 you need to declare let perms = [] inside the main function. Right now its a global variable. What is happening is that it keeps any data between function tests. So the the first test may pass, but then the next test fails because there is data from the previous test in perms
Manish Giri
@Manish-Giri
Mar 09 2017 01:37
@sethdcd welcome
CliffSmith25
@CliffSmith25
Mar 09 2017 01:38
ah, ok, thanks
well that made half of them pass
still not passing everything though
Jor
@joreyesl
Mar 09 2017 01:40
@Stolz25 Also because you have 3 functions, then the others won't have access perms, if there is another function that requires access to perms then you need to pass it in the call as an argument
CliffSmith25
@CliffSmith25
Mar 09 2017 01:40
yeah, figured that out
thanks
I think that'll get me there
that did it, thank you all
JuicyITer
@juicyiter
Mar 09 2017 01:51
hey, guys. I am wondering if my code is too complicated in the test 'Counting Cards'.

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=count +=1;
break;
case 7:
case 8:
case 9:
count=count +=0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count=count -=1;
break;
}
var move;
if(count>0){
move="Bet";
} else if(count===0||count<0){
move="Hold";
}
return count + " " + move;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Jor
@joreyesl
Mar 09 2017 01:58
@ethanman using a switch is very common. few changes.
you don't need to do count=count +=1; Its redundant, you can simply count += 1 which is the same as count = count + 1
Also the else if(count===0||count<0) can just be an else, because if(count > 0) is false, then by logiccount <= 0 is true.
Missposhtee
@Missposhtee
Mar 09 2017 02:05

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

// Your code above this line
return result;
}

wordBlanks("hit","little", "cat", "slowly");
wordBlanks("big", "dog", "ran", "quickly");

were did i go wrong pls
Roxroy
@roxroy
Mar 09 2017 02:06
@Missposhtee , for the result try adding some other words between each one
Missposhtee
@Missposhtee
Mar 09 2017 02:07
@roxroy between wat and wat pls?
hamsa-al
@hamsa-al
Mar 09 2017 02:07
Screen Shot 2017-03-08 at 9.06.44 PM.png
Nataly C.
@cstpk
Mar 09 2017 02:08
@hamsa-al spaces
Jor
@joreyesl
Mar 09 2017 02:08
@hamsa-al remove spacing inside the string, and change the ; to an =
Roxroy
@roxroy
Mar 09 2017 02:09
@Missposhtee, should contain all of the passed in words separated by and any additional words
var result = "miss " +myNoun +"miss " + myAdjective +"miss " + myVerb +"miss " + myAdverb + "miss ";
hamsa-al
@hamsa-al
Mar 09 2017 02:09
Help, my code is not working: challenge name : Escape Sequences in Strings
Cristian
@cristianalmanzar
Mar 09 2017 02:10
i need help with (Try looking at the thirdToLastLetterOfFirstName variable declaration if you get stuck.)
hamsa-al
@hamsa-al
Mar 09 2017 02:10
still not working !
Roxroy
@roxroy
Mar 09 2017 02:10
@hamsa-al , post your string here..
AJ
@DracIdea
Mar 09 2017 02:10
function palindrome(str) {



  var newStringWithoutSpecialChar = str.replace(/[^A-Za-z0-9_]/,"");


 return newStringWithoutSpecialChar;

}
palindrome("ey%&*e");
hamsa-al
@hamsa-al
Mar 09 2017 02:10
var myStr;"\nFirstLine\n\SecondLine\\rThirdLine\r"; // Change this line
Cristian
@cristianalmanzar
Mar 09 2017 02:10
help
Use Bracket Notation to Find the NthtoLast Character in a String
AJ
@DracIdea
Mar 09 2017 02:11
Im trying to get this to return without the special char and having no luck. Can anyone give me a clue as to where I'm going wrong?
Jor
@joreyesl
Mar 09 2017 02:11
@hamsa-al var myStr;"\nFirstLine\n\SecondLine\\rThirdLine\r"; you are not assigning the string to myStr, you need to use = not ;
Nataly C.
@cstpk
Mar 09 2017 02:12
@hamsa-al just do exactly what's written "FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"
Roxroy
@roxroy
Mar 09 2017 02:13
@hamsa-al , You need to assign the string , add the = , var myStr =
hamsa-al
@hamsa-al
Mar 09 2017 02:13
@joreyesl still not working
@roxroy I did, but it’s not working
Missposhtee
@Missposhtee
Mar 09 2017 02:13
@roxroy i did tried it with the miss...but not working
Nataly C.
@cstpk
Mar 09 2017 02:14
you also shouldn't have \n in the beginning of the string @hamsa-al
Missposhtee
@Missposhtee
Mar 09 2017 02:14

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

// Your code above this line
return result;
}

wordBlanks("hit","little", "cat", "slowly");
wordBlanks("big", "dog", "ran", "quickly");

Jor
@joreyesl
Mar 09 2017 02:14
@hamsa-al also you have an extra \n and \r at the beginning/end of the string
Roxroy
@roxroy
Mar 09 2017 02:14
@Missposhtee , did it work?
Missposhtee
@Missposhtee
Mar 09 2017 02:14

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

// Your code above this line
return result;
}

wordBlanks("hit","little", "cat", "slowly");
wordBlanks("big", "dog", "ran", "quickly");

Roxroy
@roxroy
Mar 09 2017 02:14
@Missposhtee , post your updated code
Robert Arifin
@renkachan
Mar 09 2017 02:14
guys
function getLocation() {
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(abc);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
function abc(position) {
console.log(position.coords.latitude);
}
why getCurrentPosition need function
i try to replace with variable
it didnt work
JenimDacket
@JenimDacket
Mar 09 2017 02:15

Why is this coming back as a wrong?

function testElse(num){
if (num > 5){ return "bigger than 5";
} else {return "5 or smaller";}

return result;
}

testElse(4);

Roxroy
@roxroy
Mar 09 2017 02:16
@Missposhtee, put a space after the words
var result ="miss "+ myNoun + "miss " + myAdjective + "miss " + myVerb + "miss "+ myAdverb;
David Blackwelder
@chessnerdbird
Mar 09 2017 02:16

function nextInLine(arr, item) {
// Your code here
var removedFromTestArr = testArr.shift();
return removedFromTestArr; // 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));

Jor
@joreyesl
Mar 09 2017 02:16
@DracIdea you want to use the global frag g otherwise you only replace the first match. /[^A-Za-z0-9]/g. Also you dont want to keep _
hamsa-al
@hamsa-al
Mar 09 2017 02:16
Nothing is working lol
Robert Arifin
@renkachan
Mar 09 2017 02:17
@JenimDacket you result is not defined
remove return result and you should be fine
Roxroy
@roxroy
Mar 09 2017 02:17
@hamsa-al , paste your code
David Blackwelder
@chessnerdbird
Mar 09 2017 02:17
I am trying to resolve nextInLine([5,6,7,8,9], 1) should return 5. Which from what I can tell it does.... However, it is not passing it so there is something that I am missing...
JenimDacket
@JenimDacket
Mar 09 2017 02:17

@renkachan How is it not defined?

I did and it said that was incorrect

AJ
@DracIdea
Mar 09 2017 02:17
@joreyesl OK, let me give that a try
Moisés Man
@moigithub
Mar 09 2017 02:18
@dblackw2 re.-read the instructions
u need to do 2 things.. in same order as posted
also u need to work with the parameters ... (arr, item )
JenimDacket
@JenimDacket
Mar 09 2017 02:18
@dblackw2 Exactly....
David Blackwelder
@chessnerdbird
Mar 09 2017 02:19
This is updated code:

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

// Test Setup
var testArr = [5,6,7,8,9];

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

Moisés Man
@moigithub
Mar 09 2017 02:19
@dblackw2 re-read above :point_up: 8 de marzo de 2017 21:18 <---click
Carlo Blanco
@ccBlanco
Mar 09 2017 02:19

So I'm confused on the format or form to the remainder % var remainder = 2;

11 % 2 = 3;

AJ
@DracIdea
Mar 09 2017 02:20
@joreyesl That worked! Thanks
CamperBot
@camperbot
Mar 09 2017 02:20
dracidea sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 578 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Mar 09 2017 02:20
@dblackw2 ok you have the shift done, but remember you also need to add num to the array. that should be done first. you can use the .push() method to accomplish that
Taydenswin
@Taydenswin
Mar 09 2017 02:20
how do you format
Moisés Man
@moigithub
Mar 09 2017 02:20
@Taydenswin click more info below
CamperBot
@camperbot
Mar 09 2017 02:20
:bulb: to format code use backticks! ``` more info
Roxroy
@roxroy
Mar 09 2017 02:21
@ccBlanco , 11% 2 = 1 not 3
Taydenswin
@Taydenswin
Mar 09 2017 02:21
Having trouble with "Escape Sequences in Strings"
Moisés Man
@moigithub
Mar 09 2017 02:22
@ccBlanco variable = formula
soo if u wanna sum 11 and 2.. and store the result on total
u do
total = 11 + 2
% is just another operator to do math.. like + - / *
Roxroy
@roxroy
Mar 09 2017 02:22
@Taydenswin , paste your code
Carlo Blanco
@ccBlanco
Mar 09 2017 02:22
thanks moise man
@moigithub Thanks
CamperBot
@camperbot
Mar 09 2017 02:22
ccblanco sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2820 | @moigithub |http://www.freecodecamp.com/moigithub
Taydenswin
@Taydenswin
Mar 09 2017 02:24
'var myStr = "Firstline\n\SecondLine\\r Thirdline";'
crap
hold on
hamsa-al
@hamsa-al
Mar 09 2017 02:25
DONE ouuuf
Taydenswin
@Taydenswin
Mar 09 2017 02:25
var myStr = "Firstline\n\\SecondLine\\\r Thirdline";
Roxroy
@roxroy
Mar 09 2017 02:26
@hamsa-al , did see your code... did I miss it?
David Blackwelder
@chessnerdbird
Mar 09 2017 02:26
Clearly I am not understanding something.....

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

// Test Setup
var testArr = [5,6,7,8,9];

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

hamsa-al
@hamsa-al
Mar 09 2017 02:26
No I figured it out :)
Roxroy
@roxroy
Mar 09 2017 02:27
@hamsa-al , great.. thought you were still stuck
Nataly C.
@cstpk
Mar 09 2017 02:27
@dblackw2 no need to declare another variable
Jor
@joreyesl
Mar 09 2017 02:28
@Taydenswin you have an extra space in \r Thirdline. Also you need to capitilize Line, in each word
Taydenswin
@Taydenswin
Mar 09 2017 02:29
@joreyesl Thank man! GG
CamperBot
@camperbot
Mar 09 2017 02:29
taydenswin sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 579 | @joreyesl |http://www.freecodecamp.com/joreyesl
David Blackwelder
@chessnerdbird
Mar 09 2017 02:29
@natalyscosta I'm sorry..... Where did I declare another variable? :worried:
Manish Giri
@Manish-Giri
Mar 09 2017 02:30
@dblackw2 you need to use arr not testArr
Jor
@joreyesl
Mar 09 2017 02:30
@dblackw2 look at the function declaration function nextInLine(arr, item), you need to be using arr not testArr and when you push you need to use item
Manish Giri
@Manish-Giri
Mar 09 2017 02:30
testArr.push(1);
also why 1?
@dblackw2
AJ
@DracIdea
Mar 09 2017 02:31
@joreyesl I'm just wondering why /[^A-Za-z0-9_]/ works in my str.replace(), but /\W/ doesn't
Jor
@joreyesl
Mar 09 2017 02:32
@DracIdea they should both work, bet remember to use the g flag. It should be /\W/g
David Blackwelder
@chessnerdbird
Mar 09 2017 02:32

This is what I have now.....
function nextInLine(arr, item) {
// Your code here
var num = num.push();
var removedFromArr = arr.shift();
return removedFromArr; // Change this line
}

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

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

I put the number 1 in just to test. It put the number 1 at the end of the array in the output.
Joseph
@revisualize
Mar 09 2017 02:33
@dblackw2 Where did you get num from?
Nataly C.
@cstpk
Mar 09 2017 02:33
you don't need to use num. just use the arguments of the function: arr and item
Joseph
@revisualize
Mar 09 2017 02:34

@dblackw2
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.

AJ
@DracIdea
Mar 09 2017 02:34
@joreyesl as soon as it sees the \, it says syntax error....not sure why
Jor
@joreyesl
Mar 09 2017 02:35
@DracIdea post that snippet? it shouldnt throw an error.
Joseph
@revisualize
Mar 09 2017 02:36
@Taydenswin Did you solve your challenge? Did you realize that "Firstline" is not the same as "FirstLine"? Did you remove the space? And did you correct "ThirdLine"?
Nataly C.
@cstpk
Mar 09 2017 02:36
@dblackw2 push item into arr, then return it without the first element. no need to declare variables
AJ
@DracIdea
Mar 09 2017 02:37
@joreyesl var newStringWithoutSpecialChar = str.replace(/\W/,"");
Jor
@joreyesl
Mar 09 2017 02:38
@DracIdea might be somewhere else, I'm getting no syntax errors on my end
Manish Giri
@Manish-Giri
Mar 09 2017 02:39
@DracIdea don't you need the _?
Joseph
@revisualize
Mar 09 2017 02:39
@DracIdea But, that still includes the _
AJ
@DracIdea
Mar 09 2017 02:39
@joreyesl you were right, I just had a \ instead of a /
Andrew Charlebois
@andrewchar
Mar 09 2017 02:40
@revisualize css grid, are you excited ? I am
its almost hereeeeeeeeeeeeee
all my dreams have come true with flexbox & soon to be css grid
AJ
@DracIdea
Mar 09 2017 02:41
@Manish-Giri @revisualize I thought it was equivalent to [^A-Za-z0-9_]?
Joel
@MMK123
Mar 09 2017 02:41
var remainder;
no clue how to do this
eyesore-
@eyesore-
Mar 09 2017 02:41
Check out lost-grid. I think it's the best grid simple.
Joel
@MMK123
Mar 09 2017 02:41
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Jor
@joreyesl
Mar 09 2017 02:41
@DracIdea it is, but remember, you also want to remove _
Andrew Charlebois
@andrewchar
Mar 09 2017 02:41
@eyesore- no need soon with cs grid
css*
Manish Giri
@Manish-Giri
Mar 09 2017 02:42
@DracIdea it is, but remember, you also want to remove _
that's why..
eyesore-
@eyesore-
Mar 09 2017 02:42
I think you could actually use css grid already with cssnext
Joel
@MMK123
Mar 09 2017 02:42
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
var remainder;
Andrew Charlebois
@andrewchar
Mar 09 2017 02:43
next week it should be out on chrome. its out right now in firefox @eyesore-
AJ
@DracIdea
Mar 09 2017 02:43
@joreyesl Ohh right, this removes everything but _ and the letters and numbers. Had it mixed up.
Andrew Charlebois
@andrewchar
Mar 09 2017 02:43
@MMK123 you need to add stuff on the right hand side to assign it
@MMK123 var remainder = something here;
AJ
@DracIdea
Mar 09 2017 02:44
@Manish-Giri @revisualize @joreyesl Thanks
CamperBot
@camperbot
Mar 09 2017 02:44
dracidea sends brownie points to @manish-giri and @revisualize and @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: dracidea already gave joreyesl points
:star2: 3451 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 4660 | @manish-giri |http://www.freecodecamp.com/manish-giri
Joel
@MMK123
Mar 09 2017 02:45
i tried var remainder = 2;
but no luck
Manish Giri
@Manish-Giri
Mar 09 2017 02:45
@MMK123 you need to let JS calculate the remainder.
you just write the expression..
Joel
@MMK123
Mar 09 2017 02:45
hmm
ok let me try
ya idk
this java script stuff is much harder than css and html
Andrew Charlebois
@andrewchar
Mar 09 2017 02:46
so you want the code to do the work for you
Joseph
@revisualize
Mar 09 2017 02:46

@MMK123 What is the returned value of num ... var num = 4 + 3;
What is the returned value of num ... var num = 10 / 5;
What is the returned value of num ... var num = 5 * 3;

Remainder:
http://images.tutorvista.com/cms/images/38/remainder1.PNG
13 % 2 is 1 ... 26 % 5 is 1 ... 24 % 6 is 0
24 % 5 is 4 ... 219 % 20 is 19
Just like in my examples above you use the % operator just like any other math operator (+, -, *, /)

solankivir
@solankivir
Mar 09 2017 02:46

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

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

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

/
task 1:phoneticLookup("charlie") should equal "Chicago"
task 2:phoneticLookup("") should equal undefined
task 3: You should not use case, switch, or if statements
/

Andrew Shieh
@andrewlikes
Mar 09 2017 02:47
javascript is so much more rewarding
Joseph
@revisualize
Mar 09 2017 02:47
@solankivir You deleted the switch and didn't create the object?
JenimDacket
@JenimDacket
Mar 09 2017 02:47
Guys, I get it!!! =DD
Andrew Charlebois
@andrewchar
Mar 09 2017 02:47
tell it what you want it to do. which is 11 % 3 @MMK123
Joseph
@revisualize
Mar 09 2017 02:47
@andrewchar :wave:
Andrew Charlebois
@andrewchar
Mar 09 2017 02:47
hi hi
JenimDacket
@JenimDacket
Mar 09 2017 02:47
call out to @joreyesl for being THE guy
Joel
@MMK123
Mar 09 2017 02:47
ohhh ok I see
thank you guys so much
solankivir
@solankivir
Mar 09 2017 02:48
@revisualize as per task, we cant use if else and switch case
Andrew Charlebois
@andrewchar
Mar 09 2017 02:48
@MMK123 we code to tell it what to do. why would we do the work. tell the computer what to do, be the boss :P
Joseph
@revisualize
Mar 09 2017 02:48
@solankivir You deleted the switch AND didn't create the object?
Jor
@joreyesl
Mar 09 2017 02:48
@JenimDacket what did I do? :)
JenimDacket
@JenimDacket
Mar 09 2017 02:49
@joreyesl You helped out like some kind of coding wizard!
Joseph
@revisualize
Mar 09 2017 02:49
@solankivir You're supposed to turn the switch that was there into an object. But, you just deleted it an didn't create the object.
Jor
@joreyesl
Mar 09 2017 02:51
@JenimDacket Well glad I could help you out then.
Ryan Matthews
@Ryntak94
Mar 09 2017 02:51
does anyone here use grunt?
Andrew Charlebois
@andrewchar
Mar 09 2017 02:53
not really
i like gulp
grunt is losing lots of popularity. lots are just using npm scripts now
JenimDacket
@JenimDacket
Mar 09 2017 02:55
QUESTION: So, with switches, all of the breaks are ignored until a true/equal statement has been identified or the default has been reached, correct?
so, if I have 10 statements and breaks after each of them, and statement 6 is the correct statement for the given situation, then it will operate the break after number 6, preventing any further statements from being executed, correct?
Andrew Charlebois
@andrewchar
Mar 09 2017 02:58
@JenimDacket it doesnt make it that far into each case. it will check your case for a math before going into that specific case statement and breaking.

This is how it works:

The switch expression is evaluated once.
The value of the expression is compared with the values of each case.
If there is a match, the associated block of code is executed.

JenimDacket
@JenimDacket
Mar 09 2017 03:00
Okay.. So I do not understand. Let me play with the challenge and then I will come baack
oooooop. Okay, one sec
Andrew Charlebois
@andrewchar
Mar 09 2017 03:01
so in short. its checking for a match with the case. if its a match. it will run the code inside that case
JenimDacket
@JenimDacket
Mar 09 2017 03:02
Okay, I think that makes sense. I will be back
And it has to be an exact match, right? ===
Andrew Charlebois
@andrewchar
Mar 09 2017 03:03
the case expression and the value of the case, yes
matching numbers, for example
Matthew
@IMDBLM
Mar 09 2017 03:06

Hey y'all I'm having some trouble with this JS challenge. I'm confused about how to do the multiple returns.

if (a < 0);
if (b < 0);

Am I missing something? Adding a return before the other return causes an error. The only thing I can think of is adding subroutines within a function.

Andrew Charlebois
@andrewchar
Mar 09 2017 03:08
@IMDBLM you could try combining those 2 statements into one "if"
Matthew
@IMDBLM
Mar 09 2017 03:09
@andrewchar I can, and I found I could without error!
@andrewchar if (a, b < 0);
Andrew Charlebois
@andrewchar
Mar 09 2017 03:10
recall what we do to use "or"?
Mark
@vinarius
Mar 09 2017 03:10
does the comma in that statement serve the same function as || ?
Andrew Charlebois
@andrewchar
Mar 09 2017 03:10
no
its improper syntax
Mark
@vinarius
Mar 09 2017 03:10
ok just making sure lol
Johnny vo
@jphivo
Mar 09 2017 03:10
@IMDBLM Can you help me with Declaring JavaScript Variable? I'm not sure what they are asking me to do.
You should declare myName with the var keyword, ending with a semicolon
Matthew
@IMDBLM
Mar 09 2017 03:11
@andrewchar (sorry for the spam of text) What's confusing me is that return portion, because there's already a return within the function. Let me go back and study the 'or' operator.
JenimDacket
@JenimDacket
Mar 09 2017 03:11

@andrewchar As it turns out, I did not understand

function caseInSwitch(val) {
var answer = "";
switch (val){
case 1:
console.log="alpha";
break;
case 2:
console.log="beta";
break;
case 3:
console.log="gamma";
break;
case 4:
console.log="delta";
break;

}
return answer;
}

Andrew Charlebois
@andrewchar
Mar 09 2017 03:11
@jphivo to declare a variable you need to start the line with "var"
next step would be to give it its name
JenimDacket
@JenimDacket
Mar 09 2017 03:12
I also tried replacing each of the "console.log" with "val" and swapping the numerals and greek letters
Johnny vo
@jphivo
Mar 09 2017 03:12
What is it asking me to write. Can you give me an example?
Philip Busacco
@Pbusacco
Mar 09 2017 03:12
Hello is anyone on the Stand in Line problem? I don't quite understand what the question is.
Mark
@vinarius
Mar 09 2017 03:13
@IMDBLM Once a 'return' statement executes within a block of code, the rest of the code within that block is foregoe'd and you move on past the function ending bracket
JenimDacket
@JenimDacket
Mar 09 2017 03:13

caseInSwitch(1);

sorry haha

Andrew Charlebois
@andrewchar
Mar 09 2017 03:13
@jphivo so here i will instanciate a variable... "var myVariable;"
Mark
@vinarius
Mar 09 2017 03:14
so for example in that exercise, you are manually typing in a return statement like it's asking, the function will run and therefore it wont pay attention to that second return statement because it only runs the first one it sees
Johnny vo
@jphivo
Mar 09 2017 03:15

@andrewchar sorry I'm still confused. This is the challenge:
// Example
var ourName;

// Define myName below this line

Andrew Charlebois
@andrewchar
Mar 09 2017 03:15
@JenimDacket you actually want to be setting your string to your answer variable
and return answer at the end
JenimDacket
@JenimDacket
Mar 09 2017 03:15
Example=
Matthew
@IMDBLM
Mar 09 2017 03:15
@vinarius But if I manually add the return, won't it always skip the 2nd return?
You know what, NM. Let me just play with it.
Andrew Charlebois
@andrewchar
Mar 09 2017 03:15
@jphivo yup so create a variable just as they did but with the new name that it wants for the challange
Joseph
@revisualize
Mar 09 2017 03:15
@JenimDacket Don't console.log you should be reassigning answer
Matthew
@IMDBLM
Mar 09 2017 03:16
thanks @andrewchar @vinarius
CamperBot
@camperbot
Mar 09 2017 03:16
imdblm sends brownie points to @andrewchar and @vinarius :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @vinarius |http://www.freecodecamp.com/vinarius
:cookie: 463 | @andrewchar |http://www.freecodecamp.com/andrewchar
Mark
@vinarius
Mar 09 2017 03:16
@IMDBLM correct once the function hits a return statement, anything past that statement within the function code block is sort of negated, or not run
Johnny vo
@jphivo
Mar 09 2017 03:18
@andrewchar Got it, thank you.
Mark
@vinarius
Mar 09 2017 03:20
@Pbusacco did you still need help?
John Nunns
@johnnunns
Mar 09 2017 03:28
did anyone find a good way to account for the consonant cluster in the pig latin challenge?
or did everyone have to hardcode?
Mark
@vinarius
Mar 09 2017 03:29
i did that challenge a couple days ago. let me check my codd
JiingWei
@jiingwei321
Mar 09 2017 03:29
function nextInLine(arr, item) {
  // Your code here
  testArr.push(2);

  //.push is the key. Push the Latter to the former.
  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));
guys i have been stuck at this part for quite some time
ive changed the code several times as well
can anyone show me the way to solve this
i am just so bad at this :(
John Nunns
@johnnunns
Mar 09 2017 03:31
don't put yourself down on it haha coding is tough
so you need to push an item into an array?
Mark
@vinarius
Mar 09 2017 03:31
@jiingwei321 you'll want to push 2 to arr, not testArr. you'll also want to use .shift()
JiingWei
@jiingwei321
Mar 09 2017 03:31
Alright ill try it out again
John Nunns
@johnnunns
Mar 09 2017 03:31
I think he just wants to push the item into the arr
why did you specifically write 2? @jiingwei321
Mark
@vinarius
Mar 09 2017 03:32
@johnnunns i feel like my solution for that one was a little extensive but i made an array consisting of all vowels and used indexOf to see if any were found and had the program sort of make a decision on what path to take using an if statement based on if the word started with a vowel
JiingWei
@jiingwei321
Mar 09 2017 03:32
nextInLine([2], 1) should return 2
this is what it needed me to do
@johnnunns i am kinda lost as to what i am suppose to do
Joseph
@revisualize
Mar 09 2017 03:33

@jiingwei321 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.

Matthew
@IMDBLM
Mar 09 2017 03:33
@vinarius OK. So I created a subroutine, but I'm still missing something. The hint is that the 'undefined' is actually a keyword. I went back to that particular challenge and it's not exactly making sense, because it seems to suggest I need an undefined var to get undefined.
var c;
  if (a || b < 0) {
   return c;
 }
`
John Nunns
@johnnunns
Mar 09 2017 03:33

function translatePigLatin(str) {
  function isVowel(x) {  return /[aeiouAEIOU]/.test(x); }
  function isConsonantCluster(x){return /[a-zA-z]/.test(x); }
  if(isVowel(str[0])) {
    return str+'way';
     }else{
  return str.slice(1) + str.substring(0,1) + "ay";
  }
}

translatePigLatin("EEonsonant");
JiingWei
@jiingwei321
Mar 09 2017 03:33
thus i am just trying to do anything and everything to solve it :smile:
John Nunns
@johnnunns
Mar 09 2017 03:33
@vinarius i'm good on the if it's a vowel
it's just if it's the cluster
like 'glove
Mark
@vinarius
Mar 09 2017 03:34
@IMDBLM message me privately
John Nunns
@johnnunns
Mar 09 2017 03:34
i can hard code it np
Matthew
@IMDBLM
Mar 09 2017 03:34
Aye cappy
JiingWei
@jiingwei321
Mar 09 2017 03:34
@vinarius @revisualize @johnnunns Thanks guys :D
CamperBot
@camperbot
Mar 09 2017 03:34
jiingwei321 sends brownie points to @vinarius and @revisualize and @johnnunns :sparkles: :thumbsup: :sparkles:
:cookie: 320 | @vinarius |http://www.freecodecamp.com/vinarius
:cookie: 208 | @johnnunns |http://www.freecodecamp.com/johnnunns
:star2: 3454 | @revisualize |http://www.freecodecamp.com/revisualize
John Nunns
@johnnunns
Mar 09 2017 03:34
@jiingwei321 what's the name of the problem so i can read
oh did you get it?
JiingWei
@jiingwei321
Mar 09 2017 03:35
Stand in Line Module
Mark
@vinarius
Mar 09 2017 03:35
@johnnunns yeah so i had a pretty different solution to this
one sec
ProjectOpenSource
@ProjectOpenSource
Mar 09 2017 03:39
How to solve: an array of arr in accordance with the specified array size size divided into several array blocks.
Philip Busacco
@Pbusacco
Mar 09 2017 03:44
Sorry yes still need help.
Do I need to push or unshift on the array?
Mark
@vinarius
Mar 09 2017 03:44
what challenge are you on @Pbusacco
Alexander Køpke
@alexanderkopke
Mar 09 2017 03:45
unshift adds to the beginning of the array, push to the end
Philip Busacco
@Pbusacco
Mar 09 2017 03:45
stand in line , I see some are having the same problem
Mark
@vinarius
Mar 09 2017 03:47
i believe that challenge teaches using .push() and .shift()
what are you having trouble understanding?
Philip Busacco
@Pbusacco
Mar 09 2017 03:48
Just the two arguments do I push on the arr or the item?
fchen00
@fchen00
Mar 09 2017 03:48
How do I write a regular expression that can not repeat the same character next to each other.
Kenard Ellis
@Kenard0
Mar 09 2017 03:48
help Profile Lookup
Mark
@vinarius
Mar 09 2017 03:49
arr stands for array, that's a collection of data that you are editing through the use of item
Philip Busacco
@Pbusacco
Mar 09 2017 03:49
Okay I think I have it now.
Mark
@vinarius
Mar 09 2017 03:49
so you are pushing, or adding to the back of, item to arr and you are shifting, or moving away from the front of, the first element of arr
JenimDacket
@JenimDacket
Mar 09 2017 03:50
I keep getting this error come back that says there is a syntax problem, then gives back a % of what was scanned
Is this normal? B/c it is making my correct solutions wrong.
Philip Busacco
@Pbusacco
Mar 09 2017 03:50
so something like arr.push(item)?
Roxroy
@roxroy
Mar 09 2017 03:50
@Kenard0 , what part is not working for you?
Mark
@vinarius
Mar 09 2017 03:50
try it out and see what happens!
you can always go to repl.it if you are looking to see exactly what is happening with the data you work with
just console.log() whatever you are working with
Alexander Køpke
@alexanderkopke
Mar 09 2017 03:51
@fchen00 any kind of character or do you specify which one?
fchen00
@fchen00
Mar 09 2017 03:51
@alexanderkopke Just alphabet
Mark
@vinarius
Mar 09 2017 03:52
heading to bed, night all
Kenard Ellis
@Kenard0
Mar 09 2017 03:52
I dont know were to start in this challenge
@Kenard0 @roxroy
Philip Busacco
@Pbusacco
Mar 09 2017 03:52
Thanks for the help vinarius
fchen00
@fchen00
Mar 09 2017 03:52
@alexanderkopke lets assume all character r lower cases
Joseph
@revisualize
Mar 09 2017 03:55

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

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

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

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

Alexander Køpke
@alexanderkopke
Mar 09 2017 03:55
@fchen00 dang, that is more difficult than I thought :(
Matthew
@IMDBLM
Mar 09 2017 03:56
@alexanderkopke We have all the faith in you!
Roxroy
@roxroy
Mar 09 2017 03:56
@Kenard0 , you will need to got through each profile, using a for loop.
find that specific name that is pass in.
If the name matches then, check if the property is in the profile, eg. if (!contact.hasOwnProperty(prop))- then print "No such property";
other wise return the profile
fchen00
@fchen00
Mar 09 2017 03:56
@alexanderkopke :smile: It's okay Alex, thx for helping lol
CamperBot
@camperbot
Mar 09 2017 03:56
fchen00 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:star2: 1184 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
fchen00
@fchen00
Mar 09 2017 03:57
Anyone else can help me with this question? "How do I write a regular expression that can not repeat the same character next to each other."
pcfly
@fl6821494
Mar 09 2017 03:57
function lookUp(firstName, prop){
// Only change code below this line
  var result="";
for(var i=0;i<contacts.length;i++){
  if(contacts[i].firstName==firstName){
     if(contacts[i][prop]==""){
       result="No such property";break;
     }else{
       result=contacts[i][prop];break;
     }
  }else{
    result="No such contact";
  }
}
  return result;
// Only change code above this line
}
this line won'tbe executed
result=No such property;break;
Kenard Ellis
@Kenard0
Mar 09 2017 03:58
thanks @roxroy I just want hint.
CamperBot
@camperbot
Mar 09 2017 03:58
kenard0 sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 370 | @roxroy |http://www.freecodecamp.com/roxroy
Kenard Ellis
@Kenard0
Mar 09 2017 03:59
thanks @fl6821494
CamperBot
@camperbot
Mar 09 2017 03:59
kenard0 sends brownie points to @fl6821494 :sparkles: :thumbsup: :sparkles:
:cookie: 39 | @fl6821494 |http://www.freecodecamp.com/fl6821494
Roxroy
@roxroy
Mar 09 2017 04:01
@fl6821494, @Kenard0 use the hasOwnProperty to test prop
if (!contact[i].hasOwnProperty(prop))
David Amanze
@GodKingShogun
Mar 09 2017 04:01
hello everyone. anyone still up :smile:
that can help
pcfly
@fl6821494
Mar 09 2017 04:02
@roxroy thanks ,but why if(contacts[i][prop]=="") won't work
CamperBot
@camperbot
Mar 09 2017 04:02
fl6821494 sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 371 | @roxroy |http://www.freecodecamp.com/roxroy
David Amanze
@GodKingShogun
Mar 09 2017 04:02
with the sum all prime number challengge
oscar carrillo
@oscarrillo90
Mar 09 2017 04:05
hey guys can i get some help with the "local scope and funtions" challenge please
David Amanze
@GodKingShogun
Mar 09 2017 04:05
@oscarrillo90 what is your question. i will try to help
oscar carrillo
@oscarrillo90
Mar 09 2017 04:06

@GodKingShogun ive tried but cant figure out these instructions......................... Instructions.....
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.

Hint
Refreshing the page may help if you get stuck.

fchen00
@fchen00
Mar 09 2017 04:07
@alexanderkopke ([a-z])(\1) Lol, I think I know what to do, I'll use regex to look for repeated neighbor instead, and I'll use JS to work through there.
:smile:
badalsaibo
@heyDante
Mar 09 2017 04:08
@oscarrillo90 You tried?
Roxroy
@roxroy
Mar 09 2017 04:09
@fl6821494 , The hasOwnProperty() method returns a boolean indicating whether the object has the specified property.
It is the proper way to do the check and will always be correct
Cory Hoban
@Khaladin
Mar 09 2017 04:10
Hi I'm stuck on calling arguments, why does args in this still have the array inside of it?

function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  return args;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
shouldn't it return just the arguments?
oscar carrillo
@oscarrillo90
Mar 09 2017 04:10
@Khaladin hey how do you post your code up like that?
Cory Hoban
@Khaladin
Mar 09 2017 04:10
the tilde key
Roxroy
@roxroy
Mar 09 2017 04:10
@fl6821494 , see MDN for more information and examples
Cory Hoban
@Khaladin
Mar 09 2017 04:11
but not the tilde p[ress it three times and then hit return
this key `
oscar carrillo
@oscarrillo90
Mar 09 2017 04:14
@Khaladin im not getting it
CamperBot
@camperbot
Mar 09 2017 04:14
:bulb: to format code use backticks! ``` more info
Leon
@clexpectation
Mar 09 2017 04:15
<script>
function runSlots() {
var slotOne;
var slotTwo;
var slotThree;
var images = ["//i.imgur.com/9H17QFk.png", "//i.imgur.com/9RmpXTy.png", "//i.imgur.com/VJnmtt5.png"];

// Only change code below this line.
var temp;
for(var i=0;i<3;i++){

  temp[i]=Math.floor(Math.random() * (3 - 1 + 1)) + 1;
}
slotOne=temp[0];
slotTwo=temp[1];
slotThree=temp[2];
// Only change code above this line.
don't know where is wrong
badalsaibo
@heyDante
Mar 09 2017 04:18
@clexpectation you should be pushing the values of temp[i] to an array
pcfly
@fl6821494
Mar 09 2017 04:28
@roxroy thank you
CamperBot
@camperbot
Mar 09 2017 04:28
fl6821494 sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:warning: fl6821494 already gave roxroy points
Ken Haduch
@khaduch
Mar 09 2017 04:29
@oscarrillo90 - to post code, you can use either a single backtick ` or three backticks on a line by themselves at the start and end of your code. They would look like this: ``` - has to be on a separate line. You can read docs on this on the fcc forum: https://forum.freecodecamp.com/t/markdown-code-formatting/18391
Joseph
@revisualize
Mar 09 2017 04:29
@clexpectation IMGUR doesn't allow hot linking.
Ousmane Kamakate
@CoastlineProduction
Mar 09 2017 04:36

var products = [ { name: "Grapefruit", calories: 170, color: "red", sold: 8200 },
{ name: "Orange", calories: 160, color: "orange", sold: 12101 },
{ name: "Cola", calories: 210, color: "caramel", sold: 25412 },
{ name: "Diet Cola", calories: 0, color: "caramel", sold: 43922 },
{ name: "Lemon", calories: 200, color: "clear", sold: 14983 },
{ name: "Raspberry", calories: 180, color: "pink", sold: 9427 },
{ name: "Root Beer", calories: 200, color: "caramel", sold: 9909 },
{ name: "Water", calories: 0, color: "clear", sold: 62123 }
];

function compareSold(colaA, colaB) {
if (colaA.sold > colaB.sold) {
return 1;
} else if (colaA.sold === colaB.sold) {
return 0;
} else {
return -1;
}
}
function printProducts(products) {
for (var i = 0; i < products.length; i++) {
console.log("Name: " + products[i].name + ", Calories: " + products[i].calories + ", Color: " + products[i].color + ", Sold: " + products[i].sold);
}
}
products.sort(compareSold);
printProducts(products);

sorry wrong code

// function compareNumbers (num1, num2) {
// if (num1 > num2) {
// return 1;
// } else if (num1 === num2) {
// return 0;
// } else {
// return -1;
// }
// }

// function compareNumbers (num1, num2) {
// return num1 - num2;
// }

// var numbersArray = [60, 50, 62, 58, 54, 54];
// numbersArray.sort(compareNumbers);
// console.log(numbersArray);

function compareNumbers (num1, num2) {
if (num1 > num2) {
return 1;
} else if (num1 === num2) {
return 0;
} else {
return -1;
}
}

function compareNumbers (num1, num2) {
return num1 - num2;
}

var numbersArray = [60, 50, 62, 58, 54, 54];
numbersArray.sort(compareNumbers);
console.log(numbersArray);

Joseph
@revisualize
Mar 09 2017 04:39
@CoastlineProduction Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.

If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.

Ousmane Kamakate
@CoastlineProduction
Mar 09 2017 04:39
ok
is this too big?

function compareNumbers (num1, num2) {
if (num1 > num2) {
return 1;
} else if (num1 === num2) {
return 0;
} else {
return -1;
}
}

function compareNumbers (num1, num2) {
return num1 - num2;
}

var numbersArray = [60, 50, 62, 58, 54, 54];
numbersArray.sort(compareNumbers);
console.log(numbersArray);

jeevanach
@jeevanach
Mar 09 2017 04:40

plz help

// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr;

myStr should have a value of This is the first sentence. This is the second sentence.
Use the += operator to build myStr
Ousmane Kamakate
@CoastlineProduction
Mar 09 2017 04:40
or should i use a gist for that also?
CamperBot
@camperbot
Mar 09 2017 04:41
:bulb: to format code use backticks! ``` more info
Wazir Robinson
@wazirrobinson
Mar 09 2017 04:52
Hello everyone, I'm having trouble with lesson 140. Can anyone help me with one example. Once I see how it's supposed to be done, I can finish the rest. Here is the problem:

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

edchen93
@edchen93
Mar 09 2017 04:56
hey guys i'm having trouble declaring a global variable
i'm typing oppsGlobal = 5;
is there anything I am missing?
Ademola Adegbuyi
@ooade
Mar 09 2017 04:57
@wazirrobinson do you know the formula for converting celsius to fahrenheit?
David Miolard
@GwadaKing
Mar 09 2017 04:57
you forgot the var before
Wazir Robinson
@wazirrobinson
Mar 09 2017 04:58
@ooade Yes, it is: The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
Ademola Adegbuyi
@ooade
Mar 09 2017 04:59
@wazirrobinson Turn the formula to what JS understands and assign it to fahrenheit
Andrew Shieh
@andrewlikes
Mar 09 2017 04:59
@wazirrobinson so fahrenheit is undefined, so you need to assign the algorithm to it
Wazir Robinson
@wazirrobinson
Mar 09 2017 05:00
@ooade I'm not sure how to do that.
Andrew Shieh
@andrewlikes
Mar 09 2017 05:01
fahrenheit = algorithm
David Miolard
@GwadaKing
Mar 09 2017 05:01
@wazirrobinson As they told you, you just have to assign the formula to your undefined variable
Wazir Robinson
@wazirrobinson
Mar 09 2017 05:02
Okay, thank you all for the help.
Abdallah Al-Azzami
@abodaz
Mar 09 2017 05:02
function reverseString(str) {
  var array=str.split(' ');
  array=array.reverse();
  str=array.join();
  return str;
}

reverseString("hello");
it should :
reverseString("hello") should become "olleh".
reverseString("Howdy") should become "ydwoH".
reverseString("Greetings from Earth") should return "htraE morf sgniteerG"
Johnny vo
@jphivo
Mar 09 2017 05:03
Can someone help me with this challenge?
var a;
var b = 2;
var a = 7;
var b = 7;
a should be assigned to b with =
not sure what it means
Ademola Adegbuyi
@ooade
Mar 09 2017 05:03
@jphivo assigning y to x means x = y; :wink:
Joseph
@revisualize
Mar 09 2017 05:04
@abodaz You need to change your split to '' and add an argument to your .join()
Ademola Adegbuyi
@ooade
Mar 09 2017 05:05
@abodaz you're splitting the array based on ' ' delimeter, you should close the gap
Joseph
@revisualize
Mar 09 2017 05:05
@jphivo How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Abdallah Al-Azzami
@abodaz
Mar 09 2017 05:05
@ooade thanks bro :D
CamperBot
@camperbot
Mar 09 2017 05:05
abodaz sends brownie points to @ooade :sparkles: :thumbsup: :sparkles:
:cookie: 849 | @ooade |http://www.freecodecamp.com/ooade
Ademola Adegbuyi
@ooade
Mar 09 2017 05:06
@abodaz :+1:
Johnny vo
@jphivo
Mar 09 2017 05:06
@revisualize @ooade thank you. got it.
CamperBot
@camperbot
Mar 09 2017 05:06
jphivo sends brownie points to @revisualize and @ooade :sparkles: :thumbsup: :sparkles:
:star2: 3455 | @revisualize |http://www.freecodecamp.com/revisualize
:cookie: 850 | @ooade |http://www.freecodecamp.com/ooade
Joseph
@revisualize
Mar 09 2017 05:08
@jphivo Does it actually make sense now?
Ziratsu
@Ziratsu
Mar 09 2017 05:10
Hi guys i'm loocked too in the celsius to farenheit exercices,
Johnny vo
@jphivo
Mar 09 2017 05:10
@revisualize yes it does. thank you.
CamperBot
@camperbot
Mar 09 2017 05:10
jphivo sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: jphivo already gave revisualize points
Ziratsu
@Ziratsu
Mar 09 2017 05:10

function convertToF(celsius) {
var fahrenheit;

// Only change code below this line

fahrenheit = (30*9/5 + 32);
// Only change code above this line
return fahrenheit;
}

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

Joseph
@revisualize
Mar 09 2017 05:10
@Ziratsu You need to understand what variables are then migrate to understand what parameters are.
Ziratsu
@Ziratsu
Mar 09 2017 05:10
Ive put my algorithm to farenheit variable but it doesnt affec the "ConvertToF
Joseph
@revisualize
Mar 09 2017 05:11
@Ziratsu Because, you're not using the celsius parameter
Ziratsu
@Ziratsu
Mar 09 2017 05:11
ho yeah ! Ive didnt notice, sorry for flooding, and thanks a lot ;)
Joseph
@revisualize
Mar 09 2017 05:12
I need to do a short write up about parameters
I have a long one.

Parameters are like variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another 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.

Yet another example code:

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

You can see how the parameter is used like a variable inside of the function.
And you can do mathematical operations to the parameter and assign the value to the variable result.

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

From knowing that please note that technically, calling parameters variables isn't correct. Parameters are part of the function declaration and when the function is called, an execution context is formed and there parameters are variables that hold the passed arguments.

If I have this code:

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

What happens when I do:

addThree(10);

And why? <--- This answer is actually the crux and most important.

Okay.. Let's break the problem down.
When you do.. addThree(10). You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
Well, inside of that function num can be used just like any other variable.
So, if I do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
So... result = 10 + 3;
Parameters are variables.
In your function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Inside of the function you can use celsius JUST like any other variable.

@Ziratsu -^
@wazirrobinson -^
Travis Fry
@definistrate1ster
Mar 09 2017 05:40
Can someone help me? I'm on the first challenge for JavaScript and I'm having trouble with the last test.
s

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
"a" should be assigned to "b" with "="
I'm not sure why it's not working
jeevanach
@jeevanach
Mar 09 2017 05:47

var firstName = "Ada";
var secondLetterOfFirstName = firstName1;

// Setup
var lastName = "Lovelace";

// Only change code below this line.
var thirdLetterOfLastName = lastName[v];

help plz
The thirdLetterOfLastName variable should have the value of v.
h1tag
@h1tag
Mar 09 2017 05:47
@definistrate1ster you have to literary assign a to b
@jeevanach what's the challenge name?
Joseph
@revisualize
Mar 09 2017 05:51
@definistrate1ster
How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Bryan
@Bryan1029
Mar 09 2017 05:51

Can anyone help me? Trying to make it so whenever someone clicks on a card, it won't let them and tells them to choose another card

var cards = [
{
rank: "queen",
suit: "hearts",
cardImage: "images/queen-of-hearts.png"
},
{
rank: "queen",
suit: "diamonds",
cardImage: "images/queen-of-diamonds.png"
},
{
rank: "king",
suit: "hearts",
cardImage: "images/king-of-hearts.png"
},
{
rank: "king",
suit: "diamonds",
cardImage: "images/king-of-diamonds.png"
},
];

var cardsInPlay = [];

function checkForMatch() {
if (cardsInPlay[0] === cardsInPlayrom-rb/rom-sql#115){
alert("You found a match!");
clearStates();
}else {
alert("Sorry, try again");
clearStates();
}
}

function clearStates() {
var numOfCards = document.getElementsByTagName("img").length;
for(i = 0; i < numOfCards;i++) {
document.getElementsByTagName("img")[i].setAttribute("src", "images/back.png");
}
cardsInPlay = [];
}

function flipCard() {
var cardId = this.getAttribute("data-id");
this.setAttribute("src", cards[cardId].cardImage);
cardsInPlay.push(cards[cardId].rank);
if(cardsInPlay.length > 1){
checkForMatch();
}
}

function createBoard() {
for(var i=0; i < cards.length;i++) {
var cardElement = document.createElement("img");
cardElement.setAttribute("src", "images/back.png");
cardElement.setAttribute("data-id", i);
cardElement.addEventListener("click", flipCard);
document.getElementById("game-board").appendChild(cardElement);
}
}

createBoard();

woops
Joseph
@revisualize
Mar 09 2017 05:52
@Bryan1029 FreeCodeCamp/HelpJavaScript Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
I want to make it so when someone clicks on a card, it won't let them and tells them to choose another card. I've completely blanked out and can't remember how to get it to work
Babu Rao Kasi
@babuharry
Mar 09 2017 05:53
hi guys, there
jeevanach
@jeevanach
Mar 09 2017 05:54

var firstName = "Ada";
var secondLetterOfFirstName = firstName1;

// Setup
var lastName = "Lovelace";

// Only change code below this line.
var thirdLetterOfLastName = lastName;

The thirdLetterOfLastName variable should have the value of v.
You should use bracket notation.
how to do??
give me suggestion
Rahsheen Porter
@rahsheen
Mar 09 2017 06:04
lastName is a string (of letters), so how would you go about accessing the 3rd letter of that string?
Abdallah Al-Azzami
@abodaz
Mar 09 2017 06:06
function palindrome(str) {
  // Good luck!

  str=str.replace(/[_,-, ,,,.]/,'');

  str.toLowerCase();
  var arr=str.split('');
  arr=arr.reverse();
  str1=arr.join(''); 
  if(str===str1)
   return true; 
  else
  return false;
}

palindrome("eye");
the problem is:
palindrome("A man, a plan, a canal. Panama") should return true.
palindrome("never odd or even") should return true.
palindrome("My age is 0, 0 si ega ym.") should return true.
palindrome("0_0 (: /-\ :) 0-0") should return true.
rajathdm
@rajathdm
Mar 09 2017 06:07
array.sort(function(a, b) {
return a - b;
});
array.sort(12,2);
How does one sort arrays in JS?
Abdallah Al-Azzami
@abodaz
Mar 09 2017 06:09
@rajathdm
if you want to sort from small to bid : return a-b
if you want to sort from big to small : return b-a
Rahsheen Porter
@rahsheen
Mar 09 2017 06:09
The link has all the basic use cases ad details ;)
rajathdm
@rajathdm
Mar 09 2017 06:10
@rahsheen Thanks.
CamperBot
@camperbot
Mar 09 2017 06:10
rajathdm sends brownie points to @rahsheen :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @rahsheen |http://www.freecodecamp.com/rahsheen
rajathdm
@rajathdm
Mar 09 2017 06:10
Tried
Bust something doesn't seem to work.
Babu Rao Kasi
@babuharry
Mar 09 2017 06:11
@rahsheen hi do you have any idea on JS drag and drop
Rahsheen Porter
@rahsheen
Mar 09 2017 06:11
@babuharry sorry, haven't done any of that just yet.
Ademola Adegbuyi
@ooade
Mar 09 2017 06:12
@rajathdm
var arr = [5, 1, 7]
arr.sort(function(a, b) { return a - b }) # sorts from smallest to largest
Babu Rao Kasi
@babuharry
Mar 09 2017 06:12
it's okay i want you to look at this once
@rahsheen it is working fyne but i want onclick submit button there get solution button on click of that draggalbe should go thier right positions
rajathdm
@rajathdm
Mar 09 2017 06:15

@ooade I'm using the samearray.sort(function(a, b) {
return a - b;
});

array.sort(4,3);

Ademola Adegbuyi
@ooade
Mar 09 2017 06:15
@rajathdm array.sort(4,3); is not valid
rajathdm
@rajathdm
Mar 09 2017 06:15
ok
Ademola Adegbuyi
@ooade
Mar 09 2017 06:16
sort method takes a function as its argument
rajathdm
@rajathdm
Mar 09 2017 06:16
So how do I call the sort method?
Ademola Adegbuyi
@ooade
Mar 09 2017 06:17
Just call it on the arr you want to sort @rajathdm
function arrangeNumbers(arr) {
   return arr.sort(function(a, b){
      return a - b;
   })
}
arrangeNumbers([4, 6, 1, 3, 7, 2]); //returns [1, 2, 3, 4, 6, 7]
Johnny vo
@jphivo
Mar 09 2017 06:20
Can someone help me with Increment a Number with JavaScript challenge? They are asking me to change myVar = myVar + 1; and use ++

var myVar = 87;

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

Nataly C.
@cstpk
Mar 09 2017 06:21
I can't quite get for loops. Any tips, videos, tutorials?/
Nataly C.
@cstpk
Mar 09 2017 06:23
@jphivo myVar++ is the same as myVar = myVar + 1
@tommygebru thanks
CamperBot
@camperbot
Mar 09 2017 06:23
natalyscosta sends brownie points to @tommygebru :sparkles: :thumbsup: :sparkles:
:cookie: 792 | @tommygebru |http://www.freecodecamp.com/tommygebru
tommy
@tommygebru
Mar 09 2017 06:24
Working on the Record Challenge, need 2 tests to pass, I have been rewriting my solution for a few hours now
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if(value===""){
delete collection[id][prop];
}
else if (value!=="")
 {
if(!collection[id].hasOwnProperty("tracks")){
collection[id][prop]=value;
}
else {
  if(collection[id].hasOwnProperty("tracks") && collection[id][prop]===""){
  collection[id][prop]=[];
  collection[id][prop].push(value);}
  else {
  collection[id][prop].push(value);
  }
}//else
}//else if
return collection;
}
Matthew Orndoff
@mattattaque
Mar 09 2017 06:24
But it’s all the same ideas
Johnny vo
@jphivo
Mar 09 2017 06:24
@natalyscosta Thank you.
CamperBot
@camperbot
Mar 09 2017 06:24
jphivo sends brownie points to @natalyscosta :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @natalyscosta |http://www.freecodecamp.com/natalyscosta
Nataly C.
@cstpk
Mar 09 2017 06:26
@abodaz you're gonna use RegExp
rajathdm
@rajathdm
Mar 09 2017 06:27
@ooade That worked! Thank you :)
Daksh Shah
@dakshshah96
Mar 09 2017 06:28

Hey everyone, I'm currently learning JavaScript and just came across the concept of closures in JavaScript. After reading this article: https://toddmotto.com/everything-you-wanted-to-know-about-javascript-scope/ I have some pretty solid idea on scopes and even managed to understand lexical scoping. I understand closures are closely tied to lexical scoping but can't really get the point of closures. If this is an example of a closure:

var sayHello = function (name) {
  var text = 'Hello, ' + name;
  return function () {
    console.log(text);
  };
};

What is the point of returning a function here? Why not just put console.log(text) at the end of the sayHello(name) function?

tommy
@tommygebru
Mar 09 2017 06:32
Struggling with the same problem for a few hours - Record Challenge
this is the error i am seeing in the console
"updateRecords(...)[5439].tracks.pop is not a function"
"Cannot read property 'push' of undefined"
Chris Cullen
@123xylem
Mar 09 2017 06:36
Error: Cannot find module 'ejs'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at new View (/home/ubuntu/workspace/node_modules/express/lib/view.js:78:30)
    at EventEmitter.render (/home/ubuntu/workspace/node_modules/express/lib/application.js:569:12)
    at ServerResponse.render (/home/ubuntu/workspace/node_modules/express/lib/response.js:960:7)
    at /home/ubuntu/workspace/animalApp/app.js:32:9
    at Layer.handle [as handle_request] (/home/ubuntu/workspace/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/ubuntu/workspace/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/home/ubuntu/workspace/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/ubuntu/workspace/node_modules/express/lib/router/layer.js:95:5)
    at /home/ubuntu/workspace/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:330:12)
    at next (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:271:10)
    at methodOverride (/home/ubuntu/workspace/animalApp/node_modules/method-override/index.js:65:14)

Im getting this Error when I have installed and included EJS in my mongo cloud9 server as you can see below

var express=require("express");
var app=express();
var bodyParser=require("body-parser");
var expressSanitizer=require("express-sanitizer");
var methodOverride=require("method-override");
var mongoose=require("mongoose");
var ejs=require("ejs");                                              //I WROTE THIS AS AN EXTRA PRECAUTION(not working tho)

app.use(expressSanitizer());
app.set("view engine","ejs");                                 //HERE I INCLUDE IT
app.use(bodyParser.urlencoded({extended:true}));
app.use(express.static("public"));
app.use(methodOverride("_method"));
mongoose.connect("mongodb://localhost/animalApp");

THE EJS also comes up in my JSON dependencies files, so that proves its saved?
Why does it not recognise my EJS files?

Ademola Adegbuyi
@ooade
Mar 09 2017 06:36
@rajathdm :+1:
And take note that sort has side-effects/mutates i.e changes the original array, so you can as well say
function arrangeNumbers(arr) {
   arr.sort(function(a, b){
      return a - b;
   });
   return arr;
}
arrangeNumbers([4, 6, 1, 3, 7, 2]); //returns [1, 2, 3, 4, 6, 7]
rajathdm
@rajathdm
Mar 09 2017 06:39
@ooade got it :+1:
Ademola Adegbuyi
@ooade
Mar 09 2017 06:39
:+1:
Markus Kiili
@Masd925
Mar 09 2017 06:46
@dakshshah96 The point is that the returned function has some private data (text) that only it can access. Maybe not the best possible example.
Ademola Adegbuyi
@ooade
Mar 09 2017 06:48
@123xylem package.json??
Chris Cullen
@123xylem
Mar 09 2017 06:49
@ooade ?
what are u asking?
Daksh Shah
@dakshshah96
Mar 09 2017 06:49
@Masd925 Wouldn't just sayHello be able to access text anyway since it is a local variable? The more I read about this, the more I get confused :worried:
Ademola Adegbuyi
@ooade
Mar 09 2017 06:49
@123xylem are you sure ejs is in your package.json file???
Chris Cullen
@123xylem
Mar 09 2017 06:50
"dependencies": {
    "body-parser": "^1.17.1",
    "ejs": "^2.5.6",
    "express-sanitizer": "^1.0.2",
    "method-override": "^2.3.7",
    "mongoose": "^4.8.6"
  }
Travis Fry
@definistrate1ster
Mar 09 2017 06:52
@revisualize
Ademola Adegbuyi
@ooade
Mar 09 2017 06:52
@123xylem seem strange, you didn't even need to require ejs
Travis Fry
@definistrate1ster
Mar 09 2017 06:53
Thanks man. I figured it out.
Markus Kiili
@Masd925
Mar 09 2017 06:53
@dakshshah96 The difference with closure is that the local variable text stays alive even though the function sayHello finishes executing, because the returned function has access to it. Maybe I can find a better example.
Daksh Shah
@dakshshah96
Mar 09 2017 06:55
@Masd925 Right. So that's what they mean by closures 'remember' the environment they were created in. Thanks, that'd be great :)
CamperBot
@camperbot
Mar 09 2017 06:55
dakshshah96 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3546 | @masd925 |http://www.freecodecamp.com/masd925
Chris Cullen
@123xylem
Mar 09 2017 06:56
@ooade yea
i dont know why its not working
Ademola Adegbuyi
@ooade
Mar 09 2017 06:57
@123xylem is that the first error log because i don't see express on your deps list??
Chris Cullen
@123xylem
Mar 09 2017 06:58
hmm yea interesting
Ademola Adegbuyi
@ooade
Mar 09 2017 07:00
@123xylem hmmm... Going off for a while... I'd say trace your steps, probably rm -rf node_modules && npm install and try it again.. And add express this time in case you're moving it to some other server
Chris Cullen
@123xylem
Mar 09 2017 07:00
@ooade Well done thankyou
CamperBot
@camperbot
Mar 09 2017 07:00
123xylem sends brownie points to @ooade :sparkles: :thumbsup: :sparkles:
:cookie: 851 | @ooade |http://www.freecodecamp.com/ooade
Chris Cullen
@123xylem
Mar 09 2017 07:00
@ooade u were right no express installed
i mustve not done --save
or something
Ademola Adegbuyi
@ooade
Mar 09 2017 07:01
@123xylem Yeah, it might not give an issue if you installed it on that current hosting server but moving to a new hosting service like heroku will result in a stack of errors :smile:
Markus Kiili
@Masd925
Mar 09 2017 07:04
@dakshshah96 Here is an example of a counter:
function counter (name, value) {
  return function () {
    value++;
    console.log(name+" "+value);
  };
}

var addPerson = counter("Persons", 0);
var addCar = counter("Cars", 0);

addPerson(); // Persons 1 
addPerson(); // Persons 2 
addCar();    // Cars 1
addPerson(); // Persons 3
addCar();    // Cars 2 
addPerson(); // Persons 4
You can have counters for different things, because each counter has access to its own copy of name and value in the closure.
Daksh Shah
@dakshshah96
Mar 09 2017 07:06
@Masd925 Ah, that makes it better. From what I understand, the closure here remembers the content of valuefrom when it was invoked, making it possible to just increment it for the next person...
Instead of passing name and value manually to counter (name, value) each time without the use of closure.
Thanks @Masd925 :D
CamperBot
@camperbot
Mar 09 2017 07:07
dakshshah96 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: dakshshah96 already gave masd925 points
Markus Kiili
@Masd925
Mar 09 2017 07:07
@dakshshah96 Yes, you would have to keep count of them yourself.
amit singh
@amitsingh17051
Mar 09 2017 07:09

var Bike = function() {

// Only change code below this line.

var gear = 0;

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

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

help me
Daksh Shah
@dakshshah96
Mar 09 2017 07:10
Hey @amitsingh17051, what kind of help do you require with this?
Just putting up the formatted code here for reference
var Bike = function() {
    // Only change code below this line.
    var gear = 0;
    this.getGear = function() {
        gear = 4;
    };
    this.setGear = function(){
        return gear;
    };
};
Dominik Soczewka
@Villentrenmerth
Mar 09 2017 07:10
@amitsingh17051 you are setting in getter and getting in setter :smile:
Daksh Shah
@dakshshah96
Mar 09 2017 07:12
Yes @amitsingh17051. @Villentrenmerth is right.
Robert Spring
@ironguard20
Mar 09 2017 07:12

This is the first time I've gotten stuck
var code = "
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
console.log([i][j]);
}
product = arr[[i][j]]*arr[[i][j]];
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3],[3]]);
"

this is for the nesting for loops
amit singh
@amitsingh17051
Mar 09 2017 07:13
right i just want to know what i'm doing wrong
Robert Spring
@ironguard20
Mar 09 2017 07:14
ignore the var code, realized I messed up the formatted styling
Daksh Shah
@dakshshah96
Mar 09 2017 07:15
@ironguard20 It's alright, everyone gets stuck once in a while :smile: Regarding your program, instead of providing the solution to you directly, I'd like you to find it yourself. Here's a hint: check the following line in your code — product = arr[[i][j]] * arr[[i][j]]; and ask for help if required.
Isn't the above mentioned statement just multiplying the square of the current value and assigning it to product with each iteration? At the end of the loop, product will contain just the squared value of the last element of your array.
How could you possibly correct this? Let me know :)
Remember: product is supposed to contain the final product i.e., multiplication of all elements in your array.
Robert Spring
@ironguard20
Mar 09 2017 07:21
so basically find a way to multiple all the elements in my array
and set product equal to the output in there
Markus Kiili
@Masd925
Mar 09 2017 07:22
@ironguard20 product should hold the result of multiplication done thus far, and at the end it will be the total result.
Daksh Shah
@dakshshah96
Mar 09 2017 07:23
Yes, correct. How would you keep multiplying the current array element i.e., arr[i][j]into product?
Also, @ironguard20 you've used arr[[i][j]]. That's wrong syntax. You're supposed to use arr[i][j] to access an two dimensional array element.
Robert Spring
@ironguard20
Mar 09 2017 07:25
so something like this then
product = arr[i][j] * product
Daksh Shah
@dakshshah96
Mar 09 2017 07:26
Yes, you're right! :clap:
Robert Spring
@ironguard20
Mar 09 2017 07:26
This one definitely threw me for a loop
Daksh Shah
@dakshshah96
Mar 09 2017 07:26
Pro tip: You can also use the shorthand product *= arr[i][j].
Robert Spring
@ironguard20
Mar 09 2017 07:26
thanks for the help!
Daksh Shah
@dakshshah96
Mar 09 2017 07:27
You're welcome @ironguard20
Robert Spring
@ironguard20
Mar 09 2017 07:27
I'll keep that in mind, somehow brain dumped that operator
Daksh Shah
@dakshshah96
Mar 09 2017 07:28
Haha, happens to the best of us @ironguard20 :D
Reine Alice Iramurikiye
@reinelic
Mar 09 2017 07:38

Hi can you please let me know whats wrong with my code?
It works for all the test except this one ["hello", "hey"]
I am supposed to return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

function mutation(arr) {
  var newArray= arr[1].toLowerCase().split('');
  var indexNum;
  var indexArray =[];

  for( var i =0;i<newArray.length;i++)
    {
       indexNum=arr[0].indexOf(newArray[i]);
       indexArray.push(indexNum);
       if(indexArray.includes(-1) === true)
         {
           return false;
         }       
      else
        {
          return true;  
        }

    }

}

Markus Kiili
@Masd925
Mar 09 2017 07:42
@reinelic Are you lowercasing both strings?
@reinelic You can return true only after checking all the second string characters.
You don't need any arrays here. Just loop over second string and indexOf check (works on strings).
Reine Alice Iramurikiye
@reinelic
Mar 09 2017 07:47
@Masd925 OK let me try that
sampah
@manusialemah
Mar 09 2017 08:06
May I ask for a help in checking an object's property?
Markus Kiili
@Masd925
Mar 09 2017 08:07
@manusialemah Sure.
sampah
@manusialemah
Mar 09 2017 08:07

What's wrong with my code?

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
var result = " ";
switch (checkProp) {
case myObj.hasOwnProperty("gift"):
result = "pony";
break;
case myObj.hasOwnProperty("pet"):
result = "kitten";
break;
case myObj.hasOwnProperty("bed"):
result = "sleigh";

}

// Your Code Here
return result;

}

// Test your code by modifying these values
checkObj("gift");

Markus Kiili
@Masd925
Mar 09 2017 08:08
@manusialemah Don't hardcode the property keys. Use checkProp. It is the function parameter that holds the passed string.
Use if and hasOwnProperty()
sampah
@manusialemah
Mar 09 2017 08:09
What do you mean by "don't hardcode the property keys"?
Markus Kiili
@Masd925
Mar 09 2017 08:10
@manusialemah Don't use "gift" etc. The function needs to work on any object with some different keys.
tycon124
@tycon124
Mar 09 2017 08:10
@manusialemah
if (myObj.hasOwnProperty(checkProp)
sampah
@manusialemah
Mar 09 2017 08:10
Why can't I use switch?
Markus Kiili
@Masd925
Mar 09 2017 08:11
@manusialemah You don't know the keys. You just need to check if the passed key is found on the object to test.
So you just use the variables.
The code needs to work on any object and any passed key.
Not just this one object written here.
sampah
@manusialemah
Mar 09 2017 08:13
I see. What I'm getting is this: So it's kind of defeating the purpose of building a function to probe the object if I decided to use the keys(pony, kitten, sleigh)?
Bonface
@TheBonface
Mar 09 2017 08:14
am really stuck , any assistance?

`` function nextInLine(arr, item) {
var testArr;

testArr=arr.push(item);
testArr=arr.pop(item);
return testArr;
}

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

Markus Kiili
@Masd925
Mar 09 2017 08:15
@manusialemah Yes, it should be a function that tests if a given property key exist on the given object. "gift" and "pet" are just keys on some specific object.
@TheBonface Use arr and item, not testArr
sampah
@manusialemah
Mar 09 2017 08:16
Thank you @Masd925
CamperBot
@camperbot
Mar 09 2017 08:16
manusialemah sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3547 | @masd925 |http://www.freecodecamp.com/masd925
Bonface
@TheBonface
Mar 09 2017 08:24
@Masd925 i have tried this
function nextInLine(arr, item) {

var before=arr.push(item);
var after= arr.pop(item); 

  return after;
}
// 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));
Markus Kiili
@Masd925
Mar 09 2017 08:25
@TheBonface Pop is wrong method.
You don't need the before variable.
sampah
@manusialemah
Mar 09 2017 08:28
@tycon124 I'll try that thanks
CamperBot
@camperbot
Mar 09 2017 08:28
manusialemah sends brownie points to @tycon124 :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @tycon124 |http://www.freecodecamp.com/tycon124
Bonface
@TheBonface
Mar 09 2017 08:28
@Masd925 ooh thanks i only changed pop() to Shift() and it worked
Markus Kiili
@Masd925
Mar 09 2017 08:29
@TheBonface :+1:
Bonface
@TheBonface
Mar 09 2017 08:29
@Masd925 thanks
CamperBot
@camperbot
Mar 09 2017 08:29
thebonface sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3548 | @masd925 |http://www.freecodecamp.com/masd925
Mikkel Halling Steen
@Mikkel3008
Mar 09 2017 08:33

var myVar = 87;

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

????

myVar = myVar should be changed?
Markus Kiili
@Masd925
Mar 09 2017 08:34
@Mikkel3008 What are you trying to do?
amit singh
@amitsingh17051
Mar 09 2017 08:34

var array = [4,5,6,7,8];

// Only change code below this line.
var singleVal = 0;
var singleVal = array.reduce(function(previousVal, currentVal){
return previousVal+currentVal;
});

singleVal = array;

hats wrong i'm doing
WiseKodama
@WiseKodama
Mar 09 2017 08:35
Greetings can anyone help me with my TTT? http://codepen.io/WiseKodama/full/xqOMjz/
Dominik Soczewka
@Villentrenmerth
Mar 09 2017 08:35
@amitsingh17051 you are changing singleVal and then assigning array to it, so reduce doesn't matter
@amitsingh17051 instead of assigning singleVal to array, or just returning singleVal
WiseKodama
@WiseKodama
Mar 09 2017 08:36
The issue is that when in two player mode the player 1 doesn't get the win screen. The game will acknowledge that it's over but it won't treat it as such. Codepen just prevents an inifinite loop...
Prashant Acharya
@Prashant-Acharya
Mar 09 2017 09:09
hey can anyone help me to complete sum all primes challenge
function sumPrimes(num) {
   var sum = num;
  var count = 0;
   for (var i = 1; i < num ; i++){
     for (var j = 1; j <= i ; j++){
       if (i%j === 0){
         count = count + 1;
       }
       if (count == 2){
         sum = sum + i;
       }
     }
   }

  return sum;
}
Pieter Stokkink
@forkerino
Mar 09 2017 09:10
@Prashant-Acharya what are you counting? The first two evenly divisible pairs of numbers?
Richard Belotte
@belotte
Mar 09 2017 09:11

I have a question. The instructions are: Return the provided string with the first letter of each word capitalised. Make sure the rest of the word is in lower case.

I have this code:

function titleCase(str) {
  var toLowerCase = str.toLowerCase();
  var newArr = toLowerCase.split(' ');
  for(var i = 0; 1 < newArr.length; i++){
    var newNestedArr = newArr[i].split('');
    var toUpperCase = newNestedArr[i][0].toUpperCase();
    var newStr = newNestedArr[i][0].splice(0, 1, toUpperCase);
    //newStr.join('');
    //return newStr;
  }
  //return newStr;
}

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

How do I swap the new capitalised letter for the lowercase one? I have

var newStr = newNestedArr[i].splice(0, 1, toUpperCase);

as you can see. I also tried

newNestedArr[i][0] = toUpperCase;
Rohit Sachdeva
@ehrohit
Mar 09 2017 09:14
@belotte doing the same question
Richard Belotte
@belotte
Mar 09 2017 09:15
what have you got?
Pieter Stokkink
@forkerino
Mar 09 2017 09:15
@belotte strings don't have a .splice method. So that won't work.
An easier way is to overwrite the string in newArr[i] with the uppercased version using simple string concatenation (+)
Rohit Sachdeva
@ehrohit
Mar 09 2017 09:15

function titleCase(str) {
var arrStr=[]; arrStr=str.split(" "); console.log(arrStr);
var newArr=[];
for(var i=0;i<arrStr.length;i++)
{
if(arrStr[i].charAt(0)===arrStr[i].charAt(0).toLowerCase())
{
console.log("The Character in Check " + arrStr[i].charAt(0) +" " +arrStr[i]);
var temp= arrStr[i].charAt(0).toUpperCase();
console.log("*" + temp);

  var string1= arrStr[i];
  string1=string1.replace(string1.charAt(0),temp);
  newArr[i]=string1;
      } 

}
console.log("Change"+ newArr);
var string = newArr.join('');
return string;
}
titleCase("I'm a little tea pot");

but I have to use splice somewhere to check all the other characters in other words too and then how to concatenate is an issue
tycon124
@tycon124
Mar 09 2017 09:16
@belotte try string.charAt(0).toUpperCase() + string.slice(1);
for each word
and split the string at space
Richard Belotte
@belotte
Mar 09 2017 09:17
@forkerino it's not a string that I am splicing. At that stage it's an array.
mmajam
@mmajam
Mar 09 2017 09:17
I can´t find where is the problem in my Sum Of Primes: My code counts correctly the tested number 10, but not the 977. Why???
function sumPrimes(num) {
  var listOfPrimes = [];
  var listOfNumbers = [];
   //Function for finding out if the number is a prime + adding it to the list of primes:
  function isPrime(testedNum) {
      var dividers = [];
      for (var i = 1; i <= testedNum; i++) {
        if (testedNum % i === 0) {
          dividers.push(i);
          }
      }
      if (dividers.length === 2 && testedNum > 1) {
        listOfPrimes.push(testedNum);
      } else {
        dividers = [];
      }    
  }
   //Creating list of numbers up to the number:
  for (var j = 1; j <= num; j++) {
      listOfNumbers.push(j);
  }
   //Testing the list of numbers - if these are primes:
  for (var k = 0; k < listOfNumbers.length; k++) {
    isPrime(listOfNumbers[k]);
  }
   //Making the sum of the primes: 
 var sumOfPrimes = listOfPrimes.reduce(function(x, y) {
    return x + y;
  });
  return sumOfPrimes;
}

sumPrimes(10);
Pieter Stokkink
@forkerino
Mar 09 2017 09:17
@belotte ah yes, didn't see you adding an extra split.
@belotte well then it should work, but you'll need a way to store the newStr in each iteration.
Rohit Sachdeva
@ehrohit
Mar 09 2017 09:18
splice will break the string in array right
Pieter Stokkink
@forkerino
Mar 09 2017 09:18
@ehrohit nope. that is .split
mmajam
@mmajam
Mar 09 2017 09:19
Could you help me please?
Rohit Sachdeva
@ehrohit
Mar 09 2017 09:19
@
Richard Belotte
@belotte
Mar 09 2017 09:20
@forkerino That's what var toUpperCase = newNestedArr[i][0].toUpperCase(); is for, to store the new cap letter.
Pieter Stokkink
@forkerino
Mar 09 2017 09:20
@belotte yeah, I mean after you create your newStr. You have to do something with that newStr
otherwise it will just be overwritten on the next loop
Rohit Sachdeva
@ehrohit
Mar 09 2017 09:21
You can use replace
Pieter Stokkink
@forkerino
Mar 09 2017 09:21
@mmajam is the outcome for 977 too low?
Rohit Sachdeva
@ehrohit
Mar 09 2017 09:21
@belotte
mmajam
@mmajam
Mar 09 2017 09:22
I don´t know, the fcc simply marks this number as not correct :-(
Pieter Stokkink
@forkerino
Mar 09 2017 09:23
@mmajam you can change the bottom line to sumPrimes(977) to see the output.
mmajam
@mmajam
Mar 09 2017 09:24
Sorry, I just did it - "Error: Potential infinite loop at line 28..." (That is in the for-loop with var=k - isPrime(listOfNumbers[k])
Richard Belotte
@belotte
Mar 09 2017 09:26

@forkerino Wouldn't the line var newStr = newNestedArr[i].splice(0, 1, toUpperCase); in


function titleCase(str) {
  var toLowerCase = str.toLowerCase();
  return newStr;
  var newArr = toLowerCase.split(' ');
  for(var i = 0; 1 < newArr.length; i++){
    var newNestedArr = newArr[i].split('');
    var toUpperCase = newNestedArr[i][0].toUpperCase();
    var newStr = newNestedArr[i].splice(0, 1, toUpperC