These are chat archives for FreeCodeCamp/HelpJavaScript

12th
May 2017
Carson Hanel
@chingy1510
May 12 2017 00:00
Anyone know about problem 216? It's the profile lookup with lists. I'm trying to figure out what it's wanting. Do I need for-loops to verify the data in the list, or is there an implicit function in jav.
java?*
hannah
@damchu
May 12 2017 00:01
ahh
i still dont rlly get it
Carson Hanel
@chingy1510
May 12 2017 00:01
It's to make code cleaner.
hannah
@damchu
May 12 2017 00:01
ive gotten the titlecase one done
Carson Hanel
@chingy1510
May 12 2017 00:01
rather than having random variable names with crazy capitalization, it's a common practice to either capitalize the first letter of every word, or underscore in lieu of spaces.
The underscore is more commonly used in C++ and larger settings, while the camel case is more generally accepted a way to portray variable names with multiple words.
In the assignment, all you were required to do was to convert the given variable names into accepted camel case.
Caleb Brenner
@cwborion
May 12 2017 00:04
having trouble with 'Using Objects for Lookups' challenge. This is what I have so far. Any hints?
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
    Adams: "alpha",
    Boston: "bravo",
    Chicago: "charlie",
    Denver: "delta",
    Easy: "echo",
    Frank: "foxtrot"
  };

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

// Change this value to test
phoneticLookup("charlie");
Manish Giri
@Manish-Giri
May 12 2017 00:06
@cwborion return result;
this still returns an empty string
look at the examples shown
hannah
@damchu
May 12 2017 00:06
oh whoops
Manish Giri
@Manish-Giri
May 12 2017 00:06
assign the value of the property val to result
hannah
@damchu
May 12 2017 00:06
realised i wasnt editing the assignments
Stephen James
@sjames1958gm
May 12 2017 00:08
@chingy1510 You need a loop for the array , then test each contact looking for the matching firstName
Caleb Brenner
@cwborion
May 12 2017 00:09
@Manish-Giri are you sure that isn't part of the code that isn't supposed to be changed?
Manish Giri
@Manish-Giri
May 12 2017 00:09
@cwborion yeah am pretty sure
besides
what is this?
 // Only change code below this line
    Adams: "alpha",
    Boston: "bravo",
    Chicago: "charlie",
    Denver: "delta",
    Easy: "echo",
    Frank: "foxtrot"
  };
is this is meant to be an object, where's the opening {
and the variable?
Caleb Brenner
@cwborion
May 12 2017 00:10
@Manish-Giri isn't it all prewritten above in the "do not change" part?
that's why I'm confused as to how or where to implement them cause they're already there but noted to not change
Manish Giri
@Manish-Giri
May 12 2017 00:11
I'm not referring to the variable declaration
leave that there
you can assign to the variable between the comments provided
Caleb Brenner
@cwborion
May 12 2017 00:11
if I'm supposed to add more, it wasn't covered in any of the previous lessons. The example is much more vague than what the exercise asks
Manish Giri
@Manish-Giri
May 12 2017 00:11
// Only change code below this line
   1. create lookup object
   2. assign to result

  // Only change code above this line
t0cc
@t0cc
May 12 2017 00:12
Manish-Giri: url?
Manish Giri
@Manish-Giri
May 12 2017 00:12
the examples in the challenge cover everything you need for this problem
Carson Hanel
@chingy1510
May 12 2017 00:12
@sjames1958gm I got the test of the name down. I formatted the 'if' statement for the property as something like if(contacts[i].prop !== undefined), but I should've done if(contacts[i][prop] !== undefined)
It ended up working.
Stephen James
@sjames1958gm
May 12 2017 00:13
@chingy1510 :+1:
Caleb Brenner
@cwborion
May 12 2017 00:13
then why is there a function and a 'return' in the exercise, but not the example? I'm confused as to how they are the same if the setup's syntax isn't the same as in the example
@Manish-Giri
Carson Hanel
@chingy1510
May 12 2017 00:14
@cwborion you're working with lists.
Er, obviously.
But the function (as far as I remember) is to return some specific list value.
Wisdom Peters
@blackcytographer
May 12 2017 00:14
hey guys please what kidda seems to be wrong with this code. var myStr; // Change this line
myStr = "I am a \"double qouted\" string inside \"double quotes\".";
Manish Giri
@Manish-Giri
May 12 2017 00:14
@cwborion well you can't expect the examples to cover every single thing do you?
they show you how to get a value from an object, which is all you need
and as for the return statement, you can completely ignore it and still pass the challenge
Carson Hanel
@chingy1510
May 12 2017 00:15
Just think of it in the context of scope. If you're using a function to do any work, you HAVE to either return it to main, or assign the result to a global variable.
Wisdom Peters
@blackcytographer
May 12 2017 00:15
@Manish-Giri sup guy pls i need help with this. var myStr; // Change this line
myStr = "I am a \"double qouted\" string inside \"double quotes\".";
Carson Hanel
@chingy1510
May 12 2017 00:15
And yeah, you can ignore it but it's generally good practice to use proper syntax.
@blackcytographer what are the instructions for your particular assignment?
Caleb Brenner
@cwborion
May 12 2017 00:16
@Manish-Giri no, but I would expect them to be similar enough to have an idea as to how it would get written in. As far as the example is concerned, I've pretty much mimicked it but with the information from the exercise.
Stephen James
@sjames1958gm
May 12 2017 00:16
@blackcytographer qouted should be quoted
Manish Giri
@Manish-Giri
May 12 2017 00:16
@blackcytographer what's the problem?
Wisdom Peters
@blackcytographer
May 12 2017 00:17
@sjames1958gm oh thanks my bad
CamperBot
@camperbot
May 12 2017 00:17
blackcytographer sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7250 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sergii
@Doomkrat
May 12 2017 00:17
var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split("string");
You should split the string by its spaces
Wisdom Peters
@blackcytographer
May 12 2017 00:17
@Manish-Giri sup guy i just solve the issue
Stephen James
@sjames1958gm
May 12 2017 00:17
@Doomkrat "string" is not spaces - the value you pass to split is the value on which split divides the string
Caleb Brenner
@cwborion
May 12 2017 00:17
that's why I'm stuck. I wrote it out the way the example would suggest based off of what I'm given, but apparently there is more to be added. I just don't know how I'd know what else needs to be added without an example that is more similar @Manish-Giri
Manish Giri
@Manish-Giri
May 12 2017 00:17
@cwborion can you post your challenge URL here?
Sergii
@Doomkrat
May 12 2017 00:17
@sjames1958gm delete spaces?
Stephen James
@sjames1958gm
May 12 2017 00:18
@Doomkrat Pass " " to split not "string"
Matt Green
@mattxgreen
May 12 2017 00:18
@Doomkrat Where you have the "string" is where you put the character you want to split by
Manish Giri
@Manish-Giri
May 12 2017 00:18
@cwborion did you see this?
var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
this was their example

you say

I wrote it out the way the example would suggest based off of what I'm given,

yet your code has

 // Only change code below this line
    Adams: "alpha",
    Boston: "bravo",
    Chicago: "charlie",
    Denver: "delta",
    Easy: "echo",
    Frank: "foxtrot"
  };
Dbakk
@Dbakk
May 12 2017 00:19
Return Early Pattern for Functions, what am I supposed to do here
Manish Giri
@Manish-Giri
May 12 2017 00:19
there's no variable name, and there's no opening { for the object either
anhtm
@anhtm
May 12 2017 00:19
Hi im on Escape Sequence in Strings Javascript tutorial
Caleb Brenner
@cwborion
May 12 2017 00:19
@Manish-Giri yes, because as far as what I can see, that is taking the information from my exercise and writing it in the same format as the information in the example. Do you see why I may think that that is how it should be input?
Dbakk
@Dbakk
May 12 2017 00:19
the exampl is console.log and return , but then the instructions are referring to a , b = less than 0
Sergii
@Doomkrat
May 12 2017 00:20
@mattxgreen don't get it anyway
Caleb Brenner
@cwborion
May 12 2017 00:20
@Manish-Giri this is what it looks like to start.
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  switch(val) {
    case "alpha": 
      result = "Adams";
      break;
    case "bravo": 
      result = "Boston";
      break;
    case "charlie": 
      result = "Chicago";
      break;
    case "delta": 
      result = "Denver";
      break;
    case "echo": 
      result = "Easy";
      break;
    case "foxtrot": 
      result = "Frank";
  }

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

// Change this value to test
phoneticLookup("charlie");
Matt Green
@mattxgreen
May 12 2017 00:21
@Doomkrat Whatever you put in quotes is what the split will use to separate into an array.
anhtm
@anhtm
May 12 2017 00:21
'''
var myStr = 'FirstLine \n \SecondLine\ \rThirdLine';
'''
it doesnt come out as expected. Does anyone knows why?
CamperBot
@camperbot
May 12 2017 00:21
:bulb: to format code use backticks! ``` more info
Matt Green
@mattxgreen
May 12 2017 00:21
@Doomkrat so "racecar".split("e") returns ["rac","car"]
Caleb Brenner
@cwborion
May 12 2017 00:22
@Manish-Giri thank you for helping, have to get to work though, I'll figure it out tomorrow.
CamperBot
@camperbot
May 12 2017 00:22
cwborion sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5477 | @manish-giri |http://www.freecodecamp.com/manish-giri
anhtm
@anhtm
May 12 2017 00:22
var myStr = 'FirstLine \n \\SecondLine\\ \rThirdLine';
Dbakk
@Dbakk
May 12 2017 00:22

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
console.log("Hello");
return "World";
console.log("byebye")
}
myFun();
The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement.

Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

Sergii
@Doomkrat
May 12 2017 00:22
@mattxgreen thanks
CamperBot
@camperbot
May 12 2017 00:22
doomkrat sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
Dbakk
@Dbakk
May 12 2017 00:22
stuck on this problem
CamperBot
@camperbot
May 12 2017 00:22
:cookie: 501 | @mattxgreen |http://www.freecodecamp.com/mattxgreen
Dbakk
@Dbakk
May 12 2017 00:23
how do you modify so a, b is < 0?
Matt Green
@mattxgreen
May 12 2017 00:23
@Doomkrat np
Dylan Demnard
@kulpio
May 12 2017 00:24

Hi all!
I a at the lesson of javascript 191 where we learn to select options with the switch statement. I am confused because even though I passed the test, my breaks have the yellow sign that says "unreachable breaks"... what does this mean? please see code below:
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
return "alpha";
break;
case 2:
return "beta";
break;
case 3:
return "gamma";
break;
case 4:
return "delta";
break;

}

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

// Change this value to test
caseInSwitch(1);

t0cc
@t0cc
May 12 2017 00:24
anhtm: save spaces
Manish Giri
@Manish-Giri
May 12 2017 00:25
@kulpio you're supposed to assign to answer in each of the cases.
t0cc
@t0cc
May 12 2017 00:25
kulpio: as you exit the switch section with 'return' before 'break' those 'breaks will never reached.
TayCodes
@TayCodes
May 12 2017 00:26
hi guys could someone please help me fix my if function? I really don't know why it's not working when the three scores are tied https://codepen.io/dev999/pen/vmRvEJ
Dylan Demnard
@kulpio
May 12 2017 00:26
so instead of "return" i should put "answer"?
@Manish-Giri
t0cc
@t0cc
May 12 2017 00:26
kulpio: eg.
Manish Giri
@Manish-Giri
May 12 2017 00:26
yes
like answer = "alpha"
@kulpio
hannah
@damchu
May 12 2017 00:26
myVar = 1++; <-- is this correct..?
Dylan Demnard
@kulpio
May 12 2017 00:27
Awesome, I understand and it worked. Thank you @t0cc Thank you @Manish-Giri
CamperBot
@camperbot
May 12 2017 00:27
kulpio sends brownie points to @t0cc and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @t0cc |http://www.freecodecamp.com/t0cc
:star2: 5478 | @manish-giri |http://www.freecodecamp.com/manish-giri
Matt Green
@mattxgreen
May 12 2017 00:28
@TayCodes Can you explain the desired behavior you are not observing?
Stephen James
@sjames1958gm
May 12 2017 00:28
@damchu Look at the example pattern i = i + 1 is replaced by i++
so myVar = myVar + 1 is replaced by ?
@damchu ++ includes both the + 1 and the =
Matt Green
@mattxgreen
May 12 2017 00:29
@TayCodes nevermind... this is your problem if (toto === tott === totr)
Dylan Demnard
@kulpio
May 12 2017 00:29
@Manish-Giri you are the back bone of this forum man. Your help comes as fast as flash gordon...and you are always on point. My goal is to be goooood like you. LOL
Manish Giri
@Manish-Giri
May 12 2017 00:29
:joy:
Matt Green
@mattxgreen
May 12 2017 00:29
@TayCodes if (toto === tott && tott === totr)
Manish Giri
@Manish-Giri
May 12 2017 00:29
ty, appreciate it @kulpio
CamperBot
@camperbot
May 12 2017 00:29
:cookie: 192 | @kulpio |http://www.freecodecamp.com/kulpio
manish-giri sends brownie points to @kulpio :sparkles: :thumbsup: :sparkles:
hannah
@damchu
May 12 2017 00:30
so that line would just be 1++; ?
TayCodes
@TayCodes
May 12 2017 00:30
@mattxgreen Thanks a lot!!!
CamperBot
@camperbot
May 12 2017 00:30
taycodes sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:cookie: 502 | @mattxgreen |http://www.freecodecamp.com/mattxgreen
t0cc
@t0cc
May 12 2017 00:30
damchu: no. You can either 'myVar++;" or "myVar += 1;' or 'myVar = myVar + 1;'. It is all the same. You can only use '++' with a variable not a number.
Stephen James
@sjames1958gm
May 12 2017 00:30
@anhtm Did you remove all the spaces?
hannah
@damchu
May 12 2017 00:31
ohhhh
okay thanks
Stephen James
@sjames1958gm
May 12 2017 00:31
@damchu ONly the variable is different - so myVar++
hannah
@damchu
May 12 2017 00:31
got it
thanks again
Dbakk
@Dbakk
May 12 2017 00:33

// Setup
function abTest(a, b) {
// Only change code below this line
abTest(a <= 0);{
return undefined;
}

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(-2,2);

deaninous
@deaninous
May 12 2017 00:33
I just randomized the bro code. Would like to know if the js is working selectively http://codepen.io/deaninous/pen/XREygG
Dbakk
@Dbakk
May 12 2017 00:33
Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Manish Giri
@Manish-Giri
May 12 2017 00:35
what is this? abTest(a <= 0);
@Dbakk
t0cc
@t0cc
May 12 2017 00:35
Dbakk: think of the word 'if (..)'
Dbakk
@Dbakk
May 12 2017 00:36
my attempt to answer, I have tried many other things, but am struggling
i tried if fucntion before, but why is the example used here so misleading..
t0cc
@t0cc
May 12 2017 00:37
Dbakk: you can literally take the instructions to form your code. 'if a or b are less than 0' ...
Dbakk
@Dbakk
May 12 2017 00:37
sure im working on that now, the example was just weird, also how do you target 2 variables at once in that type of statement
if (a <= 0)
{
return undefined;
}
but how to get both a or b
Matt Green
@mattxgreen
May 12 2017 00:38
@deaninous seems to be working reliably for me
Dbakk
@Dbakk
May 12 2017 00:38
is it a || b <= 0 ?
t0cc
@t0cc
May 12 2017 00:38
Dbakk: 'if()' is not a function. It is a 'statement'.
Dbakk: you are getting closer
Matt Green
@mattxgreen
May 12 2017 00:40
@deaninous I recommend a usability fix for getting the next item. Perhaps a button below, or put all the text inside of a button that is a different color, and can be clicked.
pauloaguiar1
@pauloaguiar1
May 12 2017 00:41
what is up dudes?, can someone my Switch statement: switch (val) {
case 1:
answer = "alpha";
break;
Stephen James
@sjames1958gm
May 12 2017 00:41
@Dbakk your code is a OR b < 0 you need a < 0 OR b < 0
t0cc
@t0cc
May 12 2017 00:41
Dbakk: the code would read like 'if a is less than 0 or b is less than 0' ...
Stephen James
@sjames1958gm
May 12 2017 00:41
@pauloaguiar1 That looks ok,
deaninous
@deaninous
May 12 2017 00:42
great point @mattxgreen Thanks I will add that
CamperBot
@camperbot
May 12 2017 00:42
deaninous sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles:
:cookie: 503 | @mattxgreen |http://www.freecodecamp.com/mattxgreen
Garo
@Garabed96
May 12 2017 00:42
Guys for twitchTv json api how do we know if the channels online, whats the variable, status doesn't really say much
Dbakk
@Dbakk
May 12 2017 00:43
okay so I just did if, else if statement.
thanks guys
David Miller
@DavidMillerFL
May 12 2017 00:43
Okay Chunky Monkey day two: Here’s what I’ve got so far

function chunkArrayInGroups(arr, size) {
  var firstHalf;
  var secondHalf;
  var emptyArray = [];

  for (i = 0; i<arr.length; i+=size){

    firstHalf = arr.slice(0, size);

    secondHalf = arr.slice(size);

    emptyArray.push(firstHalf, secondHalf);
  return emptyArray;
  }
  // Break it up.

}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3);
Dbakk
@Dbakk
May 12 2017 00:43
@sjames1958gm @t0cc thanks
CamperBot
@camperbot
May 12 2017 00:43
dbakk sends brownie points to @sjames1958gm and @t0cc :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @t0cc |http://www.freecodecamp.com/t0cc
:star2: 7251 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 12 2017 00:44
@DavidMillerFL don't return inside the loop Each pass through the loop should push 1 slice
pauloaguiar1
@pauloaguiar1
May 12 2017 00:45
@sjames1958gm thanks man, somehow it is now working, ill try more! :)
CamperBot
@camperbot
May 12 2017 00:45
pauloaguiar1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7252 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 12 2017 00:45
@DavidMillerFL Use your i variable in the slice
David Miller
@DavidMillerFL
May 12 2017 00:45
Sorry… but. were those two separate steps of instructions ?

Okay so move the return outside the loop

and use variable i for the slice.

right?

Stephen James
@sjames1958gm
May 12 2017 00:46
@DavidMillerFL yes
David Miller
@DavidMillerFL
May 12 2017 00:46
Okay on it. Thanks Stephen :) @sjames1958gm
CamperBot
@camperbot
May 12 2017 00:46
davidmillerfl sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7253 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
t0cc
@t0cc
May 12 2017 00:47
Garabed96: looking at the example JS should explain it. Or do you mean something else?
Mark T. Graybill
@Boolean-Operator
May 12 2017 00:50
Hi all, I am working on the Roman Numeral converter. I have a solution with a switch-case and a bunch of small funtions containing if/else and for loops with array.push(). I did not use array splice or indexOf. It is over 125 lines. Did anyone here tonight do it with the indexOf and get a shorter solution ? I'm just considering if I should try that way as well.
dyon3334
@dyon3334
May 12 2017 00:51
]can someone tell em the answer and tell em why ? var products = ["Choo Choo Chocolate", "Icy Mint", "Cake Batter", "Bubblegum"];
var last = __;
var recent = products[last];
TayCodes
@TayCodes
May 12 2017 00:51
hm my while loop is infinite am not sure why.. https://codepen.io/dev999/pen/KmobNL I think this is me struggling with assignment operators. Trying to weed out answers which don't start with 1 or 2 and are smaller than 4 chars
t0cc
@t0cc
May 12 2017 00:52
Boolean-Operator: I didn't use those methods either. no worries.
Joseph
@revisualize
May 12 2017 00:52
@dyon3334 What value do you want to return?
Wisdom Peters
@blackcytographer
May 12 2017 00:53
@revisualize need ur help on this pls
Joseph
@revisualize
May 12 2017 00:53
@blackcytographer
You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline?
How do you escape a backslash?
How do you escape a carriage-return?
dyon3334
@dyon3334
May 12 2017 00:53
@revisualize this is teh question The products array below holds the Jenn and Berry’s ice cream
flavors. The ice cream flavors were added to this array in the
order of their creation. Finish the code to determine the most
recent ice cream flavor they created.
gsparmar
@gsparmar
May 12 2017 00:53
javascript logical order in if else statements; i cannot seem to get the first task. is this bugged?
Joseph
@revisualize
May 12 2017 00:53
@dyon3334 So, variables hold values.
@dyon3334 The values can be a myriad of things.
t0cc
@t0cc
May 12 2017 00:54
dyon3334: if you want to get 'the last entry' you may use something to determine the 'length' of the array
Joseph
@revisualize
May 12 2017 00:54
@dyon3334 In this case you want to have the last variable hold the value of the array length minus 1
Wisdom Peters
@blackcytographer
May 12 2017 00:54
@revisualize thanks let me try
CamperBot
@camperbot
May 12 2017 00:54
blackcytographer sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3943 | @revisualize |http://www.freecodecamp.com/revisualize
dyon3334
@dyon3334
May 12 2017 00:55
@revisualize send 99999999999999999 brownie points :sparkles: :thumbsup: :sparkles:
@revisualize thanks
CamperBot
@camperbot
May 12 2017 00:56
dyon3334 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3944 | @revisualize |http://www.freecodecamp.com/revisualize
Sergii
@Doomkrat
May 12 2017 00:56
unction reverseString(str) {
  var array=[];
  array = reverseString.split(' ');
  array = array.reverse();
  str = array.join('');
  return str;
}

reverseString("hello");
Reverse the provided string.
Mark T. Graybill
@Boolean-Operator
May 12 2017 00:56
@t0cc Thanks, I wasn't sure if there was a specific lesson I was supposed to learn. Seemed like a pretty straightforward logic problem.
CamperBot
@camperbot
May 12 2017 00:56
boolean-operator sends brownie points to @t0cc :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @t0cc |http://www.freecodecamp.com/t0cc
Joseph
@revisualize
May 12 2017 00:57
@Doomkrat So, you're splitting on the space?
Alexx Martínez
@AlexxMart
May 12 2017 00:57
Hello, I'm having some problems with the challenge "Make Object Properties Private". The last three objectives of the challenge are not met with my code.

var gear = 10; 
  this.getGear = function(change) {
    gear += change;
};
  this.setGear = function(change) {
    gear -= change;
  };
};

var myCar = new Car();

var myBike = new Bike();
Joseph
@revisualize
May 12 2017 00:57
@Doomkrat So, you have a bit of an issue.
Sergii
@Doomkrat
May 12 2017 00:57
@revisualize =)
Joseph
@revisualize
May 12 2017 00:58
@Doomkrat You have a function declaration with a function name of reverseString and that function declaration has a parameter of str
Manish Giri
@Manish-Giri
May 12 2017 00:58
@AlexxMart the getGear is just supposed to return the gear value
t0cc
@t0cc
May 12 2017 00:58
Doomkrat: rethink the line "array = reverseString.split(' ');" in terms of which variable you want to split
Joseph
@revisualize
May 12 2017 00:58
@Doomkrat Parameters are used inside of your function just like variables.
Manish Giri
@Manish-Giri
May 12 2017 00:58
as the name suggests
Joseph
@revisualize
May 12 2017 00:58
@Doomkrat So, you need to evaluate do you want to run the .split() method on the function or on the parameter value?
Manish Giri
@Manish-Giri
May 12 2017 00:58
@AlexxMart and the setGear is just supposed to set the gear to change
Sergii
@Doomkrat
May 12 2017 00:59
@revisualize on the parameter value I think
Joseph
@revisualize
May 12 2017 00:59
@Doomkrat I think that's a better idea
t0cc
@t0cc
May 12 2017 00:59
Doomkrat: exactly :)
Joseph
@revisualize
May 12 2017 01:00
@t0cc If you @ people they'll see it better because their username will get highlighted.
@t0cc You can also use autocomplete when you @ someone.
Sergii
@Doomkrat
May 12 2017 01:00
how it change my code? @revisualize
HeebieGeeBee
@HeebieGeeBee
May 12 2017 01:00
@Manish-Giri @revisualize yo
Manish Giri
@Manish-Giri
May 12 2017 01:01
@HeebieGeeBee :wave:
t0cc
@t0cc
May 12 2017 01:01
revisualize: I know. I'm using IRC bridge and it is a hassle to @ before nicks because then I have no auto-compliete
HeebieGeeBee
@HeebieGeeBee
May 12 2017 01:01
@t0cc just click on their names
t0cc
@t0cc
May 12 2017 01:01
revisualize: I'm using https://irssi.org/
Sergii
@Doomkrat
May 12 2017 01:02
@revisualize I did it ))))))
@revisualize thanks
CamperBot
@camperbot
May 12 2017 01:02
doomkrat sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3945 | @revisualize |http://www.freecodecamp.com/revisualize
Sergii
@Doomkrat
May 12 2017 01:03
I'm not so dumb like I think )
Joseph
@revisualize
May 12 2017 01:03
Yo!
@t0cc oh.
David Miller
@DavidMillerFL
May 12 2017 01:04
@sjames1958gm Soooo I’m trying to add [i] to either of these and can’t seem to figure it out :(
    firstHalf = arr.slice(0, size);

    secondHalf = arr.slice(size);
Christopher Watson
@BocWatson
May 12 2017 01:04

I've completed the Word Blank challenge, but its giving me yellow flags saying that my variables are already defined. The challenge is complete, but Im wondering, is this an issue?

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {

var result = "My " + myNoun + " was very " + myAdjective + " and he " + myVerb + " very " + myAdverb + ".";

// Your code below this line
var myNoun = "dog";
var myAdjective= "big";
var myVerb = "ran";
var myAdverb = "quickly";

// Your code above this line
return result;
}

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

HeebieGeeBee
@HeebieGeeBee
May 12 2017 01:05
i watched the new ghost in a shell movie today
t0cc
@t0cc
May 12 2017 01:05
revisualize: There is python plugin for irssi, but unfortunately, it is not working as expected. Therefore, I just use IRC syntax. The Gitter chat is too slow and cluttered too me.
HeebieGeeBee
@HeebieGeeBee
May 12 2017 01:05
pretty odd
Stephen James
@sjames1958gm
May 12 2017 01:05
@DavidMillerFL So what do you pass to slice to get the second chunk?
Joseph
@revisualize
May 12 2017 01:05

@BocWatson 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) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

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

Manish Giri
@Manish-Giri
May 12 2017 01:06
@BocWatson why're you redefining the variables?
David Miller
@DavidMillerFL
May 12 2017 01:06
@sjames1958gm Well… for the second chunk I’m passing “size”, which from what I understand, designates where that slice should begin… no?
Joseph
@revisualize
May 12 2017 01:07
@BocWatson I don't know why you're re-defining your parameters inside of your function.
Stephen James
@sjames1958gm
May 12 2017 01:07
@DavidMillerFL That is for the start what about the end?
David Miller
@DavidMillerFL
May 12 2017 01:08
@sjames1958gm I assumed it would continue until the end of my array.
If I left it blank.. if I want it to end I would need to pass arguements when , like I did in the firstHalf 0, size
Stephen James
@sjames1958gm
May 12 2017 01:09
@DavidMillerFL Each pass through the loop should grab one slice from the array and push
David Miller
@DavidMillerFL
May 12 2017 01:10
Okay, so I have my slices arranged incorrectly then. Let me take another look
Stephen James
@sjames1958gm
May 12 2017 01:10
@DavidMillerFL To make a generic solution you have to slice once per loop so that the length of the array decides the number of slices
Christopher Watson
@BocWatson
May 12 2017 01:10
@revisualize you've been a great help. Thanks!
CamperBot
@camperbot
May 12 2017 01:10
bocwatson sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3946 | @revisualize |http://www.freecodecamp.com/revisualize
Christopher Watson
@BocWatson
May 12 2017 01:11
@Manish-Giri @revisualize The "Your code below this line" comment made me think I had to put something there. Kind of threw me off a bit.
It all makes sense now tho.
Joseph
@revisualize
May 12 2017 01:12
@BocWatson Cool.
David Miller
@DavidMillerFL
May 12 2017 01:14
  for (i = 0; i<arr.length; i+=size){

    firstHalf = arr.slice(0, size);

    emptyArray.push(firstHalf);

  }
  // Break it up.
  return emptyArray;
@sjames1958gm ^ So I’m doing one slice and one push per loop
But it’s repeating the same first chunk over and over
Stephen James
@sjames1958gm
May 12 2017 01:15
@DavidMillerFL So, when i = 0 you select 0, size - when i = size (the next pass) what do slice
David Miller
@DavidMillerFL
May 12 2017 01:15
Pardon?
Manish Giri
@Manish-Giri
May 12 2017 01:16
@BocWatson :+1:
Stephen James
@sjames1958gm
May 12 2017 01:16
@DavidMillerFL What are the slice parameters to get the second chunk?
David Miller
@DavidMillerFL
May 12 2017 01:17

@sjames1958gm

l o a d i n g. . . lol

I wonder if this SeattleJS is going to be Live.
Anthony Contreras
@AmazeCPK
May 12 2017 01:34
Need some help figuring out why I'm not getting any data back
The console.log in the image controller outputs 'undefined' messages
Juan Pablo Jaramillo
@JuanP97
May 12 2017 01:51
Guys sorry for the ignorance, but how do I show code in the chat?
deaninous
@deaninous
May 12 2017 01:53
```
then your code then close by time same sequence of ticks
Gene
@bginop
May 12 2017 01:55
hey guys i am working on the search for a palindrome challenge and freecodecamp provided a hint which redirects you to a mozilla page. This page discusses using string.prototype.reverse(). My question is does anyone understand how this function of theirs works? I'm trying ot understand it to apply it to my challenge.
function styleHyphenFormat(propertyName) {
function upperToHyphenLower(match, offset, string) {
return (offset ? '-' : '') + match.toLowerCase();
}
return propertyName.replace(/[A-Z]/g, upperToHyphenLower);
}
Basically I don't get how match, offset, string works withing the second function in conjunction with return
deaninous
@deaninous
May 12 2017 01:56
function styleHyphenFormat(propertyName) {
function upperToHyphenLower(match, offset, string) {
return (offset ? '-' : '') + match.toLowerCase();
}
return propertyName.replace(/[A-Z]/g, upperToHyphenLower);
}
Gene
@bginop
May 12 2017 01:56
thanks for reprinting that
deaninous
@deaninous
May 12 2017 01:57
yupp. is that 2 function?
Gene
@bginop
May 12 2017 01:57
yeah i'm trying to understand how this work
like how doe sthe match, offset, string work with the return function below it
it seems like the logical way to go to solve this challenge but first I'd like to understand how it works cause the coding before these challanges dont really discuss this advanced technique
Juan Pablo Jaramillo
@JuanP97
May 12 2017 01:58
thanks @deaninous
CamperBot
@camperbot
May 12 2017 01:58
juanp97 sends brownie points to @deaninous :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @deaninous |http://www.freecodecamp.com/deaninous
deaninous
@deaninous
May 12 2017 01:58
yupp, @JuanP97 thanks
CamperBot
@camperbot
May 12 2017 01:58
deaninous sends brownie points to @juanp97 :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @juanp97 |http://www.freecodecamp.com/juanp97
deaninous
@deaninous
May 12 2017 01:59
You seem to have 2 functions but they are into each other
Gene
@bginop
May 12 2017 01:59
Yeah this is mozillas developer code
the link i.e., the hint within the challanege takes you to this code
some how this sucker works but i dont know why and i'd like to understand why
deaninous
@deaninous
May 12 2017 02:00
match tests for a pattern
Gene
@bginop
May 12 2017 02:00
it does?
ok what does offset and string do? i'm guess offset changes something and the string tests for a string?
deaninous
@deaninous
May 12 2017 02:01
var test = "iam testing"
undefined
test.match("am")
Array [ "am" ]
example
Gene
@bginop
May 12 2017 02:02
ok i see that
i guess i can google the rest now that i know you can do that
deaninous
@deaninous
May 12 2017 02:02
replace does the replacement
Gene
@bginop
May 12 2017 02:03
so you can utilize a method within a function ?
deaninous
@deaninous
May 12 2017 02:03
test
"iam testing"
test.replace("ing", "ed")
"iam tested"
Gene
@bginop
May 12 2017 02:03
if so, that is the coolest thing i have learned in coding as of yet
deaninous
@deaninous
May 12 2017 02:04
I know regex is powerful
Gene
@bginop
May 12 2017 02:05
wow thats actually is mind blowing - like no sarcasm
thanks for helping me understand that
Joseph
@revisualize
May 12 2017 02:05
deaninous
@deaninous
May 12 2017 02:06
any time. which one are you working on?
Gene
@bginop
May 12 2017 02:07
palindrome challenge
what a beast
So i started to apply that funky code from mozilla but I didnt understand that it was allowing me to utilize methods within a function
Joseph
@revisualize
May 12 2017 02:07
Anyone think @bginop is going to flip out when they realize that RegExp exists and they are going to build a regex expression using JS functions.
deaninous
@deaninous
May 12 2017 02:08
How are you going to tackle it. @bginop
Gene
@bginop
May 12 2017 02:08
so I think that code its basically bypassing str.match()
Francisco Franco
@frenktico
May 12 2017 02:09
Hey shiny happy people, let's talk about bugs and code that's not working :D
Joseph
@revisualize
May 12 2017 02:09
@bginop Don't use .match() for that lesson.
Francisco Franco
@frenktico
May 12 2017 02:09

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

// Change these values to test
golfScore(5, 4);
deaninous
@deaninous
May 12 2017 02:09
str represents the string you are working on. So ed ```
Joseph
@revisualize
May 12 2017 02:09
@frenktico "Hole-in-one!"
Gene
@bginop
May 12 2017 02:09
uhh well..... basically i wanted to see how that crazy function worked which in a way puts any text to lower case
Tanweer
@antweer
May 12 2017 02:09
would someone mind helping me out with the profile lookup
Joseph
@revisualize
May 12 2017 02:10
@frenktico Your string needs to be EXACT.
Tanweer
@antweer
May 12 2017 02:10
function lookUpProfile(firstName, prop){
  for(var x = 0; x<contacts.length; x++){
    if(contacts[x].firstName == firstName){
      if(prop in contacts[x]){
        return contacts[x].prop;
      }else{
        return("No such property");
      }
    }else{
      return("No such contact");
    }
  }
}
Gene
@bginop
May 12 2017 02:10
from there the hints in the challange say make the string in lower case and remove all numbers, special characters, etc
deaninous
@deaninous
May 12 2017 02:10
str.toLowerCase
Joseph
@revisualize
May 12 2017 02:10
@antweer So, your issue is that you're loop isn't looping.
Tanweer
@antweer
May 12 2017 02:10
oh
Joseph
@revisualize
May 12 2017 02:10
@antweer Yeah.
Gene
@bginop
May 12 2017 02:11
then it wants you to do a logic test to see if a palindrome exists. So in my mind. we need switch(). join(). reverse()
Joseph
@revisualize
May 12 2017 02:11
@antweer You need to be very very declarative when you want a return statement triggered.
Gene
@bginop
May 12 2017 02:11
then were gonna need an if statement that tests the logic to see if the reversed lower case word is the same as the original word so if x === y then return true
deaninous
@deaninous
May 12 2017 02:12
@yupp right track. There might also be some special characters to strips
Francisco Franco
@frenktico
May 12 2017 02:12
Thanks @revisualize
CamperBot
@camperbot
May 12 2017 02:12
frenktico sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3948 | @revisualize |http://www.freecodecamp.com/revisualize
deaninous
@deaninous
May 12 2017 02:13
Souds right
Gene
@bginop
May 12 2017 02:13
yeah i think that is what this is for: return str.replace(/[A-Z|0-9|$%@#+-.]/gi,remove
been testing that bad boy
deaninous
@deaninous
May 12 2017 02:14
replace takes 2 args
Gene
@bginop
May 12 2017 02:14
sorry. 2 args? does that mean arguments?
deaninous
@deaninous
May 12 2017 02:15
yea, what to replace and what to replace with
ex str.replace(/[a-z]/, "ii")
after the comma
Gene
@bginop
May 12 2017 02:17
ohh that second part was cut off. return str.replace(/[A-Z|0-9|$%@#+-.]/gi,removeAndShrink
thats my function above which i didn't print
deaninous
@deaninous
May 12 2017 02:18
I dont think that would work. Some of them like "." need to be escaped
Gene
@bginop
May 12 2017 02:18

function palindrome(str) {
function removeAndShrink(match, string){
return match.toLowerCase();

}

// Good luck!
return str.replace(/[A-Z|0-9|$%@#+-.]/gi,removeAndShrink) ;
}

palindrome("10 HAMBURGER PIE$ with Ch@eese!");

this is just me playing aroudn with replace to ensure i understand it
insofar to replaces HAMBURGER with hamburger
deaninous
@deaninous
May 12 2017 02:19
you can use regular expression classes
Gene
@bginop
May 12 2017 02:19
now i would like to understand how offset within that second function works because google seems to discuss this method as something used in JQUERY not javascript
basically i'm trying ot gain a full understanding of that crazy mozilla function i posted a while ago
deaninous
@deaninous
May 12 2017 02:21
I personnaly have never used it
Gene
@bginop
May 12 2017 02:22
that function is such a mutant my developer friend has never seen it either
its pure BANANAS!
deaninous
@deaninous
May 12 2017 02:22
yea, the field is large
Gene
@bginop
May 12 2017 02:23
mind blowing!
hey deaninous, thanks for yoru help. being such a beginning your guidance really helped
deaninous
@deaninous
May 12 2017 02:25
People always help
here is what i found on mdn after pasting your code
str.replace(regexp|substr, newSubstr|function)
Ryan
@Ryankennedy77
May 12 2017 02:26
hello all, can someone assist me with "return largest numbers in an array, this is what i have

function largestOfFour(arr) {
// You can do this!
var largestNumber = [0,0,0,0];
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr[i][j]; j++) {
if (arr[i][j] < arr[i][j + 1]) {
largestNumber[i] = arr[i][j];
}
}
}
return largestNumber;
}

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

deaninous
@deaninous
May 12 2017 02:27
function largestOfFour(arr) {
// You can do this!
var largestNumber = [0,0,0,0];
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr[i][j]; j++) {
if (arr[i][j] < arr[i][j + 1]) {
largestNumber[i] = arr[i][j];
}
}
}
return largestNumber;
I think your code targets a multidimentional array @Ryankennedy77
also your return statement is out of scope
Ryan
@Ryankennedy77
May 12 2017 02:30
the return statement is still inside the function, is that not where it should be
Joseph
@revisualize
May 12 2017 02:30
@deaninous No it isn't.
@Ryankennedy77 Your return statement is in the correct place.
deaninous
@deaninous
May 12 2017 02:31
my bad. I copied and left out a bracket
Ryan
@Ryankennedy77
May 12 2017 02:31
so where is my logic error in the code, any idea?
Joseph
@revisualize
May 12 2017 02:31
@Ryankennedy77 Your if condition isn't really correct.
@Ryankennedy77 I don't think you should be comparing against: arr[i][j + 1]
Ryan
@Ryankennedy77
May 12 2017 02:32
hmm okay i think i understand that, ill come up with another wy around it, thanks!
Joseph
@revisualize
May 12 2017 02:33
@Ryankennedy77 What if you compared against the value in your largestNumber array
Wade Hextell
@auswade
May 12 2017 02:33

can someone help me with this test please?

https://www.freecodecamp.com/challenges/stand-in-line

Manish Giri
@Manish-Giri
May 12 2017 02:34
@auswade what's the problem
Joseph
@revisualize
May 12 2017 02:34

@auswade Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9

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

Again the two parameters for the nextInLine function are arr & item.

Per the instructions: 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.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

Ryan
@Ryankennedy77
May 12 2017 02:34
perfect, i wrote that part of the code before adding the largestnumber array so that makes sense, thank you!
Wade Hextell
@auswade
May 12 2017 02:35
so another function inside the one they already write there?
Joseph
@revisualize
May 12 2017 02:35
@auswade no.
Ryan
@Ryankennedy77
May 12 2017 02:35
@revisualize @deaninous i appreciate the help
Wade Hextell
@auswade
May 12 2017 02:35
ok, i didn't think so
deaninous
@deaninous
May 12 2017 02:36
@Ryankennedy77 anytime, sir
Wade Hextell
@auswade
May 12 2017 02:36
sorry about my lack of tagging @revisualize
Sara
@skd726
May 12 2017 02:37
Hi guys, I'm having some trouble with my API linking to my button, can anyone help?
Javed Kadri
@devajirdak
May 12 2017 02:40
Guys I am stuck on this switch problem, What am I doing wrong. I am getting an ReferenceError : Can't find variable: a

function switchOfStuff(val) {
var answer = "";

// Only change code below this line

switch (val){
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";

}

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

// Change this value to test
switchOfStuff(a);

Stephen James
@sjames1958gm
May 12 2017 02:41
@devajirdak Make sure you call the function with "a" not a
deaninous
@deaninous
May 12 2017 02:41
@auswade the assignment wants you t o add the variable name item to the end of the array then remove the elemt in first position is the array. Simuling a queue being severd
Stephen James
@sjames1958gm
May 12 2017 02:41
Also the cases are strings "a" etc you are using a variable a which is not defined @devajirdak
Caio Amorim
@cmcamorim
May 12 2017 02:42
Hey people, why var myStr= "FirstName\n\SecondLine\\rThirdLine"; does not realize the escape sequences correctly?
Kevin Gong
@kevingong1995
May 12 2017 02:42

Hi i am having trouble with my queue, why is it not pushing and popping like it should be? I have this as my code

function nextInLine(arr, item) {
arr.push(item);
var popped = arr.pop();
return popped; // Change this line
}

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

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

Stephen James
@sjames1958gm
May 12 2017 02:42
@cmcamorim FirstLine not FirstName
@kevingong1995 pop removes from end not front
Kevin Gong
@kevingong1995
May 12 2017 02:43
how would i go about removing the front ?
or would i have to arr.pop(arr[0])?
Stephen James
@sjames1958gm
May 12 2017 02:43
@kevingong1995 shift instead of pop
Caio Amorim
@cmcamorim
May 12 2017 02:43
@cmcamorim FirstLine not FirstName I can't believe this was the mistake rs
Wade Hextell
@auswade
May 12 2017 02:44
@deaninous yes, I'm trying to make that happen with the before and after that appears in the console...correct?
Javed Kadri
@devajirdak
May 12 2017 02:44
@sjames1958gm That was it, Thanks a lot
CamperBot
@camperbot
May 12 2017 02:44
devajirdak sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7254 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
deaninous
@deaninous
May 12 2017 02:44
yupp @auswade
Wade Hextell
@auswade
May 12 2017 02:45
right now i am here:
Before: [1,2]
6
After: [2]
Before: [1,2]
6
After: [2,1]
now @deaninous
deaninous
@deaninous
May 12 2017 02:51
the array is [1,2,4,5,6] if you push(7) you get [1,2,3,4,5,6,7] Now return the operation of removing 1 from the array
@auswade
FelixHakaraia
@FelixHakaraia
May 12 2017 02:51

function confirmEnding(str, target) {
  var endingCha = str.substring(target.length - 0);
  if (endingCha === target) {
    return true;
  } else {
    return false;
  }
}

confirmEnding("Bastian", "n");
What am i missing guys?
kerafyrm02
@kerafyrm02
May 12 2017 02:52
Why length - 0?
deaninous
@deaninous
May 12 2017 02:52

```str.substring(target.length - 0);

``` will get an error

FelixHakaraia
@FelixHakaraia
May 12 2017 02:52
@kerafyrm02 Was just trying things and that was the format the example for .substring was in
I have removed it and am still not returning the right result
kerafyrm02
@kerafyrm02
May 12 2017 02:53
target is n and youre comparing to the last letter of str?
str[str.length - 1]
FelixHakaraia
@FelixHakaraia
May 12 2017 02:53
It isnt always the last letter
deaninous
@deaninous
May 12 2017 02:53
indexing the length of the string will throw an error
FelixHakaraia
@FelixHakaraia
May 12 2017 02:54
There are a couple tests where it's a whole word
kerafyrm02
@kerafyrm02
May 12 2017 02:54
index the length of a str does NOT throw an error
deaninous
@deaninous
May 12 2017 02:54
only starts working at the point mentioned by @kevingong1995 down to 0
kerafyrm02
@kerafyrm02
May 12 2017 02:55
var str = 'abcd'
undefined
str.length
4
deaninous
@deaninous
May 12 2017 02:55
str[str.length]
that is indexing
kerafyrm02
@kerafyrm02
May 12 2017 02:55
that doesn't throw an error either
Wade Hextell
@auswade
May 12 2017 02:55
can someone please let me know why this test says that i only need to change this one line (see below)
function nextInLine(arr, item) {
  // Your code here

  //arr.shift();
  //var testArr;
  //arr.push(1);
  return item;  // Change this line
}

// Test Setup
var testArr = [];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
kerafyrm02
@kerafyrm02
May 12 2017 02:55
str[3]
"d"
Wade you should just reset the quiz
deaninous
@deaninous
May 12 2017 02:57
you are super right @kerafyrm02 now go test it
kerafyrm02
@kerafyrm02
May 12 2017 02:57
i did- i pasted the console log
Wade Hextell
@auswade
May 12 2017 02:57
@kerafyrm02 @deaninous thanks for you help guys...resetting now...
CamperBot
@camperbot
May 12 2017 02:57
auswade sends brownie points to @kerafyrm02 and @deaninous :sparkles: :thumbsup: :sparkles:
:cookie: 213 | @kerafyrm02 |http://www.freecodecamp.com/kerafyrm02
:cookie: 343 | @deaninous |http://www.freecodecamp.com/deaninous
deaninous
@deaninous
May 12 2017 02:58
did it work? @auswade
kerafyrm02
@kerafyrm02
May 12 2017 02:58
var str = 'abcd'
str[str.length - 1]
"d"
Wade Hextell
@auswade
May 12 2017 02:59
it only took away some of the lines i put there but trying what you wrote now... @deaninous
deaninous
@deaninous
May 12 2017 03:00
let me pm you
@au
@auswade
kerafyrm02
@kerafyrm02
May 12 2017 03:00
You aren't supposed to return item.
That's one issue. You return the pop
or shift
if it's front of line.
Lane Goodman
@LanesGood
May 12 2017 03:01
Hi there!
Wade Hextell
@auswade
May 12 2017 03:02
@kerafyrm02 i tried the poping and shifting, there are three tests on this particular page that it must pass
Lane Goodman
@LanesGood
May 12 2017 03:02
Doing the "profile lookup" challenge, I totally feel like i have it but still no luck
Wade Hextell
@auswade
May 12 2017 03:03

@kerafyrm02
these are the conditions and the first one is always passed but the rest don't change and I've gone back to the manipulating arrays section but maybe i need to go over it some more back there...

nextInLine([], 1) should return 1
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

Lane Goodman
@LanesGood
May 12 2017 03:03
anyone willing to talk through it?
Wade Hextell
@auswade
May 12 2017 03:04
@LanesGood Do you have a link to your challenge?
Lane Goodman
@LanesGood
May 12 2017 03:05
its the "lookupProfile" challenge in Basic Javascript
Cara
@CaraLarissa
May 12 2017 03:05
Hey everyone! I'm working on the MadLibs in JavaScript and I pssed but t mkes no sense
kerafyrm02
@kerafyrm02
May 12 2017 03:05
Wade
Cara
@CaraLarissa
May 12 2017 03:05
passed*
Wade Hextell
@auswade
May 12 2017 03:05
yes?
kerafyrm02
@kerafyrm02
May 12 2017 03:05
Post the instructions here.
And ill explain line by line
That's best way to tackle these questions.
Lane Goodman
@LanesGood
May 12 2017 03:06
@kerafyrm02 me or Cara?
kerafyrm02
@kerafyrm02
May 12 2017 03:06
Wade.
Cara
@CaraLarissa
May 12 2017 03:06
Hey everyone! I'm working on the MadLibs in JavaScript and I passed the challenge but the answer makes no sense*
Wade Hextell
@auswade
May 12 2017 03:06

ok...

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

kerafyrm02
@kerafyrm02
May 12 2017 03:07
Ok. Step 1.
Add number to end of array.
Cara
@CaraLarissa
May 12 2017 03:07
I've been taking notes and I don't want to move on yet because I don't understand how I passed the challenge when the madlib makes no sense and isn't functioning correctly imo
kerafyrm02
@kerafyrm02
May 12 2017 03:07
arr = [1,2,3,4];
ismael garcia
@leamsigc
May 12 2017 03:07
for me this work im on the same challenge arr.push();
kerafyrm02
@kerafyrm02
May 12 2017 03:07
arr.push(5);
adds to end.
Wade Hextell
@auswade
May 12 2017 03:07
i have arr=[1,2,3,4,5]
ahhhh
ismael garcia
@leamsigc
May 12 2017 03:07
and then return arr.shift();
kerafyrm02
@kerafyrm02
May 12 2017 03:08
then remove the first item
arr.shift()
removes it
then it says 'return the number removed'
so you do that 1 of 2 ways
```
Steven
@LemonTruth
May 12 2017 03:08

function findLongestWord(str) {
  str = str.split(" ");
  strReplica = str;
  for (i = 0; i < strReplica.length; i++){
    str.push(str[i].length); str.shift(str[i]);
  }
  str.sort(function(a, b){
    return b - a;
  });

  return str[1];
}
does my code make any sense to you guys?
kerafyrm02
@kerafyrm02
May 12 2017 03:08
return arr.shift()
or
var removed_item = arr.shift();
return removed_item;
Wade Hextell
@auswade
May 12 2017 03:09
hold up
kerafyrm02
@kerafyrm02
May 12 2017 03:09
That's it.
ismael garcia
@leamsigc
May 12 2017 03:09

function nextInLine(arr, item) {
// Your code here
arr.push(item);

return arr.shift(); // Change this line
}

kerafyrm02
@kerafyrm02
May 12 2017 03:09
^^
Csaba Balogh
@JasonCorp84
May 12 2017 03:09
Hello
I am working on the return biggest numbers in array
Steven
@LemonTruth
May 12 2017 03:10
@JasonCorp84 heyy
Wade Hextell
@auswade
May 12 2017 03:10
function nextInLine(arr, item) {
  // Your code here

  testArr.push(5);
  testArr.shift();

  return item;  // Change this line
}
i had this.
Manish Giri
@Manish-Giri
May 12 2017 03:10
@auswade function nextInLine(arr, item)
Csaba Balogh
@JasonCorp84
May 12 2017 03:10
but all I got is the biggest number of all
Manish Giri
@Manish-Giri
May 12 2017 03:10
where are you using arr?
in your code
Csaba Balogh
@JasonCorp84
May 12 2017 03:11
I want to evaluate each nested arrays right?
micojay020
@micojay020
May 12 2017 03:11
can someone help me
with thit
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
Csaba Balogh
@JasonCorp84
May 12 2017 03:12
and before the for loop goes forward, it should assign the biggest number in the array to an array
micojay020
@micojay020
May 12 2017 03:12
ive been trying this
Wade Hextell
@auswade
May 12 2017 03:12
@kerafyrm02 @micojay020 @Manish-Giri thanks guys, all good now
CamperBot
@camperbot
May 12 2017 03:12
auswade sends brownie points to @kerafyrm02 and @micojay020 and @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: auswade already gave kerafyrm02 points
:star2: 5479 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 212 | @micojay020 |http://www.freecodecamp.com/micojay020
micojay020
@micojay020
May 12 2017 03:12
and i cant figure it out
anyone ? thanks
Wade Hextell
@auswade
May 12 2017 03:12
I've been away for a while and am trying to get back into the daily routine of this
kerafyrm02
@kerafyrm02
May 12 2017 03:12
Lemon why are you returning str[1]? SHouldnt it be str[0]?
Manish Giri
@Manish-Giri
May 12 2017 03:12
@micojay020 isn't there an example shown, using .hasOwnProperty?
micojay020
@micojay020
May 12 2017 03:13
yes
but idont ive tried like 10 time already
Manish Giri
@Manish-Giri
May 12 2017 03:13
so follow that then
micojay020
@micojay020
May 12 2017 03:13
and i cant figure it out
Manish Giri
@Manish-Giri
May 12 2017 03:13
then show what you tried
Steven
@LemonTruth
May 12 2017 03:13
@kerafyrm02 You're right. aha, completely missed that thanks
CamperBot
@camperbot
May 12 2017 03:13
:cookie: 214 | @kerafyrm02 |http://www.freecodecamp.com/kerafyrm02
lemontruth sends brownie points to @kerafyrm02 :sparkles: :thumbsup: :sparkles:
micojay020
@micojay020
May 12 2017 03:13
i have reset a lot of times
kerafyrm02
@kerafyrm02
May 12 2017 03:13
Mico what does the instructions say?
Paste it here.
micojay020
@micojay020
May 12 2017 03:13

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".

Run tests (ctrl + enter)

Manish Giri
@Manish-Giri
May 12 2017 03:14
can't help if you won't show your code
micojay020
@micojay020
May 12 2017 03:14
okay ill give it a try again then ill paste
kerafyrm02
@kerafyrm02
May 12 2017 03:15
Mico use .hasOwnProperty()
Steven
@LemonTruth
May 12 2017 03:16
@micojay020 use an if then an else statement
monarkb
@monarkb
May 12 2017 03:18
hi guys past 3 days I am stucked at a challenge and am not able to solve it can anyone help me? "Quoting Strings with Single Quotes"
micojay020
@micojay020
May 12 2017 03:18
i tried this
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  myObj.hasOwnProperty("gift");

  return "kitten";
}

// Test your code by modifying these values
checkObj("pet");
Manish Giri
@Manish-Giri
May 12 2017 03:19
@micojay020 you're testing for gift
what happens if pet is passed in?
or bed?
deaninous
@deaninous
May 12 2017 03:19
Whatever the input, it will output 'kitten'
Csaba Balogh
@JasonCorp84
May 12 2017 03:27
@micojay020 do you understand objects ?
Csaba Balogh
@JasonCorp84
May 12 2017 03:34
that would solve this for you
kerafyrm02
@kerafyrm02
May 12 2017 03:42
myObj.hasOwnProperty("gift");
does nothing.
Andrew Saganda
@asaganda
May 12 2017 03:46

Having trouble completing a JS challenge, string immutability.

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me

I have to correct the assignment to myStr to achieve the desired effect
It's probably something stupid

Guderian Raborg
@hypercuber
May 12 2017 03:47
Hi, everyone. Help me get the gray background behind the black background pretty please:

<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<title>wiki</title>
<script src="libraries/p5.js" type="text/javascript"></script>

<script src="libraries/p5.dom.js" type="text/javascript"></script>
<script src="libraries/p5.sound.js" type="text/javascript"></script>

<script src="sketch.js" type="text/javascript"></script>

<style>
body {
padding: 0; margin: 0px;
text-align: center;
color: white;
opacity: .7;
}
canvas {
vertical-align: top;
}
h1 {
background-color: black;
margin: 10px 10px 0px 10px;
padding: 5px;
border-radius: 25px 25px 25px 25px;
z-index: 10;
}
.box {
background-color: gray;
margin: -10px 10px 10px 10px; /T R B L/
padding: 5px 5px 50px 5px;
border-radius: 25px / 25px;
z-index: -10;
}
#tf {
border-radius: 25px / 25px;
padding: 3px 5px 3px 5px;
}
#btn {
border-radius: 25px / 25px;
padding: 3px 5px 3px 5px;
}

</style>
</head>
<body>

<h1> Wikipedia Viewer </h1>

<div class="box">
<p> Welcome to my Wikipedia search tool </p>

<input type="text" id="tf">
<button type="button" id="btn"> Search </button>


<a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">/b </a>

</div>

</body>
</html>

How do I put .box behind h1 background ?
Andrew Saganda
@asaganda
May 12 2017 03:47

I tried adding this line,

myStr = "Hello World";

right above the index part but that didn't pass

Guderian Raborg
@hypercuber
May 12 2017 03:49
it should be:

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr = "Hello World"; // Fix Me

got it?
Vamp
@the-vampiire
May 12 2017 03:52
any of you who have finished the tictactoe project: did you build your own AI or use someone else’s algo / library?
Csaba Balogh
@JasonCorp84
May 12 2017 03:53
Do you guys know any good naming conventions ? It starts to be difficult to follow variables for me...
any articles?
HeebieGeeBee
@HeebieGeeBee
May 12 2017 03:54
@the-vampiire i made my own one
but i think lots of ppltry and incorporate the minimax algorithm
Andrew Saganda
@asaganda
May 12 2017 03:54
@hypercuber Yes thanks
CamperBot
@camperbot
May 12 2017 03:54
asaganda sends brownie points to @hypercuber :sparkles: :thumbsup: :sparkles:
:cookie: 353 | @hypercuber |http://www.freecodecamp.com/hypercuber
Andrew Saganda
@asaganda
May 12 2017 03:55
the directions weren't clear or something as i read the github issue thread
Guderian Raborg
@hypercuber
May 12 2017 03:55
@asaganda Okay. Now help me on my question :/ :) :?
np
Vamp
@the-vampiire
May 12 2017 03:56
@HeebieGeeBee any advice on doing so? did you base it on anything or just from scratch? I have no experience with ai
HeebieGeeBee
@HeebieGeeBee
May 12 2017 03:57
mine wasnt really true ai
it was if its the first turn and center square was available, take it
then if theres a chance to win, take it
then if theres a chance player will win, block him
if none of thats available pick a random square
Vamp
@the-vampiire
May 12 2017 04:00
well tbh i dont know what the definition of ai is
but that sounds like intelligent decison making to me!
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:00
i guess i dunno either
Vamp
@the-vampiire
May 12 2017 04:00
i think its those center ones that wll be challenging
i thought the same thing
while i was walking the dogs
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:01
center ones?
Vamp
@the-vampiire
May 12 2017 04:01
but i was trying to think of a way to code a winning route without hardcoding the different patterns
ismael garcia
@leamsigc
May 12 2017 04:01
@hypercuber what exactly do you wanna do???
Vamp
@the-vampiire
May 12 2017 04:01
ya “chance to win take it, chance to lose block it” requires knowing what a “win” is
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:02
i had an array containing all the possible win lines
Guderian Raborg
@hypercuber
May 12 2017 04:02
@leamsigc I want the background of h1 to be on front of the gray background
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:02
think theres 8
water-melon91
@water-melon91
May 12 2017 04:02
please sir tell me any forum and web sites (e.g www.freecodecamp.com) for ios swift
i learn mobile and web
Guderian Raborg
@hypercuber
May 12 2017 04:02
@leamsigc Later I want to add some hover effect
ismael garcia
@leamsigc
May 12 2017 04:04
@hypercuber like this >??? https://codepen.io/Leamsigc/pen/KmoEXe
Guderian Raborg
@hypercuber
May 12 2017 04:06
@leamsigc idk. I am planning on making a sketch on what I want...
ismael garcia
@leamsigc
May 12 2017 04:07
ok @hypercuber make the sketch and let me know if i can help you
Csaba Balogh
@JasonCorp84
May 12 2017 04:09
image.png
I do not get this. It return everything true as I expect it, however it do not return true with a long string
what do I miss ?

function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor

return str.charAt(str.length-1) === target.charAt(target.length-1);
}

confirmEnding("Bastian", "n");

this: confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") should return false.
returns false
BKLN85
@BKLN85
May 12 2017 04:11
Hello good people, Im having trouble with the String.fromCharCode()
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:11
@JasonCorp84 youre meant to compare the end to target
and target might be longer than just one character
Guderian Raborg
@hypercuber
May 12 2017 04:12
Csaba Balogh
@JasonCorp84
May 12 2017 04:12
@HeebieGeeBee yes, but all others return true
ismael garcia
@leamsigc
May 12 2017 04:12
@JasonCorp84 probable you should add if statement
VijayVj7
@VijayVj7
May 12 2017 04:12
@hypercuber you can z-index for stacking the elements
Guderian Raborg
@hypercuber
May 12 2017 04:12
I need the background of h1 separate to add effects
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:13
an if statement isnt needed
Guderian Raborg
@hypercuber
May 12 2017 04:13
@VijayVj7 I know but it does not stack the background
Csaba Balogh
@JasonCorp84
May 12 2017 04:13
even this :confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain") should return false.
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:13
you just need to think about what youre taking from the end of str to confirm with target
Guderian Raborg
@hypercuber
May 12 2017 04:13
@VijayVj7 Thanks here is my code:
CamperBot
@camperbot
May 12 2017 04:13
hypercuber sends brownie points to @vijayvj7 :sparkles: :thumbsup: :sparkles:
:warning: @vijayvj7's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Guderian Raborg
@hypercuber
May 12 2017 04:15
  body {
    padding: 0; margin: 0px;
    text-align: center;
    color: white;
    opacity: .7;
  } 
  canvas {
    vertical-align: top;
  } 
  h1 {
    background-color: black;
    margin: 10px 10px 0px 10px;
    padding: 5px;
    border-radius: 25px 25px 25px 25px;
    z-index: 10;
  }
  .box {
    background-color: gray;
    margin: -10px 10px 10px 10px; /*T R B L*/
    padding: 5px 5px 50px 5px;
    border-radius: 25px / 25px;
    z-index: -10;
  }
  #tf {
    border-radius: 25px / 25px;
    padding: 3px 5px 3px 5px; 
  }
  #btn {
    border-radius: 25px / 25px;
    padding: 3px 5px 3px 5px; 
  }
<h1> Wikipedia Viewer </h1>

<div class="box">
  <p> Welcome to my Wikipedia search tool </p>

  <input type="text" id="tf"> 
  <button type="button" id="btn"> Search </button> 


  <a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">/b </a>

</div>
The problem is just h1 and .box in css
I tried z-index but idk why it does not work on background
Ogundele Olumide
@Lumexralph
May 12 2017 04:18
@HeebieGeeBee Good Morning
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:18
@Lumexralph morning
Ogundele Olumide
@Lumexralph
May 12 2017 04:19
@hypercuber what're you trying to achieve?
@HeebieGeeBee howdy?
HeebieGeeBee
@HeebieGeeBee
May 12 2017 04:19
not much hows you?
ismael garcia
@leamsigc
May 12 2017 04:20
@hypercuber https://codepen.io/Leamsigc/pen/KmoEXe someting like this ???
Guderian Raborg
@hypercuber
May 12 2017 04:21
@Lumexralph Something that looks like this: https://www.openprocessing.org/sketch/427988
Ogundele Olumide
@Lumexralph
May 12 2017 04:22
@HeebieGeeBee just woke
Guderian Raborg
@hypercuber
May 12 2017 04:22
@leamsigc That seem to work. I will play with it. I am not very good with css so I would learn something there. Thanks!
CamperBot
@camperbot
May 12 2017 04:22
hypercuber sends brownie points to @leamsigc :sparkles: :thumbsup: :sparkles:
:cookie: 195 | @leamsigc |http://www.freecodecamp.com/leamsigc
Guderian Raborg
@hypercuber
May 12 2017 04:23
That should work better than i thought bc I was thinking of using p5js to change background color
*what I had in mind
ismael garcia
@leamsigc
May 12 2017 04:24
if you have a better idea for it just it me up and i will help if i can @hypercuber
*let me know
deaninous
@deaninous
May 12 2017 04:30
That is some sick design skills
Brittany Rutherford
@brittanyrutherford
May 12 2017 04:37
i am not able to understand the reduce function
Manish Giri
@Manish-Giri
May 12 2017 04:40
@brittanyrutherford why not
any specific doubt?
Brittany Rutherford
@brittanyrutherford
May 12 2017 04:42
thanks @Manish-Giri
CamperBot
@camperbot
May 12 2017 04:43
brittanyrutherford sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5481 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
May 12 2017 04:43
:+1:
Ogundele Olumide
@Lumexralph
May 12 2017 04:43
:smiling_imp:
Manish Giri
@Manish-Giri
May 12 2017 04:44
ggm
:bow:
Ogundele Olumide
@Lumexralph
May 12 2017 04:45
i want to show you a code, i'll pm you
Claudio Restifo
@Marmiz
May 12 2017 04:48
:wave: campers!
quick question: someone of you had any experience of using a fe-framework (React - Vue - Angular)with huge (>10.000 records) tables?
If so mind share some feedback?
Thanks <3
W0RDZ
@W0RDZ
May 12 2017 04:49
hi guys i have a problem with my code for "check for palindromes", anyone help me work out why it is returning false for "_eye"?
where can i post my code? first time on here :S

function palindrome(str) {

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

if (str.length === 0) {
  return true;  
}

if (str[0] !== str[str.length-1]) {
  return false;
}

else {return palindrome(str.slice(1,str.length - 1));
}

}
palindrome("_eye");

Ogundele Olumide
@Lumexralph
May 12 2017 04:51
@W0RDZ you need to remove underscores
W0RDZ
@W0RDZ
May 12 2017 04:51
str = str.toLowerCase().replace(/\W/g, "");
shouldnt that do it?
Ogundele Olumide
@Lumexralph
May 12 2017 04:52
@W0RDZ \W doesn't include underscores
Claudio Restifo
@Marmiz
May 12 2017 04:52
@W0RDZ copying your code but with better formatting :)

function palindrome(str) {

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

    if (str.length === 0) {
      return true;  
    }

    if (str[0] !== str[str.length-1]) {
      return false;
    }

    else {return palindrome(str.slice(1,str.length - 1));
    }
}
palindrome("_eye");
@W0RDZ also FYI:
\W matches any non-word character (equal to [^a-zA-Z0-9_])
undersocre is included
Ogundele Olumide
@Lumexralph
May 12 2017 04:53
@Marmiz underscore is not included
@W0RDZ try using this regex /[\W\_]/g
Claudio Restifo
@Marmiz
May 12 2017 04:55
the underscore is not matched
(we're telling the same thing in two different ways ^^)
Ogundele Olumide
@Lumexralph
May 12 2017 04:56
@Marmiz that's true...... sorry :smile:
Claudio Restifo
@Marmiz
May 12 2017 04:57
np ;)
W0RDZ
@W0RDZ
May 12 2017 04:57
.replace(/[\W_]/g, "") worked thanks heaps!
so can you add any specific characters after \W?
oh silly question haha
Steven
@LemonTruth
May 12 2017 04:58
function findLongestWord(str) {
  string = str.split(" ");
  stringClone = str.split(" ");
  for (i = 0; i < stringClone.length; i++){
    stringy = string.push(string[i].length);
  }
 console.log(stringy);
}
when I run this, the console prints 18. can someone please explain why?
please
Gavo Bon
@GavoGavo
May 12 2017 05:00
Hello all. For "Stand in Line" under the Javascript part of the Front End cert, should the task in the 2nd paragraph read "Call the 'nextInLine' function..." rather than "Write a function 'nextInLine'" (sorry, haven't figured out the markdown composition yet)
Markus Kiili
@Masd925
May 12 2017 05:02
@the-vampiire Switches are usually avoided in favor of if's or lookup objects. There are some rare use cases though.
@Lumexralph @Marmiz Morning.
Claudio Restifo
@Marmiz
May 12 2017 05:04
@Masd925 morning to you :wave:
Zayar Min Aye
@zayarminaye
May 12 2017 05:04
hi guys,, i'm stuck in "Stand in Line" challenge...any help is appreciated
Ogundele Olumide
@Lumexralph
May 12 2017 05:05
@Masd925 morning
Zayar Min Aye
@zayarminaye
May 12 2017 05:05
i don't have any idea how to solve it

function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

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

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

Ogundele Olumide
@Lumexralph
May 12 2017 05:06
@GavoGavo @zayarminaye 1. add item to the end of arr array 2. remove the first element in arr array and return it, you need 2 array methods
Zayar Min Aye
@zayarminaye
May 12 2017 05:07
could u show me an example ?
Ogundele Olumide
@Lumexralph
May 12 2017 05:08
@zayarminaye how do you add a value to the end of an array?
Zayar Min Aye
@zayarminaye
May 12 2017 05:09
by using push() ?
Gavo Bon
@GavoGavo
May 12 2017 05:09
Thanks Ogundele, but I don't know that answers my question... it says to create the function.. but the function is already there. SHould it be worded a little differently, for clarity? I seem to be having trouble grasping functions so I am asking the question genuinely, not knowing if the problem is the way the question is written, or my comprehension
Ogundele Olumide
@Lumexralph
May 12 2017 05:09
@zayarminaye yes, so push item to arr
@GavoGavo just work with that function, and perform the tasks in the body
Steven
@LemonTruth
May 12 2017 05:11
@GavoGavo by that its just saying to edit the already started function
@GavoGavo the function isn't necessarily finished to do the job its asking yet
Zayar Min Aye
@zayarminaye
May 12 2017 05:14
@Lumexralph after push()?
Gavo Bon
@GavoGavo
May 12 2017 05:15
oh ok. I'll have a go thanks @Lumexralph and @LemonTruth.
CamperBot
@camperbot
May 12 2017 05:15
:warning: @lemontruth's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
gavogavo sends brownie points to @lumexralph and @lemontruth :sparkles: :thumbsup: :sparkles:
:star2: 1727 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 12 2017 05:15
@zayarminaye how do you use push method?
Zayar Min Aye
@zayarminaye
May 12 2017 05:16
arr.push(6);
that one is for adding
Ogundele Olumide
@Lumexralph
May 12 2017 05:16
@zayarminaye push item
Dan Skelly
@dskell88
May 12 2017 05:16
rookie coder here! I'm trying to figure out how to convert celsius to fahrenheit in this javascript coding challenge.
Ogundele Olumide
@Lumexralph
May 12 2017 05:17
@dskell88 what do you have?
Zayar Min Aye
@zayarminaye
May 12 2017 05:18
arr.push(6);
arr.shift();
return item; // Change this line
Dan Skelly
@dskell88
May 12 2017 05:18
okay, well it wants me to return 6 different numbers. I'm trying to see understand the logic and the concepts here.
Zayar Min Aye
@zayarminaye
May 12 2017 05:18
what does it mean "change this line"
i don't get it
:(
Dan Skelly
@dskell88
May 12 2017 05:18

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = celcius * (9/5) + 32;

// Only change code above this line
return fahrenheit;

}

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

Coy Sanders
@coymeetsworld
May 12 2017 05:19
@dskell88 you spelled celsius differently in your code
Steven
@LemonTruth
May 12 2017 05:20
@zayarminaye all that means is it wants you to change the code in that line
computermusic
@computermusic
May 12 2017 05:20

Can someone help walk me through this callback problem? I’ve been struggling for hours. I don’t understand how to approach this..

setTimeout(off, 500);

function on(x) {
    x = 1;
    return(x);
}

function off(x) {
    x = 0;
    return(x);
}

function turnOnOff(x, callback){
  setTimeout(function(){
    callback(x)
  })
}

I’m trying to set a value(x) to 1, and then 500 milliseconds later set x to 0, and print it each time...

Markus Kiili
@Masd925
May 12 2017 05:21
@dskell88 The function parameter celsius holds the passed number when the function is called. By using the parameter in the function code, you make it work with any passed number.
Steven
@LemonTruth
May 12 2017 05:21
@zayarminaye the // is a note and it doesn't affect your code
Ogundele Olumide
@Lumexralph
May 12 2017 05:21
@dskell88 celcius ==> celsius
computermusic
@computermusic
May 12 2017 05:22
I don’t know if I’m remotely approaching this correctly.
setTimeout(off, 500);

function on(x) {
    x = 1;
    return(x);
}

function off(x) {
    x = 0;
    return(x);
}
This all makes sense. But I don’t know how to “chain them”.
Chain them as in, turn something on, print it and a second later turn it off.
and then print that
Zayar Min Aye
@zayarminaye
May 12 2017 05:24
i know that // ..
i don't know what to change in that line
arr.push(6);
arr.shift();
this is what i have done so far
adding and removing element from the array
computermusic
@computermusic
May 12 2017 05:26
function nextInLine(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine([2], 1)); // Modify this line to test
console.log("After: " + JSO
@zayarminaye What do you need to do?
Steven
@LemonTruth
May 12 2017 05:26
@zayarminaye okay, good. don't you want to return the value you removed?
Zayar Min Aye
@zayarminaye
May 12 2017 05:28
arr.push(6);
arr.shift();
return arr;
like that?
Markus Kiili
@Masd925
May 12 2017 05:28
@computermusic Do you mean this or something else:
var x;

function on(x) {
    x = 1;
    console.log(x);
}

function off(x) {
    x = 0;
    console.log(x);
}

on();
setTimeout(off, 500);
computermusic
@computermusic
May 12 2017 05:29
@Masd925 YES
Steven
@LemonTruth
May 12 2017 05:29
@zayarminaye it says to return the element that was removed right? not to return the entire array.
computermusic
@computermusic
May 12 2017 05:29
@Masd925 AH. Someone advised I use callbacks but it was confusing me
Imran Pollob
@pollmix
May 12 2017 05:30

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 check(firstName, prop) {

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

}

console.log(check("Sherllock","likes"));

here i cant output no such contact
Steven
@LemonTruth
May 12 2017 05:31
@zayarminaye how would you be able to return only the first element of the array?
Imran Pollob
@pollmix
May 12 2017 05:31
Uncaught TypeError: Cannot read property 'firstName' of undefined
Gavo Bon
@GavoGavo
May 12 2017 05:31
I can't do it.. I honestly don't understand the request in Stand in Line.
Zayar Min Aye
@zayarminaye
May 12 2017 05:31
arr.push(6);
return arr.shift();
Steven
@LemonTruth
May 12 2017 05:31
@GavoGavo okay, send your code
Markus Kiili
@Masd925
May 12 2017 05:31
@computermusic You can also do this:
var x;

function func (val) {
  return function () {
    x = val;
    console.log(val);
  }
}

func(1)();
setTimeout(func(0), 500);
if you for example need more values than just 0 and 1.
Gavo Bon
@GavoGavo
May 12 2017 05:32

@LemonTruth I don't have any :) I don't understand what they're asking.

It seems to say "write a function..." when there is already a function that's been started at least.

computermusic
@computermusic
May 12 2017 05:33
@Masd925 @Masd925 Thank you for the advice. I will study these ideas.
CamperBot
@camperbot
May 12 2017 05:33
computermusic sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4063 | @masd925 |http://www.freecodecamp.com/masd925
Steven
@LemonTruth
May 12 2017 05:33
@zayarminaye okay very nice! now why are you pushing 6?
Zayar Min Aye
@zayarminaye
May 12 2017 05:33
it says to add number to the end of the array
Steven
@LemonTruth
May 12 2017 05:34
@GavoGavo okay, the function has been started but you're supposed to add code into the function.
Zayar Min Aye
@zayarminaye
May 12 2017 05:34
that's why i used push() function to add number
computermusic
@computermusic
May 12 2017 05:35
@Masd925 Why did you write
Steven
@LemonTruth
May 12 2017 05:35
@zayarminaye yes, you're supposed to add a number but what number are you adding?
Gavo Bon
@GavoGavo
May 12 2017 05:35
Thanks @LemonTruth I think I need to dwell on this a little more. I feel lost
CamperBot
@camperbot
May 12 2017 05:35
gavogavo sends brownie points to @lemontruth :sparkles: :thumbsup: :sparkles:
:warning: @lemontruth's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
computermusic
@computermusic
May 12 2017 05:35
func(1)();
Why double () ()?
Zayar Min Aye
@zayarminaye
May 12 2017 05:35
@LemonTruth I added 6
Steven
@LemonTruth
May 12 2017 05:35
@zayarminaye why 6?
Zayar Min Aye
@zayarminaye
May 12 2017 05:35
it didn't say which number to add ..
i just added some random number
@LemonTruth
Steven
@LemonTruth
May 12 2017 05:36
@zayarminaye it wants you to add whatever number they run for item.
Markus Kiili
@Masd925
May 12 2017 05:36
@computermusic func(1) is a function that sets x to 1 and logs it. That function needs to be called for it to happen.
Steven
@LemonTruth
May 12 2017 05:37
@zayarminaye if i ran
Eric Hasegawa
@EricHasegawa
May 12 2017 05:37
Hey, I'm on the "nesting for loops" challenge and I'm quite lost, can anyone lend a hand?
computermusic
@computermusic
May 12 2017 05:38
@Masd925 I know , in your example though you used double parentheses. Was that on purpose?
```
func(1)();
Steven
@LemonTruth
May 12 2017 05:38
nextInLine(testArr, 6)
it would work, but what if I used a different number?
@zayarminaye
computermusic
@computermusic
May 12 2017 05:38
Why not just
func(1);
Zayar Min Aye
@zayarminaye
May 12 2017 05:39
i still don't get it .. @LemonTruth
Mayank Gupta
@mayankguptadotcom
May 12 2017 05:39
var array = [];
function factorialize(num) {
  for (var i=0; i<num; i++){
    array = array.push[num];
    num--;
  }
  num = arr.reduce(function(a,b){
    return a*b;
  }, 1);
  return num;
}

factorialize(5);
Markus Kiili
@Masd925
May 12 2017 05:39
@computermusic That would evaluate to a function like this function () {x = 1;console.log(val);}. You need to call it with () for things to happen.
Steven
@LemonTruth
May 12 2017 05:40
@zayarminaye basically, you want to push item itself
Zayar Min Aye
@zayarminaye
May 12 2017 05:41
got it .. @LemonTruth
Markus Kiili
@Masd925
May 12 2017 05:41
@computermusic As you see in the code, func returns a function.
Zayar Min Aye
@zayarminaye
May 12 2017 05:41
i am supposed to add arr.push(item);
thanks for your help @LemonTruth
CamperBot
@camperbot
May 12 2017 05:41
zayarminaye sends brownie points to @lemontruth :sparkles: :thumbsup: :sparkles:
:warning: @lemontruth's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Steven
@LemonTruth
May 12 2017 05:41
@zayarminaye exaclty
@zayarminaye do you get why tho?
Zayar Min Aye
@zayarminaye
May 12 2017 05:41
yes
Steven
@LemonTruth
May 12 2017 05:41
@zayarminaye okay cool. glad i could help
computermusic
@computermusic
May 12 2017 05:41
@Masd925 I do see that. I’ll have to ponder the extra (). trying to interpret
Zayar Min Aye
@zayarminaye
May 12 2017 05:41
the parameter is alreayd passed in function nextInLine(testArr, 1)
@LemonTruth
@LemonTruth thanks
CamperBot
@camperbot
May 12 2017 05:42
zayarminaye sends brownie points to @lemontruth :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @lemontruth |http://www.freecodecamp.com/lemontruth
Mayank Gupta
@mayankguptadotcom
May 12 2017 05:43
i'm not sure why is this giving me
TypeError: Cannot read property of 'push' of undefined
var array = [];
function factorialize(num) {
  for (var i=0; i<num; i++){
    array = array.push[num];
    num--;
  }
  num = arr.reduce(function(a,b){
    return a*b;
  }, 1);
  return num;
}

factorialize(5);
Steven
@LemonTruth
May 12 2017 05:43
@Masd925 ayy, help a homie out
Manish Giri
@Manish-Giri
May 12 2017 05:43
@mayankguptadotcom array = array.push[num];
is the problem
Markus Kiili
@Masd925
May 12 2017 05:43
@mayankguptadotcom Check what the return value of push is.
Manish Giri
@Manish-Giri
May 12 2017 05:43
read on MDN about .push()
Mayank Gupta
@mayankguptadotcom
May 12 2017 05:44
ok thanks!
Steven
@LemonTruth
May 12 2017 05:44
function findLongestWord(str) {
  string = str.split(" ");
  stringClone = str.split(" ");
  for (i = 0; i < stringClone.length; i++){
    stringy = string.push(string[i].length);
  }
  for (i = 0; i < stringy/2; i++){
    string.shift(i);
  }
   string.sort(function(a, b){
    return b - a;
  });
 console.log(string[0]);
}
does anyone see the problem with my code?
Vicky Lai
@vickylai
May 12 2017 05:45
https://codepen.io/vickylaiio/pen/RVMwmj?editors=0012#
If I want it to continue searching the string?
Ogundele Olumide
@Lumexralph
May 12 2017 05:47
@LemonTruth i = 0; i < stringy/2 do you mean i = 0; i < stringy.length is stringy meant to be an array?
Vicky Lai
@vickylai
May 12 2017 05:47
Nvm. Got it
Steven
@LemonTruth
May 12 2017 05:48
@Lumexralph stringy is an integer for some reason
Dan Couper
@DanCouper
May 12 2017 05:49
Push returns the new length of an array, you're setting stringy as that
Ogundele Olumide
@Lumexralph
May 12 2017 05:49
@LemonTruth from here stringy = string.push(string[i].length); stringy is a reference to the string array
@LemonTruth and yes, what @DanCouper said too
Steven
@LemonTruth
May 12 2017 05:49
@Lumexralph so stringy is an array?
Dan Couper
@DanCouper
May 12 2017 05:50
No, an integer
Ogundele Olumide
@Lumexralph
May 12 2017 05:50
@LemonTruth it's the length of the new array after push method added element to string array
divi2904
@divi2904
May 12 2017 05:50
Capture21.JPG
can someone tell me what's wrong with this code
?
Vicky Lai
@vickylai
May 12 2017 05:51
Okay real question. How to handle this?
https://codepen.io/vickylaiio/pen/RVMwmj?editors=0012#
Steven
@LemonTruth
May 12 2017 05:51
okay, so it is an integer. what do you see is my problem then? @Lumexralph @DanCouper
Dan Couper
@DanCouper
May 12 2017 05:51
@divi2904 post the code here, not a picture of it
Ogundele Olumide
@Lumexralph
May 12 2017 05:51
@LemonTruth what do you aim to achieve with the 2 for loops?
divi2904
@divi2904
May 12 2017 05:52

@DanCouper function translatePigLatin(str) {
var str1= str.split("");
if(str1[0] ==='a','e','i','o','u') {
str1.push('way');
return str1.join('');
}

else if(str1[0] !='a','e','i','o','u'){
var one = str1.shift();
str1.push(one,'ay');
var str3=str1.join('');
return str3;

}

}

translatePigLatin("california");

Steven
@LemonTruth
May 12 2017 05:53
@Lumexralph I basically want to turn an array of strings into an array of numbers so I can order them from greatest to smallest. Once i've done that, I can take the first element which will be the largest string and return it.
Ogundele Olumide
@Lumexralph
May 12 2017 05:54
@LemonTruth do you have a good understanding of map method ?
Steven
@LemonTruth
May 12 2017 05:54
@Lumexralph aawwww snapp
@Lumexralph I realized that im printing the final result. not returning it
@Lumexralph and not really.
Dan Couper
@DanCouper
May 12 2017 05:56
@divi2904 That is not how you do comparisons in if statements, needs to be like (foo === 1|| foo === 2|| foo===3), what you've written is a syntax error.
Steven
@LemonTruth
May 12 2017 05:56
@Lumexralph all I know is that it can modify each element in an array independently
Ogundele Olumide
@Lumexralph
May 12 2017 05:58
@LemonTruth in case that didn't work, split the string onto an array of words, if you can use map use it to return the length of each string and then you can sort. you can also use a for loop, use a variable initialized to 0, compare it to the length of every word in the array and assign the greater length per iteration and when the loop is return you can return the variable which should have held the length of the longest word by then
Vicky Lai
@vickylai
May 12 2017 05:59

function convertHTML(str) {
for (i in str) {
    console.log(str[i]);
    switch (true) {
        case str[i] == '&':
            var converted = str.replace(/\&/g, '&amp;');
            break;
        case str[i] == '<':
            var converted = str.replace(/\</g, '&lt;');
            break;
        case str[i] == '>':
            var converted = str.replace(/\>/g, '&gt;');
            break;
        case str[i] == '"':
            var converted = str.replace(/\"/g, '&quot;');
            break;
        case str[i] == "'":
            var converted = str.replace(/\'/g, '&apos;');
            break;
        default:
            var converted = str;
    }
}
  return converted;
}

console.log(convertHTML("<>"));
It's finding the first bracket "<", but only replaces the second ">". Help?
divi2904
@divi2904
May 12 2017 05:59
@DanCouper It doesn't show error and only one block of if is working at a time.
Markus Kiili
@Masd925
May 12 2017 06:00
@vickylaiio switch (true) doesn't look good.
Vicky Lai
@vickylai
May 12 2017 06:01
@Masd925 It means well though, and tries hard. One day it'll find a nice husband.
Steven
@LemonTruth
May 12 2017 06:01
@Lumexralph wow, that can make my code A LOT more concise. thanks very muuch
CamperBot
@camperbot
May 12 2017 06:01
lemontruth sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1728 | @lumexralph |http://www.freecodecamp.com/lumexralph
Markus Kiili
@Masd925
May 12 2017 06:01
@vickylaiio Maybe switch(str[i]) and case: "&"
Vicky Lai
@vickylai
May 12 2017 06:02
@Masd925 Works but doesn't solve the "<>" problem
@Masd925 Actually now it doesn't work.
Coy Sanders
@coymeetsworld
May 12 2017 06:03
could also do a regex search/replace @vickylaiio
Markus Kiili
@Masd925
May 12 2017 06:03
That would be much better idea yes.
Dan Couper
@DanCouper
May 12 2017 06:03
@divi2904 you have to correct the if statements, and surely only one block can work at a time anyway?
Vicky Lai
@vickylai
May 12 2017 06:04
@coymeetsworld I think... maybe I'm confused. I thought I was. Uh oh.
Coy Sanders
@coymeetsworld
May 12 2017 06:05
oh I see @vickylaiio, well your replace calls already go through and replace everything
so you don't really need to run a for loop or a switch statement
Vicky Lai
@vickylai
May 12 2017 06:05
@coymeetsworld Gotcha
Coy Sanders
@coymeetsworld
May 12 2017 06:05
just run those 5 replace methods and you should be good
Vicky Lai
@vickylai
May 12 2017 06:05
But then why no worky
Coy Sanders
@coymeetsworld
May 12 2017 06:06
what you have above?
Chris Cullen
@123xylem
May 12 2017 06:06

$ webpack
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API s chema.

  • configuration.output.path: The provided value "./app/temp/scripts" is not an absolute path!
const path = require('path');
path: path.resolve(__dirname, './dist'),

module.exports= {
    entry:"./app/assets/scripts/app.js",      //Where we take js files from
    output: {
        path:"./app/temp/scripts",            //where we put them
        filename:"App.js"                     //what we call compiled bunch
    }
}

ANy idea how to fix this? error?

Coy Sanders
@coymeetsworld
May 12 2017 06:06
oh well one thing is you're always calling replace on str
but you're storing the results in converted
Dan Couper
@DanCouper
May 12 2017 06:07
@vickylaiio being applied to str. And each one creates a new string, so only the last one registers
Coy Sanders
@coymeetsworld
May 12 2017 06:07
you should just omit the converted variable and just reassign back to str, that should help
Vicky Lai
@vickylai
May 12 2017 06:07
@DanCouper AAAHHH
Coy Sanders
@coymeetsworld
May 12 2017 06:07
what @DanCouper said too
Vicky Lai
@vickylai
May 12 2017 06:07
@DanCouper Thank you
CamperBot
@camperbot
May 12 2017 06:07
vickylaiio sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 707 | @dancouper |http://www.freecodecamp.com/dancouper
Vicky Lai
@vickylai
May 12 2017 06:08
yes. yes ok I can do this
Dan Couper
@DanCouper
May 12 2017 06:08
Better would be have an array, and just push either the conversion or str[i] every time, then join
Coy Sanders
@coymeetsworld
May 12 2017 06:09
I just called replace 5 times
Vicky Lai
@vickylai
May 12 2017 06:09
Was trying to do it without array 'cause I feel like I'm too dependent on them
Coy Sanders
@coymeetsworld
May 12 2017 06:09
less code, but probably less efficient than looping once
Vicky Lai
@vickylai
May 12 2017 06:09
This worked:

function convertHTML(str) {
str = str.replace(/\&/g, '&amp;');
str = str.replace(/\</g, '&lt;');
str = str.replace(/\>/g, '&gt;');
str = str.replace(/\"/g, '&quot;');
str = str.replace(/\'/g, '&apos;');
  return str;
}

console.log(convertHTML("<>"));
I dunno if anyone's paying attention but I have a habit of overthinking things...
Coy Sanders
@coymeetsworld
May 12 2017 06:10
@vickylaiio yeah that's what I had as my soln too
its good to try things out, but don't not use something because you feel like you're using it too much :)
Charu Agarwal
@freebird1195
May 12 2017 06:10
Hey, I need some help. Anyone here?
Dan Couper
@DanCouper
May 12 2017 06:10
If you use the loop and switch, you don't need to use replace at all, either build up a new string (or array)
Coy Sanders
@coymeetsworld
May 12 2017 06:11
right, just would take more code and it would be a little faster
I would think
Dan Couper
@DanCouper
May 12 2017 06:11
Very much faster, but yeah a bit more code (less than the original attempt tho)
Favian Ioel P.
@FavianIoel
May 12 2017 06:12
@vickylaiio you are cute
Coy Sanders
@coymeetsworld
May 12 2017 06:12
would it be very much faster?
replace is n speed, 5 calls would be 5n
Dan Couper
@DanCouper
May 12 2017 06:12
Yeah, no regex, no function calls
Coy Sanders
@coymeetsworld
May 12 2017 06:12
oh true
@freebird1195 what's up?
Manish Giri
@Manish-Giri
May 12 2017 06:12
@freebird1195 post the problem and the code..
Charu Agarwal
@freebird1195
May 12 2017 06:13
Here it is.
Coy Sanders
@coymeetsworld
May 12 2017 06:13
@DanCouper you still have to run at least a join and a split i would imagine right?
Charu Agarwal
@freebird1195
May 12 2017 06:13
image.png
Can't seems to figure out why it doesn't work
Manish Giri
@Manish-Giri
May 12 2017 06:14
at the very outset
Alexander Køpke
@alexanderkopke
May 12 2017 06:14
🕺
Manish Giri
@Manish-Giri
May 12 2017 06:14
the challenge expects an array
Charu Agarwal
@freebird1195
May 12 2017 06:14
collection.filter will return an array
Markus Kiili
@Masd925
May 12 2017 06:14
@vickylaiio You can combine those replaces into one:
function convertHTML(str) {
  var conversion = {'&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;', "'":'&apos;' };
  return str.replace(/[\&\<\>\"\']/g,function(char){
    return conversion[char];
  });
}
Manish Giri
@Manish-Giri
May 12 2017 06:15
did you check the console?
Favian Ioel P.
@FavianIoel
May 12 2017 06:15
@freebird1195 the second return is useles , it will never enter in it.
Coy Sanders
@coymeetsworld
May 12 2017 06:15
it should return an array
Vicky Lai
@vickylai
May 12 2017 06:15
@Masd925 I hear violins.
Coy Sanders
@coymeetsworld
May 12 2017 06:15
2nd return could happen @FavianIoel
Charu Agarwal
@freebird1195
May 12 2017 06:15
   if((!obj.hasOwnProperty(temp[i]) || obj[temp[i]]!==source[temp[i]]))
this works.
Favian Ioel P.
@FavianIoel
May 12 2017 06:16
third i mean
Charu Agarwal
@freebird1195
May 12 2017 06:16
the issue was hasOwnProperty(temp[i]) not [temp[i]]
Favian Ioel P.
@FavianIoel
May 12 2017 06:16
@coymeetsworld the one with return true
Vicky Lai
@vickylai
May 12 2017 06:16
I read about replace taking a function but didn't get it. Thank you! @Masd925
Markus Kiili
@Masd925
May 12 2017 06:16
@vickylaiio Sorry, I am not nice. You have to continue looking :imp:
CamperBot
@camperbot
May 12 2017 06:16
vickylaiio sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4064 | @masd925 |http://www.freecodecamp.com/masd925
Coy Sanders
@coymeetsworld
May 12 2017 06:17
@freebird1195 oh yep thats the issue
Maksim
@SirGoldman
May 12 2017 06:17
Hi, can somone explain me, why my code doesing work?
Coy Sanders
@coymeetsworld
May 12 2017 06:17
hasOwnProperty is a function, not an array
doesn't use square brackets uses parenthesis
im not sure if theres anything else wrong after a second glance
Maksim
@SirGoldman
May 12 2017 06:18

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

function checkObj(checkProp) {
  if(myObj.hasOwnProperty(checkProp)){
    return myObj.checkProp;
  }else{
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
Favian Ioel P.
@FavianIoel
May 12 2017 06:18
@SirGoldman yes, what is your problem
Manish Giri
@Manish-Giri
May 12 2017 06:18
@SirGoldman use bracket notation
myObj.checkProp;
Maksim
@SirGoldman
May 12 2017 06:19
Yea it worked. But why it didin't work with dot?
Manish Giri
@Manish-Giri
May 12 2017 06:20
no
Coy Sanders
@coymeetsworld
May 12 2017 06:20
can't use dot for variables @SirGoldman
Dan Couper
@DanCouper
May 12 2017 06:20
@coymeetsworld there would be one join at the end: you don't need to split to iterate through the string. String concatenation isn't as fast as pushing to an array then joining, + there is only a single array you push to as opposed to building a new string on aach iteration
Coy Sanders
@coymeetsworld
May 12 2017 06:21
using a dot will check for a property with that name in the object, so in this case it would check for a property in myObj named "checkProp", not the value of the variable checkProp
Maksim
@SirGoldman
May 12 2017 06:21
ohhh
@coymeetsworld Thanks a lot :)
CamperBot
@camperbot
May 12 2017 06:22
sirgoldman sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2580 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld