These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Jun 2017
Bailey
@baileyg2016
Jun 21 2017 00:00
Shooooot never mind put it in the function thank you
@JLuboff
Joseph
@revisualize
Jun 21 2017 00:00
GRRR!
How do I change a stupid switch port to Full Duplex
David Temple
@dtemple55
Jun 21 2017 00:00
oops did'nt work @JLuboff
oops now it is
dont mind me
Joseph
@revisualize
Jun 21 2017 00:04
GOT IT!
YAY!
HP switch configurations!
Woot
who wants to help me get the front-end up and running?
revisualize @revisualize leaves.
fdemaa
@fdemaa
Jun 21 2017 00:20
How can i delete the first letter of all my strings?
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:21
@fdemaa you can use splice
Zdudezy
@Zdudezy
Jun 21 2017 00:21
anyone know how to do wordblanks
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:21
first make the array of words and then iterate through them, and then use splice
@Zdudezy in that parameters are used to make a proper sentence but remember to put space between them and you can add whatever text you wants to add.
Zdudezy
@Zdudezy
Jun 21 2017 00:23
how do you add space inbetween the words
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:25
@Zdudezy + concatenate operator use there. it joins two expression togetter.
Ginger
@GingerChew
Jun 21 2017 00:25
I'm on the profile lookup for js and I'm having a problem getting my lookup function to return the property thats input, but I can get it to pull up the first name of the object in question
abraham anak agung
@padunk
Jun 21 2017 00:25
good morning...
Ginger
@GingerChew
Jun 21 2017 00:25
```function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0;i<contacts.length;i++) {
if (firstName == contacts[i].firstName && prop == contacts[i][prop]) {
return contacts[i][prop];
}
}}
abraham anak agung
@padunk
Jun 21 2017 00:25
anyone know what is better concat or push?
fdemaa
@fdemaa
Jun 21 2017 00:29
@forwebtech can i use something like this console.log(a.splice([i][0],[1])); ?
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:30
@fdemaa splice accepts numbers not arrays so just
@fdemaa mdn.io/splice
Nefton
@neftonjin
Jun 21 2017 00:30
hi can someone help me with the Selecting from many options with Switch Statements chalange .

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

  switch(answer){
    case 1:
     console.log("alpha"); break;


    case 2 :
         console.log("beta"); break;

    case 3:
      console.log("gamma"); break;

    case 4:  console.log("delta");  break;


           }

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

// Change this value to test
caseInSwitch(1);
what i am doing wrong ?
fdemaa
@fdemaa
Jun 21 2017 00:32
@forwebtech thanks
CamperBot
@camperbot
Jun 21 2017 00:32
fdemaa sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 723 | @forwebtech |http://www.freecodecamp.com/forwebtech
abraham anak agung
@padunk
Jun 21 2017 00:33
@neftonjin your answer var is empty, you should switch your val
Nick Danvers
@Ravenor222
Jun 21 2017 00:37
Hey guys, im doing "comparison with the logical and operator
if (val >= 25 && val <= 50) {
return "yes";
seems like it should work, however some of the requirements aren't passing
Manny Simeus
@ejsimeus
Jun 21 2017 00:39
Does someone mind helping me? I am currently doing Increments with Javascript..https://www.freecodecamp.com/challenges/increment-a-number-with-javascript
Nick Danvers
@Ravenor222
Jun 21 2017 00:39
What do you need Manny
abraham anak agung
@padunk
Jun 21 2017 00:40
@Ravenor222 it should work. try refresh your browser
Nick Danvers
@Ravenor222
Jun 21 2017 00:40
@padunk ty will give it a try
CamperBot
@camperbot
Jun 21 2017 00:40
ravenor222 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 352 | @padunk |http://www.freecodecamp.com/padunk
Manny Simeus
@ejsimeus
Jun 21 2017 00:40
@Ravenor222 How do I can change the code to use the ++ operator on my Var?
Nick Danvers
@Ravenor222
Jun 21 2017 00:40
@ejsimeus the ++ operator is basically like saying +1, if myVar = 87;
think of how you could use the var myVar, and use the ++ operator to return the number 88
Nefton
@neftonjin
Jun 21 2017 00:41
still not working
Will Hart
@willhart108
Jun 21 2017 00:41
Screen Shot 2017-06-20 at 5.40.41 PM.png
Nick Danvers
@Ravenor222
Jun 21 2017 00:41
Link what youve written?
Will Hart
@willhart108
Jun 21 2017 00:41
am i missing something?
Nick Danvers
@Ravenor222
Jun 21 2017 00:42
That should work will
abraham anak agung
@padunk
Jun 21 2017 00:42
@neftonjin show your code. you have to assign var answer to something. it is there for a reason
Nick Danvers
@Ravenor222
Jun 21 2017 00:42
try using "
However maybe a refresh is necessary
Will Hart
@willhart108
Jun 21 2017 00:42
@Ravenor222 i tried refreshing and both " and '
Nefton
@neftonjin
Jun 21 2017 00:43
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line

  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;
  }
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
Nick Danvers
@Ravenor222
Jun 21 2017 00:43
@willhart108 can you link the page
Manish Giri
@Manish-Giri
Jun 21 2017 00:43
@neftonjin why're you using console.log in each case?
Nick Danvers
@Ravenor222
Jun 21 2017 00:43
@ejsimeus Its the default page you would have to copy paste the actual code
Moisés Man
@moigithub
Jun 21 2017 00:43
@neftonjin assign values to answer variable instead of console.log
Nefton
@neftonjin
Jun 21 2017 00:43
it says to change the code below the var answer
Nick Danvers
@Ravenor222
Jun 21 2017 00:45
@padunk if a refresh didnt fix it what do you think might be the issue
abraham anak agung
@padunk
Jun 21 2017 00:45
@Ravenor222 show your code here.
Nick Danvers
@Ravenor222
Jun 21 2017 00:45
@padunk if (val >= 25 && val <= 50) {
return "yes";
sry

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

if (val >= 25 && val <= 50) {
return "yes";

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

// Change this value to test
testLogicalAnd(25);

Will Hart
@willhart108
Jun 21 2017 00:46
@Ravenor222 refreshing didn't work and i also tried in Chrome (i use Safari by default)
Nick Danvers
@Ravenor222
Jun 21 2017 00:46
All the tests line up, for example testLogicalAnd(25) returns yes, however on the bottom left it doesnt check off
Manny Simeus
@ejsimeus
Jun 21 2017 00:46
@Ravenor222var
myVar = 87;// Only change code below this line
myVar = myVar i++;
Nick Danvers
@Ravenor222
Jun 21 2017 00:46
i
Manish Giri
@Manish-Giri
Jun 21 2017 00:46
@willhart108 post your challenge URL
Nick Danvers
@Ravenor222
Jun 21 2017 00:46
is the myVar
Manish Giri
@Manish-Giri
Jun 21 2017 00:46
click "run tests' first
Nick Danvers
@Ravenor222
Jun 21 2017 00:46
myVar++
"i" is the example var
Artair-faolan
@Artair-faolan
Jun 21 2017 00:47
Hello everyone, I am stuck on the first remainer part, can anyone help me with it?
Nefton
@neftonjin
Jun 21 2017 00:47
i got it . thanks
abraham anak agung
@padunk
Jun 21 2017 00:47
@Ravenor222 hmm...i have no idea. it work here. maybe try clearing your cache?
Will Hart
@willhart108
Jun 21 2017 00:47
@Manish-Giri do what now?
Moisés Man
@moigithub
Jun 21 2017 00:47
@Ravenor222 "YES" vs "yes" or "Yes" are not the same string... check which test if failing and compare the expected result vs whatever u returning
Manny Simeus
@ejsimeus
Jun 21 2017 00:48
@Ravenor222 Thank you!
CamperBot
@camperbot
Jun 21 2017 00:48
ejsimeus sends brownie points to @ravenor222 :sparkles: :thumbsup: :sparkles:
:cookie: 183 | @ravenor222 |http://www.freecodecamp.com/ravenor222
Manish Giri
@Manish-Giri
Jun 21 2017 00:49
@willhart108 click "RUN TESTS" first
Artair-faolan
@Artair-faolan
Jun 21 2017 00:49
https://www.freecodecamp.com/challenges/finding-a-remainder-in-javascript I can not figure how to do this, someone might want to look into rewriting the instructions?
Manish Giri
@Manish-Giri
Jun 21 2017 00:49
otherwise it won't show your code
Will Hart
@willhart108
Jun 21 2017 00:50
not sure what you're asking
Screen Shot 2017-06-20 at 5.40.41 PM.png
Nick Danvers
@Ravenor222
Jun 21 2017 00:52
@padunk thanks clearing the cache did it
CamperBot
@camperbot
Jun 21 2017 00:52
ravenor222 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:warning: ravenor222 already gave padunk points
Will Hart
@willhart108
Jun 21 2017 00:52
does my code look wrong? it generated correctly but it's not letting me move on
Kevin
@kevinwr
Jun 21 2017 00:52

Hey, all. Got a question here as to what's happening in my code. I imagine it has something to do with scope, but haven't figured it out yet.

function factorialize(num) {


  //create an array of numbers less than or equal to the variable num
  for (i = 1; i <= num; i++) {
    var array = [ ];
    array[i-1] = i;
  }

  console.log(array);
}

factorialize(5);

This returns the array: [undefined, undefined, undefined, undefined, 5].

I know my call to array is outside of the scope, which is why I'm getting undefined, but I'm curious why I get 5 at the end of the array. I would expect another undefined.

Will Hart
@willhart108
Jun 21 2017 00:52
oh maybe the double ""s
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:52
@willhart108 separate your code as:
var mystr = ....
mystr += ....
Manish Giri
@Manish-Giri
Jun 21 2017 00:53
@willhart108 try using double quotes
and if it doesn't work, post a screenshot.
Kevin
@kevinwr
Jun 21 2017 00:54
@Manish-Giri Hey, Maish. Good seeing you here. Hope you're well.
*Manish
Manish Giri
@Manish-Giri
Jun 21 2017 00:54
@kevinwr hey, I'm good, how're you?
Moisés Man
@moigithub
Jun 21 2017 00:54
@kevinwr move array declaration outside teh loop
Kevin
@kevinwr
Jun 21 2017 00:55
@Manish-Giri not too shabby. Been spending a lot of time reading some JS books to learn more
Na-Ya
@Na-Ya
Jun 21 2017 00:55
Hi, can anyone please tell me why I am getting NaN when I try to return fahrenheit in my project?
AisuluOmar
@AisuluOmar
Jun 21 2017 00:55

Hi, Guys. I need your help. I need to :Assign the value 7 to variable a.

Assign the contents of a to variable b.

var a=7;
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:56
@AisuluOmar as you assign 7 to a, so, as it is assign a to b. the thing which needs to be assign, comes at right.
Kevin
@kevinwr
Jun 21 2017 00:56
@moigithub I know I need to. THat's not what I'm asking. I'm asking why there remains a 5 at the end. I expect it to be "undefined"
AisuluOmar
@AisuluOmar
Jun 21 2017 00:57
but how to assign the contents of a to vaiarble b ?
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:57
@Na-Ya make sure all values are numbers. it happens when we do something like that 2 x '3'
@AisuluOmar b = a
AisuluOmar
@AisuluOmar
Jun 21 2017 00:58
@forwebtech
var a=7;
b=a
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:58
@AisuluOmar if b is not pre-declared then use var keyword.
AisuluOmar
@AisuluOmar
Jun 21 2017 00:59
@forwebtech I tried b=a, but it doesn't work
Na-Ya
@Na-Ya
Jun 21 2017 00:59
@forwebtech I get the error no matter what i change the value of fahrenheit to, even just a plain number
Aizaz Shahid
@aizazshahid
Jun 21 2017 00:59
@AisuluOmar var b=a
Na-Ya
@Na-Ya
Jun 21 2017 00:59
@forwebtech but celsius works
Will Hart
@willhart108
Jun 21 2017 01:00
Screen Shot 2017-06-20 at 5.59.49 PM.png
@Manish-Giri
even worse.. unless my code was off lol
Manish Giri
@Manish-Giri
Jun 21 2017 01:00
@willhart108 remove the backslash.
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:01

@Na-Ya

celsius = Math.round(data.currently.temperature)+'°C';
      fahrenheit = (Math.round(celsius * (9/5) +32))+'°F';

try to console your celsius and check the value, surely it will be string. just store the number in celsius and fahrenheit and at the time of printing just add the string part to it.

David Temple
@dtemple55
Jun 21 2017 01:01
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "myNoun" +" myAdjective" + "myVerb"+"myAdverb" + Result;
  // Your code below this line
var Result ="mycat"+"myDog";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("myNoun", "myAdjective", "myVerb", "myAdverb", Result);
i have no clue about the code
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:02
@dtemple55 didn't you read the comments:
  // Your code below this line

  // Your code above this line
Will Hart
@willhart108
Jun 21 2017 01:02
@Manish-Giri var myStr = "This is the start. " + "This is the end\"." ;
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:02
This message was deleted
Manish Giri
@Manish-Giri
Jun 21 2017 01:02
@willhart108 at the end also
David Temple
@dtemple55
Jun 21 2017 01:02
explain??
CamperBot
@camperbot
Jun 21 2017 01:02

freeCodeCamp Wiki:

:point_right: The freeCodeCamp wiki can be found on our forum.
Please follow the link and search there.
Manish Giri
@Manish-Giri
Jun 21 2017 01:02
why're you putting backslashes?
@willhart108
"first " + "second."
no \
Na-Ya
@Na-Ya
Jun 21 2017 01:03
@forwebtech thank you , you were right. total oversight on my part!
CamperBot
@camperbot
Jun 21 2017 01:03
na-ya sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 724 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:03
@dtemple55
 var result;
  // Your code below this line
// assign  the parameters here. don't change the above or below lines.
  // Your code above this line
  return result;
Will Hart
@willhart108
Jun 21 2017 01:03
@Manish-Giri escaping
Manish Giri
@Manish-Giri
Jun 21 2017 01:03
why?
there's no " outside, so no need to escape.
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:04
@willhart108 whenever we use same quotes inside quotes then we need to escape them, like " my \"value\" "
Nick Danvers
@Ravenor222
Jun 21 2017 01:04

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

if (val >=10 || val <=20) {
return "Outside";
}

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

// Change this value to test
testLogicalOr(10);

Will Hart
@willhart108
Jun 21 2017 01:04
var myStr = "This is the start. " + "This is the end." ;
back to the start
Nick Danvers
@Ravenor222
Jun 21 2017 01:04
Should testLogicalOr(10) not return inside?
Manish Giri
@Manish-Giri
Jun 21 2017 01:05
that looks right
Will Hart
@willhart108
Jun 21 2017 01:05
but that doesn't work
David Temple
@dtemple55
Jun 21 2017 01:05
didn't work @forwebtech
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:05

@willhart108

var myStr = "This is the start. ".
myStr +=  "This is the end." ;

as i said previously.

Nick Danvers
@Ravenor222
Jun 21 2017 01:05
@willhart108 are you using chrome
@willhart108 I just had a question where I needed to clear my cache before it let me advance
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:05
@dtemple55 paste the code again ?
Nick Danvers
@Ravenor222
Jun 21 2017 01:05
@forwebtech Should he not be able to do that in one line?
Will Hart
@willhart108
Jun 21 2017 01:06
ill try
i sue safari
Manish Giri
@Manish-Giri
Jun 21 2017 01:06
@forwebtech you don't need to use +=
also it doesn't mention anything about it in instructions.
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:06
@Ravenor222 if FCC wants like that then it will work in that way.
Manish Giri
@Manish-Giri
Jun 21 2017 01:06
@willhart108 how did it work for me?
Screenshot 2017-06-20 21.06.06.png
same code as yours
Nick Danvers
@Ravenor222
Jun 21 2017 01:06
Okay I seem to remember doing it in one line
@Manish-Giri How do you make it black?
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:07
@Manish-Giri because he removes the first line i think, that's why ask him te reset the page.
David Temple
@dtemple55
Jun 21 2017 01:07
@forwebtech can you just send me a prototype
hell as confused
Paulg05
@Paulg05
Jun 21 2017 01:07
Hey guys, needd help with this one. "Write a function divide that accepts two numbers and returns the first number divided by the second number" it should print out five, and my console.log is console.log(divide(10, 2));
Manish Giri
@Manish-Giri
Jun 21 2017 01:07
@Ravenor222 you can change the theme in settings
I think it's called "night mode"
Nick Danvers
@Ravenor222
Jun 21 2017 01:07
thanks looks good
Will Hart
@willhart108
Jun 21 2017 01:08
guess because i erased the example it didn't work but now it did.. weird
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:08
@dtemple55
variable = "value1 " + para1 + " " + para2 + ...;
Will Hart
@willhart108
Jun 21 2017 01:08
@Manish-Giri thank you
CamperBot
@camperbot
Jun 21 2017 01:08
willhart108 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6053 | @manish-giri |http://www.freecodecamp.com/manish-giri
Will Hart
@willhart108
Jun 21 2017 01:08
@Ravenor222 thank you
CamperBot
@camperbot
Jun 21 2017 01:08
willhart108 sends brownie points to @ravenor222 :sparkles: :thumbsup: :sparkles:
:cookie: 184 | @ravenor222 |http://www.freecodecamp.com/ravenor222
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:08
doesn't matter how you will use them just separate them with spaces, @dtemple55
Manish Giri
@Manish-Giri
Jun 21 2017 01:08
@willhart108 you don't need to erase stuff unless they ask you to..
Nick Danvers
@Ravenor222
Jun 21 2017 01:08
@willhart108 Did that work?
fdemaa
@fdemaa
Jun 21 2017 01:08
@kevinwr a hint for that algorithm, you have to use a var and set it to 1 , and use it inside your for loop
David Temple
@dtemple55
Jun 21 2017 01:10
okay thanks @forwebtech
CamperBot
@camperbot
Jun 21 2017 01:10
dtemple55 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 725 | @forwebtech |http://www.freecodecamp.com/forwebtech
Kevin
@kevinwr
Jun 21 2017 01:10
@fdemaa why?
Nick Danvers
@Ravenor222
Jun 21 2017 01:11

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

if (val>=10 || val<=20) {
return "Outside";
}

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

// Change this value to test
testLogicalOr(15);

testLogicalor(10) should return inside, however it returns outside, am I missing something? Im not too sure about how || is used
Kevin
@kevinwr
Jun 21 2017 01:12

@fdemaa got this to work in the end:

function factorialize(num) {
  var array = [ ];

  //create an array of numbers less than or equal to the variable num
  for (i = 1; i <= num; i++) {
    array[i-1] = i;
  }

  return array.reduce(function(x,y){
    return x + y;
  })

}

factorialize(5);

THe code before was just me messing around to see what happened with the code when I did certain things.

Aizaz Shahid
@aizazshahid
Jun 21 2017 01:12
@Ravenor222 why don't you just switch position of those return statements.
Nick Danvers
@Ravenor222
Jun 21 2017 01:12
Cause it says only change above the line!
abraham anak agung
@padunk
Jun 21 2017 01:12
Hey guys, about Pomodoro clocks is it run session first then break then session...etc?
Manish Giri
@Manish-Giri
Jun 21 2017 01:12
I think i got it
@kevinwr what was your question with this?
function factorialize(num) {


  //create an array of numbers less than or equal to the variable num
  for (var i = 1; i <= num; i++) {
    var array = [ ];
    array[i-1] = i;
  }

  console.log(array);

}
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:13
@Ravenor222 i actually asked him why he can't ?
Nick Danvers
@Ravenor222
Jun 21 2017 01:13
@forwebtech Now that i've switched it actually none of the requirements are checked off except "only 1 if statement"
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:13
users don't read the comments at first.
he needs to change his condition.
Nick Danvers
@Ravenor222
Jun 21 2017 01:13
Sorry who are you talking about?
Kevin
@kevinwr
Jun 21 2017 01:14

@Manish-Giri

The result from that was an array [undefined, undefined, undefined, undefined, 5]. I was curious why there was a 5 at the end; I expected another undefined.

Aizaz Shahid
@aizazshahid
Jun 21 2017 01:14
you need to change your condition.
Manish Giri
@Manish-Giri
Jun 21 2017 01:14
because in the last iteration of the array
Nick Danvers
@Ravenor222
Jun 21 2017 01:14
@forwebtech You said I don't read the comments?
Manish Giri
@Manish-Giri
Jun 21 2017 01:14
you are putting 5 at index 4
@kevinwr
so it holds 5
and since array is reset each time
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:14
@Ravenor222 oh sorry ! my bad.
Nick Danvers
@Ravenor222
Jun 21 2017 01:15
@forwebtech yea i think theres a misunderstanding
Manish Giri
@Manish-Giri
Jun 21 2017 01:15
the previous 4 spots are undefined.
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:15
yes !
Manish Giri
@Manish-Giri
Jun 21 2017 01:15
@kevinwr
Nick Danvers
@Ravenor222
Jun 21 2017 01:15
@forwebtech np I was confused
Kevin
@kevinwr
Jun 21 2017 01:15
@Manish-Giri AAHHHHHH I see now. Duh.. Got it. Thanks, Manish
CamperBot
@camperbot
Jun 21 2017 01:15
kevinwr sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6055 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 21 2017 01:15
:+1:
Nick Danvers
@Ravenor222
Jun 21 2017 01:15
@forwebtech When you said change the return statements position, where you talking to me?
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:16
@Ravenor222 well i actually got confused. at first but then i checked you asked for help : )
Nick Danvers
@Ravenor222
Jun 21 2017 01:16
@forwebtech yes I still need help with the question hehe, in case you know the answer
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:16
@Ravenor222 you need to change the condition just use
David Temple
@dtemple55
Jun 21 2017 01:17
@forwebtech what of wordBlanks("a", variable, "b")
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:17
@dtemple55 don't change the arguments you just need to change the code where comments are mentioned.
Nick Danvers
@Ravenor222
Jun 21 2017 01:17
@forwebtech Just use what?
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:18
@Ravenor222
if ( val is less than 10 ||  val is greater than 20 ) 
  return "Outside";
nimaipandit
@nimaipandit
Jun 21 2017 01:18

@dardandemiri

```js

the "Stand in Line" javascript challenge
function queue(arr, item) {
// Your code here
arr.push(item);
item = arr.shift();
return item; // Change this line
}
``` can you explain a little further? This exercise doesn't give any clue that we should use pop or shift. Also, you changed nextInLine to "queue and I don't know why

Nick Danvers
@Ravenor222
Jun 21 2017 01:18
So youre saying to replace <= withe written statements/
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:18
@Ravenor222 yes ! precisely.
Nick Danvers
@Ravenor222
Jun 21 2017 01:18
@forwebtech hmm, they have me learning to use <=, so ill give that a try
@forwebtech thanks
CamperBot
@camperbot
Jun 21 2017 01:19
ravenor222 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 726 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:19
@Ravenor222 :+1:
David Temple
@dtemple55
Jun 21 2017 01:20
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
var Result="myNoun"+ "myAdjective" + varn;
 var varn ="myVerb" + "myAdverb";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
am starting to give up I can get it
just dont understand the instructions at all
Nick Danvers
@Ravenor222
Jun 21 2017 01:21
@forwebtech using written notation gives the the message " unknown syntax" however you writing "less than" made me try using < > as opposed to <= >= and it worked
@forwebtech so thanks for your insights but I guess I can't use written notation for this part yet =P
CamperBot
@camperbot
Jun 21 2017 01:22
ravenor222 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: ravenor222 already gave forwebtech points
nimaipandit
@nimaipandit
Jun 21 2017 01:23
@camperbot do you do anything else besides notify us about brownie points?
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:23
@Ravenor222 val < 10 || val > 20, atleast now you know the syntax :)
Nick Danvers
@Ravenor222
Jun 21 2017 01:25
@forwebtech hehe yes at this point I've got it
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:26
@dtemple55 if you put parameters in strings then they just becomes parameter, i think you need to learn how to concatenate strings with variables.
David Temple
@dtemple55
Jun 21 2017 01:27
I just dont understand the question thats all
nimaipandit
@nimaipandit
Jun 21 2017 01:28
@dtemple55 this one is a little tricky because the plus signs need to be in the right place
Nick Danvers
@Ravenor222
Jun 21 2017 01:28
@dtemple55 That exercise has the worst wording I have seen
@dtemple55 I didn't know what it was asking me either
David Temple
@dtemple55
Jun 21 2017 01:28
dont have problems with strings just dont get what am supposed to do
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:28
@dtemple55 but you don't know how to concat string with variables
so do that exercise one time and then again try that challenge.
nimaipandit
@nimaipandit
Jun 21 2017 01:28
@dtemple55 you put a word in parentheses and a plus sign between each word
David Temple
@dtemple55
Jun 21 2017 01:29
I have done that exercise before
I know
Nick Danvers
@Ravenor222
Jun 21 2017 01:29
Read your code again I see what he is talking about
David Temple
@dtemple55
Jun 21 2017 01:31
seen it but still doesn't make a diffrence
the problem is with the wordBlank() variable
Nick Danvers
@Ravenor222
Jun 21 2017 01:32
you mean function?
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:32
@dtemple55 first that's not a variable its function and
var Result="myNoun"+ "myAdjective" + varn;
what are you doing that ?
David Temple
@dtemple55
Jun 21 2017 01:32
oooops fuction i mean
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:33
and why did you create varn ?
David Temple
@dtemple55
Jun 21 2017 01:33
no that was a mistake
I have removed that
Nick Danvers
@Ravenor222
Jun 21 2017 01:33
we only have the1 code you linked
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:33
so please paste the code ?
David Temple
@dtemple55
Jun 21 2017 01:34
You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.
didnt get the meaning of thAT part
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:35
provided words are passed as arguments, which will access through parameter names.
David Temple
@dtemple55
Jun 21 2017 01:36
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  // Your code below this line
var result="myNoun"+ "myAdjective" + "myVerb" + "myAdverb";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("myNoun", "myAdjective", "myVerb", "myAdverb");
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:37
@dtemple55 why did you change the arguments values, but that's ok, the problem is just as we told you, you are using parameters name inside string, and that will create an issue.
did you try that challenge which i told ?
David Temple
@dtemple55
Jun 21 2017 01:42
yes I did
I had to reset my code and do it again no problems
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:43
@dtemple55 ok do you know what are parameters ?
David Temple
@dtemple55
Jun 21 2017 01:43
NO
// Example
var ourName = "Free Code Camp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";

// Only change code below this line
var myName= "David Temple";
var myStr= "My name is" + myName +" and I am swell";
AJ
@ClaudeDebussy
Jun 21 2017 01:43

Hello everyone. I am working on the factorial algorithm challenge. As far as I can tell, my code works (but it gets to the answer in a kind of roundabout way: creates an array of the factorial numbers and then iterates through, multiplying to itself). FCC doesnt accept the answer. Here is the repl.it:

https://repl.it/HrQ1/22

Ginger
@GingerChew
Jun 21 2017 01:44
can I get some help with my function? It's for the profile look up challenge
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:44
function foo( para1, para2) {
//  para1   and para2 are parameters
// they are variables which will store the values from 
// arguments when we pass them on its call
}
foo("value1", "value2");
David Temple
@dtemple55
Jun 21 2017 01:44
i do not know what are parameters @forwebtech
ooooooh crap
i get it now
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:45
@dtemple55 value1 and value2 are argument values, which we passed them, so they will store in para1 and para2, so, we can access them within inside the function.
abraham anak agung
@padunk
Jun 21 2017 01:46
@ClaudeDebussy which test that you didn't passed?
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:46
@dtemple55 :+1:
AJ
@ClaudeDebussy
Jun 21 2017 01:46
factorialize(5) should return 120.
factorialize(10) should return 3628800.
factorialize(20) should return 2432902008176640000.
factorialize(0) should return 1.
Ravi Kishore Thella
@ravikishorethella
Jun 21 2017 01:47
@ClaudeDebussy show what you did
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:47
@ClaudeDebussy try for the bigger one.
abraham anak agung
@padunk
Jun 21 2017 01:48
your code is ok @ClaudeDebussy try refresh the browser?
AJ
@ClaudeDebussy
Jun 21 2017 01:48
never mind... it went this time
weird
thanks everyone!
Ginger
@GingerChew
Jun 21 2017 01:48
can I get some help with the scoping on my java script function?
AJ
@ClaudeDebussy
Jun 21 2017 01:48
maybe I copied and pasted wrong... but i did it twice :\
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:48
@ClaudeDebussy :+1:
abraham anak agung
@padunk
Jun 21 2017 01:48
@GingerChew show your code here
Ginger
@GingerChew
Jun 21 2017 01:49
function lookUpProfile(firstName, prop){ // Only change code below this line var property; for (var i = 0; i < contacts.length; i++) { if (firstName == contacts[i].firstName) { for (property in contacts[i]) { if (property == prop) { return contacts[i][property]; } } } } }
function lookUpProfile(firstName, prop){
// Only change code below this line
  var property;
  for (var i = 0; i < contacts.length; i++) {
    if (firstName == contacts[i].firstName) {
      for (property in contacts[i]) {
        if (property == prop) {
          return contacts[i][property];
        }
      }
    }
  }
}
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:49
@ClaudeDebussy that challenge could be done in that way:
function factorialize(n) {
  return (n === 1 || n === 0)  ? 1 : factorialize(n-1) * n; 
}
AJ
@ClaudeDebussy
Jun 21 2017 01:50
@forwebtech Good point :P
Nick Danvers
@Ravenor222
Jun 21 2017 01:50
How do people keep golf score?
what does (5, 4) score mean?
Ginger
@GingerChew
Jun 21 2017 01:50
That's what I've got so far, but I can't figure out how to get it to check if the property is present in the object?
Aizaz Shahid
@aizazshahid
Jun 21 2017 01:50
@ClaudeDebussy but stick with your own solution until you will not understand.
abraham anak agung
@padunk
Jun 21 2017 01:50
@GingerChew use hasOwnProperty method. I think it is already write in the instructions
AJ
@ClaudeDebussy
Jun 21 2017 01:51
@forwebtech Yeah, I'm sure I'll start to 'see' how to do things more simply as time goes on
Ginger
@GingerChew
Jun 21 2017 01:51
okay cool thanks @padunk
CamperBot
@camperbot
Jun 21 2017 01:51
gingerchew sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @padunk |http://www.freecodecamp.com/padunk
Claudio R M
@cl4udiorm
Jun 21 2017 01:53
does anybody help me ?
"FirstLine newline backslash SecondLine backslash carriage-return ThirdLine"
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
myStr = "FirstLine \n \SecondLine\ \rThirdLine"
Aline
@alinaum
Jun 21 2017 01:54

function palindrome(str) {
// Good luck!
var newStr = [];
var revSrt;
var cleanStr= [];

cleanStr = str.replace(/\W/g, '');
cleanStr.toLowerCase();

for(i=0; i<cleanStr.length; i++){
newStr[i] = cleanStr[i];
}

revSrt = newStr.reverse();

if(newStr == revSrt){
return true;
}

else {
return false;
}

}

abraham anak agung
@padunk
Jun 21 2017 01:54
@cl4udiorm backlash is \\
Aline
@alinaum
Jun 21 2017 01:55
it's not returning false, and I have no idea what the problem is
Claudio R M
@cl4udiorm
Jun 21 2017 01:55

var myStr;

myStr = "FirstLine \n \SecondLine\ \rThirdLine"

it doesn't work !
abraham anak agung
@padunk
Jun 21 2017 01:55
@cl4udiorm \\Second it will show backlash. read the instruction
Claudio R M
@cl4udiorm
Jun 21 2017 01:57

@padunk
TypeError: "FirstLine \n \SecondLine\ \rThirdLine"

is not a function. (In '"FirstLine \n \SecondLine\ \rThirdLine"

(function(){
if (myStr !== undefined){
return 'myStr = '+ JSON.stringify(myStr);}
else{return null;}})', '"FirstLine \n \SecondLine\ \rThirdLine"

' is "FirstLine
\SecondLine\
ThirdLine")

abraham anak agung
@padunk
Jun 21 2017 01:58
why you do it like that? what the challenge url
Claudio R M
@cl4udiorm
Jun 21 2017 01:58
143
@padunk it's 143
Will Gotsch
@NonchalantPotato
Jun 21 2017 01:59
Can someone help me out with queues?
abraham anak agung
@padunk
Jun 21 2017 02:00
i don't remember the number, what is the challenge name? i don't think u should write it like that
Will Gotsch
@NonchalantPotato
Jun 21 2017 02:00
I believe it's 172
It's called Stand in Line
abraham anak agung
@padunk
Jun 21 2017 02:02
@NonchalantPotato you need to use method describe earlier. push, shift, unsfhit or pop. pick which is right
Will Gotsch
@NonchalantPotato
Jun 21 2017 02:02
gotcha
and it says in the directions "Add the number to the end of the array" but it never says what to add
it lists up to 5, should I just add 6?
abraham anak agung
@padunk
Jun 21 2017 02:03
@cl4udiorm why u write a function? just write it as it is. It told you to change this line. Not to make a function
Claudio R M
@cl4udiorm
Jun 21 2017 02:04
man i didn't a function. that code was the report error
abraham anak agung
@padunk
Jun 21 2017 02:05
Ok, than you should write backlash like this \\ as the instructions said
Claudio R M
@cl4udiorm
Jun 21 2017 02:05

@padunk I wrote this...

var myStr;

myStr = "FirstLine \n SecondLine\ \rThirdLine"

var myStr;

myStr = "FirstLine \n \SecondLine\ \rThirdLine"

David Temple
@dtemple55
Jun 21 2017 02:05
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
var Result = myNoun + myAdjective + myVerb + myAdverb ;

  // Your code above this line
  return Result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
abraham anak agung
@padunk
Jun 21 2017 02:05
\\SecondLine\\ it is the correct one. To write backslash you need to write it like this \\
David Temple
@dtemple55
Jun 21 2017 02:06
I think am giving up on coding
Pleasus
@Pleasus
Jun 21 2017 02:06
@dtemple55 you need " " spaces, too
abraham anak agung
@padunk
Jun 21 2017 02:06
@dtemple55 don't. you need a sentence for that
David Temple
@dtemple55
Jun 21 2017 02:07
which spaces??
abraham anak agung
@padunk
Jun 21 2017 02:07
spaces between words
Pleasus
@Pleasus
Jun 21 2017 02:07
myNoun + " " + myAdjective...etc.
David Temple
@dtemple55
Jun 21 2017 02:07
i have been battling with this challenge for 5hours @padunk
tried that @Pleasus
abraham anak agung
@padunk
Jun 21 2017 02:08
@dtemple55 all you need is your own text + myNoun + your own text + myVerb ....etc something like that. and spaces between words.
Pleasus
@Pleasus
Jun 21 2017 02:12
like: "The " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdjective + ".";
David Temple
@dtemple55
Jun 21 2017 02:13
i have tried that
Pleasus
@Pleasus
Jun 21 2017 02:13
sorry, that last one was supposed to be myAdverb
David Temple
@dtemple55
Jun 21 2017 02:13
didnt work
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
var Result = "The" + "" + myNoun +"" + myAdjective + ""+ myVerb + "" + myAdverb + "."  ;

  // Your code above this line
  return Result;
}

// Change the words here to test your function
wordBlanks(" dog", " big", " ran", " quickly");
Pleasus
@Pleasus
Jun 21 2017 02:14
you may want to use lower case for result
abraham anak agung
@padunk
Jun 21 2017 02:14
"" and " " is different. and you don't need to make new variable
David Temple
@dtemple55
Jun 21 2017 02:16
okay who has completed the challenge
if anybody can remember then please send me the code
Pleasus
@Pleasus
Jun 21 2017 02:18

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

// Your code above this line
return result;
}

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

David Temple
@dtemple55
Jun 21 2017 02:21
its the same but mine aint working
Pleasus
@Pleasus
Jun 21 2017 02:22
note the spaces in between the quotation marks and the lower case 'result'. anything else and I have no idea
David Temple
@dtemple55
Jun 21 2017 02:22
i did not those spaces
is it a bug?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
result = "The" + myAdjective + "" + myNoun + "" + myVerb + "" + myAdverb + "."  ;

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks(" dog", " big", " ran", " quickly");
Manish Giri
@Manish-Giri
Jun 21 2017 02:26
@dtemple55 "" is an empty string
add a space - " "
David Temple
@dtemple55
Jun 21 2017 02:27
YESSSSssss!!!!!!
it worked finally
after almost 6 hours
i think the wording of that challenge is really poor
slertka
@slertka
Jun 21 2017 02:44
Hey guys, having trouble with the "Seek and Destroy" algorithm challenge

function destroyer(arr) {
  // Remove all the values

  for (var i=0; i<arr.length; i++) {
    for (var j=1; j<arguments.length; j++) {
      if (arr[i] == arguments[j]) {
        arr.splice(i,1);
      }
    }
  }
  //return arr;
  return arr;
}

destroyer([2, 3, 2, 3], 2, 3);
my code returns [2], but should return []
same when I use the input ([3, 5, 1, 2, 2], 2, 3, 5)
it should return [1] but returns [1, 2]
abraham anak agung
@padunk
Jun 21 2017 02:47
@slertka splice will change your array length, maybe it skiped
slertka
@slertka
Jun 21 2017 02:48
that's what I'm thinking too...
I tried setting the arr.length equal to a variable outside the for loop but that didn't fix the problem
and that wouldn't make sense for the input [2, 3, 2, 3] if .splice was causing the problem
abraham anak agung
@padunk
Jun 21 2017 02:51
why don't use delete @slertka
slertka
@slertka
Jun 21 2017 02:51
hmm ok will need to look into that!
Manish Giri
@Manish-Giri
Jun 21 2017 02:52
@slertka you can do it another way
also, I think you should create an actual array out of arguments, to begin with..
slertka
@slertka
Jun 21 2017 02:56
yeah working on that now
Chuck Wongus
@YesImChuck
Jun 21 2017 02:59
Hello all! I'm having an issue with the Factorialize a Number algorithm. I'm not understanding what I am doing wrong.
function factorialize(num) {
  arr = [];
  var i = 1;
  while(i < num + 1){
    arr.push(i);
    i++;
  }
  addedArr = arr.reduce(function(a,b){
    return a * b;
  });

  return addedArr;
}

factorialize(10);
I'm not able to get factorialize(0) to return 1
CreateTheHype
@CreateTheHype
Jun 21 2017 03:01
anyone know whats wrong with my code? on using objects for lookups
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:01
@YesImChuck i = 1, so your while loop would never run if you pass 0. You would have empty array
CreateTheHype
@CreateTheHype
Jun 21 2017 03:01
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var val = {
    alpha:"Adams",

    bravo:"Boston",

    charlie:"Chicago",

    delta:"Denver",

    echo:"Easy",

    foxtrot:"Frank",

  };

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

// Change this value to test
phoneticLookup("alpha");
Manish Giri
@Manish-Giri
Jun 21 2017 03:01
@slertka this is what I did -
  1. made an array out of the arguments other than arr
  2. Iterated over arr and returned those elements not present in the array from step 1.
pjalexander
@pjalexander
Jun 21 2017 03:01
why are you using a while loop AND reduce? reduce will REDUCE the array to one value(the factorialized number in the case).
Greg Duncan
@GregatGit
Jun 21 2017 03:02
@YesImChuck a simple if conditon to return 1 if num is 0 at the start of the function
Manish Giri
@Manish-Giri
Jun 21 2017 03:02
@CreateTheHype if you name your object as val -
var val = {
    alpha:"Adams",

    bravo:"Boston",

    charlie:"Chicago",

    delta:"Denver",

    echo:"Easy",

    foxtrot:"Frank",

  };
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:02
@YesImChuck you need to handle whennum` is 0
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:02
@Manish-Giri I think that you have an extra ,
Manish Giri
@Manish-Giri
Jun 21 2017 03:02
@CreateTheHype won't you overwrite the parameter val here - function phoneticLookup(val)
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:02
@Manish-Giri I saw it, thanks...Good Morning
CamperBot
@camperbot
Jun 21 2017 03:02
lumexralph sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6057 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 21 2017 03:02
@Lumexralph :sunny:
pjalexander
@pjalexander
Jun 21 2017 03:03
my bad chuck. I forgot , its not an array of numbers they give you to begin.
Chuck Wongus
@YesImChuck
Jun 21 2017 03:03
Thanks @GregatGit and @Lumexralph ... didn't think it was that easy. haha
CamperBot
@camperbot
Jun 21 2017 03:03
yesimchuck sends brownie points to @gregatgit and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 868 | @gregatgit |http://www.freecodecamp.com/gregatgit
:star2: 1971 | @lumexralph |http://www.freecodecamp.com/lumexralph
Chuck Wongus
@YesImChuck
Jun 21 2017 03:04
All good @pjalexander , lol.
slertka
@slertka
Jun 21 2017 03:04
thanks @Manish-Giri i got it!
CamperBot
@camperbot
Jun 21 2017 03:04
slertka sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6058 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:04
@Manish-Giri i'm not an Insomniac after all cos I just woke :smirk:
@Manish-Giri taking your project from the perfect local work to an online platform can be such a drag. pain
abraham anak agung
@padunk
Jun 21 2017 03:07
Hi guys, i need to review my calculator, is it working ok?
https://codepen.io/padunk/full/dWKzEz/
Ralph Nahra
@Rallph
Jun 21 2017 03:09
Hi, I'm doing the smallest common multiples challenge, and it seems that the link provided for explanation explains it differently than the challenge description. On the link it says the largest common multiple of 1 and 5 is 5. On FCC it says the largest common multiple is 10
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:09
@padunk If I have too many numbers, I won't be able to see the whole numbers
abraham anak agung
@padunk
Jun 21 2017 03:10
@ShenyuSun how many? it can't display more than 14 digit. but it still calculating it in history
oh wait, you mean out of screen?
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:12
@padunk it happens when I choose Chinese
@padunk yes, and also, If I just click a number, and then hit = twice, it went into weird state.
Adam Bohannon
@abohannon
Jun 21 2017 03:12
Can anyone help me understand why my reduce method is returning undefined?

function uniteUnique(arr) {

  arr.reduce(function(prev,curr){
    return prev + curr
  })

  // return arr;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
abraham anak agung
@padunk
Jun 21 2017 03:13
ok, cool. Thanks @ShenyuSun
CamperBot
@camperbot
Jun 21 2017 03:13
padunk sends brownie points to @shenyusun :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @shenyusun |http://www.freecodecamp.com/shenyusun
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:13
@padunk If I hit '5', and click =, and then click = again. it gave me 55, and then if I keep clicking =, it gave me 0
Diego Mayer
@Chrono79
Jun 21 2017 03:13
@abohannon your function needs to return, try return arr.reduce...
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:14
@abohannon function returns undefined by default, you need to return the reduced array......
Avery Biskup
@fraknard
Jun 21 2017 03:14
Adam Bohannon
@abohannon
Jun 21 2017 03:15
@Lumexralph this still returns undefined
function uniteUnique(arr) {


 var x = arr.reduce(function(prev,curr){
   prev + curr
  })

  return x;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
HappyRedditor59
@HappyRedditor59
Jun 21 2017 03:15

can someone pls help? i'm on Truncate a string challenge. instead of returning "A-" it return "..."

this is my code:

function truncateString(str, num) {
  // Clear out that junk in your trunk

  if (str.length > num){
    str = str.slice(0, num-3);
    str = str + "...";

  }
  else if (num <= 3){
    str = str.slice(0, num);
    str = str + "...";
  }
  return str;
}

truncateString("A-", 1);
Adam Bohannon
@abohannon
Jun 21 2017 03:16
@Chrono79 this also returns undefined
function uniteUnique(arr) {


 return arr.reduce(function(prev,curr){
   prev + curr;
  });

}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:16
@abohannon you're not returning the accumulator in the reduce callback, try return prev + curr
Diego Mayer
@Chrono79
Jun 21 2017 03:17
@abohannon
function uniteUnique(arr) {

  return arr.reduce(function(prev,curr){
    return prev + curr
  })

  // return arr;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
not that it solves the challenge, but at least it's properly written
Adam Bohannon
@abohannon
Jun 21 2017 03:18
@Chrono79 @Lumexralph ok cool thank you for the help
CamperBot
@camperbot
Jun 21 2017 03:18
abohannon sends brownie points to @chrono79 and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1972 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 4349 | @chrono79 |http://www.freecodecamp.com/chrono79
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:21
@fraknard You should provide a message to tell the users when there's no search results.
Ginger
@GingerChew
Jun 21 2017 03:26
I'm having trouble with this algorithm, for checking if a string is a palindrome
```
 function palindrome(str) {
    // Good luck!
    var string = str.toLowerCase();
    string = string.split('');
    var reverseString = string.reverse();
    reverseString = reverseString.join('');
    if (string.equals(reverseString)===true) {
      return true;
    } else {
      return false;
    }
  }
when I run it in repl.it it also says that .equals isn't a function, but I can find the docs for it
Avery Biskup
@fraknard
Jun 21 2017 03:28
@ShenyuSun Okay.
@HappyRedditor59 check the first if statement, it might be using that one..
@HappyRedditor59 Maybe the program doesn't make it to the second if statement because it follows the first if statements logic.
Artair-faolan
@Artair-faolan
Jun 21 2017 03:30
Hello everyone, I am stuck on the assignment where I convert celsius to fahrenheit, I do not know where to begin...
Diego Mayer
@Chrono79
Jun 21 2017 03:31
@GingerChew you need to remove all that's not a letter or a number of your string
And where did you get .equals() ?
HappyRedditor59
@HappyRedditor59
Jun 21 2017 03:31
@fraknard thanks, i just fixed the logic and it worked.
CamperBot
@camperbot
Jun 21 2017 03:31
happyredditor59 sends brownie points to @fraknard :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @fraknard |http://www.freecodecamp.com/fraknard
Manish Giri
@Manish-Giri
Jun 21 2017 03:31
@Artair-faolan there's a formula on the left..
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:31
@Artair-faolan start with the formula
Manish Giri
@Manish-Giri
Jun 21 2017 03:31
you just need to plug in the celsius variable..
Artair-faolan
@Artair-faolan
Jun 21 2017 03:32
I do not know how to do that.
Manish Giri
@Manish-Giri
Jun 21 2017 03:32
@Lumexralph teach me d3
Ginger
@GingerChew
Jun 21 2017 03:32
@Chrono79 i tried doing that with the .replace() function but I can't seem to get it to work right? I got .equals() from googling online
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:32
@Manish-Giri :smirk:
Diego Mayer
@Chrono79
Jun 21 2017 03:32
@GingerChew you need a proper regex to do that
use == or ===
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:33
@Manish-Giri you have a good website I can upload sound to use in my project?
Ginger
@GingerChew
Jun 21 2017 03:33
@Chrono79 how do I set up a proper regex? are there some docs I could look up to find out?
Artair-faolan
@Artair-faolan
Jun 21 2017 03:35
I can not figure out how to do this at all...
Manish Giri
@Manish-Giri
Jun 21 2017 03:35
@Lumexralph like a site with free sounds?
or a hosting site?
Ginger
@GingerChew
Jun 21 2017 03:35
@Chrono79 thanks m8
CamperBot
@camperbot
Jun 21 2017 03:35
gingerchew sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4350 | @chrono79 |http://www.freecodecamp.com/chrono79
Avery Biskup
@fraknard
Jun 21 2017 03:38
@HappyRedditor59 Nice.
@HappyRedditor59 function truncateString(str, num) { return (str.length > num && num > 3) ? str.slice(0, num - 3) + "..." : ((num <= 3) ? str.slice(0, num) + "..." : str); } truncateString("Absolutely Longer", 2);
function truncateString(str, num) { return (str.length > num && num > 3) ? str.slice(0, num - 3) + "..." : ((num <= 3) ? str.slice(0, num) + "..." : str); }
truncateString("Absolutely Longer", 2);
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:38
@Manish-Giri i used a click sound for my calculator locally, now using it online is a big work, HTML5 audio seems to be returning a promise. I get the url but getting the src sound to be downloaded and used in my JS file is killing
Ginger
@GingerChew
Jun 21 2017 03:39
@Chrono79 I think I have my regex set up now, but my expression is always returning false?
Artair-faolan
@Artair-faolan
Jun 21 2017 03:39
Hello, how do I complete that exercise?
Ginger
@GingerChew
Jun 21 2017 03:40
 function palindrome(str) {
    // Good luck!
    var string = str.toLowerCase();
    string = string.replace(/\W/|string, string|'');
    string = string.split('');
    var reverseString = string.reverse();
    reverseString = reverseString.join('');
    if (string === reverseString) {
      return true;
    } else {
      return false;
    }
  }
Diego Mayer
@Chrono79
Jun 21 2017 03:40
@GingerChew that's not ok
the regular expresion should be between the // and I would use g modifier, the second argument of replace should be only ''
Ginger
@GingerChew
Jun 21 2017 03:41
@Chrono79 so I don't need to specify the string?
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:43
Hey all, getting stuck on this stuff right here, seems as if it should work, but it isn't. Any suggestions?
Diego Mayer
@Chrono79
Jun 21 2017 03:44
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:44
Oh also, how do i show what lesson im working on?
Diego Mayer
@Chrono79
Jun 21 2017 03:45
click more info below, copy and paste your code formatting it
CamperBot
@camperbot
Jun 21 2017 03:45
:bulb: to format code use backticks! ``` more info
pursuitgit
@pursuitgit
Jun 21 2017 03:45
Hi friends, could anyone offer some guidance on the Chunky Monkey challenge? I'm struggling tto think of how to even go about achieving this. Some directional help would be great! https://www.freecodecamp.com/challenges/chunky-monkey

function chunkArrayInGroups(arr, size) {
  // Break it up.
  arr = arr.slice(0, size);

  return arr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Ginger
@GingerChew
Jun 21 2017 03:46
@Chrono79 I'm confused, that repl.it has it how I have it in my code? what are you trying to show me?
Diego Mayer
@Chrono79
Jun 21 2017 03:46
@pursuitgit don't overwrite arr like that, and you'll probably want to use some loop
rlgerman25
@rlgerman25
Jun 21 2017 03:46
Can anyone help me with my weather app?
Diego Mayer
@Chrono79
Jun 21 2017 03:46
@GingerChew that it doesn't replace how you thought
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:46
@Chrono79 Quick question.... how come phase "1 eye for of 1 eye " is not palindrome? there's eye
pursuitgit
@pursuitgit
Jun 21 2017 03:46
@Chrono79 ok, I'll have a go with a for loop and make sure to not overwrite the array! thankyou
CamperBot
@camperbot
Jun 21 2017 03:46
pursuitgit sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4351 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 21 2017 03:47
@ShenyuSun the numbers make that a non palindrome
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:47

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

// Test Setup
var testArr = [4];

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

CamperBot
@camperbot
Jun 21 2017 03:47
:bulb: to format code use backticks! ``` more info
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:47
darn
Ginger
@GingerChew
Jun 21 2017 03:47
@Chrono79 so I should use something like [^a-z0-9]? since that would only look for lowercase alphabets and numericals and replace all else?
Diego Mayer
@Chrono79
Jun 21 2017 03:47
@TheCoalTrain
`<- backtick
@GingerChew there is an i modifier (ignore case) for regex, or add A-Z to your regex
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:48
@Chrono79 Right, but how come "My age is 0, 0 si ega ym." is a palindrome? It has numbers too.
Diego Mayer
@Chrono79
Jun 21 2017 03:48
@ShenyuSun the position is different, one is symmetric, one is not
Manish Giri
@Manish-Giri
Jun 21 2017 03:48
@Lumexralph I used an API for sounds, it works well. Let me find it.
Ginger
@GingerChew
Jun 21 2017 03:49
@Chrono79 string = string.replace(/[^a-z0-9]/gi|string, string|'') that's what I've got so far, but I think I have my regex is still messed up
Diego Mayer
@Chrono79
Jun 21 2017 03:49
@GingerChew what is that |string, string|? Replace that for a comma
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:49
function nextInLine(arr, item) {
  // Your code here
  var myVar = testArr.shift(arr); 
  testArr.push(item);
  return myVar;  // Change this line
}

// Test Setup
var testArr = [4];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:49
@Manish-Giri that'll be appreciated
rlgerman25
@rlgerman25
Jun 21 2017 03:49
Can anyone help me with the weather app?
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:50
got it
Diego Mayer
@Chrono79
Jun 21 2017 03:50
@TheCoalTrain :+1:
don't use testArr, look at your function definition, use it's parameters
order matters
shift doesn't use arguments
Ogundele Olumide
@Lumexralph
Jun 21 2017 03:50
@TheCoalTrain 1. push item into arr 2. use shift, remove the first element and return it
Ginger
@GingerChew
Jun 21 2017 03:51
@Chrono79 thanks, that did it, plus I was not rejoining my original string after splitting it for a reversal
CamperBot
@camperbot
Jun 21 2017 03:51
gingerchew sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: gingerchew already gave chrono79 points
Sanket Chaudhari
@sanket143
Jun 21 2017 03:55

I am not getting what this means myBike.getGear() should return 3 after calling myBike.setGear(3)
does this means

myBike.setGear(3);
myBike.getGear();

should return 3;

Manish Giri
@Manish-Giri
Jun 21 2017 03:55
@Lumexralph this one
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:56
@Chrono79 so... "1 eye eye 1" will be palindrome, correct?
Diego Mayer
@Chrono79
Jun 21 2017 03:56
@ShenyuSun yes
BlackTiger
@BlackTigerRoar
Jun 21 2017 03:56
@Chrono79 Thank you. Time to think about how to solve this challenge
CamperBot
@camperbot
Jun 21 2017 03:56
shenyusun sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4352 | @chrono79 |http://www.freecodecamp.com/chrono79
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:56
Well I did them both times, now It's not even close to working lol, but this is how it looks
function nextInLine(arr, item) {
  // Your code here
  var myVar = testArr.push(item); 
  testArr.shift([0]);
  return myVar;  // 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));
I pretty much just flip flopped it
Diego Mayer
@Chrono79
Jun 21 2017 03:57

@TheCoalTrain

don't use testArr, look at your function definition, use it's parameters
order matters
shift doesn't use arguments

function nextInLine(arr, item) { <- function definition
arr and item are the function parameters
Sanket Chaudhari
@sanket143
Jun 21 2017 03:58

I am not getting what this means
myBike.getGear() should return 3 after calling myBike.setGear(3)
does this means

myBike.setGear(3);
myBike.getGear();

should return 3;

Diego Mayer
@Chrono79
Jun 21 2017 03:58
@sanket143 yes
@TheCoalTrain myVar doesn't contain the removed element there
TheCoalTrain
@TheCoalTrain
Jun 21 2017 03:59
@Chrono79 so I shouldn't be using shift or push right?
sounds good
Sanket Chaudhari
@sanket143
Jun 21 2017 04:00
Okay @Chrono79 then I've done this from this code
var Bike = function() {

  // Only change code below this line.
  var gear = 0;
  this.setGear = function(change) {
    gear += change;
    return gear;
  };
  this.getGear = function() {
    return gear;
  };
};
var myBike = new Bike();
myBike.setGear(3);
myBike.getGear();
Diego Mayer
@Chrono79
Jun 21 2017 04:00
@TheCoalTrain push and shift, in that order
@sanket143 setGear shouldn't return
and why using += ?
Sanket Chaudhari
@sanket143
Jun 21 2017 04:01
@Chrono79 because I've initialize the value of gear 0 and so to set the value I += the change
Diego Mayer
@Chrono79
Jun 21 2017 04:02
@sanket143 and how would you make to change the gear to a lower value then? setGear should use =, not +=
pursuitgit
@pursuitgit
Jun 21 2017 04:02
hello, can anyone help me with if I'm getting close to the answer?

function chunkArrayInGroups(arr, size) {
  // Break it up.

  var newArray = [];
  var i = 0;
  var n = arr.length;

  while (i < n) {
    newArray.push(arr.slice(i, size));
  }

  return newArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Diego Mayer
@Chrono79
Jun 21 2017 04:03
@pursuitgit that's an infinite loop
you're not changing i value there
pursuitgit
@pursuitgit
Jun 21 2017 04:04
hmm if I go i++ I get this returned
[["a","b"], ["b"],[ ], [ ]]
Sanket Chaudhari
@sanket143
Jun 21 2017 04:04
@Chrono79 so I should gear == change
Diego Mayer
@Chrono79
Jun 21 2017 04:04
== is for comparisons, = is to set a value
Sanket Chaudhari
@sanket143
Jun 21 2017 04:04
okay got it
Diego Mayer
@Chrono79
Jun 21 2017 04:04
@pursuitgit you can change i in some other way, not always i++ or i--
Sanket Chaudhari
@sanket143
Jun 21 2017 04:05
Thanks @Chrono79
CamperBot
@camperbot
Jun 21 2017 04:05
sanket143 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4353 | @chrono79 |http://www.freecodecamp.com/chrono79
mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:05

Hey guys, what am I doing wrong with my object lookup?

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

// Only change code below this line

var lookup = {"alpha": "Adams", "bravo": "Boston", "charlie": "Chicago", "delta": "Denver", "echo": "Easy", "foxtrot": "Frank",};

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

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

pursuitgit
@pursuitgit
Jun 21 2017 04:05
  while (i < n) {
    newArray.push(arr.slice(i, size));
    i = size +1;
  }
Diego Mayer
@Chrono79
Jun 21 2017 04:05
@pursuitgit not exactly, but closer
you also would want to change the slice limits (both) so you actually cut different slices
sriramdvhere
@sriramdvhere
Jun 21 2017 04:06
Hi... i have a doubt in javascript... how to get the Last element 5 in the array
destroyer([3, 5, 1, 2, 2], 2, 3, 5);
pursuitgit
@pursuitgit
Jun 21 2017 04:06
@Chrono79 so I need to make sure to modify i after the loop and I should be ok?
Diego Mayer
@Chrono79
Jun 21 2017 04:06
@sriramdvhere with arguments object
@pursuitgit and the slice arguments
@mrgrizzlie33 you need to use your object to set result value before it is returned
sriramdvhere
@sriramdvhere
Jun 21 2017 04:08
but when i pass this array to function 3rd element is shown as 2 but not the 5.. pls explian.. @Chrono79
TheCoalTrain
@TheCoalTrain
Jun 21 2017 04:08
@Chrono79 The only problem is, is when i remove test array and keep the function definition in the parameters when i write my code, it wont do anything down in the console other then say JSON loop or whatever, so do i have to create multiple variables in order to figure this thing out? Because I feel like I'm on the verge of passing this thing, just confused when it comes to this part in the test.
Diego Mayer
@Chrono79
Jun 21 2017 04:09
@TheCoalTrain use arr instead of testArr, arr is your function's argument, testArr is a global var used in a few test cases
TheCoalTrain
@TheCoalTrain
Jun 21 2017 04:09
so i should use arr.shift rather than testArr.shift
Diego Mayer
@Chrono79
Jun 21 2017 04:09
@sriramdvhere arr is only the first argument, when you do arr[3] is is the 4th element of the first argument, the array
@TheCoalTrain yes
TheCoalTrain
@TheCoalTrain
Jun 21 2017 04:09
@Chrono79 also thanks for all the cooperation man, I appreciate it!
CamperBot
@camperbot
Jun 21 2017 04:09
thecoaltrain sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4354 | @chrono79 |http://www.freecodecamp.com/chrono79
Manish Giri
@Manish-Giri
Jun 21 2017 04:10
@sriramdvhere you can loop through arguments starting at 1 and make a new array out of those numbers..
sriramdvhere
@sriramdvhere
Jun 21 2017 04:11
@Manish-Giri ya.. but how to access the element after the first Array?
Manish Giri
@Manish-Giri
Jun 21 2017 04:11
@sriramdvhere arguments[1]
I just told you
Diego Mayer
@Chrono79
Jun 21 2017 04:12
@sriramdvhere see the mdn link
Manish Giri
@Manish-Giri
Jun 21 2017 04:12
@sriramdvhere you can loop through arguments starting at 1
TheCoalTrain
@TheCoalTrain
Jun 21 2017 04:12
function nextInLine(arr, item) {
  // Your code here
  arr.push(item); 
  testArr.shift([]);
  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));
Moisés Man
@moigithub
Jun 21 2017 04:13
IF the documentation about arguments isnt enough.. there are also few youtube videos explaining that @sriramdvhere
TheCoalTrain
@TheCoalTrain
Jun 21 2017 04:13
it keeps saying shift undefined, is that when i use variable? Also Ill change testarr
Manish Giri
@Manish-Giri
Jun 21 2017 04:13
@sriramdvhere if this is your function call - destroyer([3, 5, 1, 2, 2], 2, 3, 5);
arguments[0] is [3, 5, 1, 2, 2], arguments[1] is 2, and so on
Diego Mayer
@Chrono79
Jun 21 2017 04:13
@TheCoalTrain don't use testArr at all inside the function
althought shift will ignore the argument you're passing, don't pass it!!! ;)
mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:14

@Chrono79 Yea, so now i've got to here:

...
var lookup = {"alpha": "Adams", "bravo": "Boston", "charlie": "Chicago", "delta": "Denver", "echo": "Easy", "foxtrot": "Frank"};

result = lookup;
...
I just don't know how to declare the val of lookup in the result =, when I haven't delcared it in the object itself.

Diego Mayer
@Chrono79
Jun 21 2017 04:14
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:15
@Manish-Giri where did you host the sound ?
Diego Mayer
@Chrono79
Jun 21 2017 04:15
@mrgrizzlie33 did you see the challenge I told you? You're setting result as the whole object, you need to access the object's property passed in val
Manish Giri
@Manish-Giri
Jun 21 2017 04:15
@Lumexralph dropbox
for the pomodoro project
and for simon, it was hosted by fcc on aws s3
sriramdvhere
@sriramdvhere
Jun 21 2017 04:16
@Manish-Giri @Chrono79 @moigithub Thanks... I will read and get back to guys
CamperBot
@camperbot
Jun 21 2017 04:16
sriramdvhere sends brownie points to @manish-giri and @chrono79 and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 4355 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 6059 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 3393 | @moigithub |http://www.freecodecamp.com/moigithub
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:16
@Manish-Giri i'm using dropbox, don't know what I'm missing
Manish Giri
@Manish-Giri
Jun 21 2017 04:17
@Lumexralph remember to replace www with dl
in the shared URL
mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:17
@Chrono79 I saw it, but that shows you how to set it for a specific value in the object. In this challenge I need the val to be editable based on what phoneticLookup(val) is, but when I go result=lookup.phoneticLookup(val), it doesn't work
Diego Mayer
@Chrono79
Jun 21 2017 04:17
@mrgrizzlie33 what's your object's name?
lookup isn't it?
What's the function parameter? It's val
You have to use lookup and val, not phoneticLookup(val) <- that's another function call, and you'll get an unwanted recursion loop
Try (remember the challenge I told you to review)
mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:18
@Chrono79 Yep
@Chrono79 Correct
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:18
@Manish-Giri check your message for the URL link I created
TheCoalTrain
@TheCoalTrain
Jun 21 2017 04:22
@Chrono79 I done did it, thanks again man
function nextInLine(arr, item) {
  // Your code here
  arr.push(item); 
  var removeFromTestArr = arr.shift([]);
  return removeFromTestArr;  // 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));
CamperBot
@camperbot
Jun 21 2017 04:22
thecoaltrain sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: thecoaltrain already gave chrono79 points
Ashish Patel
@ashishjiit
Jun 21 2017 04:23
titleCaseOver
mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:25
@Chrono79 I got it. Thanks so much. I've been having some trouble understanding this javascript stuff, and it's kinda annoying how I learn one method just to have it replaced. I hope I can start figuring it out on my own, but we'll see...
CamperBot
@camperbot
Jun 21 2017 04:25
mrgrizzlie33 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4356 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 21 2017 04:25
:+1:
:wave: all
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:30
@TheCoalTrain you don't need to pass an argument into the shift method and you can avoid using extra variable by doing return arr.shift();
@Chrono79 be good bro
Brandon Thomas
@hazeion
Jun 21 2017 04:38
can someone explain to me what the point of the + when using a regular expression (for instance to find digits). so the /\d+/g. It says "Appending a plus sign (+) after the selector, e.g. /\d+/g, allows this regular expression to match one or more digits." not really understanding the meaning
somboy95
@somboy95
Jun 21 2017 04:39
Can someone help me with html syntax for queries using else if ladder?
TheCoalTrain
@TheCoalTrain
Jun 21 2017 04:39
@Lumexralph Oh hey, sorry didn't see your message, but thanks! I didn't think to just return that, I thought for some reason making a variable would be the best way, but thanks! Any tips and tricks are an awesome help
CamperBot
@camperbot
Jun 21 2017 04:39
thecoaltrain sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1973 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:40
@hazeion it helps match 1 or more occurrence of any digit
Adam Faraj
@adamfaraj
Jun 21 2017 04:40
i'm not getting random quotes from this API....any ideas?
James Patrick Kerrane
@jamesjpk123
Jun 21 2017 04:41

I am stuck on the challenge "Using Objects for Lookups"
My code is here:

https://gist.github.com/jamesjpk123/8dc48a54f4b9d7993340bfe5129331eb

I am failing the requirements:

phoneticLookup("alpha") should equal "Adams"
phoneticLookup("bravo") should equal "Boston"
phoneticLookup("charlie") should equal "Chicago"
phoneticLookup("delta") should equal "Denver"
phoneticLookup("echo") should equal "Easy"
phoneticLookup("foxtrot") should equal "Frank"
phoneticLookup("") should equal undefined

I am passing the requirement:

You should not use case, switch, or if statements

Can anyone help me?
Adam Faraj
@adamfaraj
Jun 21 2017 04:42
.getJSON vs .ajax()? which is better?
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:43
@hazeion e.g
"123" using /\d/g, will match individual occurrence (3 matches) but using
/\d+/g matches it all together, get 1 match
@jamesjpk123 use the val parameter holding respective property names or keys to access the value stored in that key in the lookup object and assign the value to result
@adamfaraj getJSON seems to be succinct cos it's jQuery
which is better I cannot say
Mauricio Salas
@MauriSg99
Jun 21 2017 04:46
a should be assigned to b with =
I dont get this in :/
var a = 7;
var b = 7;
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:46
@MauriSg99 assign a to b
@MauriSg99 b = a;
BlackTiger
@BlackTigerRoar
Jun 21 2017 04:48
@jamesjpk123 You are returning empty string.
Mauricio Salas
@MauriSg99
Jun 21 2017 04:48
@Lumexralph Thanks!
CamperBot
@camperbot
Jun 21 2017 04:48
maurisg99 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1974 | @lumexralph |http://www.freecodecamp.com/lumexralph
BlackTiger
@BlackTigerRoar
Jun 21 2017 04:49
@jamesjpk123 you have var result = ""; at the top, and you return result, which is still empty. Try to do something with result, so it can return something
mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:53

I'm embarassed to be back so quickly, but I have hit yet another road block. Can someone help me understand why this code won't display "Not Found" if the checkProp isn't in myObj?

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

function checkObj(checkProp) {
// Your Code Here

if (checkProp) {myObj.hasOwnProperty(checkProp); return myObj[checkProp];}
else return "Not Found";
}
// Test your code by modifying these values
checkObj("asdg");

BlackTiger
@BlackTigerRoar
Jun 21 2017 04:54
@mrgrizzlie33 if (checkProp) {myObj.hasOwnProperty(checkProp); return myObj[checkProp];} <== Sytax is not correct here
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 04:54

hello! I have a situation here, my answer is not being submitted. :worried:
When I do something like :

var arr = ["a", "b"];
return arr;

then it works..

but if I do :

var arr = [];
arr.push("a");
arr.push("b");
return arr;

then it's not working..
what do u think is the problem here?

mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:54
@ShenyuSun It isn't? What is wrong?
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:55
@mrgrizzlie33 if(myObj.hasOwnProperty(checkProp))
BlackTiger
@BlackTigerRoar
Jun 21 2017 04:55
@mrgrizzlie33 There you go, check Ogundele's answer. good community :)
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 04:56
can any1 help plz?
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:57
@ManojBahuguna both should work, this will work too arr.push("a", "b");
mrgrizzlie33
@mrgrizzlie33
Jun 21 2017 04:57
@Lumexralph @ShenyuSun Wow thanks so much guys. I've really been struggling to understand this javascript stuff and I appreciate all the help I can get.
CamperBot
@camperbot
Jun 21 2017 04:57
mrgrizzlie33 sends brownie points to @lumexralph and @shenyusun :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @shenyusun |http://www.freecodecamp.com/shenyusun
:star2: 1975 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:57
@ManojBahuguna depends on the instructions
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 04:57
the exact answer is being shown in the console window.. but it's just not submitting
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:58
@ManojBahuguna on FCC?
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 04:58
@Lumexralph yes
the Steamroller question
Ogundele Olumide
@Lumexralph
Jun 21 2017 04:59
@ManojBahuguna what are the instructions? show your full code
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:00

The question :
Flatten a nested array. You must account for varying levels of nesting.

My code :

var flatArr = [];

function flattenArray(arr) {
  if(!Array.isArray(arr))
    return arr;

  arr.forEach(function(val, index){
    if(Array.isArray(arr)){
      var result = flattenArray(val, flatArr);
      if(result !== undefined)
        flatArr.push(result);
    }
  });

  return undefined;
}

function steamrollArray(arr){
//   flattenArray(arr);
  flatArr.push("a");
  flatArr.push("b");
  return flatArr;
}

steamrollArray([[["a"]], [["b"]]]);
var flatArr = [];

function flattenArray(arr) {
  if(!Array.isArray(arr))
    return arr;

  arr.forEach(function(val, index){
    if(Array.isArray(arr)){
      var result = flattenArray(val, flatArr);
      if(result !== undefined)
        flatArr.push(result);
    }
  });

  return undefined;
}

function steamrollArray(arr){
  flattenArray(arr);
  return flatArr;
}

steamrollArray([[["a"]], [["b"]]]);
MRLSU
@MRLSU
Jun 21 2017 05:02
javascript is hard bro
for realz
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:04
in the steamrollArray() function if return ["a", "b"], it's being submitted. but this, or if I do the above thing, it's not.. :worried:
Ashish Patel
@ashishjiit
Jun 21 2017 05:05

var myVar = 87;

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

myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
where is problem
the question is
myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
and answer is

var myVar = 87;

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

BlackTiger
@BlackTigerRoar
Jun 21 2017 05:06
@ashishjiit myVar won't be 88 anymore because myVar++
@ashishjiit It was 87, it became 88 after myVar = myVar +1. It became 89 after myVar = myVar++
sriramdvhere
@sriramdvhere
Jun 21 2017 05:10
Hi all, can someone explain this line var args = Array.prototype.slice.call(arguments,1);
var args = Array.prototype.slice.call(arguments,1);
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:13
gosh! it was not working because of the global var.. worked instantly when I moved flatArr declaration inside function.. :smile:
so no globalvars in fcc.. got it..
Adam Faraj
@adamfaraj
Jun 21 2017 05:14
how do i properly set my cache to false in an AJAX request?
$.ajax({
  method: 'GET',
  url: "https://www.quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1,",
  cache: false,
  dataType: "json"
}).then(function(data){
  $(".btn").on('click', function(){
  $.each(data, function(i, data){
        $('.quote__container--text').html(JSON.stringify(data.content));
        $('.quote__container--author').html(JSON.stringify(data.title));
        console.log(data)
}); 
});
});
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:15
try adding 'v={Some Random Number}' after your GET url. it will not cache the content anymore..
sriramdvhere
@sriramdvhere
Jun 21 2017 05:15
@ShenyuSun Thanks.
CamperBot
@camperbot
Jun 21 2017 05:15
:cookie: 246 | @shenyusun |http://www.freecodecamp.com/shenyusun
sriramdvhere sends brownie points to @shenyusun :sparkles: :thumbsup: :sparkles:
BlackTiger
@BlackTigerRoar
Jun 21 2017 05:16
@sriramdvhere roar~
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:16
:laughing:
Adam Faraj
@adamfaraj
Jun 21 2017 05:16
@ManojBahuguna so method: 'GET=34'?
or you mean the actual URL?
this is from jquery:
cache (default: true, false for dataType 'script' and 'jsonp')
Type: Boolean
If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
Ogundele Olumide
@Lumexralph
Jun 21 2017 05:20
@ashishjiit myVar++; is all you need to do
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:21
@adamfaraj no the actual URL
got it @adamfaraj will try that on my next project.. :smile: thanks
CamperBot
@camperbot
Jun 21 2017 05:23
manojbahuguna sends brownie points to @adamfaraj :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @adamfaraj |http://www.freecodecamp.com/adamfaraj
Adam Faraj
@adamfaraj
Jun 21 2017 05:24
@ManojBahuguna dog, its not working
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:24
wht's not working?
Adam Faraj
@adamfaraj
Jun 21 2017 05:25
i'm not getting a random quote when i press the button. just the same quote
Markus Ivancsics
@ivancsicsmarkus
Jun 21 2017 05:25
@adamfaraj Could you send me your URL?
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:26
var randomNumber = Math.random();
$.ajax({
  method: 'GET',
  url: "https://www.quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&v=" + randomNumber + ",",
  cache: false,
  dataType: "json"
}).then(function(data){
  $(".btn").on('click', function(){
  $.each(data, function(i, data){
        $('.quote__container--text').html(JSON.stringify(data.content));
        $('.quote__container--author').html(JSON.stringify(data.title));
        console.log(data)
}); 
});
});
try doing this
generate a random number each time and then pass it to the 'v' (version) parameter of the query string of url
this tells the browser that it's a different version so expect to receive something new and not the same content
Adam Faraj
@adamfaraj
Jun 21 2017 05:28
i got it
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:28
@adamfaraj hope that works
Adam Faraj
@adamfaraj
Jun 21 2017 05:28
$(".btn").on('click', function(){
  $.ajax({
  method: 'GET',
  url: "https://www.quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
  cache: false,
  dataType: "json"
}).then(function(data){
        $('.quote__container--text').html(JSON.stringify(data[0].content));
        $('.quote__container--author').html(JSON.stringify(data[0].title));
        console.log(data)
}); 
});
i had to put the ajax call in my btn function
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:29
lol.. so it wasn't about caching..
Markus Ivancsics
@ivancsicsmarkus
Jun 21 2017 05:30
@adamfaraj
$(".btn").on('click', function(){
  $.ajax({
  method: 'GET',
  url: "https://www.quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
  cache: false,
  dataType: "json"
}).then(function(data){
        $('.quote__container--text').html(JSON.stringify(data[0].content));
        $('.quote__container--author').html(JSON.stringify(data[0].title));
        console.log(data)
}); 
});
Adam Faraj
@adamfaraj
Jun 21 2017 05:31
yeah. that's my code. lol
Manoj Bahuguna
@ManojBahuguna
Jun 21 2017 05:31
great work :+1:
Adam Faraj
@adamfaraj
Jun 21 2017 05:35
man...idk what the hell i did. haha
thank god for Traversy Media and funfunfunction
and stackoverflow
Olivier Alcantara
@Ollieopps
Jun 21 2017 05:42
For the Counting Cards assignment I cant seem to figure out what my problem is
Ogundele Olumide
@Lumexralph
Jun 21 2017 05:43
@Ollieopps show your code
Olivier Alcantara
@Ollieopps
Jun 21 2017 05:43

var count = 0;

function cc(card) {
// Only change code below this line
var blackJack;
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
blackJack = "Bet";
break;
case 7:
case 8:
case 9:
blackJack = "Hold";
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
blackJack = "Hold";
break;
}

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

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

Ogundele Olumide
@Lumexralph
Jun 21 2017 05:44
@Ollieopps you need to check if count is positive > 0 or not to return count + string (Bet or Hold)
Olivier Alcantara
@Ollieopps
Jun 21 2017 05:44
Alright thanks!
physicalgorithm
@physicalgorithm
Jun 21 2017 05:59

function titleCase(str) {

  var splittedString = str.split(" ");
  var newSent = [];

  for (var indexWord = 0; indexWord < splittedString.length; indexWord++) {

    var splittedWords = splittedString[indexWord].split("");
    var newWord = [];

    for (var indexLetter = 0; indexLetter < splittedWords.length; indexLetter++) {
      if (indexLetter === 0) { newWord.push(splittedWords[indexLetter].toUpperCase); } 
      else { newWord.push(splittedWords[indexLetter].toLowerCase); }
    }

    var newString = newWord.join("");
    newSent.push(newString);

  }

  var newSentence = newSent.join(" ");
  return newSentence;

}

titleCase("aLOHA beaches");
why this code doesn't works?
Markus Ivancsics
@ivancsicsmarkus
Jun 21 2017 06:01
@physicalgorithm You made one small issue.
@physicalgorithm You are just referencing to the toLowerCase and toUpperCase function. Not calling it.

@physicalgorithm instead do:

if (indexLetter === 0) { newWord.push(splittedWords[indexLetter].toUpperCase()); } 
      else { newWord.push(splittedWords[indexLetter].toLowerCase()); }

notice the () after the function name!

physicalgorithm
@physicalgorithm
Jun 21 2017 06:02
oh! I didn't know there is such a thing :worried:
What's the diffrence between calling and referencing it?
Markus Ivancsics
@ivancsicsmarkus
Jun 21 2017 06:04

@physicalgorithm my function:

function hello(name) {
    alert("hello " + name);
}

you can call it like:

hello("physicalgorithm");

@physicalgorithm if you would like to store it in a variable:

var asd = hello;

now, you can use asd as a function:

asd("physicalgorithm");
@physicalgorithm You always used ()s, look:
newWord.push(*datatopush*)
physicalgorithm
@physicalgorithm
Jun 21 2017 06:06
yeah I know but, If there is no parameter in the function, why we need to add paranthesis? It's seems weird to me :shipit:
But I got the point, thanks! @ivancsicsmarkus
CamperBot
@camperbot
Jun 21 2017 06:07
physicalgorithm sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 631 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Markus Ivancsics
@ivancsicsmarkus
Jun 21 2017 06:08
@physicalgorithm without a paranthesis, how would you know if it is a variable or a function? ;)
L0ri
@L0ri
Jun 21 2017 06:08
In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
help
physicalgorithm
@physicalgorithm
Jun 21 2017 06:11
@L0ri

function nextInLine(arr, item) {
  var oldie = arr[0];
  if (arr.length === 0) {
    oldie = item;
  }
  arr.push(item);
  arr.shift();

  return oldie;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Ogundele Olumide
@Lumexralph
Jun 21 2017 06:12
@L0ri item is the parameter that holds the number for the function when called, arr holds the array, you need to 1.use an array method to add item to the end of arr
2.use another array method to remove the first element in arr
  • return the removed element in your function
Pieter Stokkink
@forkerino
Jun 21 2017 06:12
@physicalgorithm sorry to say, but that is a very bad solution.
@Lumexralph :wave:
Ogundele Olumide
@Lumexralph
Jun 21 2017 06:14
@forkerino Bro!
abraham anak agung
@padunk
Jun 21 2017 06:14
Hi guys, to add new data, which is better? concat or push?
Pieter Stokkink
@forkerino
Jun 21 2017 06:15
@padunk I prefer concat, because it returns a new array
physicalgorithm
@physicalgorithm
Jun 21 2017 06:15
@forkerino Actually, I googled it now :smile:
abraham anak agung
@padunk
Jun 21 2017 06:15
@forkerino so it will not change the original array?
Pieter Stokkink
@forkerino
Jun 21 2017 06:16
@physicalgorithm why would that be helpful to L0ri? If he wanted that he could google it himself
@padunk correct.
@padunk that is why it is useful.
@padunk In general I use .concat if I need to return an array together with one or more new elements. If I need to build up an array within the same scope and need to use it later on in the same scope, I use .push.
Shyamli Arora
@CiaoShyamli
Jun 21 2017 06:18
hey guys ,how this function is get computed .. Math.floor(Math.random() * 20);
abraham anak agung
@padunk
Jun 21 2017 06:18
@forkerino hmm...ok. thanks. i still learning about this pure function and immutability
CamperBot
@camperbot
Jun 21 2017 06:18
padunk sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2691 | @forkerino |http://www.freecodecamp.com/forkerino
physicalgorithm
@physicalgorithm
Jun 21 2017 06:18
@forkerino It would or not, that is his decision. I just thinked that, if he found a solution he won't ask us. Because of that, I quickly find on google
Pieter Stokkink
@forkerino
Jun 21 2017 06:19
@padunk the principles behind it are very powerful and they can prevent a lot of bugs, so it definitely has its advantages to use pure functions.
@physicalgorithm Not everyone googles a solution before asking a question and I would even say that googling a solution can prevent you from learning what the lesson is about. But to each their own method of teaching.
physicalgorithm
@physicalgorithm
Jun 21 2017 06:21
@forkerino what's you algorithm about Stand in Line project, I'm wondering how to improve this code?
abraham anak agung
@padunk
Jun 21 2017 06:22
yes, i still trying to understand which method is connect with pure functions
Pieter Stokkink
@forkerino
Jun 21 2017 06:22
@CiaoShyamli from the inside out. First Math.random() gets called, which returns a number between 0 including and 1 excluding. This is then multiplied by 20, which gives a number between 0 including and 20 excluding. Math.floor rounds that number down to the nearest whole number.
i'm getting this error
Do not change code above the line
Pieter Stokkink
@forkerino
Jun 21 2017 06:23
@padunk It comes with time and practice. It is not something you learn by memorizing.
abraham anak agung
@padunk
Jun 21 2017 06:23
:+1:
Pieter Stokkink
@forkerino
Jun 21 2017 06:24
@physicalgorithm I can pm it to you.
Shyamli Arora
@CiaoShyamli
Jun 21 2017 06:26
can you explain my mathematically
lokeshlucky1
@lokeshlucky1
Jun 21 2017 06:26
dudes help for my question plz
Shyamli Arora
@CiaoShyamli
Jun 21 2017 06:26
me*
lokeshlucky1
@lokeshlucky1
Jun 21 2017 06:26
yeah @CiaoShyamli
Pieter Stokkink
@forkerino
Jun 21 2017 06:26
@lokeshlucky1 sounds like you changed code above the line ...
pardhu331
@pardhu331
Jun 21 2017 06:28
I have an issue is this page can any one of you help me
https://www.freecodecamp.com/challenges/escape-sequences-in-strings
Pieter Stokkink
@forkerino
Jun 21 2017 06:28
@CiaoShyamli Math.floor rounds down, I don't know how to write that mathematically in a different way.
Say [0-1) is the range 0 (including) to 1 (excluding).
Math.random() gives a number in this range.
[0-1) * 20 = [0-20)
So you have a number in that range, but it can be something like 17.0384509281354012973
Math.floor turns that into 17
@lokeshlucky1 Please copy paste your code here, that link just shows the setup code without anything you've written
@pardhu331 what did you try?
pardhu331
@pardhu331
Jun 21 2017 06:29
pieter stokkink I have an issue is this page can any one of you help me
https://www.freecodecamp.com/challenges/escape-sequences-in-strings
@forkerino var myStr = "FirstLine\n\SecondLine\rThirdLine";
i wrote like this.
var myStr = "FirstLine\n\SecondLine\rThirdLine"; // Change this line
Pieter Stokkink
@forkerino
Jun 21 2017 06:30
@pardhu331 backslashes need to be escaped: \\
pardhu331
@pardhu331
Jun 21 2017 06:31
ok thank you for helping me.
Shyamli Arora
@CiaoShyamli
Jun 21 2017 06:32
thanks @forkerino
CamperBot
@camperbot
Jun 21 2017 06:32
ciaoshyamli sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2692 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jun 21 2017 06:32
:+1:
pardhu331
@pardhu331
Jun 21 2017 06:34
@forkerino the only requirment remaining to satisfy is
(myStr should have encoded text with the proper escape sequences and no spacing. ) in this page
https://www.freecodecamp.com/challenges/escape-sequences-in-strings
Vali
@valimikayilov
Jun 21 2017 06:34
guys how to do "Stand in Line" challenge
function nextInLine(arr, item) {
  // Your code here


  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Joshua Frias
@Juke-Magic
Jun 21 2017 06:34
yo guys
why is
for (var i = 0; i < num; i++) {
return str;
}
returning only one str
???
Pieter Stokkink
@forkerino
Jun 21 2017 06:35
@pardhu331 can you show your current code?
@21-Orange return stops a function
so by extension it stops the loop
Thomas
@sjurs1
Jun 21 2017 06:36
Good morning guys
pardhu331
@pardhu331
Jun 21 2017 06:36
This worked and it is going to next next exercise
(var myStr = "FirstLine\n\SecondLine\\rThirdLine";).
Tartu123
@Tartu123
Jun 21 2017 06:36
I'm stuck with the Stand in Line function as well
Mukul Agrawal
@mukul09
Jun 21 2017 06:37
@Geek-Killer first use .push() method to insert the item in your array and then use .shift() method to remove the 1st element from the array
Tartu123
@Tartu123
Jun 21 2017 06:40
@mukul09 I know I have to use push and shift methods, but can't figure out how exactly. Keep getting errors
Mukul Agrawal
@mukul09
Jun 21 2017 06:45
share your code @Tartu123
abraham anak agung
@padunk
Jun 21 2017 06:46
@pardhu331 \\Second
Vali
@valimikayilov
Jun 21 2017 06:46
@mukul09 like that ?
function nextInLine(arr, item) {
  // Your code here
 testArr.push(item);
 testArr.shift(arr);
  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));
Mukul Agrawal
@mukul09
Jun 21 2017 06:48
@Geek-Killer use arr instead of testArr in
testArr.push(item);
testArr.shift(arr);
Pieter Stokkink
@forkerino
Jun 21 2017 06:48
@Geek-Killer don't use testArr in your function. The array is arr
Mukul Agrawal
@mukul09
Jun 21 2017 06:49
@Geek-Killer no need to write something in .shift() method
Valdovas1
@Valdovas1
Jun 21 2017 06:50
Hello peeps !
function mutation(arr) {
if (arr[0] === arr[1]){
  return true;
}else if (arr[0] != arr[1]){
  return false;
}



  }

mutation(["hello", "hey"]);
@Manish-Giri What do you mean first letters ?
Tartu123
@Tartu123
Jun 21 2017 06:52

function nextInLine(arr, item) {
// Your code here
arr.push();
arr.shift();
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));

Manish Giri
@Manish-Giri
Jun 21 2017 06:52
ah nvm
@Valdovas1 you're comparing 2 arrays
Valdovas1
@Valdovas1
Jun 21 2017 06:52
@Manish-Giri But it does not work still. Only get the false back
Manish Giri
@Manish-Giri
Jun 21 2017 06:52
you need to compare the letters in them
@Valdovas1
@Tartu123 arr.shift(); - you need to return this value
Valdovas1
@Valdovas1
Jun 21 2017 06:53
@Manish-Giri Okey okey. So i should add like this arr[0][1] != arr[0][]1 ?
Tartu123
@Tartu123
Jun 21 2017 06:54
@Manish-Giri Still doesn't work
Manish Giri
@Manish-Giri
Jun 21 2017 06:54
@Tartu123 arr.push(); - what is this pushing?
Vali
@valimikayilov
Jun 21 2017 06:54
@mukul09 @forkerino I didn't got it (
Tartu123
@Tartu123
Jun 21 2017 06:54
dno
Manish Giri
@Manish-Giri
Jun 21 2017 06:55
@Valdovas1 that will compare every letter according to it's position in the 2 words
that won't work
Valdovas1
@Valdovas1
Jun 21 2017 06:55
@Manish-Giri Damn..
Manish Giri
@Manish-Giri
Jun 21 2017 06:55
@Tartu123 read on MDN how .push() works
Valdovas1
@Valdovas1
Jun 21 2017 06:55
@Manish-Giri going to read more then
Manish Giri
@Manish-Giri
Jun 21 2017 06:56
@Valdovas1 what you need is a way to check if all letters in the second word are present in the first word or not..
Valdovas1
@Valdovas1
Jun 21 2017 06:56
@Manish-Giri thanks !
CamperBot
@camperbot
Jun 21 2017 06:56
valdovas1 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6063 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 21 2017 06:57
@Valdovas1 what you have will check if a letter in a specific position in the 2 words are same or not, like for hello and hey, the first 2 checks will pass, since at position 0, both words have h and at position 1, both words have e, but at position 2, you have l in the first word and y in the second word, and it will return false..
ozimanik
@ozimanik
Jun 21 2017 06:58
excusé moi
function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  return (str.slice(-target.length) === target);
}

end("Bastian", "n", "");

//confirmEnding("Bastian", "n") should return true.
//confirmEnding("Connor", "n") should return false.
//confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") should return false.
//confirmEnding("He has to give me a new name", "name") should return true.
//confirmEnding("Open sesame", "same") should return true.
//confirmEnding("Open sesame", "pen") should return false.
//confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain") should return false.
whäts wröng ì dônt úndêrstánd
Ronald T. Casili
@nvlled
Jun 21 2017 07:03
@Tartu123 takes one parameter, the item you are adding to the array
For instance, arr.push('x') adds 'x' to the right side of arr.
shift removes item from the left side
@ozimanik try str.slice(-1)
ozimanik
@ozimanik
Jun 21 2017 07:03
@nvlled kk ty
CamperBot
@camperbot
Jun 21 2017 07:03
:cookie: 194 | @nvlled |http://www.freecodecamp.com/nvlled
ozimanik sends brownie points to @nvlled :sparkles: :thumbsup: :sparkles:
Ronald T. Casili
@nvlled
Jun 21 2017 07:04
wait, that's not enough though
Dan Couper
@DanCouper
Jun 21 2017 07:04
No, what you have is fine, don't do -1
ozimanik
@ozimanik
Jun 21 2017 07:04
@DanCouper didnt work anyway
but whats wrong i dont understand
Dan Couper
@DanCouper
Jun 21 2017 07:04
Console log str.slice(-target.length)
To see what it is giving you
I'm half asleep so I think I'm missing something, but it looks right
ozimanik
@ozimanik
Jun 21 2017 07:05
kk ty it 9 a.m in austria
abraham anak agung
@padunk
Jun 21 2017 07:06
it work here.
Manish Giri
@Manish-Giri
Jun 21 2017 07:06
@ozimanik works fine for me
TheCoalTrain
@TheCoalTrain
Jun 21 2017 07:07
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == 1) {
    return "Hole in one!";
  }
  else if (strokes - par - 2) {
    return "Eagle";
  }
  else if (strokes - par - 1) {
    return "Birdie";
  }
  else if (par == strokes) {
    return "Par";
  }
  else if (strokes + 1) {
    return "Bogey";
  }
  else if (par + 2){
    return "Change Me";
  }
  else if (par + 3) {
    return "Go Home!";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(4, 1);
Having a little bit of trouble with this one. Any suggestions/tips?
Manish Giri
@Manish-Giri
Jun 21 2017 07:07
@TheCoalTrain else if (strokes - par - 2)
what is this comparing to?
and the rest too
Dan Couper
@DanCouper
Jun 21 2017 07:07
The second and third conditions are missing a comparison
TheCoalTrain
@TheCoalTrain
Jun 21 2017 07:08
subtracting strokes from par, in order to make it say the return
but its not really working out
ozimanik
@ozimanik
Jun 21 2017 07:08
@Manish-Giri still dont works for me
Dan Couper
@DanCouper
Jun 21 2017 07:08
Oh, and the last three
TheCoalTrain
@TheCoalTrain
Jun 21 2017 07:08
im trying to use the parameters because they're numerical as it says in the directions
Ronald T. Casili
@nvlled
Jun 21 2017 07:08
@ozimanik i think this one works too:
var end = (str, target) => str.endsWith(target)
Manish Giri
@Manish-Giri
Jun 21 2017 07:08
@TheCoalTrain wrong comparisons
@ozimanik function end(str, target) - your function is named end but is called with confirmEnding
confirmEnding("Bastian", "n")
Einstein
@Mwithiga
Jun 21 2017 07:09
re-think how you do the comparisons
Manish Giri
@Manish-Giri
Jun 21 2017 07:09
how did that happen?
@ozimanik
Dan Couper
@DanCouper
Jun 21 2017 07:09
Conditions 2, 3, 5, 6 and 7 need to be === to something @TheCoalTrain , like conditions 1 and 4
crimsonangel665
@crimsonangel665
Jun 21 2017 07:10
how do i call function multiple times?
TheCoalTrain
@TheCoalTrain
Jun 21 2017 07:10
ohhhh
Dan Couper
@DanCouper
Jun 21 2017 07:10
if (something === something else) or if (something < something else) etc @TheCoalTrain
TheCoalTrain
@TheCoalTrain
Jun 21 2017 07:10
@DanCouper dude idk how i went over that
Ronald T. Casili
@nvlled
Jun 21 2017 07:11
@crimsonangel665 either manually or using a loop:
someFunction();
someFunction();
someFunction();
// or this
for (var i = 0; i < 10; i++)
    someFunction();
TheCoalTrain
@TheCoalTrain
Jun 21 2017 07:11
@DanCouper Okay, lemme retry this again lol, thanks
CamperBot
@camperbot
Jun 21 2017 07:11
thecoaltrain sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
Dan Couper
@DanCouper
Jun 21 2017 07:11
@crimsonangel665 in what context? Need to see what you're trying to do
CamperBot
@camperbot
Jun 21 2017 07:11
:cookie: 795 | @dancouper |http://www.freecodecamp.com/dancouper
crimsonangel665
@crimsonangel665
Jun 21 2017 07:11

// Example
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5

// Only change code below this line.

function functionWithArgs() {
console.log( 1 + 2);
console.log( 7 + 9);
}
//function functionWithArgs() {

//}
functionWithArgs();
functionWithArgs();

calling it twice doesnt help lol
Manish Giri
@Manish-Giri
Jun 21 2017 07:12
help what?
@crimsonangel665
Long Nguyen
@longnt80
Jun 21 2017 07:12
anyone want to review my TicTacToe game? Criticisms are welcome
https://s.codepen.io/longnt80/debug/BZWBxm/wQMPoZbZXmqk
crimsonangel665
@crimsonangel665
Jun 21 2017 07:13
calling the function twice after each other only outputs the last console.log
Dan Couper
@DanCouper
Jun 21 2017 07:13
You don't need to call it multiple times, it's just asking you to add arguments and log the sum. You don't write 1 + 2 or whatever, that's what the function is for
At the minute your function has no arguments
Vali
@valimikayilov
Jun 21 2017 07:14
@longnt80 the computer didn't put the 3rd one)
Long Nguyen
@longnt80
Jun 21 2017 07:16
@Geek-Killer who went first in that game?
abraham anak agung
@padunk
Jun 21 2017 07:16
@longnt80 nice, but i won once :smile:
Long Nguyen
@longnt80
Jun 21 2017 07:17
@padunk hah, nice job