These are chat archives for FreeCodeCamp/HelpJavaScript

19th
May 2017
Idrees
@Idrees5
May 19 2017 00:06

hi guys, i'm very new to this forum. I'm on Word Blanks challenge. Does anyone know how to do this problem?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result = "My noun is \wordBlacks(0) and myAdjective is \wordBlanks(1)."

// Your code above this line
return result;
}

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

my result = section is wrong i think
Mike
@MikeJSchorah
May 19 2017 00:09
Is anyone familiar with Codewars or Hacker Rank?
Long Nguyen
@longnt80
May 19 2017 00:16
@Idrees5 try to create a sentence using those parameter, the output can be like this: The big dog ran quickly
Idrees
@Idrees5
May 19 2017 00:17
its what i'm trying to do but the parameter i'm trying to enter seems incorrect
MoisΓ©s Man
@moigithub
May 19 2017 00:18
@Idrees5 review string concatenation with variables exercise
Long Nguyen
@longnt80
May 19 2017 00:18
@Idrees5 do you remember connecting variables with strings?
Idrees
@Idrees5
May 19 2017 00:18
yes i think i do
var myName = "Idrees"
Long Nguyen
@longnt80
May 19 2017 00:18
It's the same
Idrees
@Idrees5
May 19 2017 00:20
thanks Moises
Long Nguyen
@longnt80
May 19 2017 00:20
For example"The" + myNoun .....
Mike
@MikeJSchorah
May 19 2017 00:20
@moigithub Are you familiar with Codewars or Hackerrank?
hectorhinestroza
@hectorhinestroza
May 19 2017 00:21
hello guys i am in the same challenge and this is my code

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "
";
// Your code below this line
result = "i was walking down with my " += myNoun "then a really " += myAdjective " rat came out of nowhere so my dog " + myVerb " as fast as he could " += myAdverb "hididng" ;

// Your code above this line
return result;
}

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

can you tell me what is wrong with it?
it doesn't run
Idrees
@Idrees5
May 19 2017 00:22
Iongnt80 I understand how to concatenate however my issues is the exact parameter for passing the wordBlanks( myNoun)
Long Nguyen
@longnt80
May 19 2017 00:22
Only + not +=
hectorhinestroza
@hectorhinestroza
May 19 2017 00:23
i tried but is still not working
Long Nguyen
@longnt80
May 19 2017 00:24
@Idrees5 you just need to pass all your parameters in there
@hectorhinestroza you need + sign before and after each parameter
hectorhinestroza
@hectorhinestroza
May 19 2017 00:26
oh that's right i got it thank you
by the way i thought + and += had the same function
Keon Samuel
@keonsam
May 19 2017 00:27
d3 vs react?
Idrees
@Idrees5
May 19 2017 00:29

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

result = "Today I'm walking my " + wordBlanks(myNoun) + "and he is " + wordBlanks(myAdjective) + " he also " + wordBlanks(myVerb) + wordBlanks(myAdverb);
// Your code above this line
return result;
}

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

ok...so what am i doing wrong here
Long Nguyen
@longnt80
May 19 2017 00:30
you don't call the function wordBlanks in there
just myNoun
you call the parameter
Idrees
@Idrees5
May 19 2017 00:31
Thank you Sir now I got it
Long Nguyen
@longnt80
May 19 2017 00:32
@Idrees5
the last line wordBlanks("dog", "big", "ran", "quickly"); calls the function wordBlanks, then the function execute and receive those words: "dog", "big", "ran", "quickly" as the values for parameters: myNoun, myAdjective, myVerb, myAdverb
Ryan Esaul Woodard
@gurew86
May 19 2017 00:32
I kept forgetting to add my spaces into it
into each string so the sentence would read properly
Idrees
@Idrees5
May 19 2017 00:33
yes sir, now that makes perfect sense.
i was trying to call it by myNoun as the logic made sense to me but i was getting the syntax wrong
Long Nguyen
@longnt80
May 19 2017 00:35
copy your code again
Idrees
@Idrees5
May 19 2017 00:35
but now makes even more sense when you say it like that :)
Michael A Roberts
@maroberts
May 19 2017 00:35
studlyCapVar is defined and has a value of 10
Long Nguyen
@longnt80
May 19 2017 00:37
@Idrees5 remember to add spaces like @gurew86 said
Idrees
@Idrees5
May 19 2017 00:37

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

result = "Today I'm walking my " + myNoun + " and he is " + myAdjective + " he also " + myVerb + " " + myAdverb;
// Your code above this line
return result;
}

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

yes sir here it is and words like a charm
Long Nguyen
@longnt80
May 19 2017 00:37
:+1:
Luis Alcazar
@alcazluis
May 19 2017 00:38
got a quick question
about lesson
Find the Lenght of a string
CamperBot
@camperbot
May 19 2017 00:38
find the lenght of a string
nothing found
Luis Alcazar
@alcazluis
May 19 2017 00:38
I beliece all I have to do is ad .lenght to lastname
to complete the task
but it won't work
Idrees
@Idrees5
May 19 2017 00:39
i just completed that challenge
Luis Alcazar
@alcazluis
May 19 2017 00:39
any ideas?
Idrees
@Idrees5
May 19 2017 00:39
so its fresh in my mind
Luis Alcazar
@alcazluis
May 19 2017 00:39
k what am I missing
do you know?
allI think I have to do is add .lenght
Idrees
@Idrees5
May 19 2017 00:39
myLastCharacterOfmyLastName = lastname[lastname.length -1]
Long Nguyen
@longnt80
May 19 2017 00:40
@alcazluis .length not .lenght
Idrees
@Idrees5
May 19 2017 00:40
var lastname = "Osborne"
so the result should be e
Luis Alcazar
@alcazluis
May 19 2017 00:40
I feel stupid
you're right
thanks
Idrees
@Idrees5
May 19 2017 00:40
nah
Luis Alcazar
@alcazluis
May 19 2017 00:40
length
jeje
thanks!
Idrees
@Idrees5
May 19 2017 00:40
i wouldn't know either but i just completed that challenge
Long Nguyen
@longnt80
May 19 2017 00:41
you need to be very careful with typo
better to copy and paste
Courtland Messam
@courtlandmessam
May 19 2017 00:47
Hey guys I'm working on the "Stand in Line" assignment and could use some help :smile:
I'm supposed to be creating a queue where I add item to the end of an array and then remove the first item in the array and also return the item removed
function nextInLine(arr, item) {
  // Your code here
  arr.push(item).shift();
  return arr.shift();  // Change this line
}
Is anyone there?
Please help a struggling coder
Makenze Kelly
@astoroid
May 19 2017 00:52

Hello Everyone. Please I need your help.
(Use Conditional Logic with If Statements)

User Agent is: Google Chrome Version 58.0.3029.110 (64-bit)
Please describe how to reproduce this issue, and include links or screenshots if possible.

My code:

// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.

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

// Change this value to test
trueOrFalse(false);

Courtland Messam
@courtlandmessam
May 19 2017 00:54
Nevermind figured it out hahahahahaahaha
Stephen James
@sjames1958gm
May 19 2017 01:00
Your return string for true is not correct
      return "Yes, that was true";
@astoroid ^^^
https://forum.freecodecamp.com/t/markdown-code-formatting/18391
this link shows how to format code for chat
Makenze Kelly
@astoroid
May 19 2017 01:05
@sjames1958gm Stephen James, Thanks for your help.
CamperBot
@camperbot
May 19 2017 01:05
astoroid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7379 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 19 2017 01:06
@astoroid :+1:
CBSpartan
@CBSpartan
May 19 2017 01:16
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;
var player = testObj[playerNumber]; // Change this Line

Hey guys, I'm a little confused about accessing this object. Why do we not have to use testObj[16] or testObj.16 to access the 16 property when we assign it to the variable playerNumber?

For example, in the following code when we access the nameproperty in order to update it, we don't just use name. We use myDog.name.

var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"]
};
myDog.name = "Happy Coder";
Mowie123
@mowie123
May 19 2017 01:19
Is there anyone available that can take a look at my tic tac toe game and figure out why a function is not running?
Pete Givens
@petegivens
May 19 2017 01:22
Hi everyone I'm running into a brick wall with the Profile Lookup challenge in the basic javascript chapter. Can anyone take a look at this code and tell me why when I uncomment the "else if" statements the original if statement stops working?? https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%0A%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%20firstName%20%26%26%20contacts%5Bi%5D.hasOwnProperty(prop))%20%7B%0A%20%20%20%20%20%20%20%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%7D%20%2F*else%20if%20(contacts%5Bi%5D.firstName%20!%3D%20firstName)%20%7B%0A%20%20%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%20%20%20%20%7D%20else%20if%20(!contacts%5Bi%5D.hasOwnProperty(prop))%20%7B%0A%20%20%20%20%20%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%7D%20*%2F%0A%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
I hope that link preserves my code...it seems like it does?
kao720302
@kao720302
May 19 2017 01:23
i can not make this to happen-->wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
can someone please help?
this is my code--->
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result = "\"dog\"," + "\"big\"," + "\"ran\"," + "\"quickly\"";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");
Pete Givens
@petegivens
May 19 2017 01:29
is this your actual code ?
@kao720302 the line
result = "\"dog\"," + "\"big\"," + "\"ran\"," + "\"quickly\"";
you should be using the parameter names not the literal arguments
kao720302
@kao720302
May 19 2017 01:30
@petegivens yes
CBSpartan
@CBSpartan
May 19 2017 01:31
@kao720302 I'm still a beginner. However, as the exercise says, 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.
@kao720302 Like this...
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {

  // Your code below this line
  var result = "The " + myNoun + " had " + myAdjective + " feet and " + myVerb + " very " + myAdverb + " home.";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Pete Givens
@petegivens
May 19 2017 01:32
function wordBlanks(myNoun, myAdjective) {
  result  = myAdjective + " " + myNoun;
  return result;

wordBlanks("house", "red") \\ this would produce the string "red house"
@kao720302 exactly
kao720302
@kao720302
May 19 2017 01:33
@petegivens @CBSpartan Thank you and I will keep working on it until i figure it out
CamperBot
@camperbot
May 19 2017 01:33
kao720302 sends brownie points to @petegivens and @cbspartan :sparkles: :thumbsup: :sparkles:
:cookie: 207 | @cbspartan |http://www.freecodecamp.com/cbspartan
:cookie: 221 | @petegivens |http://www.freecodecamp.com/petegivens
Pete Givens
@petegivens
May 19 2017 01:33
@CBSpartan have you finished the basic JS portion?
CBSpartan
@CBSpartan
May 19 2017 01:35
@petegivens Not yet. I'm in "Using Objects for Lookups" currently. So I almost am.
Pete Givens
@petegivens
May 19 2017 01:35
@CBSpartan ok cool. I'm stuck about 10 challenges ahead of you. LMK if you figure out the Profile Lookup challenge o_0
@kao720302 CBSpartan gave a good solution to the problem, though there are many. I think the critical piece you are missing is that you were writing code with the literal string values that you want to appear. Your function should be using the parameters, so that no matter which arguments get passed into the function it will work
CBSpartan
@CBSpartan
May 19 2017 01:38
@petegivens No prob :) I'm actually taking a little extra time reviewing the lessons about objects, they are fairly challenging to me.
@kao720302 Happy to help! :)
Joseph
@revisualize
May 19 2017 01:41
@CBSpartan Giving away answers doesn't actually help someone with long term learning.
Brittany Rutherford
@brittanyrutherford
May 19 2017 01:42
hi all :D
Pete Givens
@petegivens
May 19 2017 01:42
hi @brittanyrutherford
Joseph
@revisualize
May 19 2017 01:42

@kao720302 Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

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

You can use the fName and uName parameters just like a variable inside of your function.
Now this example only uses two parameters fName and uName. Whereas, wordBlanks has four parameters.

Brittany Rutherford
@brittanyrutherford
May 19 2017 01:43
hi @petegivens
Joseph
@revisualize
May 19 2017 01:44
@brittanyrutherford Hello.
Brittany Rutherford
@brittanyrutherford
May 19 2017 01:44
hi @revisualize
whenever I learn JS, I keep forgetting what I learned
CBSpartan
@CBSpartan
May 19 2017 01:45
@revisualize Wasn't trying to just give an answer. I thought it was a good example and could serve as a model.
Brittany Rutherford
@brittanyrutherford
May 19 2017 01:46
I wrote some applications, but if you ask me now, how many ways do we have to write loops in JS, I won't know
it's like JS is too dynamic, I can't be in control
what to do in this case?
Joseph
@revisualize
May 19 2017 01:47
@brittanyrutherford Learning has to be repeatition.
kao720302
@kao720302
May 19 2017 01:47
@revisualize @petegivens @CBSpartan thank you guys and I made them to work.
CamperBot
@camperbot
May 19 2017 01:47
kao720302 sends brownie points to @revisualize and @petegivens and @cbspartan :sparkles: :thumbsup: :sparkles:
:warning: kao720302 already gave cbspartan points
:warning: kao720302 already gave petegivens points
:star2: 3983 | @revisualize |http://www.freecodecamp.com/revisualize
Brittany Rutherford
@brittanyrutherford
May 19 2017 01:48
watching a course on how to learn :(
Pete Givens
@petegivens
May 19 2017 01:49
meta
blacksun123
@blacksun123
May 19 2017 01:49
Hi there every1. i need help with the Convert Celsius to Fahrenheit
Pete Givens
@petegivens
May 19 2017 01:50
@blacksun123 sure, post your code
blacksun123
@blacksun123
May 19 2017 01:50
i don't know where to start :(

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

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

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

Brittany Rutherford
@brittanyrutherford
May 19 2017 01:50
thanks @revisualize :)
CamperBot
@camperbot
May 19 2017 01:50
brittanyrutherford sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3984 | @revisualize |http://www.freecodecamp.com/revisualize
CBSpartan
@CBSpartan
May 19 2017 01:54

Perhaps you can help me clarify this @revisualize ...

// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;
var player = testObj[playerNumber]; // Change this Line

Hey guys, I'm a little confused about accessing this object. Why do we not have to use testObj[16] or testObj.16 to access the 16 property when we assign it to the variable playerNumber?

For example, in the following code when we access the nameproperty in order to update it, we don't just use name. We use myDog.name.

var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"]
};
myDog.name = "Happy Coder";
Joseph
@revisualize
May 19 2017 01:55
@CBSpartan Sure.
@CBSpartan So, let's back up a bit.
@CBSpartan Let's start with variables.
@CBSpartan Variables hold values. And those values are referenced when you access the variable.
CBSpartan
@CBSpartan
May 19 2017 01:56
@revisualize Right.
Joseph
@revisualize
May 19 2017 01:56
@CBSpartan So, playerNumber = 16; is storing the value 16 in the variable that can be referenced as playerNumber
@CBSpartan So, when you do testObj[playerNumber]; you're basically saying insert the value of playerNumber here.
@CBSpartan So, it is testObj[16];
@revisualize But, if you tried to do testObj.playerNumber; that won't work.
@CBSpartan Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
@CBSpartan Again because quotes define strings.
@CBSpartan testObj.playerNumber; is the same as testObj["playerNumber"];
and there is no "playerNumber" property key in your object testObj
Boris
@Boris1011
May 19 2017 01:59
Help if I may please.....!! Starting the ES6 challenges on the beta website and I'm already stuck.....
Joseph
@revisualize
May 19 2017 02:00
@CBSpartan Now, when you do testObj[16] the value in object access if it isn't a variable is converted to a string.
@Boris1011 Does the challenge have a bug? Does the challenge even work? What if your code is fine but the challenge is broken.
@Boris1011 It's a beta for a reason.
CBSpartan
@CBSpartan
May 19 2017 02:02
@revisualize Hmmm. I'm gonna have to read through that several times here....
Charles Astor
@CodeAstor
May 19 2017 02:03
Would anyone know why the push method is pushing elements into a new array even when they shouldn't be?
Joseph
@revisualize
May 19 2017 02:03

@Boris1011 I did this:

"use strict";

let favorite = redNosedReindeer + " is Santa's favorite reindeer.";
let redNosedReindeer = "Rudolph";
let redNosedReindeer = "Comet";

Doesn't work.

@Boris1011 Looks like there is a bug with the challenge.
Charles Astor
@CodeAstor
May 19 2017 02:04
E.G if(arr[i] !== false) newAr.push(arr[i])
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:05
can someone suggest a good place where we can play with javascript codes? while also be able to output on the screen?
Charles Astor
@CodeAstor
May 19 2017 02:05

function bouncer(arr) {
// Don't show a false ID to this bouncer.
var a = [];
for(var i = 0; i < arr.length;i++){

if((arr[i] !== false || isNaN(arr[i])

|| arr[i] !== undefined || arr[i] !==0 || arr[i]!== null|| arr[i] !== ""))
a.push(arr[i]);

}
return a;
}

bouncer([7, "ate", "", false, 9]);

Joseph
@revisualize
May 19 2017 02:06
@CodeAstor Your code is doing what you are telling it to do.
eyesore-
@eyesore-
May 19 2017 02:06
@sinharaksh1t repl.it
Boris
@Boris1011
May 19 2017 02:07
@revisualize I didn't even get that far..... js and all this really confuses me.... or maybe it's just the challeneges....
:confounded:
buddermancer
@buddermancer
May 19 2017 02:07
Hello I need assistance
Joseph
@revisualize
May 19 2017 02:07
@Boris1011 Would you try to learn how to drive a car with a car that has experimental breaks and an experimental engine that stops randomly or may explode?
buddermancer
@buddermancer
May 19 2017 02:07
Can anyone help me?
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:08
@eyesore- wow thanks a tonne man!! :D
CamperBot
@camperbot
May 19 2017 02:08
sinharaksh1t sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 84 | @eyesore- |http://www.freecodecamp.com/eyesore-
Charles Astor
@CodeAstor
May 19 2017 02:08
It is still pushing the entire old array into the new one
Joseph
@revisualize
May 19 2017 02:08
@CodeAstor That's what you're telling it to do.
buddermancer
@buddermancer
May 19 2017 02:08
@eyesore- Can you help me?
eyesore-
@eyesore-
May 19 2017 02:08
@sinharaksh1t No problem!
Joseph
@revisualize
May 19 2017 02:08
@buddermancer ASK YOUR QUESTION!
eyesore-
@eyesore-
May 19 2017 02:08
@buddermancer What's up?
buddermancer
@buddermancer
May 19 2017 02:08
Alright jeez mate
Joseph
@revisualize
May 19 2017 02:08
@buddermancer Don't ask to ask. Just ask.
@CodeAstor Let's say I pass a value through your if.
Boris
@Boris1011
May 19 2017 02:09
@revisualize you saying I should stick to the normal FCC website instead of the beta one??
Joseph
@revisualize
May 19 2017 02:09
@Boris1011 The normal website isn't full of bugs.
buddermancer
@buddermancer
May 19 2017 02:09
In the challenge "Chaining If Else Statements" I'm pretty sure I have everything right, but it's giving me an error

function testSize(num) {
// Only change code below this line
if (num <5){
return "Tiny";
} else if (num <10);{
return "Small";
} else if (num < 15); {
return "Medium";
}

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

// Change this value to test
testSize(7);

Joseph
@revisualize
May 19 2017 02:09
@CodeAstor Let's evaluate this:
if((arr[i] !== false || isNaN(arr[i]) || arr[i] !== undefined || arr[i] !==0 || arr[i]!== null|| arr[i] !== ""))
Charles Astor
@CodeAstor
May 19 2017 02:10
So if I pass in a var array = [false], I need it to not push that in
eyesore-
@eyesore-
May 19 2017 02:10
@buddermancer What error are you getting?
Boris
@Boris1011
May 19 2017 02:10
@revisualize ok true, but the beta has more languages to learn?? Or..... idk....
buddermancer
@buddermancer
May 19 2017 02:10
On the second "else if" it's saying "Expected an identifier and instead saw 'else'.
Charles Astor
@CodeAstor
May 19 2017 02:10
my if statement says !== false (push..._
Joseph
@revisualize
May 19 2017 02:10
@CodeAstor let's say the value of i is 0 and the value of arr[0] is ""
@CodeAstor Do you want to work with me here?
buddermancer
@buddermancer
May 19 2017 02:10
also "Expected an assignment or function call and instead saw an expression" and "Missing semicolon"
Charles Astor
@CodeAstor
May 19 2017 02:10
I'm listening
Joseph
@revisualize
May 19 2017 02:11
@CodeAstor Okay. So, let me know when you get a true
@CodeAstor arr[i] !== false ... Is this true?
eyesore-
@eyesore-
May 19 2017 02:11
@buddermancer You've got some syntax errors in your code. There's too many semicolons.
buddermancer
@buddermancer
May 19 2017 02:11
do I need a semicolon after the returns
eyesore-
@eyesore-
May 19 2017 02:11
@buddermancer Semicolons are only on termination.
buddermancer
@buddermancer
May 19 2017 02:11
?
Oh I get it
eyesore-
@eyesore-
May 19 2017 02:11
@buddermancer Only after those returns. You dont need them after the conditionals
buddermancer
@buddermancer
May 19 2017 02:12
I don't need them after the else if statements
Charles Astor
@CodeAstor
May 19 2017 02:12
I'm not sure
buddermancer
@buddermancer
May 19 2017 02:12
thanks @eyesore-
CamperBot
@camperbot
May 19 2017 02:12
buddermancer sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 85 | @eyesore- |http://www.freecodecamp.com/eyesore-
Joseph
@revisualize
May 19 2017 02:12
@CodeAstor "" !== false ... is this true?
eyesore-
@eyesore-
May 19 2017 02:12
@buddermancer Exactly, no problem!
Joseph
@revisualize
May 19 2017 02:12
@CodeAstor Remember we were saying i is 0 and arr[0] is ""
Charles Astor
@CodeAstor
May 19 2017 02:12
That is true right?
Joseph
@revisualize
May 19 2017 02:12
So, is "" !== false?
Then it would be TRUE
@CodeAstor The if statement is triggered.
Charles Astor
@CodeAstor
May 19 2017 02:13
Oh, I see
Joseph
@revisualize
May 19 2017 02:13
@CodeAstor Let's pass false
false !== false ... false
Chris
@aznthnder
May 19 2017 02:14
I am having a hard time with the Escape Sequences in Strings challenge...
Joseph
@revisualize
May 19 2017 02:14
isNaN(false) ... false
@CodeAstor false !== undefined ... true
If statement is triggered.
@CodeAstor With or conditions you just need 1 condition to be true
Charles Astor
@CodeAstor
May 19 2017 02:15
I see
I should know better lol, thaks
buddermancer
@buddermancer
May 19 2017 02:15
How do I give an if expression multiple assignments?
Joseph
@revisualize
May 19 2017 02:16
@CodeAstor If you change all of your ||s to &&s you may have a different result.
buddermancer
@buddermancer
May 19 2017 02:16
do I need the && || things?
eyesore-
@eyesore-
May 19 2017 02:16
@buddermancer || is for or and && is for and
Joseph
@revisualize
May 19 2017 02:16
@buddermancer Do you need a semicolon after return statements ... Yes.
buddermancer
@buddermancer
May 19 2017 02:16
Alright, I'm surprised I understood what you just said
That was an old question @revisualize
eyesore-
@eyesore-
May 19 2017 02:17
@buddermancer If you do || if one of the statements is true then it is all true with && all need to be true for it to be true.
Charles Astor
@CodeAstor
May 19 2017 02:17
Thanks @revisualize . I think I figured it out
CamperBot
@camperbot
May 19 2017 02:17
codeastor sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3985 | @revisualize |http://www.freecodecamp.com/revisualize
buddermancer
@buddermancer
May 19 2017 02:17
Ok thank you
eyesore-
@eyesore-
May 19 2017 02:18
@buddermancer Yeah, no problem. Anytime.
Joseph
@revisualize
May 19 2017 02:18
@CodeAstor Question.. Why are you trying to rebuild what is already built into JavaScript?
Chris
@aznthnder
May 19 2017 02:18
how do I assign the following lines in to the single variable myStr using escape sequences? FirstLine\SecondLine\ThirdLine
Charles Astor
@CodeAstor
May 19 2017 02:18
Is there already a method for this?
CBSpartan
@CBSpartan
May 19 2017 02:18

@revisualize Okay, what you said makes sense. But why can't I use "name" = "Happy Coder" ; in

var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"]
};
myDog.name = "Happy Coder";

Because, in the following code. They just use 16 to assign it to playerNumber. They don't identify the object that 16 is coming from like they do with "name" in the above example.

// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;
var player = testObj[playerNumber]; // Change this Line
Charles Astor
@CodeAstor
May 19 2017 02:19
I just started JavaScript a couple days ago, so I'm not familiar with all of the methods
Stephen James
@sjames1958gm
May 19 2017 02:19
@aznthnder It will be only one line in a single string.
copy the string given into the editor and replace the keywords with the matching escape codes.
start with
var myStr = "";
Joseph
@revisualize
May 19 2017 02:20

@CBSpartan If you do this:

var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"]
};
myDog.name = "Happy Coder";

You want to change myDog.name = "Happy Coder"; to name = "Happy Coder"; ?

Rakshit Sinha
@sinharaksh1t
May 19 2017 02:21
hola geniuses!!
Why is it that arr.sort() doesn't work whereas arr.sort(arr) works?
What is the reason to pass the array itself in the arguments when you are already calling the sort method by using the dot operation of the array you want sorted?
Joseph
@revisualize
May 19 2017 02:22
@CBSpartan Or are you trying to do myDog."name" ? (Which doesn't work by the way.)
Claudio Restifo
@Marmiz
May 19 2017 02:22
@sinharaksh1t if you pass arr.sort() without argument will sort the elements inside according to their Unicode value
Joseph
@revisualize
May 19 2017 02:23
@CBSpartan or are you trying to d myDog["name"] = "Happy Coder";?
Stephen James
@sjames1958gm
May 19 2017 02:23
@sinharaksh1t The second one is invalid as you are supposed to pass a function to sort, not an array.
Joseph
@revisualize
May 19 2017 02:23

@CBSpartan Or are you actually trying to do:

"name" = "Happy Coder";

Which really doesn't work.

Stephen James
@sjames1958gm
May 19 2017 02:24

@CBSpartan

var playerNumber = 16;
var player = testObj[playerNumber]; // Change this Line

This is trying to show you that your property name could be stored in a variable.
And if it is then you have to use [] around the variable name

CBSpartan
@CBSpartan
May 19 2017 02:24
@revisualize My code passes the tests. I'm just confused about how 16 from an object can be assigned to variable without identifying what object it came from in the assignment. Because in
Chris
@aznthnder
May 19 2017 02:24
@sjames1958gm this is what I entered var myStr;// "FirstLine\n \SecondLine\ \rThirdLine"; and it still isn;t correct...
Stephen James
@sjames1958gm
May 19 2017 02:25
@CBSpartan 16 is not from the object.
Joseph
@revisualize
May 19 2017 02:25
@CBSpartan 16 is not from an object.
16 is a number.
var playerNumber = 16; that's assigning the value 16 to the variable playerNumber
Stephen James
@sjames1958gm
May 19 2017 02:25
@aznthnder You need to assign the string to myStr - you have the string as part of a comment.
@aznthnder Then you will need to remove all spaces in the string.
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:26
@sjames1958gm this definitely works cause I saw it Beau's tutorials video on youtube. Who makes youtube videos on javascript for freecodecamp. and i tried it myself too.
CBSpartan
@CBSpartan
May 19 2017 02:26

@revisualize Right. But in

// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;
var player = testObj[playerNumber]; // Change this Line

it is.

Rakshit Sinha
@sinharaksh1t
May 19 2017 02:26
@Marmiz well i thought the same but that didn't happen somehow.
Joseph
@revisualize
May 19 2017 02:26
@CBSpartan 16 is not an object.
Stephen James
@sjames1958gm
May 19 2017 02:26
@sinharaksh1t What are you sorting?
Joseph
@revisualize
May 19 2017 02:26
@CBSpartan Where is 16 an object?
CBSpartan
@CBSpartan
May 19 2017 02:27
@revisualize A property of the object is what i meant.
Joseph
@revisualize
May 19 2017 02:27
@CBSpartan Yeah. It's a property.
Stephen James
@sjames1958gm
May 19 2017 02:27
@CBSpartan 16 is a number and just happens to be the property of the object.
Assigning 16 to playerNumber is just assigning the number to the variable
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:27
@sjames1958gm an array of strings
eyesore-
@eyesore-
May 19 2017 02:28
@sinharaksh1t I don't think I will be able to explain it as well as the sort documentation does. Check it out https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort?v=control
Stephen James
@sjames1958gm
May 19 2017 02:28
@sinharaksh1t
var arr = ["test", "play", "abc"];
arr.sort()
(3) ["abc", "play", "test"]
Claudio Restifo
@Marmiz
May 19 2017 02:29
@sinharaksh1t you can show your code so we can see why it's working like that
Joseph
@revisualize
May 19 2017 02:29
@CBSpartan
var members = {
    tw: "Namath",
    st: "Montana",
    nt: "Unitas"
}
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:29
@eyesore- thanks for that I will check it out.
CamperBot
@camperbot
May 19 2017 02:29
:warning: sinharaksh1t already gave eyesore- points
sinharaksh1t sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
May 19 2017 02:29
var arr = ["test", "play", "abc"];
arr.sort(arr)
(3) ["abc", "play", "test"]
Joseph
@revisualize
May 19 2017 02:29
@CBSpartan members.nt would access the value "Unitas"
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:30
@Marmiz okay let me try to show it here
eyesore-
@eyesore-
May 19 2017 02:30
@sinharaksh1t No problem. If you ever just want to look at documentation for methods you are using MDN is a good source. http://devdocs.io/ is also cool. It pulls from different places.
Vinicius Otacilio
@Karumba15
May 19 2017 02:30

// Example
var firstName = "Ada";
var lastLetterOfFirstName = firstName[firstName.length - 1];

// Setup
var lastName = "Lovelace";

// Only change code below this line.
var lastLetterOfLastName = Mee[Mee.length - 1];

Rakshit Sinha
@sinharaksh1t
May 19 2017 02:30
@sjames1958gm ah, that example could you try doing arr.sort(arr) and see what result you get?
Vinicius Otacilio
@Karumba15
May 19 2017 02:30
why this is wrong?
Joseph
@revisualize
May 19 2017 02:31

@CBSpartan

var members = {
    tw: "Namath",
    st: "Montana",
    coolGuy: "Unitas"
}

members.coolGuy;" would access the value"Unitas"`

Vinicius Otacilio
@Karumba15
May 19 2017 02:31
is saying that i have do use .length to get the last letter
Stephen James
@sjames1958gm
May 19 2017 02:31
@sinharaksh1t I did look up
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:31
@eyesore- gotcha!
@sjames1958gm and the result?
Stephen James
@sjames1958gm
May 19 2017 02:31
@Karumba15 Use lastName variable
@sinharaksh1t Same, both worked
@revisualize members.2000 is invalid
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:32
sounds good. now let me show you the example i was working with where arr.sort() didn't work.
it was an array of numbers
Stephen James
@sjames1958gm
May 19 2017 02:32
@sinharaksh1t Yes, you have to supply a function to arr.sort to sort numbers
Joseph
@revisualize
May 19 2017 02:33

@CBSpartan

var members = {
    tw: "Namath",
    st: "Montana",
    2000: "Unitas"
}

var val = 2000;
members[val]; ... would access the value "Unitas"

@sjames1958gm fixed.
Claudio Restifo
@Marmiz
May 19 2017 02:33
@sinharaksh1t as explained before sort without arguments will arrange the values in their unicode order.
So 10 will come first than 2 (for example)
arr =[ 1, 10 ,2]
arr.sort() // [1, 10 ,2]
CBSpartan
@CBSpartan
May 19 2017 02:34
@revisualize Okay, I think I understand. However, I've gtg and I'm going to come back and review what you've said a little more to solidify it my mind. Thank you for your help and patience!
CamperBot
@camperbot
May 19 2017 02:34
cbspartan sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3986 | @revisualize |http://www.freecodecamp.com/revisualize
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:35
@Marmiz yeah thanks for that i see what you're saying
CamperBot
@camperbot
May 19 2017 02:35
sinharaksh1t sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 875 | @marmiz |http://www.freecodecamp.com/marmiz
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:35
@sjames1958gm ohkay
Anson Ervin
@Ansontheprogrammer
May 19 2017 02:35
please help, i just cant get it to match my string in the function. I'm supposed to match in reverse, spaces, and commas.

function palindrome(str) {
// Good luck!
str = str.toLowerCase();
var newV = /^str*/i;
var glo = str.match(newV);
if (str === glo){
return true;
}
else{
return false;
}
}

palindrome("racecar");

Rakshit Sinha
@sinharaksh1t
May 19 2017 02:35
@Marmiz @sjames1958gm check this out
var arr = [34,6,45,2,54];
.. console.log(arr.sort());
.. console.log(arr.sort(arr));
// [ 2, 34, 45, 54, 6 ]
// [ 2, 34, 45, 54, 6 ]
Claudio Restifo
@Marmiz
May 19 2017 02:36
@sinharaksh1t it worked as expected. They are oredered according to the Unicode encription
and btw passing arr as a argument has no effect. sort accept a function as argument
HeebieGeeBee
@HeebieGeeBee
May 19 2017 02:38
still a work in progress but if anyone would like to have a go and see if they spot anything buggy, that would be much appreciated https://heebiegeebee.github.io/JS_Arkanoid_Clone/
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:38
@Marmiz yes you're right they worked as expected.. as per the unicode..
and I dont know if it has any effect or not, but it still works
Stephen James
@sjames1958gm
May 19 2017 02:39
w @sinharaksh1t sort is expecting a fucntion so probably just ignores the array
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:40
btw, so if i dont want sorting to take place according to the unicode then i will have to pass the function right?
function(a,b) {
return a-b;
}
correct?
@sjames1958gm ohh, i see.. yeah mayve
*maybe
Claudio Restifo
@Marmiz
May 19 2017 02:40

@sinharaksh1t according to the docs:

arr.sort(compareFunction)

Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element.

You are not passing a function so it's the same as omitting

Rakshit Sinha
@sinharaksh1t
May 19 2017 02:40
@Marmiz gotcha! it's weird to not see errors when doing something wrong.. :p unlike java
Michael Grienauer
@mgrienauer
May 19 2017 02:41
doing steamroller and keep getting an error that a is undefined...not sure why though...
function steamrollArray(arr) {

  var flatten = function(a,b){
    if (Array.isArray(b)){
      return a.concat(b);
    } 
  };

  return arr.reduce(flatten,[]);
}

steamrollArray([1, [2], [3, [[4]]]]);
Claudio Restifo
@Marmiz
May 19 2017 02:41
technically you are not doing anything wrong since the function accept also no arguments
but I see what you mean :)
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:41
@Marmiz haha yea :package:
*:P
eyesore-
@eyesore-
May 19 2017 02:42
@sinharaksh1t It doesn't give an error because it is looking for an object. Functions are object and so are arrays.
Chris
@aznthnder
May 19 2017 02:43
@sjames1958gm Thank you.
CamperBot
@camperbot
May 19 2017 02:43
aznthnder sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7380 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:43
@eyesore- yeah, you're right
Chris
@aznthnder
May 19 2017 02:43
@sjames1958gm thanks. i just started the JavaScript challenges and they are very challenging
CamperBot
@camperbot
May 19 2017 02:43
aznthnder sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: aznthnder already gave sjames1958gm points
Michael Grienauer
@mgrienauer
May 19 2017 02:44
any ideas?
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:45
@eyesore-
  1. What are JavaScript types?
    Following are the JavaScript types:
    Number
    String
    Boolean
    Function
    Object
    Null
    Undefined
i read this somewhere
how is it that functions and objects are separate, if you said that functions are same as objects
on the beginning few lessons on freecodecamp they too mentioned that javascript has 7 types which are :smile:
number, null. string, boolean, symbol, object, undefined
Claudio Restifo
@Marmiz
May 19 2017 02:47
@mike93og93 I think that at a certain point your reduce function will reach [3 ,[[4]]] the nested array, but you cannot concat it.
Anson Ervin
@Ansontheprogrammer
May 19 2017 02:47

hey what am i doing wrong please?

function palindrome(str) {
// Good luck!
str = str.toLowerCase();
var newV = /^str*/i;
var glo = str.match(newV);
if (str === glo){
return true;
}
else{
return false;
}
}

palindrome("racecar");

Claudio Restifo
@Marmiz
May 19 2017 02:48
If I recall correctly concat does not recurse into nested array
eyesore-
@eyesore-
May 19 2017 02:48
@sinharaksh1t functions are an instance of Function which inherits from Object
Michael Grienauer
@mgrienauer
May 19 2017 02:48
@Marmiz thanks..still not sure why it's saying a is undefined though
CamperBot
@camperbot
May 19 2017 02:48
mike93og93 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:cookie: 876 | @marmiz |http://www.freecodecamp.com/marmiz
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:48
ah, okay
eyesore-
@eyesore-
May 19 2017 02:49
@sinharaksh1t pretty much anything that is not a primitive is an object.
Rakshit Sinha
@sinharaksh1t
May 19 2017 02:49
@eyesore- gotcha!
Claudio Restifo
@Marmiz
May 19 2017 02:54
@mike93og93 maybe because you're trying to concat b into flatten which is a function? Not 100% sure tho
you can try to console.log(typeof a) to check
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:05
just curious. can array.reduce() method be used with an array of strings? if yes. how?
RuthCollins
@RuthCollins
May 19 2017 03:07
hello everyone
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:07
@RuthCollins Hello!! and welcome to the javascript help forum!!!
RuthCollins
@RuthCollins
May 19 2017 03:07
thank you
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:08
:)
eyesore-
@eyesore-
May 19 2017 03:08
@sinharaksh1t Yes, what are you trying to do?
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:09
@eyesore- reduce an array of strings to the only index which has the greatest lenght
length*
to the only word
brenbroussard
@brenbroussard
May 19 2017 03:10
I need help with the
Stand in Line" javascript study
eyesore-
@eyesore-
May 19 2017 03:10
@sinharaksh1t Yeah, that is totally possible. You'd want to iterate through the array and just change the result to the current word if it has a greater length
brenbroussard
@brenbroussard
May 19 2017 03:11
I'm not sure what i'm missing
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:11
@brenbroussard code?
@eyesore- yeah trying to think of the logic
brenbroussard
@brenbroussard
May 19 2017 03:11
Yes im teying to send snapshot
RuthCollins
@RuthCollins
May 19 2017 03:12
my forEach works fine but my for loop isnt working, please I need an explanation concerning the two
function sumArray(arr) {
    var sum = 0;
    for (var x = arr; x < 0; x++) {
        sum += x;
    }
    return sum;
}
sumArray([20, 20, 5]);

function sumArray(arr) {
    var sum = 0;
    arr.forEach(function(x) {
        sum += x
    });
}
the for loop isnt working
why
brenbroussard
@brenbroussard
May 19 2017 03:13

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

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

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

Rakshit Sinha
@sinharaksh1t
May 19 2017 03:13
@RuthCollins you need to assign the value of x to 0
not arr
oh wait,
set it to arr.length-1
setting it's value to arr makes x an array, which you dont want. you want a number to be stored in
x
brenbroussard
@brenbroussard
May 19 2017 03:14
My dirrctions:
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.
RuthCollins
@RuthCollins
May 19 2017 03:14
@sinharaksh1t it still doesnt work
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:15
decrement x--
RuthCollins
@RuthCollins
May 19 2017 03:15
function sumArray(arr) {
    var sum = 0;
    for (var x = 0; x < arr; x++) {
        sum += x;
    }
    return sum;
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:15
@RuthCollins you need to use x--
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:16
@RuthCollins over here, you need to use x<arr.length instead of arr
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:16
sum += arr[x]
RuthCollins
@RuthCollins
May 19 2017 03:16
@HeebieGeeBee please explain
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:16
you need to access every arr element to add it to the sum variable
brenbroussard
@brenbroussard
May 19 2017 03:16
I think i need to find a way to not just add any number to the array, bit to add incrementally each time the finction is called. Right? At this point i just told it to add a 6.
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:17
and you access every arr elemet by using arr[x]
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:17
@RuthCollins x is simply a loop variable, but what you need is the sum of the elements of the array which you can access by arr[x]
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:17
but your loop isnt realy setup properly
RuthCollins
@RuthCollins
May 19 2017 03:18
thanks @sinharaksh1t
CamperBot
@camperbot
May 19 2017 03:18
ruthcollins sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @sinharaksh1t |http://www.freecodecamp.com/sinharaksh1t
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:18
@RuthCollins :D
RuthCollins
@RuthCollins
May 19 2017 03:18
thanks @HeebieGeeBee
CamperBot
@camperbot
May 19 2017 03:18
ruthcollins sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1663 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:19
for (var x = 0; x < arr.length; x++) or for(var x = arr.length-1: x => 0; x--) if you really want to go from the back of the array to the front
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:21
is this a good practice to reduce lines of code by cascading functions one after the other while changing the initial variable?
str = str.split(" ").reduce(function(accum,curr) {
return accum.length < curr.length ? curr : accum;
});
return str.length;
or should I use more variables while keeping initial value unchanged
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:22
dont even know what youre saying
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:22
ah, never mind..
eyesore-
@eyesore-
May 19 2017 03:22
@sinharaksh1t Yeah, method chaining is good.
brenbroussard
@brenbroussard
May 19 2017 03:22
@sinharaksh1t could you please point me in the right direction?
Rick Riggs
@wikiwiggs
May 19 2017 03:23
@sinharaksh1t I think using less variables is more efficient if yo can get away with it.
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:23
@sinharaksh1t oh chaining methods
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:23
@eyesore- thanks! I thought the same coz that way i can keep space complexity to least like O(1) while doing so many operations. But I just didn't know if this is a widely accepted good practice.
CamperBot
@camperbot
May 19 2017 03:23
sinharaksh1t sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 86 | @eyesore- |http://www.freecodecamp.com/eyesore-
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:23
@wikiwiggs yeah
@HeebieGeeBee haha yeah, sorry didn't use proper terminology
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:24
just make sure you know what youre getting returned from each method before you chain them
eyesore-
@eyesore-
May 19 2017 03:24
@sinharaksh1t Oh, it wont really make a difference in space complexity since it is not a loop within a loop, but it is neatly organized.
@sinharaksh1t Plus functional programming looks so pretty. haha
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:24
@brenbroussard what is your error?
@HeebieGeeBee yeah sounds good
@eyesore- true that! and well yea damn complexity wont really have much of a difference here, you're right
brenbroussard
@brenbroussard
May 19 2017 03:26
@sinharaksh1t pretty much the whole thing. Here's a copy/paste:
zackn9ne
@zackn9ne
May 19 2017 03:26

what is this code doing

```
var Carousel = {
props: {
current_slide: null,
total_slides: null
},
init: function () {

brenbroussard
@brenbroussard
May 19 2017 03:26
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
zackn9ne
@zackn9ne
May 19 2017 03:26
    var Carousel = {
        props: {
            current_slide: null,
            total_slides: null
        },
        init: function () {
what is this doing im so lost
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:26
@zackn9ne nothing
eyesore-
@eyesore-
May 19 2017 03:26
@sinharaksh1t What I meant to say is that big O is for time complexity really. It will have more space if you are creating more data structures. i.e. objects and arrays.
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:26
its an object
zackn9ne
@zackn9ne
May 19 2017 03:27
@HeebieGeeBee an object called Carousel?
Rick Riggs
@wikiwiggs
May 19 2017 03:27
@zackn9ne it's not even closed
zackn9ne
@zackn9ne
May 19 2017 03:27
no guys theres way more to it
im lost from the start
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:27
yes looks like its the start of a constructor function
zackn9ne
@zackn9ne
May 19 2017 03:27
never seen a sytax like this
Rick Riggs
@wikiwiggs
May 19 2017 03:27
yes an object called Carousel
zackn9ne
@zackn9ne
May 19 2017 03:28
        bindEvents: function () {
has more parts like above
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:28
it means that one of its properties is a function
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:28
@brenbroussard
function nextInLine(arr, item) {
// Your code here
testArr.push(6); testArr.shift();
return item; // adjust this line
}
the array in the arguments is arr so you gotta use that inside the function, not testArr
zackn9ne
@zackn9ne
May 19 2017 03:29
@HeebieGeeBee so I gotta lookup constructor functions
Rick Riggs
@wikiwiggs
May 19 2017 03:29
@zackn9ne are you going to be on in 45 min from now, I have to go pickup my child in the next few minutes, but I would be happy to explain oop basics in a private chat.
zackn9ne
@zackn9ne
May 19 2017 03:29
is this an es6 thing or an old shocol way
Rick Riggs
@wikiwiggs
May 19 2017 03:29
old school
zackn9ne
@zackn9ne
May 19 2017 03:29
@wikiwiggs prob not
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:29
also, initialise item to arr.shit() so that you can store its value and return the same @brenbroussard
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:29
es6 has classes
zackn9ne
@zackn9ne
May 19 2017 03:29
whats the modern way to do it es6 class?
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:29
@eyesore- gotcha!
zackn9ne
@zackn9ne
May 19 2017 03:30
just give me some stuff to lookup
  1. constructor functions
  1. oop basics
oops 1=+
Rick Riggs
@wikiwiggs
May 19 2017 03:31
@zackn9ne - I have a youtube mini-series on javascript OOP basics. It doesn't cover everything, but it will get you moving.
https://www.youtube.com/watch?v=Uchrqugjof8&list=PLnMF9In69aCWw35AZxD5UeQ9vLgBrUXVF
zackn9ne
@zackn9ne
May 19 2017 03:32
cool because I don't get the benefit of why this code was put into an object for somereason
is the es6 way, this would all be in a Class?
brenbroussard
@brenbroussard
May 19 2017 03:32
@sinharaksh1t i haven't been doing this very long. What
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:33
if its called object orientated programming, kinda gives a clue that things will be orientated around objects @zackn9ne
brenbroussard
@brenbroussard
May 19 2017 03:33
What section should i review that will help me see how to put it within the function?
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:33
but htne everything in javascript is an object i think
eyesore-
@eyesore-
May 19 2017 03:34
@HeebieGeeBee pretty much everything that is not a primitive is an object.
zackn9ne
@zackn9ne
May 19 2017 03:34
objects I thought it was just for traditional JSON datasets
eyesore-
@eyesore-
May 19 2017 03:35
@zackn9ne It's put in there for inheritance. Look up class inheritance and then look at why it's not good and the issue it can create.
zackn9ne
@zackn9ne
May 19 2017 03:35
{ name: billy,
superPower: ice
}
@eyesore- aka variable scoping?
eyesore-
@eyesore-
May 19 2017 03:35
@zackn9ne Arrays and Functions are objects. JSON is just a data format.
@zackn9ne No, scoping is something else.
zackn9ne
@zackn9ne
May 19 2017 03:36
aw crap
i've been trying to scope in here and am lost too
but if i read up on inheritance and JS objects Oriented I think it will provide some light
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:37
@zackn9ne youre thinking of an object literal i think
zackn9ne
@zackn9ne
May 19 2017 03:38
reading this on MDN now Using a constructor function
eyesore-
@eyesore-
May 19 2017 03:39
@zackn9ne Have you heard of funfunfunction?
zackn9ne
@zackn9ne
May 19 2017 03:39
yes watched quite a few
eyesore-
@eyesore-
May 19 2017 03:41
His intro to OOP videos are really good. You should check them out if you haven't already
zackn9ne
@zackn9ne
May 19 2017 03:42
ill try it cuz MDN makes no sense to me now
oh yea prototypes, i have no clue what those are too
this should be good thx
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:43
coding train is also good on OOP
zackn9ne
@zackn9ne
May 19 2017 03:43
i gotta learn prototypes hella bad lol
cant believe i keep putting this off
arrozconfrijoles
@arrozconfrijoles
May 19 2017 03:44
hey I have a question about one of the challenges called Seek and Destroy
I have to delete stuff from an array
Which I don't have any problem doing. I have a problem accessing the other arguments that are outside the array.
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:46
@mouthfullofgoldteeth you need to use the arguments object
should be link to it in the challenge
arrozconfrijoles
@arrozconfrijoles
May 19 2017 03:46
the program is set up like this where it sends the argument like this [1, 2, 3, 4], 2, 3
@HeebieGeeBee I'll read through that page it linked again but I wasn't quite understanding it
priyanka bhalla
@priyanka-bhalla
May 19 2017 03:47

function testSize(num) {
// Only change code below this line
if(num<5){
return "tiny";

}
else if(num<10){ return "small"; } else if(num<15){ return "medium"; }else if(num<20){ return "large"; } else if(num>=20){
return "huge";
}
else{
return "Change Me";
}
// Only change code above this line
}

// Change this value to test
testSize(7);
testSize(0) should return "Tiny"
testSize(4) should return "Tiny"
testSize(5) should return "Small"
testSize(8) should return "Small"
testSize(10) should return "Medium"
testSize(14) should return "Medium"
testSize(15) should return "Large"
testSize(17) should return "Large"
testSize(20) should return "Huge"
testSize(25) should return "Huge"

HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:48
the arguments object is an array like object
Rakshit Sinha
@sinharaksh1t
May 19 2017 03:48
@brenbroussard sorry i was away.. did it still not solve your issue?
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:48
and you can access the values by using arguments[0] arguments[1] etc @mouthfullofgoldteeth
priyanka bhalla
@priyanka-bhalla
May 19 2017 03:49
please help me to solve
this code
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:50
@priyanka-bhalla your strings arent correct
capitalize the first letter
arrozconfrijoles
@arrozconfrijoles
May 19 2017 03:50
@HeebieGeeBee that's the part I'm having trouble with. I can't figure out how to access the second part of the argument
rugano
@rugano
May 19 2017 03:50
Hello campers,I need your help in debugging my random quote machine.The images aren't showing and also the quotes.please help here: https://codepen.io/Njue/full/xdyGBg
Long Nguyen
@longnt80
May 19 2017 03:50
@mouthfullofgoldteeth arguments is a key word. In that lesson, if you console.log(arguments); it'll show an array
arguments is similar to array which you can access its values like this arguments[0]. However, arguments is NOT an array, it cannot use array methods
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:50
s @mouthfullofgoldteeth what do you mean by the second part of the argument?
Gabe Rotberg
@grotberg
May 19 2017 03:51
@rugano need to include jquery. You can do that on the javascript part of the pen settings
arrozconfrijoles
@arrozconfrijoles
May 19 2017 03:51

function destroyer(arr) {

  return arguments[0];
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
returrns
[1, 2, 3, 1, 2, 3]
priyanka bhalla
@priyanka-bhalla
May 19 2017 03:51
thanks for the help:)
arrozconfrijoles
@arrozconfrijoles
May 19 2017 03:51
I can't access what is outside the array
or I haven't figured out how to do so
Long Nguyen
@longnt80
May 19 2017 03:51
@mouthfullofgoldteeth try arguments[1]
Gabe Rotberg
@grotberg
May 19 2017 03:52
@rugano oh, you have it but you're getting a 403 error. Use this address https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
arrozconfrijoles
@arrozconfrijoles
May 19 2017 03:52
@longnt80 @HeebieGeeBee ay thanks guys
CamperBot
@camperbot
May 19 2017 03:52
mouthfullofgoldteeth sends brownie points to @longnt80 and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 1664 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
zackn9ne
@zackn9ne
May 19 2017 03:56
ok what's this part i'm still lost
    var Carousel = {
        props: {
            current_slide: null,
            total_slides: null
        },
is props: a common syntax for something
is current_slide a var?
how would i console.log current_slide
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:57
its just a name of a key
zackn9ne
@zackn9ne
May 19 2017 03:57
props is a key in a object of Carousel
HeebieGeeBee
@HeebieGeeBee
May 19 2017 03:57
Carousel.props.current_slides
zackn9ne
@zackn9ne
May 19 2017 03:57
let me try to log this
priyanka bhalla
@priyanka-bhalla
May 19 2017 03:57

function golfScore(par, strokes) {
// Only change code below this line

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

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

golfScore(4, 1) should return "Hole-in-one!"
golfScore(4, 2) should return "Eagle"
golfScore(5, 2) should return "Eagle"
golfScore(4, 3) should return "Birdie"
golfScore(4, 4) should return "Par"
golfScore(1, 1) should return "Hole-in-one!"
golfScore(5, 5) should return "Par"
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"
please tell me how to solve it by busing if else statement
arrozconfrijoles
@arrozconfrijoles
May 19 2017 03:59
@priyanka-bhalla I used the strokes - par to make a complex if else thing
priyanka bhalla
@priyanka-bhalla
May 19 2017 04:00
but how
please give me the example
arrozconfrijoles
@arrozconfrijoles
May 19 2017 04:01
`if ( strokes - par == 0) {
zackn9ne
@zackn9ne
May 19 2017 04:01
here comes back with undefined
    var Carousel = {
        props: {
            current_slide: 1,
            total_slides: null
        },

        init: function () {
            console.log(`props verification ${Carousel.props.current_slides}`)
       //     Carousel.bindEvents();
            $('.carousel-cells article:first-of-type').addClass('first').addClass('active');
            $('.carousel-cells article:last-of-type').addClass('last');
        },
arrozconfrijoles
@arrozconfrijoles
May 19 2017 04:01
whoops
zackn9ne
@zackn9ne
May 19 2017 04:02
when i' expecting "1"
arrozconfrijoles
@arrozconfrijoles
May 19 2017 04:02
if (strokes - par == 0) { return "Par"; }
Netrunner21
@Netrunner21
May 19 2017 04:05
@mouthfullofgoldteeth I used a switch statement to add up the counts, and an if statement to return bet or hold based on the count.
zackn9ne
@zackn9ne
May 19 2017 04:06
oh duh misspelling
wooo
why props: though
what is "props"
and why did they set it to null?
brenbroussard
@brenbroussard
May 19 2017 04:07
@sinharaksh1t that's ok, i went away too to learn how to put this on a function AND no, i'm still lost πŸ™
zackn9ne
@zackn9ne
May 19 2017 04:07
what the hell are props
Long Nguyen
@longnt80
May 19 2017 04:09
@zackn9ne :point_up: May 19, 2017 11:07 AM
{
  current_slide: 1,
  total_slides: null
 },
rugano
@rugano
May 19 2017 04:09
@grotberg thank you,it finally toed the line,
CamperBot
@camperbot
May 19 2017 04:09
rugano sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
:cookie: 386 | @grotberg |http://www.freecodecamp.com/grotberg
zackn9ne
@zackn9ne
May 19 2017 04:09
@longnt80 what does it mean "props"
in computer science terms, why did they name this key "props"
inside of this object
Long Nguyen
@longnt80
May 19 2017 04:10
@zackn9ne not sure what you mean, props is just the key of the property
they could name it anything
zackn9ne
@zackn9ne
May 19 2017 04:10
what does props imply, is it any convention I am unaware of
Long Nguyen
@longnt80
May 19 2017 04:11
@zackn9ne just a name
zackn9ne
@zackn9ne
May 19 2017 04:11
immediatly following there is a key called init
which contains a funct
Long Nguyen
@longnt80
May 19 2017 04:11
they are names
zackn9ne
@zackn9ne
May 19 2017 04:11
so its a key with an object that sets variables?
eyesore-
@eyesore-
May 19 2017 04:11
@zackn9ne Are you using React?
zackn9ne
@zackn9ne
May 19 2017 04:11
no thats the wierd part
Long Nguyen
@longnt80
May 19 2017 04:12
what's the weird part?
zackn9ne
@zackn9ne
May 19 2017 04:12
that im not using React
i think props is a convention in React
priyanka bhalla
@priyanka-bhalla
May 19 2017 04:13

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

}
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);
its not working please help me to solve errors

zackn9ne
@zackn9ne
May 19 2017 04:13
current_slide: 1
is the same as
let current_slide = 1
?
aka is it setting a variable?
arrozconfrijoles
@arrozconfrijoles
May 19 2017 04:15
@priyanka-bhalla you need to do if else statements
Long Nguyen
@longnt80
May 19 2017 04:15
I don't know React so yeah props could be a variable
arrozconfrijoles
@arrozconfrijoles
May 19 2017 04:15
if...
if else...
if else...
else...
Long Nguyen
@longnt80
May 19 2017 04:16
no it's
if...
else if..
else
brenbroussard
@brenbroussard
May 19 2017 04:17
@sinharaksh1t thanks for trying to help. I'll have to get back to it tomorrow night 😜
CamperBot
@camperbot
May 19 2017 04:17
brenbroussard sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @sinharaksh1t |http://www.freecodecamp.com/sinharaksh1t
zackn9ne
@zackn9ne
May 19 2017 04:20
oh kewl
JavaScript does not have "methods" in the form that class-based languages define them. In JavaScript, any function can be added to an object in the form of a property. An inherited function acts just as any other property, including property shadowing as shown above (in this case, a form of method overriding).
Anurag Lahon
@anuraglahon16
May 19 2017 04:20
Have anyone solve the steam roller problem...is i have to use some slice
zackn9ne
@zackn9ne
May 19 2017 04:21

that was a junky paste hold on

"JavaScript does not have "methods" in the form that class-based languages define them. In JavaScript, any function can be added to an object in the form of a property. An inherited function acts just as any other property, including property shadowing as shown above (in this case, a form of method overriding)."

-> best part here -> In JavaScript, any function can be added to an object in the form of a property.
Masaki
@masaki1223
May 19 2017 04:22

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  function replacer(match, p1,offset, string){
   return '-'+p1.toLowerCase();
  }
  str=str.replace(/(_)/g,'-').replace(/(\s)/g,'-').replace(/([A-Z])/g, replacer);
  return str;
}

spinalCase('AllThe-small Things');
Please help me solve this problem...
zackn9ne
@zackn9ne
May 19 2017 04:22
aka next: function () {
aka funcName: function() { do stuff },
Anurag Lahon
@anuraglahon16
May 19 2017 04:22
@masaki1223 which challenge?
eyesore-
@eyesore-
May 19 2017 04:22
@zackn9ne Yeah man, that's what we were trying to tell you. What language are you coming from?
priyanka bhalla
@priyanka-bhalla
May 19 2017 04:23

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

}
// Only change code above this line
}

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

zackn9ne
@zackn9ne
May 19 2017 04:23
@eyesore- i suck at ruby but i learned it 1st
doubt they have objects containing methods
Anurag Lahon
@anuraglahon16
May 19 2017 04:23
@priyanka-bhalla i think u should use break
zackn9ne
@zackn9ne
May 19 2017 04:24
@eyesore- what problem does having objects in methods solve?
..er methods in objects
priyanka bhalla
@priyanka-bhalla
May 19 2017 04:24
not working
Masaki
@masaki1223
May 19 2017 04:25
@anuraglahon16 I'm on Spinal Tap Case right now
priyanka bhalla
@priyanka-bhalla
May 19 2017 04:25
i think break always used in switch statement
Anurag Lahon
@anuraglahon16
May 19 2017 04:26
@masaki1223 you should remove the spaces using split and then join it
eyesore-
@eyesore-
May 19 2017 04:26
@zackn9ne Yeah, in ruby it is handled different. When you are using Array methods. Those are functions in an object.
Rick Riggs
@wikiwiggs
May 19 2017 04:31
@priyanka-bhalla your birdie statement is wrong
@zackn9ne Think of methods as a tailored set of functions that work specifically for the nature of the design of your object.
RakeshNerkar
@Rakesh18754
May 19 2017 04:34
Is Object.getPrototypeOf(O) and proto are the same thing?
Aditya
@ezioda004
May 19 2017 04:34
@priyanka-bhalla Re read your code and the list of stroke they provided, fix it accordingly and stick to the sequence in the given list, also watch for < > operator.
minhsphuc12
@minhsphuc12
May 19 2017 04:34
In this challenge, how can I gather all remaining arguments into one array? https://www.freecodecamp.com/challenges/seek-and-destroy
function destroyer(arr) {
  // Remove all the values
  var survive = [];
  var deleter = Array.from(arguments).splice(0,1);

  for (var i=0;i<arr.length;i++) {
    if (deleter.indexOf(arr[i]) === -1) {
      survive.push(arr[i]);
    }
  }
  return survive;
}
destroyer([1, 2], 2);
RakeshNerkar
@Rakesh18754
May 19 2017 04:34
Is Object.getPrototypeOf(O) and __proto__
are the same thing?
Rick Riggs
@wikiwiggs
May 19 2017 04:36
@Rakesh18754 __proto__ is deprecated, don't use it unless you have old code that relys on it
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto
Mukul Agrawal
@mukul09
May 19 2017 04:36
is this the best way to find the longest word in a string
function findLongestWord(str) {
  var count=0;
  var array=str.split(" ");
  var l=array.length;
  for(var i=0;i<l;i++)
    {
      var tempArray=array[i];
      var newArray=tempArray.split("");
         if(count<newArray.length)
           count=newArray.length;

    }
  return count;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
zackn9ne
@zackn9ne
May 19 2017 04:38
Ilet Carousel = { a: 2, slideWidth: $('article').width(),
Rick Riggs
@wikiwiggs
May 19 2017 04:38
@mukul09 So you got the split part down good, I would use reduce to tighten up the code though, but there is nothing wrong with this.
zackn9ne
@zackn9ne
May 19 2017 04:39
in the above situation it does NOT like me trying to access slideWidth
Rick Riggs
@wikiwiggs
May 19 2017 04:40
@zackn9ne are you doing this in the browser or in a Node.js instance
zackn9ne
@zackn9ne
May 19 2017 04:40
browser
Rick Riggs
@wikiwiggs
May 19 2017 04:40
@zackn9ne What browser?
zackn9ne
@zackn9ne
May 19 2017 04:40
i can access this.a to access a
but when its a jQuery , maybe i gotta set it to a variable first in the object value
Tony
@nastex21
May 19 2017 04:42
I'm utterly hopeless when it comes to the reduce method, like I get the gist of it but using it for advance problems (I'm on Pairwise problem in the Advanced Algorithm Scripting) makes my head spin. Does anyone have resources on helping me with reduce method that isn't the Mozilla link? I feel like just using nested for loops for it and avoid using reduce.
Rick Riggs
@wikiwiggs
May 19 2017 04:43
@zackn9ne Yeah I would try that first.
@nastex21 I can get into a private message session with you, so we don't spam the room with code.
eyesore-
@eyesore-
May 19 2017 04:45
@nastex21 If you understand the basics, but want to really know the insides and outs I would suggest to reimplement your own reduce so you can know how it all works. If you'd like I can send you a serious of tests so you can try to implement reduce from scratch.
Rakshit Sinha
@sinharaksh1t
May 19 2017 04:46
@brenbroussard haha great! hope it helps!
I was working on chunky monkey question on basic js algorithms section. the only way that I see to solve it is by using two loops which i really dont wanna use.
there should be a way to solve it without using two loops right?
Rick Riggs
@wikiwiggs
May 19 2017 04:48
@nastex21 I just finished that exercise today myself, and I used reduce twice on it. Definitely a good way to go.
Rakshit Sinha
@sinharaksh1t
May 19 2017 04:48
I am not trying to ask the solution, just trying to see that i am moving forward in the right direction or not
Tony
@nastex21
May 19 2017 04:49
@eyesore- Yes send me those tests if you can. I would greatly appreciate it.
eyesore-
@eyesore-
May 19 2017 04:51
@nastex21 Yeah, let me write it up. Let me finish this chapter in Injustice first.
brenbroussard
@brenbroussard
May 19 2017 04:53
@sinharaksh1t i have only worked thru the 50+ lessons in javascript this past week. That's my entire experience in coding while keeping a 70 hour work week πŸ˜–
Rakshit Sinha
@sinharaksh1t
May 19 2017 04:54
@brenbroussard ah, that's not too bad as long as you do it everyday
brenbroussard
@brenbroussard
May 19 2017 04:55
@sinharaksh1t And it hasen't covered looping yet, so it shouldn't need it. Should only need the knowledge covered thus far in freecodecamp javascript
Rakshit Sinha
@sinharaksh1t
May 19 2017 04:55
which one are you talking about?
Idrees
@Idrees5
May 19 2017 04:55
my problem is that i start and then stop then start again
Rakshit Sinha
@sinharaksh1t
May 19 2017 04:56
@Idrees5 try to use pomodoro technique and try to sit at least one sitting per day.. you will probably eventually get in the habit

I finally managed to come up with a solution using one loop but that's it. not better..

I was working on chunky monkey question on basic js algorithms section. the only way that I see to solve it is by using two loops which i really dont wanna use.
there should be a way to solve it without using two loops right?

brenbroussard
@brenbroussard
May 19 2017 04:57
@sinharaksh1t i started in Basic Javascript and on lesson 55 or 56
Idrees
@Idrees5
May 19 2017 04:57
Thanks Rakshit, I will look into it. It's mainly because of my work and family schedule but hey i'll get through it!
Rakshit Sinha
@sinharaksh1t
May 19 2017 04:58
Yeah! keep the momentum going!! :D @Idrees5
@brenbroussard oh all right
brenbroussard
@brenbroussard
May 19 2017 04:58
Its called "stand in line"
Rakshit Sinha
@sinharaksh1t
May 19 2017 04:59
awesome , keep going! @brenbroussard
brenbroussard
@brenbroussard
May 19 2017 05:00
@sinharaksh1t thanks Rakshit!!! I hope to figure this out by tomorrow so I can move o πŸ˜€πŸ‘
CamperBot
@camperbot
May 19 2017 05:00
brenbroussard sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:warning: brenbroussard already gave sinharaksh1t points
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:02
@brenbroussard yeah! hit me up if you get stuck! happy to help
priyanka bhalla
@priyanka-bhalla
May 19 2017 05:08

function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch(val)
{
case 1:
answer = "Marley";
break;
case 2:
answer = "The Answer";
break;
case 3:
answer = "There is no #1";
break;
case 4:
answer = "Missed me by this much!";
break;
case 5:
answer = "Ate Nine";
break;
default:
answer ="empty string";
break;
}

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

// Change this value to test
chainToSwitch(7);

chainToSwitch("bob") should be "Marley"
chainToSwitch(42) should be "The Answer"
chainToSwitch(1) should be "There is no #1"
chainToSwitch(99) should be "Missed me by this much!"
chainToSwitch(7) should be "Ate Nine"
chainToSwitch("John") should be "" (empty string)
chainToSwitch(156) should be "" (empty string)
having error

help please
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:10
your case is wrong
all the cases are wrong in fact
make sure your cases have the appropriate values
Masaki
@masaki1223
May 19 2017 05:14

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

  function replacer(p1){
    if(p1===str[0][0]){
    return p1.toLowerCase();
    }
    else{
    return '-'+p1.toLowerCase();
  }}
  function replacer1(p1){
    if(p1===str[0][0]){
      return p1;
    }
    else if(p1===str[i][0]){
      return '-'+p1;
    } else {
      return p1;
  }}

 str= str.split(' ');
  var newArr=[];
  for(var i=0; i<str.length; i++){

  newArr.push(str[i].replace(/_/g, '').replace(/([a-z])/g,replacer1).
              replace(/([A-Z])/g,replacer));
  }
  return newArr.join('');

}

spinalCase('This Is Spinal Tap');
In this code, because str[0][0] is T, Tap's T would return p1.toLowerCase()...
How can I fix this?
Im on Spinal Tap Case challenge
brenbroussard
@brenbroussard
May 19 2017 05:18

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

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

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

@
@
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:19
@brenbroussard in your nextInLine function, check the value of item. there isn't any. you have to initialise the value of the item to arr.shift();
brenbroussard
@brenbroussard
May 19 2017 05:20
This g0t 2 of 4 tests oasswx
tests passed
Sanskar Gupta
@sanskar752000
May 19 2017 05:21
please help me I am stuck with the problem of word Blanks in Java scripts course
lagasi
@lagasi
May 19 2017 05:21
@brenbroussard You need to return what was shifted out, not the item
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:21
@lagasi @brenbroussard you have to return item itself but before doing that you need to change the value of the item. change it once you push it
arr.push(item);
item=arr.shift();
return item;
brenbroussard
@brenbroussard
May 19 2017 05:22
Item = 6;
Sanskar Gupta
@sanskar752000
May 19 2017 05:22

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

// Your code above this line
return result;
}

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

brenbroussard
@brenbroussard
May 19 2017 05:22
Ok
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:23
@sanskar752000 what's the error?
Sanskar Gupta
@sanskar752000
May 19 2017 05:23
how I can solve this world Blank problem
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:23
@brenbroussard did you get it right this time?
lagasi
@lagasi
May 19 2017 05:23
@sinharaksh1t @brenbroussard that's not necessary just return arr.shift()
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:24
@lagasi yeah, same thing
Sanskar Gupta
@sanskar752000
May 19 2017 05:24
@sinharaksh1t I am getting trouble solving this.
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:24
I mean i meant the same
@sanskar752000 what's the error
?
lagasi
@lagasi
May 19 2017 05:24
@sinharaksh1t Yes, but it's not good to change the input
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:25
@lagasi gotcha boss!
Sanskar Gupta
@sanskar752000
May 19 2017 05:26
@sinharaksh1t what to do in this problem
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:26
initialise the variable result to the 4 arguments in the correct order using + opreator
*operator
Sanskar Gupta
@sanskar752000
May 19 2017 05:27
can you please solve it for me @sinharaksh1t
brenbroussard
@brenbroussard
May 19 2017 05:27
It worked!!! But i don't get why i didn't have to give a value like
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:28
at the end, result should have "big dog ran quickly" @sanskar752000
brenbroussard
@brenbroussard
May 19 2017 05:28
item = item + 1
Fabian Ifionu
@fabestine1
May 19 2017 05:28
hello guys, someone asked me to help him edit his website, what do I need to do that. Please help
Sanskar Gupta
@sanskar752000
May 19 2017 05:28
ohh!! I got it thanks @sinharaksh1t
CamperBot
@camperbot
May 19 2017 05:28
sanskar752000 sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @sinharaksh1t |http://www.freecodecamp.com/sinharaksh1t
brenbroussard
@brenbroussard
May 19 2017 05:28
or item = 6
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:28

@brenbroussard huh?

item = item + 1

@sanskar752000 you're welcome
Fabian Ifionu
@fabestine1
May 19 2017 05:30
@sanskar752000 @brenbroussard cab u help me
hello guys, someone asked me to help him edit his website, what do I need to do that. Please help
brenbroussard
@brenbroussard
May 19 2017 05:30
I was thinking that since my order in the array was in numerical order, then i should add a 1 each time the funtiin is called ... ive got a lot to ke
learn. Thanks so much and goodnight πŸ˜‰
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:31
sure! anytime
goodnight :D
@fabestine1 can you elaborate on what you're asking for?
Fabian Ifionu
@fabestine1
May 19 2017 05:33
i friend called me and said there are things he wants to change in his website and asked if I can help me to edit the site
what do I need to do this
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:33
what changes do you want to make?
you're question is pretty vague man
Fabian Ifionu
@fabestine1
May 19 2017 05:34
this is thw website: http://www.menyiwacu.com/
there are mistakes he wants to be corrected
Sanskar Gupta
@sanskar752000
May 19 2017 05:36
@sinharaksh1t sir it still not getting solved.... it is showing an error
Fabian Ifionu
@fabestine1
May 19 2017 05:36
like in the header there is a img address under the Advert at the top left hand said
side
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:36
@fabestine1 you need to edit in the source code of the website,
@sanskar752000 show your code
Sanskar Gupta
@sanskar752000
May 19 2017 05:37

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

result = "dog, " + " big, " + " ran, " + " quickly";
// Your code above this line
return result;
}

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

Fabian Ifionu
@fabestine1
May 19 2017 05:37
the side is not mine, so I have to ask him for the code
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:38
@sanskar752000 use the variables in the function argument man
@fabestine1 yes
Sanskar Gupta
@sanskar752000
May 19 2017 05:39
can you please show how it's done I'm new in this @sinharaksh1t
I am still learning
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:40
okay
so do you know what are function arguments?
myNoun, myAdjective etc are called function arguments
Sanskar Gupta
@sanskar752000
May 19 2017 05:41
ok
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:41
so they store the values which are passed in paranthesis during function call
Sanskar Gupta
@sanskar752000
May 19 2017 05:42
yep!!
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:42

wordBlanks("dog", "big", "ran", "quickly");

this line is the function call

Sanskar Gupta
@sanskar752000
May 19 2017 05:42
hmm
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:42
so now myNoun = "dog"
myAdjective = "big"
and so on
you can also write
var newString = myNoun+myAdjective;
this will output dogbig
now it should be clear to you how to output "big dog ran quickly" in result
Sanskar Gupta
@sanskar752000
May 19 2017 05:44
ohh!
I got it and I'm going to give a try
priyanka bhalla
@priyanka-bhalla
May 19 2017 05:45
chainToSwitch("bob") should be "Marley"
chainToSwitch(42) should be "The Answer"
chainToSwitch(1) should be "There is no #1"
chainToSwitch(99) should be "Missed me by this much!"
chainToSwitch(7) should be "Ate Nine"
chainToSwitch("John") should be "" (empty string)
chainToSwitch(156) should be "" (empty string)
case is wrong could u please explain me whats wrong with this

function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch(val)
{
case 1:
answer = "Marley";
break;
case 2:
answer = "The Answer";
break;
case 3:
answer = "There is no #1";
break;
case 4:
answer = "Missed me by this much!";
break;
case 5:
answer = "Ate Nine";
break;
default:
answer ="empty string";
break;
}

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

// Change this value to test
chainToSwitch(7);

Rakshit Sinha
@sinharaksh1t
May 19 2017 05:46
@sanskar752000 great! let me know if that helps
@priyanka-bhalla check your case values
Masaki
@masaki1223
May 19 2017 05:49

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
 str= str.split(' ');
  var newArr=[];

  function replacer(p1){
    if(p1===str[0][0]){
    return p1.toLowerCase();
    }
    else{
    return '-'+p1.toLowerCase();
  }}

  function replacer1(p1){
    if(p1===str[0][0]){
      return p1;
    }
    else if(p1===str[i][0]){
      return '-'+p1;
    } else {
      return p1;
  }}



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

  newArr.push(str[i].replace(/_/g, '').replace(/([a-z])/g,replacer1).
              replace(/([A-Z])/g,replacer));
  }
  return newArr.join('');

}

spinalCase('This Is Spinal Tap');
Please help me...
Sanskar Gupta
@sanskar752000
May 19 2017 05:55
no sir it didn't help out
@sinharaksh1t it is showing this: wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib)
Rakshit Sinha
@sinharaksh1t
May 19 2017 05:56
@sanskar752000 code?
Sanskar Gupta
@sanskar752000
May 19 2017 05:57
one sec @sinharaksh1t

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

var newStr = "Noun " + " myAdjective " + " myVerb " + " myAdverb";
result = "dog, " + " big, " + " ran, " + " quickly";
// Your code above this line
return result;
}

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

Rakshit Sinha
@sinharaksh1t
May 19 2017 06:00
@sanskar752000 this is all you need to do:
result=myAdjective+" "+myNoun+", "+myVerb+" "+myAdverb;
Sanskar Gupta
@sanskar752000
May 19 2017 06:01
ok I'm trying @sinharaksh1t
still not worked out
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:04
code:?
Sanskar Gupta
@sanskar752000
May 19 2017 06:05
sorry I am giving trouble to u @sinharaksh1t
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:05
it's all right, as long as it helps
Sanskar Gupta
@sanskar752000
May 19 2017 06:05

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

result = "Noun+"," +myAdjective+ "," +myVerb+ "," +myAdverb";
result = "dog, " + " big, " + " ran, " + " quickly";
// Your code above this line
return result;
}

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

Rakshit Sinha
@sinharaksh1t
May 19 2017 06:06
why have you assigned 2 values to result?
remove the first one
Sanskar Gupta
@sanskar752000
May 19 2017 06:06
ok
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:06
and you still havent changed your second line
check the solution i sent above
that's all that result needs to be equal to. what you are doing is incorrect

@sanskar752000 check this:

@sanskar752000 this is all you need to do:
result=myAdjective+" "+myNoun+", "+myVerb+" "+myAdverb;

Sanskar Gupta
@sanskar752000
May 19 2017 06:08
can please me give me full solution
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:08

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

// Your code above this line
return result;
}

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

Sanskar Gupta
@sanskar752000
May 19 2017 06:11
thanks a lot sir it has solved you're amazing thanks @sinharaksh1t
CamperBot
@camperbot
May 19 2017 06:11
sanskar752000 sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:warning: sanskar752000 already gave sinharaksh1t points
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:11
:+1:
Vicky Lai
@vickylai
May 19 2017 06:13
function addTogether(x) {
    return function makeSum(y) {
        return x + y;
    };
}
Can someone help me understand why addTogether(2)(3) returns 5, but addTogether(2,3) returns the inner function?
Sanskar Gupta
@sanskar752000
May 19 2017 06:13
can i get your pesonal number or anything to contact you for help ?? @sinharaksh1t
Aaron Bell
@awb715
May 19 2017 06:15
anyone have experience withthe freecodecamp bot?
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:16
@sanskar752000 You will more often than not find help here regardless of the time. You can also dm me directly if you want by using "chat privately" option.
I'd also suggest to keep all your questions to this forum because even if not many people seem active, there might be those who only read and not post anything who could be benefited by questions asked by others.
minhsphuc12
@minhsphuc12
May 19 2017 06:16
In this challenge, how can I gather all remaining arguments into one array? https://www.freecodecamp.com/challenges/seek-and-destroy
function destroyer(arr) {
  // Remove all the values
  var survive = [];
  var deleter = Array.from(arguments).splice(0,1);

  for (var i=0;i<arr.length;i++) {
    if (deleter.indexOf(arr[i]) === -1) {
      survive.push(arr[i]);
    }
  }
  return survive;
}
destroyer([1, 2], 2);
Sanskar Gupta
@sanskar752000
May 19 2017 06:17
right said!! @sinharaksh1t
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:19
@vickylaiio I'm not 100 % sure but I think it's because addTogether(2)(3) uses one argument for function one and second argument for the next function that's called in line.. whereas addTogether(x,y) doesn't exist, so it considers it as a single argument and gives the second function as the return value
@minhsphuc12
var args= Array.prototype.slice.call(arguments);
var args=[].slice.call(arguments);
Vicky Lai
@vickylai
May 19 2017 06:20
@sinharaksh1t Confirmed with arguments.length. Thanks!
CamperBot
@camperbot
May 19 2017 06:20
vickylaiio sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @sinharaksh1t |http://www.freecodecamp.com/sinharaksh1t
Qulu Mammadli
@qulu1
May 19 2017 06:21
hey Guys! i am doing "Check for Palindromes" algorithm scripting. Anyones knows how to match 2 arrays in js?
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:21
@vickylaiio what was the result with arguments.length ?
Vicky Lai
@vickylai
May 19 2017 06:21
@sinharaksh1t Wait, scratch that. My bad.
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:21
@qulu1 == operator works just fine
@vickylaiio ah,ok
Vicky Lai
@vickylai
May 19 2017 06:21
The length for (x, y) was 2.
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:21
as expected.
minhsphuc12
@minhsphuc12
May 19 2017 06:23
@sinharaksh1t solved it using slice. This challenge UI must have debug module, it is so critical.
function destroyer(arr) {
  // Remove all the values
  var survive = [];
  var argu = Array.from(arguments);
  var deleter =argu.slice(1,argu.length);

  for (var i=0;i<arr.length;i++) {
    if (deleter.indexOf(arr[i]) === -1) {
      survive.push(arr[i]);
    }
  }
  return survive;
}

destroyer([1, 2], 2);
@sinharaksh1t thanks
CamperBot
@camperbot
May 19 2017 06:23
minhsphuc12 sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @sinharaksh1t |http://www.freecodecamp.com/sinharaksh1t
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:24
@minhsphuc12 ah, awesome!
Qulu Mammadli
@qulu1
May 19 2017 06:25
@sinharaksh1t i splitted strings into arrays, they re different, but still gives true
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:28
@qulu1 my bad
what are you trying to compare again?
Qulu Mammadli
@qulu1
May 19 2017 06:29
@sinharaksh1t its okay mate, i just try to compare two arrays, so if they match, return true
var string = str.replace(/[\W_]+/g,"").toLowerCase().split("");
var reverseString = string.reverse();
if (string == reverseString) {
    console.log(true);
}else {
    console.log(false);
}
Masaki
@masaki1223
May 19 2017 06:33
str = str.replace(/([a-z])([A-Z])/g, '$1 $2');
What does this $1 and $2 mean?
minhsphuc12
@minhsphuc12
May 19 2017 06:34
@qulu1 your regex can be too simple. Have you passed that one?
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:34
@qulu1 console.log(JSON.stringify(a1)==JSON.stringify(a2));
can be used to check 2 arrays.
however, I'd suggest you to convert the arrays into strings using join() function and then simply compare using ==
@minhsphuc12 can be simpler than that?
Qulu Mammadli
@qulu1
May 19 2017 06:35
@minhsphuc12 yeap, it works just fine, i need to escape all all non-alphanumeric characters and spaces
@sinharaksh1t actually i didnt know i can compare 2 strings with that, its better way, thanks you :)
CamperBot
@camperbot
May 19 2017 06:35
qulu1 sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @sinharaksh1t |http://www.freecodecamp.com/sinharaksh1t
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:36
@qulu1 no problem
Qulu Mammadli
@qulu1
May 19 2017 06:37
anyone here completed whole front-end stuff?
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:38
Screen Shot 2017-05-19 at 2.37.24 AM.png
here you go @masaki1223
Vicky Lai
@vickylai
May 19 2017 06:39
If yall want a laugh, run this...

function addTogether(x) {
    function makeSum(y) {
        console.log('1');
        return x + y;
    };
    if (arguments.length == 2){
        console.log('2');
        if (Number.isInteger(arguments[0]) && Number.isInteger(arguments[1])) {
            console.log('3');
            return makeSum(arguments[0],arguments[1])
        }
    } else 
    if (arguments.length == 1){
        console.log('4');
        return makeSum(arguments[0])
    }
}

console.log('answer: ', addTogether(2, 3));
I think it's breaktime...
minhsphuc12
@minhsphuc12
May 19 2017 06:40
@sinharaksh1t no his regex is good
Rakshit Sinha
@sinharaksh1t
May 19 2017 06:41
@minhsphuc12 Yup! That's ideal. I used the same
Matt Flynn
@flynnwebdev
May 19 2017 06:51
Help games
minhsphuc12
@minhsphuc12
May 19 2017 07:02
@flynnwebdev what game?
Pieter Stokkink
@forkerino
May 19 2017 07:10
Good day!
@qulu1 I finished the front-end certificate. What do you want to know?
CamperBot
@camperbot
May 19 2017 07:11
:bulb: to format code use backticks! ``` more info
Mukul Agrawal
@mukul09
May 19 2017 07:13
@forkerino congo!!!
Pieter Stokkink
@forkerino
May 19 2017 07:14
congo?
Rakshit Sinha
@sinharaksh1t
May 19 2017 07:17
@forkerino he meant congratulations
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:17
morning
congrats for what?
Qulu Mammadli
@qulu1
May 19 2017 07:18
front end certificate i guess
Rakshit Sinha
@sinharaksh1t
May 19 2017 07:18
yeah
Nicolas MARTINHO
@NicolasMartinho
May 19 2017 07:18

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

function lookUpProfile(firstName, prop){
// Only change code below this line
var name ="";
var prp ="";
j = 1;
for (i=0;i<contacts.length;i++) {
  if (contacts[i].firstName == firstName) {
  name = contacts[i].firstName;
    j = i;
  } 
  switch (prop) {
   case "likes":
     prp = contacts[j].likes;
     break;
   case "number":
     prp = contacts[j].number;
     break;
   case "lastName":
     prp = contacts[j].lastName;
     break;
 }
}
if (name !== "" && prp !== "") {
  return prp;
}
else if (name !== "" && prp === "") {
  return "No such property";
}
else {
  return "No such contact";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes")
Hello guys, my code works but it seems a bit clumsy, how can I improve it ? It should display the value of the property input if it exists
Pieter Stokkink
@forkerino
May 19 2017 07:19
@sinharaksh1t @mukul09 ah ok, it was months ago, so missed the connection.
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:21
@forkerino how goes it?
Pieter Stokkink
@forkerino
May 19 2017 07:21
@NicolasMartinho Yes, there is a lot of things you can do to improve it. One of the best things you can do is to make a check if the contact has the property inside your if (nest another if inside), and use the variable to access the property value (instead of creating a whole switch block for all cases, imagine what would happen if your objects have 200 properties!).
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:22
working in the chat bot?
Pieter Stokkink
@forkerino
May 19 2017 07:23
@HeebieGeeBee ok ok I've looked into it a bit. It is cool, but I want to finish my homework for an online course on algorithms first.
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:23
oh ok
Rakshit Sinha
@sinharaksh1t
May 19 2017 07:25
@NicolasMartinho this was my solution in case you wanna have a look at this:
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0;i<contacts.length;i++) {
if(contacts[i].firstName == firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
return "No such property";
}
}
return "No such contact";
// Only change code above this line
}
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:26
@forkerino https://heebiegeebee.github.io/JS_Arkanoid_Clone/ been working on this, just trying to get some controls working with mobile
Nicolas MARTINHO
@NicolasMartinho
May 19 2017 07:27
@sinharaksh1t I was totally forgetting the .hasOwnProperty() ! thx a lot ^^
CamperBot
@camperbot
May 19 2017 07:27
nicolasmartinho sends brownie points to @sinharaksh1t :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @sinharaksh1t |http://www.freecodecamp.com/sinharaksh1t
Pieter Stokkink
@forkerino
May 19 2017 07:28
@HeebieGeeBee Nice! I'm getting flashbacks!
Rakshit Sinha
@sinharaksh1t
May 19 2017 07:28
@NicolasMartinho no prob
gerome0123
@gerome0123
May 19 2017 07:28
s possible to view a word document in html???
s possible to view a word document in html???
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:28
@forkerino lol
Elvis Knapman
@mksoftworks
May 19 2017 07:34
so does the this keyword make everything in the object public? and not using it makes the variables and such private?
Rakshit Sinha
@sinharaksh1t
May 19 2017 07:34
when doing this inside the constructor , yes
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:34
its not the this that makes the variables global
its because youre not declaring it with var or let
Xarri Jorge
@xarrijorge
May 19 2017 07:35
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:35
but the this points to the instance of the constructor
Xarri Jorge
@xarrijorge
May 19 2017 07:35
@mksoftworks or read javascript enlightenment
Elvis Knapman
@mksoftworks
May 19 2017 07:36
@HeebieGeeBee I get global and local, but I'm talking private. Or are private and local meant as the same here?
thanks @kodinglife
CamperBot
@camperbot
May 19 2017 07:36
mksoftworks sends brownie points to @kodinglife :sparkles: :thumbsup: :sparkles:
:cookie: 378 | @kodinglife |http://www.freecodecamp.com/kodinglife
Elvis Knapman
@mksoftworks
May 19 2017 07:37
also, isn't this used as determining what variable you are referencing? What I mean is, say you have an argument passes with same name as your object property, wouldn't this identify it to the program as your object property
Markus Kiili
@Masd925
May 19 2017 07:38
@mksoftworks When you use a constructor to make a new object new constr(); the engine makes a new plain object {} and puts it as value of this when the constructor code is run, and returns it at the end. So new is a special way to execute a function. Those properties defined inside the constructor with this.propName=... become properties of the new object.
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:39
@Masd925 yo
Markus Kiili
@Masd925
May 19 2017 07:39
@HeebieGeeBee Hello.
Pieter Stokkink
@forkerino
May 19 2017 07:40
@Masd925 :wave:
Xarri Jorge
@xarrijorge
May 19 2017 07:41
@mksoftworks Yeah, private is local. There is no defined private variable in the documentation.
Elvis Knapman
@mksoftworks
May 19 2017 07:41
new is just executing the constructor to create the instance of the object, correct?
Markus Kiili
@Masd925
May 19 2017 07:41
@forkerino Yo.
gerome0123
@gerome0123
May 19 2017 07:41
how to view html tag using href?
how to view html tag using href?
how to view html tag using href?
Markus Kiili
@Masd925
May 19 2017 07:42
@mksoftworks Yes, there is something special going on there as I described when you use new.
Elvis Knapman
@mksoftworks
May 19 2017 07:43
@Masd925 I don't think it's special, per se, it's just creating a new object instance then using the constructor to set it up.
Markus Kiili
@Masd925
May 19 2017 07:43
@mksoftworks I just mean that it differs from normal function call. What happens internally.
Kevin Gong
@kevingong1995
May 19 2017 07:44

Hi guys, I need help with the profile look up assignment. Can anyone point me to which part im doing wrong?

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

Elvis Knapman
@mksoftworks
May 19 2017 07:44
@Masd925 I was asking about this because I come from a bit of a Java background, and yes, I know the 2 aren't related, but this keyword in Java was mainly used to select your object variable
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:45
@kevingong1995 first prop is a variable
so cant use dot notation with it
secondly the logic for the second if statements is kinda wrong i feel
Elvis Knapman
@mksoftworks
May 19 2017 07:46
@kevingong1995 I went through a similar thing, Your if statements at the bottom are only searching through the first contact then finishing, rather than all. Also it's
return contacts[i][prop];
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:47
@kevingong1995 seems to me no such propertly needs to beinside the loop
Kevin Gong
@kevingong1995
May 19 2017 07:48
wouldnt that if statement be outside my while loop because once its out of the loop, i am technically done looking through the contacts?
HeebieGeeBee
@HeebieGeeBee
May 19 2017 07:48
and only returned if theres a firstname match, but that match doesnt also have the prop property
@kevingong1995 you return no such property if theres a first name match, but that match doesnt have the property
how are you going to know if theres a first name match after the loop?
Elvis Knapman
@mksoftworks
May 19 2017 07:49
@kevingong1995 that first if statement after the loop will only check last record, if I'm not mistaken, because the count variable will already be incremented to the last number
@kevingong1995 it has to be in the loop, then you can leave the No such contact outside of the loop but within function
@kevingong1995 also your if statements dont even have braces
Kevin Gong
@kevingong1995
May 19 2017 07:53
i dont think if statements really need braces if there is just one line of method
Elvis Knapman
@mksoftworks
May 19 2017 07:53
@kevingong1995 make sure once you get your condition checks in the loop, you don't increment the count until AFTER the checks, that way all checks are done on each iteration
Markus Kiili
@Masd925
May 19 2017 07:53
@mksoftworks Yes, in java this always points to the current instance. In JS it is better to think about this as a variable on the function execution context (similar to arguments variable). Its value depends on how the function was called. Only in the case of function called as a method, this points to the calling object (there are around 7 other cases there).
Elvis Knapman
@mksoftworks
May 19 2017 07:55
@kevingong1995 I'm just trying to help, it's best practice to use them
Makopa
@makopa
May 19 2017 07:56
hi Good day campers :fire: why in react they always end the last property with a comma " , " ? is it suppose to be cause on of an error? here are the sample
{
title: 'React',
url: 'https://facebook.github.io/react/',
author: 'Jordan Walke',
num_comments: 3,
points: 4,
objectID: 0,
}
Victor Popescu
@VicPopescu
May 19 2017 07:57
@makopa maybe they delete properties and forget to delete the comma too
Makopa
@makopa
May 19 2017 07:57
@VicPopescu im reading a book on react. and they always doing it
Nir Tal
@nirtal85
May 19 2017 07:57
<code> test </test>
Makopa
@makopa
May 19 2017 07:58
@VicPopescu and it didnt cause an error too
Victor Popescu
@VicPopescu
May 19 2017 07:58
@makopa "To make copy&pasting easier"
@makopa but it's a bad practice, because browsers ignore it, doesn't mean it's correct
Makopa
@makopa
May 19 2017 07:58
@VicPopescu ow i see, cause as far as i remember, it can cause an error if im using normal plain javascript.
Pieter Stokkink
@forkerino
May 19 2017 07:59
@kevingong1995 they don't need braces but they improve readability a lot, and prevent bugs when you change your code. As does proper indentation. I only omit braces when I write everything on one line for a short if:
if (x == 0) return "zero"; for example.
Victor Popescu
@VicPopescu
May 19 2017 07:59
@makopa only IE on earlier version of JS will cause an error I think
Makopa
@makopa
May 19 2017 07:59
@VicPopescu oic! thanks victor for clarification and explanation! :+1:
CamperBot
@camperbot
May 19 2017 07:59
makopa sends brownie points to @vicpopescu :sparkles: :thumbsup: :sparkles:
:cookie: 412 | @vicpopescu |http://www.freecodecamp.com/vicpopescu
Victor Popescu
@VicPopescu
May 19 2017 07:59
@makopa but don't do that cuz its bad practice
Makopa
@makopa
May 19 2017 07:59
@VicPopescu ya noted!
Victor Popescu
@VicPopescu
May 19 2017 07:59
@makopa you're welcome
Markus Kiili
@Masd925
May 19 2017 08:00
JavaScript has allowed trailing commas in array literals since the beginning, and later added them to object literals (ECMAScript 5) and most recently (ECMAScript 2017) to function parameters.
Pieter Stokkink
@forkerino
May 19 2017 08:00
It is a problem with JSON, those trailing commas
HeebieGeeBee
@HeebieGeeBee
May 19 2017 08:00
why would they write in the ability to be able to have bad syntax?
Nir Tal
@nirtal85
May 19 2017 08:01
how do i highlight code?
HeebieGeeBee
@HeebieGeeBee
May 19 2017 08:02
between backticks
Pieter Stokkink
@forkerino
May 19 2017 08:02
@nirtal85 ''' more info below
CamperBot
@camperbot
May 19 2017 08:02
:bulb: to format code use backticks! ``` more info
Elvis Knapman
@mksoftworks
May 19 2017 08:03
@nirtal85 3 backticks, shift+enter to go down a line, put your code, then shift+enter and 3 more backticks
Makopa
@makopa
May 19 2017 08:03
i yea i remeber trailing commas cause error when i try to make an API JSON
Victor Popescu
@VicPopescu
May 19 2017 08:09

@Masd925 In ES3 specification:

ObjectLiteral :
    { }
    { PropertyNameAndValueList }

you sure that will allow it?

I know ES5 included it in specification too

ObjectLiteral :
    { }
    { PropertyNameAndValueList }
    { PropertyNameAndValueList , }

I guess depends on the browser too

Pieter Stokkink
@forkerino
May 19 2017 08:12
@VicPopescu I think that is precisely what he said.
Victor Popescu
@VicPopescu
May 19 2017 08:12
@forkerino it'ok then :))
Pieter Stokkink
@forkerino
May 19 2017 08:12
sure is
Ogundele Olumide
@Lumexralph
May 19 2017 08:16
@forkerino @HeebieGeeBee @Masd925 Good morning
Pieter Stokkink
@forkerino
May 19 2017 08:16
@Lumexralph Bro!
HeebieGeeBee
@HeebieGeeBee
May 19 2017 08:17
@Lumexralph morning