These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Jun 2016
Norvin Burrus
@ndburrus
Jun 04 2016 00:00
This message was deleted
gurdit
@Gurdit
Jun 04 2016 00:00
where to add the back-ticks , at the end of the code or at the beginning ?
ok @ndburrus
ThaleSelaht
@ThaleSelaht
Jun 04 2016 00:01
@Gurdit both
Norvin Burrus
@ndburrus
Jun 04 2016 00:01
@Gurdit ..sorry, that line was good... backticks are placed at the beginning and at the end of the code. see the other comment regarding tiny (above)
Diego Mayer
@Chrono79
Jun 04 2016 00:02
@Gurdit :point_up: 3 de junio de 2016 20:57
gurdit
@Gurdit
Jun 04 2016 00:02
the code was running and also showing the perfect output
but challenge is not proceeding
forward
Jonathan Carroll
@gkcodeman
Jun 04 2016 00:03
@Chrono79 you still here? Lol nice!
gurdit
@Gurdit
Jun 04 2016 00:03
hahaha
Diego Mayer
@Chrono79
Jun 04 2016 00:03
I live here @gkcodeman
Jonathan Carroll
@gkcodeman
Jun 04 2016 00:03
@Chrono79 mind if we all stay in your house along side ya?
Diego Mayer
@Chrono79
Jun 04 2016 00:04
just don't dirty the carpet ;)
Jonathan Carroll
@gkcodeman
Jun 04 2016 00:04
@Chrono79 shoes @ door . Check!!
Virtual door
Oh man this is JavaScript land. Let me get outta here. I'm not bad but I got some work to do in this area.
Diego Mayer
@Chrono79
Jun 04 2016 00:06
don't forget the shoes!
Jonathan Carroll
@gkcodeman
Jun 04 2016 00:07
@Chrono79 whew. Thanks woulda been funny walking home without the sneaks
CamperBot
@camperbot
Jun 04 2016 00:07
gkcodeman sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1013 | @chrono79 |http://www.freecodecamp.com/chrono79
Jonathan Mitchell
@Vanhealen
Jun 04 2016 00:15

So ive noticed that some methods are written as "onName" to access the property "Name". For instance with ajax the method

.onreadystatechange

accesses the property

readystatechange

of the object created by a new AJAX request, we can call that object "request" if I had the following lines of code

var request = new XMLHTTPrequest()

Am I getting this right??

are the methods prefixes with "on" and the properties don't have the "on" prefix?
Diego Mayer
@Chrono79
Jun 04 2016 00:22
@Vanhealen are you sure readystatechange is a property?
Isn't it readystate?
https://developer.mozilla.org/es/docs/Web/Events/readystatechange
Venkat
@bvenkatr
Jun 04 2016 00:23
Hi There, Can you expect the output of below code snippet?
var fun1 = function (input, cb) {
  setTimeout(function () {
    cb(input);
  }, 2000);
};
function fetchProfiles() {
  for (var i = 0; i < 5; i++) {
    fun1(i, function (i) {
      console.log(`${i}`);
    });
  }
}

fetchProfiles();
Jonathan Mitchell
@Vanhealen
Jun 04 2016 00:23
@Chrono79 I am pretty unsure at this point. I am trying to learn about AJAX right now. (I know almost nothing about it). MDN says its an attribute
Diego Mayer
@Chrono79
Jun 04 2016 00:25
@Vanhealen well, it also says that readystatechange is an event
Jonathan Mitchell
@Vanhealen
Jun 04 2016 00:25

@Chrono79 so "onreadystatechange" is a property
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/onreadystatechange

when it is called with

XMLHttpRequest.onreadystatechange = callback

it becomes a method!

However "readystatechange" is an event

so the method to evaluate the event is "onreadystatechange" and the event itself is "readystatechange"
thanks @Chrono79
CamperBot
@camperbot
Jun 04 2016 00:25
vanhealen sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1014 | @chrono79 |http://www.freecodecamp.com/chrono79
Jonathan Mitchell
@Vanhealen
Jun 04 2016 00:25
I hope thats correct. If I am wrong please let me know
Diego Mayer
@Chrono79
Jun 04 2016 00:25
no problem
Jonathan Mitchell
@Vanhealen
Jun 04 2016 00:27
@Chrono79 was I correct?
Diego Mayer
@Chrono79
Jun 04 2016 00:31
I'm not sure if calling it a method is ok, they refer to it as a property with a callback
Jonathan Mitchell
@Vanhealen
Jun 04 2016 00:31
well a method is a property
its just a property that is a function
so you could say that is it a property of the XMLHttprequest constructor and that would be correct?
Diego Mayer
@Chrono79
Jun 04 2016 00:33
This technical ajax discussion is not my cup of tea, maybe someone else could confirm or deny it
But what you say makes sense
Reggie
@ReggieSibley
Jun 04 2016 00:37
function orderMyLogic(val) {
  if (val < 10) {
    return "Less than 10";
  } 

   else if(val < 5) {
    return "Less than 5";
  } 

  else {
    return "Greater than or equal to 10";
  }

}

// Change this value to test
orderMyLogic(3);
logical order in if else statements, what am i doing wrong?
Diego Mayer
@Chrono79
Jun 04 2016 00:38
@ReggieSibley what happens when you try with 3? It says "Less than 10" which is true although it should say "Less than 5"
Jan
@janmitck
Jun 04 2016 00:42
this switch is becoming a witch
Yrureta
@Yrureta
Jun 04 2016 00:42
@ReggieSibley Put first the second condition.
Jan
@janmitck
Jun 04 2016 00:43

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(val) {
case "b":
answer = "apple";
break;
case "b";
answer = "bird";
break;
case "c";
answer = "cat";
default:
answer = "stuff";
break;
}

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

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

Diego Mayer
@Chrono79
Jun 04 2016 00:43
@janmitck you have two "b" cases, and some typos
case "b"; <- this should be : instead of ;
Jan
@janmitck
Jun 04 2016 00:44
@Chrono79 nice catch
I fixed it and it still doesn't work
@Chrono79 okay I'll try that
@Chrono79 on the right track thanks!
CamperBot
@camperbot
Jun 04 2016 00:45
janmitck sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1015 | @chrono79 |http://www.freecodecamp.com/chrono79
Jonathon Lopez
@JonathonLLopez
Jun 04 2016 00:46
I'm having some trouble with this:

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

  // Only change code below this line
  var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy", 
    "foxtrot": "Frank"
  };
  lookup["val"];
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
Diego Mayer
@Chrono79
Jun 04 2016 00:47
@JonathonLLopez it's not "val" inside the brackets, and you should assign that to result, that's the var you're returning
Norvin Burrus
@ndburrus
Jun 04 2016 00:47
@JonathonLLopez review the example simple reverse lookup chart...
David Gagne
@david-gagne
Jun 04 2016 00:55

Hi campers,

I'm on the "Stand in Line" challenge and truly have no clue how to go about completing it. Here's what I have thus far:

function nextInLine(arr, item) {

  return nextInLine([""], item);  // Change this line
}

Please help.

Jonathon Lopez
@JonathonLLopez
Jun 04 2016 00:56

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

  // Only change code below this line
  var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy", 
    "foxtrot": "Frank"
  };
  result = lookup[""];

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

// Change this value to test
phoneticLookup("charlie");
I think this is closer, but I still can't figure out what I'm missing
David Gagne
@david-gagne
Jun 04 2016 00:56
Also, could someone explain the lingo of this challenge? I'm confused by the description.
Diego Mayer
@Chrono79
Jun 04 2016 00:57
@JonathonLLopez use val here: result = lookup[""]; No quotes needed
Jonathon Lopez
@JonathonLLopez
Jun 04 2016 00:59
@Chrono79 that was confusing because when I asked for help previously somone mentioned that I needed quotes around the variable
Diego Mayer
@Chrono79
Jun 04 2016 01:00
@JonathonLLopez I can't think of a case where you could need quotes around a var, but ok, here they're not needed
Daniel Godigna
@DGAcode
Jun 04 2016 01:00
where I can find a good text about iteration with while?
Jonathon Lopez
@JonathonLLopez
Jun 04 2016 01:01
@Chrono79 I guess if I wasn't looking in the wrong direction the whole time it might've been easier. Thank you though
CamperBot
@camperbot
Jun 04 2016 01:01
jonathonllopez sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1016 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 04 2016 01:02
@david-gagne you have to review the previous challenges where you manipulate an array
Manipulate Arrays With push
Manipulate Arrays With pop
Manipulate Arrays With shift
Manipulate Arrays With unshift
David Gagne
@david-gagne
Jun 04 2016 01:03
@Chrono79 I'm looking at them, but I'm having a tough time figuring out how to format the code.
Norvin Burrus
@ndburrus
Jun 04 2016 01:04
@33hawk ..you may fid this useful: MDN, Loops and iteration, {ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration } w3school.com, JavaScript While Loop {ref: http://www.w3schools.com/js/js_loop_while.asp } For, While, and Do... While Loops inJavaScript, {ref: https://www.kirupa.com/html5/loops_in_javascript.htm }, Looping in JavaScript, {ref: http://james.padolsey.com/javascript/looping-in-javascript/ }
Diego Mayer
@Chrono79
Jun 04 2016 01:04
@david-gagne
Add the number to the end of the array <- which of the above methods could you use to do this?
David Gagne
@david-gagne
Jun 04 2016 01:04
.push()
Diego Mayer
@Chrono79
Jun 04 2016 01:05
ok, and how do you code that? your array name is arr and the number is item
Daniel Godigna
@DGAcode
Jun 04 2016 01:05
@ndburrus good thanks, the thing is I know how to do the basic stuff, but a complex one is not easy
CamperBot
@camperbot
Jun 04 2016 01:05
33hawk sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 484 | @ndburrus |http://www.freecodecamp.com/ndburrus
Gabriel Rowe
@gabrielwr
Jun 04 2016 01:05
Hey guys, can anybody help me with the "using objects for lookups" page? I am having a hard time figuring out what is needed
jstormail2
@jstormail2
Jun 04 2016 01:05
Hello! Would you all mind helping me with a little js on this codepen? http://codepen.io/jstormail2/pen/jrPqow
Gabriel Rowe
@gabrielwr
Jun 04 2016 01:06
or what they are looking for
David Gagne
@david-gagne
Jun 04 2016 01:07
@Chrono79 arr.push(item)
@Chrono79 I think...
Norvin Burrus
@ndburrus
Jun 04 2016 01:07
@gabrielwr can you post your code so far? ... they are asking for a conversion of the switch to a lookup table.
Gabriel Rowe
@gabrielwr
Jun 04 2016 01:08

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

// Only change code below this line
var lookup(val) = {
"alpha": result = "Adams";

 "bravo": result = "Boston";

 "charlie": result = "Chicago";

"delta": result = "Denver";

"echo": result = "Easy";

"foxtrot": result = "Frank";

};

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

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

Diego Mayer
@Chrono79
Jun 04 2016 01:08
@gabrielwr create an objects where it's keys are the values of your cases and the values (of your properties) are the values you're assigning to result
@david-gagne that's ok
David Gagne
@david-gagne
Jun 04 2016 01:09
@Chrono79 I'm getting there. I can take it from here. Thanks!
CamperBot
@camperbot
Jun 04 2016 01:09
david-gagne sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1017 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 04 2016 01:09
@david-gagne :+1:
Norvin Burrus
@ndburrus
Jun 04 2016 01:09
@gabrielwr check/review the lookup table formatting per the example...
Gabriel Rowe
@gabrielwr
Jun 04 2016 01:10
oops, sorry I posted older code!

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

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

 "bravo": result = "Boston",

 "charlie": result = "Chicago",

"delta": result = "Denver",

"echo": result = "Easy",

"foxtrot": result = "Frank",

};

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

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

Hopeej
@Hopeej
Jun 04 2016 01:10
hey guys! I'm really confused by the "Word Blanks" challenge. I'm not quite sure what I need to do or fix. Any advice or help?
Gabriel Rowe
@gabrielwr
Jun 04 2016 01:10
nevermind, I think I got it
Norvin Burrus
@ndburrus
Jun 04 2016 01:10
@gabrielwr same comment... is there a result used in the example table?
Dylan
@dhcodes
Jun 04 2016 01:10
help word blanks
CamperBot
@camperbot
Jun 04 2016 01:10

:point_right: challenge word blanks [wiki]

Challenge Word Blanks

We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

:pencil: read more about challenge word blanks on the FCC Wiki

Dylan
@dhcodes
Jun 04 2016 01:11
@Hopeej they give you some variables
you need to concatenate them with +
"The " + myNoun + etc.
Hopeej
@Hopeej
Jun 04 2016 01:11
Thanks!
Norvin Burrus
@ndburrus
Jun 04 2016 01:11
This message was deleted
jstormail2
@jstormail2
Jun 04 2016 01:13
Any suggestions you all? :smile:
Dylan
@dhcodes
Jun 04 2016 01:13
@ndburrus i was just refreshing myself of the challenge to help hopee
Norvin Burrus
@ndburrus
Jun 04 2016 01:14
This message was deleted
Peter Weinberg
@no-stack-dub-sack
Jun 04 2016 01:17
help Caesars Cipher
CamperBot
@camperbot
Jun 04 2016 01:17

:point_right: algorithm caesars cipher [wiki]

Algorithm Caesars Cipher

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is shifted by 13 places. e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Dylan
@dhcodes
Jun 04 2016 01:18
@no-stack-dub-sack the trouble i had on that was that if the number landed outside the alphabet, you need to do the opposite operation
i.e. + should be -
Norvin Burrus
@ndburrus
Jun 04 2016 01:19
@jstormail2 what were/are you working on?
jstormail2
@jstormail2
Jun 04 2016 01:20
@ndburrus I was trying to get a js plugin to work on a code pen above
Diego Mayer
@Chrono79
Jun 04 2016 01:20
@jstormail2 multiple console errors, check that
Jonathon Lopez
@JonathonLLopez
Jun 04 2016 01:21

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

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty("checkProp"); 
  if (checkProp === myObj[checkProp]) {
    return myObj[checkProp];
  } else {
    return "Not Found";
  }
}
// Test your code by modifying these values
checkObj("gift");
Should I be using an if statement for this?
Peter Weinberg
@no-stack-dub-sack
Jun 04 2016 01:21
@dhcodes Yeah, I thought of that, so anything A-M needs to be shifted up 13 and anything N-Z needs to be shifted down 13, right?
Norvin Burrus
@ndburrus
Jun 04 2016 01:21
@jstormail2 what kind/type of js plugin? oh, i see it above...
Peter Weinberg
@no-stack-dub-sack
Jun 04 2016 01:21
I'm having other issues besides that though
Diego Mayer
@Chrono79
Jun 04 2016 01:21
@JonathonLLopez this line by itself, doesn't do anything: myObj.hasOwnProperty("checkProp");
You should use that as your if condition
jstormail2
@jstormail2
Jun 04 2016 01:22
Ohh, I forgot to remove those links to external sheets, but I put the code in the css/js sections
It's a responsive lightbox plugin http://sorgalla.com/lity/
Peter Weinberg
@no-stack-dub-sack
Jun 04 2016 01:22
@dhcodes you have to use a loop to iterate through the string to convert every character to ASCII right?
Jonathon Lopez
@JonathonLLopez
Jun 04 2016 01:25
@Chrono79 More like this then?

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

function checkObj(checkProp) {
  // Your Code Here 
  if (myObj.hasOwnProperty("checkProp") ) {
    return myObj[checkProp];
  } else {
    return "Not Found";
  }
}
// Test your code by modifying these values
checkObj("gift");
Diego Mayer
@Chrono79
Jun 04 2016 01:25
@JonathonLLopez yes, does it work? No, it doesn't, why the quotes? "checkProp"
Jonathon Lopez
@JonathonLLopez
Jun 04 2016 01:26
@Chrono79 not currently
@Chrono79 oh you're right. I keep putting variables in quotes. I suppose I was following the example. Thanks
jstormail2
@jstormail2
Jun 04 2016 01:29
Well, I removed most of the console errors except Uncaught ReferenceError: lity is not defined(anonymous function) @ index.html:42
index.html:46 Uncaught ReferenceError: lity is not defined(anonymous function) @ index.html:46
Norvin Burrus
@ndburrus
Jun 04 2016 01:29
This message was deleted
Yi Jie Tan
@ejaetan
Jun 04 2016 01:33
Screen Shot 2016-06-03 at 6.32.36 PM.png
Hi, I am working on the "Record Collection" at the JavaScript section. May I do what have I done wrong in line 35 and 36?
Diego Mayer
@Chrono79
Jun 04 2016 01:35
@ejaetan look at the test case that's not passing
Daniel Godigna
@DGAcode
Jun 04 2016 01:35
This message was deleted
Yi Jie Tan
@ejaetan
Jun 04 2016 01:36
it doesn't push the value into the array
@Chrono79
Diego Mayer
@Chrono79
Jun 04 2016 01:36
@ejaetan because there is no array to start with
Yi Jie Tan
@ejaetan
Jun 04 2016 01:37
ok, so i guess i will have to write a statement to add the new property into the object?
@Chrono79
Diego Mayer
@Chrono79
Jun 04 2016 01:38
yes, only if it doesn't exist
Daniel Godigna
@DGAcode
Jun 04 2016 01:40
help Find the Longest Word in a String
CamperBot
@camperbot
Jun 04 2016 01:40

:point_right: algorithm find the longest word in a string [wiki]

Algorithm Find the Longest Word in a String

Explanation:

You have to go through each word and figure out which one is the longest and return not the word, but how many characters it has.

:pencil: read more about algorithm find the longest word in a string on the FCC Wiki

Yi Jie Tan
@ejaetan
Jun 04 2016 01:40
@Chrono79 I added this before push, but it doesn't work. =(
if (!collection[id][prop]) {
collection[id][prop] = "tracks";
}
Dylan
@dhcodes
Jun 04 2016 01:41
yep @no-stack-dub-sack
sorry but i gotta run. good luck
jstormail2
@jstormail2
Jun 04 2016 01:43
any suggestions on how to get rid of the uncaught reference errors?
Diego Mayer
@Chrono79
Jun 04 2016 01:46
@ejaetan no, it won't work like that, you could use hasOwnProperty to check if tracks exist and instead of push if it doesn't assign the value to the prop
Sudeep Narkar
@sudeepnarkar
Jun 04 2016 01:49
What css framework are you guys using for the ziplines?
I do not want to to code in the front end from scratch.
Are you guys using bootstrap?
lorenalugo
@lorenalugo
Jun 04 2016 01:51
@ejaetan I did this challenge today, notice that the id doesn't have the tracks array, so you have to create the array using the new value of the function
I need help with nesting for loops, i don't find the mistake:
lorenalugo
@lorenalugo
Jun 04 2016 01:56
function multiplyAll(arr) {
var product = 1;
for (var i=0; i <= arr.length; i++) {
for (var j=0; j <= arr[i].length; j++) {
product *= arr[i][j];
}
}
return product;
}
multiplyAll([[1,2],[3,4],[5,6,7]]);
it doesn't work, says TYPE ERROR: arr[i] undefined
jstormail2
@jstormail2
Jun 04 2016 02:03
Well I finally figured out how to get rid of the uncaught reference errors, but it still isn't working
Now I'm having trouble with autoplays even though I'm trying to use document ready
eeflores
@eeflores
Jun 04 2016 02:09
@lorenalugo use i < arr.length and j < arr[i].length instead of using <=
@lorenalugo the last element of an array is arr.length - 1
jstormail2
@jstormail2
Jun 04 2016 02:10
Heck yes finally figured it out after hours, does anyone know how to simplify this?

```<script type="text/javascript">
$(document).on('click', '.myclass', function (clickEvent) {

var lightbox = lity();
$(".myclass").on('click', '[data-lightbox]', lightbox('https://www.youtube.com/watch?v=gTLkCgCO0NI'));

});

</script>```

Yi Jie Tan
@ejaetan
Jun 04 2016 02:11
@lorenalugo @Chrono79 thanks guys! it works! =D
CamperBot
@camperbot
Jun 04 2016 02:11
:warning: could not find receiver for lorenalugo
:star2: 1018 | @chrono79 |http://www.freecodecamp.com/chrono79
ejaetan sends brownie points to @lorenalugo and @chrono79 :sparkles: :thumbsup: :sparkles:
Brendan Kinahan
@BKinahan
Jun 04 2016 02:11
lol, gitter added the video in because the code wasn't formatted. backticks should be on their own lines, @jstormail2 :)
jstormail2
@jstormail2
Jun 04 2016 02:12
lol thanks :smile:
lorenalugo
@lorenalugo
Jun 04 2016 02:13
@eeflores thanks i didn't notice. it worked
CamperBot
@camperbot
Jun 04 2016 02:13
lorenalugo sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 739 | @eeflores |http://www.freecodecamp.com/eeflores
David Gagne
@david-gagne
Jun 04 2016 02:18
@Chrono79 I finall y got it after having dinner! Turns out attempting to code isn't very effective on an empty stomach.
jstormail2
@jstormail2
Jun 04 2016 02:20
I haven't figured out how to simplify the code above without inflicting auto-play, any suggestions?
Chris Cullen
@123xylem
Jun 04 2016 02:28

@123xylem

function pairElement(str) {
  var arr=str.split("");
  var AT=["A","T"];
  var TA=["T","A"];
  var CG=["C","G"];
  var GC=["G","C"];
  var newarr=[];
  for(i=0;i<arr.length;i++){
   if(arr[i]=== "G"){
    arr.push(GC)  ;


    }
    if(arr[i]=== "C"){
     arr.push(CG) ;


    }else if(arr[i]=== "A"){
      arr.splice(arr[i], 0, AT);


    }else if(arr[i]=== "T"){
      arr.splice(arr[i], 0, TA);

    }return arr;

  }

}

pairElement("GCG");

Do you know why this only works on the first if statement and ignores the rest?
The .splice and .push change was just me testing if it was something to do with that but it wasnt.

Moisés Man
@moigithub
Jun 04 2016 02:29
@123xylem u have a variable named newArr whats used for ??
Brett Guillory
@kurzninja
Jun 04 2016 02:30
You should try using switch/case statements
@123xylem
Everyone should come join the FreeCodeCamp room at Plug.dj :D
Nando Delgado
@nandod1707
Jun 04 2016 02:32

@khaduch

@nandod1707 - are you familiar with "walking through" the execution of a loop and figuring out what the code would do under different circumstances? If you are, what would happen if your function argument was "Sherlock" instead of "Akira" - would your code be able to find that contact?

Hey thanks for taking the time to reply! I must be missing something :/ wouldn't the function be able to find the contact?

CamperBot
@camperbot
Jun 04 2016 02:32
nandod1707 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1253 | @khaduch |http://www.freecodecamp.com/khaduch
Moisés Man
@moigithub
Jun 04 2016 02:34
@123xylem put ur code here.. pythontutor.com/javascript.html
Stephen
@stephepush
Jun 04 2016 02:35
I'm working on the "Title Case a Sentence" algorithm. Is this too complicated?
function titleCase(str) {
    str = str.toLowerCase();
    str = str.split(" ");
    function firstUpper(str){
        for(i=0; i<str.length;i++);
        var firstCap = str.substr(0,1);
        firstCap = firstCap.toUpperCase();
        var otherChars = str.substr(1);
        var concatStr = firstCap.concat(otherChars);
    }
    firstUpper(str);

}

titleCase("I'm a little tea pot");
Stephen
@stephepush
Jun 04 2016 02:43
guess theres no one here on friday night, lol
Frank XC
@tenkdayz
Jun 04 2016 02:43
@stephepush does that work?
Stephen
@stephepush
Jun 04 2016 02:43
it doesn't
im wondering if im even on the right track
Frank XC
@tenkdayz
Jun 04 2016 02:43
whats the output?
you have to return something.
Stephen
@stephepush
Jun 04 2016 02:44
yep there isn't an output right now
when i try and run it, it says str.substr is not a function
Cassidy Blay
@CBlay
Jun 04 2016 02:46
Hello everyone.
Frank XC
@tenkdayz
Jun 04 2016 02:46
you have to make it cycle all the words.. doesnt seem like it's doing that
jstormail2
@jstormail2
Jun 04 2016 02:46
Hello :smile:
Cassidy Blay
@CBlay
Jun 04 2016 02:47

I'm having difficulty in making the code output "Hi World" to the dev console. Help please.

// Example
function reusableFunction() {
console.log("Heyya, World");
}

reusableFunction();

// Only change code below this line

jstormail2
@jstormail2
Jun 04 2016 02:48

I still don't think I'm doing this right

<script type="text/javascript">
$(document).on('click', '.myclass', function (clickEvent) {
var lightbox = lity();
$(".myclass").on('click', '[data-lightbox]', lightbox('https://www.youtube.com/watch?v=gTLkCgCO0NI'));
});
</script>

I feel like I am duplicating the .on('click') and it doesn't change my cursor when I hover over it

Anthony
@Coding-in-progress
Jun 04 2016 02:49
@CBlay I can help as I just did this one
jstormail2
@jstormail2
Jun 04 2016 02:50
I've googled this a bit, and I think it has something to with binding, any suggestions? :frowning:
Cassidy Blay
@CBlay
Jun 04 2016 02:50
@Anthony pls help
JD Tadlock
@jdtdesigns
Jun 04 2016 02:50
@jstormail2 you have the codepen?
Anthony
@Coding-in-progress
Jun 04 2016 02:51

@CBlay First you have to write the function
function reusableFunction() {

}
a

as it shows the example above
Cassidy Blay
@CBlay
Jun 04 2016 02:52
Oh okay thanks
Anthony
@Coding-in-progress
Jun 04 2016 02:52
function reusableFunction() {
console.log("Hi World");
}
jstormail2
@jstormail2
Jun 04 2016 02:53
@jdtdesigns if you have any suggestions, I'll gladly try them :smile: I've been trying this for hours as a js newbie
Anthony
@Coding-in-progress
Jun 04 2016 02:53
then just call the function and end with semicolon
Cassidy Blay
@CBlay
Jun 04 2016 02:53
Oh it worked !
JD Tadlock
@jdtdesigns
Jun 04 2016 02:53
@jstormail2 you have quite a mess going on lol
Cassidy Blay
@CBlay
Jun 04 2016 02:53
Thank you so so much
Anthony
@Coding-in-progress
Jun 04 2016 02:53
np Cblay
Ryan Williams
@Ryanwfile
Jun 04 2016 02:54
Can anyone help me with figuring out why my code for Caesar's Cipher won't pass the tests as I keep getting what appears to be the correct answers with no extra white space but they won't register as correct.
Jesse Nuese Yaker
@JesseNuese
Jun 04 2016 02:54

// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

myPlants[1].list[1];
Can any help me with this? it says secondTree is not defined
JD Tadlock
@jdtdesigns
Jun 04 2016 02:55
@jstormail2 it seems to work fine for me. To change the cursor, just add .myclass { cursor: pointer; } to the css
you need to fix your html though
all the scripts need to be added through settings->js
also add jquery through that
Brett Guillory
@kurzninja
Jun 04 2016 02:56
man, my cursor is acting weird in the FCC code editor
jstormail2
@jstormail2
Jun 04 2016 02:57
@jdtdesigns awesome! Still learning codepen, so I wasn't sure how to accomplich that. I'll follow your suggestion and back in a moment :smile:
sh*
Alrighty, I cleaned it up a bit
Unfortunately, I seemed to break the js code though
Alexander Køpke
@alexanderkopke
Jun 04 2016 03:03
@JesseNuese I ran your code and returns pine.
jstormail2
@jstormail2
Jun 04 2016 03:07
Yay, got it to load! :smile:
@jdtdesigns
Alexander Køpke
@alexanderkopke
Jun 04 2016 03:08
@JesseNuese you deleted this: var secondTree = ""; assign the secondTree variable to myPlants[1].list[1];
JD Tadlock
@jdtdesigns
Jun 04 2016 03:09
@jstormail2 nice ;)
Norvin Burrus
@ndburrus
Jun 04 2016 03:10
@JesseNuese also ran code - result => 'pine'
Jesse Nuese Yaker
@JesseNuese
Jun 04 2016 03:11
@alexanderkopke wow my own dipshittery never ceases to amaze
jstormail2
@jstormail2
Jun 04 2016 03:12
@jdtdesigns could you look at the JS section of the codepen for a moment? I'm just wondering if it needs cleaning with all the .on('click') or not
Ryan Williams
@Ryanwfile
Jun 04 2016 03:12

Can anyone help with this code for Caesar's Cipher please, it returns the correct answers but it's not passing any tests

var newArr = [];
function rot13(str) { // LBH QVQ VG!
  var arr = str.split('');
  for (var i = 0;i<arr.length;i++){

    switch (arr[i]) {
    case "A"://1
        arr[i] = "N";
        newArr.push(arr[i]);
      break;
    case "B"://2
        arr[i] = "O";
        newArr.push(arr[i]);
      break;
    case "C"://3
        arr[i] = "P";
        newArr.push(arr[i]);
      break;
    case "D"://4
        arr[i] = "Q";
        newArr.push(arr[i]);
      break;
    case "E"://5
        arr[i] = "R";
        newArr.push(arr[i]);
      break;
    case "F"://6
        arr[i] = "S";
        newArr.push(arr[i]);
      break;
    case "G"://7
        arr[i] = "T";
        newArr.push(arr[i]);
      break;
    case "H"://8
        arr[i] = "U";
        newArr.push(arr[i]);
      break;
    case "I"://9
        arr[i] = "V";
        newArr.push(arr[i]);
      break;
    case "J"://10
        arr[i] = "W";
        newArr.push(arr[i]);
      break;
    case "K"://11
        arr[i] = "X";
        newArr.push(arr[i]);
      break;
    case "L"://12
        arr[i] = "Y";
        newArr.push(arr[i]);
      break;
    case "M"://13
        arr[i] = "Z";
        newArr.push(arr[i]);
      break;
    case "N"://14
        arr[i] = "A";
        newArr.push(arr[i]);
      break;
    case "O"://15
        arr[i] = "B";
        newArr.push(arr[i]);
      break;
    case "P"://16
        arr[i] = "C";
        newArr.push(arr[i]);
      break;
    case "Q"://17
        arr[i] = "D";
        newArr.push(arr[i]);
      break;
    case "R"://18
        arr[i] = "E";
        newArr.push(arr[i]);
      break;
    case "S"://19
        arr[i] = "F";
        newArr.push(arr[i]);
      break;
    case "T"://20
        arr[i] = "G";
        newArr.push(arr[i]);
      break;
    case "U"://21
        arr[i] = "H";
        newArr.push(arr[i]);
      break;
    case "V"://22
        arr[i] = "I";
        newArr.push(arr[i]);
      break;
    case "W"://23
        arr[i] = "J";
        newArr.push(arr[i]);
      break;
    case "X"://24
        arr[i] = "K";
        newArr.push(arr[i]);
      break;
    case "Y"://25
        arr[i] = "L";
        newArr.push(arr[i]);
      break;
    case "Z"://26
        arr[i] = "M";
        newArr.push(arr[i]);
      break;
    default:
        arr[i] = arr[i];
        newArr.push(arr[i]);
      break;

  }//switch

}//for 
  return newArr.join('').trim();
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Thank you

Cassidy Blay
@CBlay
Jun 04 2016 03:12

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

// Only change code below this line.
function functionWithArgs(c, d) {
console.log(7 + 9);
}
function functionWithArgs(a, b) {
console.log(2 + 1);
}

@Coding-in-progress how about this? What am i not doing correctly? It's supposed to show both inputs to the dev console

Norvin Burrus
@ndburrus
Jun 04 2016 03:15
@CBlay ...what are you trying to do?
Cassidy Blay
@CBlay
Jun 04 2016 03:15
I've found the solution
Thank you
@ndburrus thanks...I've been able to figure it out
CamperBot
@camperbot
Jun 04 2016 03:16
cblay sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 486 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 04 2016 03:16
@CBlay ok...
WB
@waglebr
Jun 04 2016 03:17
Question: anyone knows whats the difference between string.slice() and string.substr()?
WB
@waglebr
Jun 04 2016 03:19
@kurzninja
I had read it already but don't get what's the practical difference...
Ken Haduch
@khaduch
Jun 04 2016 03:20

@nandod1707 - I don't have your code in front of me, but basically, the answer to your question in :point_up: June 3, 2016 10:32 PM is no. You are using a for loop to look for a person from the contacts list with a name that matches the firstName value. If you don't match it (I think you also had the .hasOwnProperty method in there to look for the matching property?) you then had an "else if" that checked that. (I did just search and actually found your code that you posted back in this note: https://gitter.im/FreeCodeCamp/HelpJavaScript?at=5751f9c6e96484d0692f6d2f ) You had this code:

  for (var i = 0; i < contacts.length; i++) {      // 1
    if (contacts[i].firstName == firstName) {  //2
      if (contacts[i].hasOwnProperty(prop)) {  //3
        return contacts[i][prop];  //4
      } //5
      else { //6
        return "No such property"; // 7
      } // 8
    }  // 9
    else { //10
      return "No such contact"; // 11
    } //12
  } //13

I put comments with line numbers. You check for the firstName match on line 2 - if you get the match, then you go and look for the property. That is good. But if you don't get a match on the firstName, you go to the else on line 10 - and immediately return "No such contact". So if the first contact does not match, then you return "No such contact", and never proceed to the second, third, and fourth entries in the list.

There is a website that you can use to plug your code into and see the flow - http://pythontutor.com/javascript.html - I haven't used it very much, but I did check it out one time. It seems like a useful debug / learning tool. You can also (if you know how) use the developer's console and step through the execution of the code to see what happens, and you would also be able to determine this behavior. But stepping through the code manually and thinking through the execution flow is pretty straightforward for a problem like this one.

I hope that helps? I'm not sure if you got help from anyone else on this problem... good luck!

Chris Cullen
@123xylem
Jun 04 2016 03:22

@kurzninja @moigithub ion pairElement(str) {
var arr=str.split("");
var newarr=[];
var AT=["A","T"];
var TA=["T","A"];
var CG=["C","G"];
var GC=["G","C"];
for(i=0;i<arr.length;i++){
switch(arr[i])
{
case "A" :
arr.push(AT); break;

     case 'T' :
      arr.push(TA);    break;

     case 'C' :
       arr.push(CG); break;

     case 'G' :
            arr.push(GC);  break;


  }
arr.shift();

}return arr;

}

pairElement("GCT");
THis should work but my .shift takes out the middle C case for some reason as opposed to the str data

Brett Guillory
@kurzninja
Jun 04 2016 03:22
@waglebr honestly, not much practical difference
just two different functions that do the same/similar things
Chris Cullen
@123xylem
Jun 04 2016 03:23
@kurzninja im using the switch but my shift takes out my middle switch statement instead of the original string chars
which doesnt make sense as my str chars are first in the arr
WB
@waglebr
Jun 04 2016 03:24
@kurzninja
Ok, thanks!
CamperBot
@camperbot
Jun 04 2016 03:24
waglebr sends brownie points to @kurzninja :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @kurzninja |http://www.freecodecamp.com/kurzninja
Justin Woodward
@jwoo92
Jun 04 2016 03:27
can anyone assist me with the algorithm challenge 'roman numeral converter'? i have been stuck on it for several days. this is what i have so far:

function convertToRoman(num) {
 var number = [1000, 500, 100, 50, 40, 10, 9, 5, 4, 1];
 var roman = ['M', 'D', 'C', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
 var result = num.toString().split('');



  return result;
}

convertToRoman(36);
Brett Guillory
@kurzninja
Jun 04 2016 03:32
@123xylem I think your biggest problem is you are pushing to the wrong array, aren't you?
@jwoo92 that one is a really tough one
Kikelomo
@queennectarine
Jun 04 2016 03:33
help Seek and Destroy
CamperBot
@camperbot
Jun 04 2016 03:33

:point_right: algorithm seek and destroy [wiki]

Algorithm Seek and Destroy

Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Justin Woodward
@jwoo92
Jun 04 2016 03:33
@kurzninja i have heard that from many. this one slowed me down a lot.
Brett Guillory
@kurzninja
Jun 04 2016 03:34
search for roman numeral converter algorithm and you'll find a good one
then it's a matter of implementing it in Javascript
Chris Cullen
@123xylem
Jun 04 2016 03:34
@kurzninja yea I had to push to newarr... BUT .. Why was shift not shifting the first element of arr?
Alexander Køpke
@alexanderkopke
Jun 04 2016 03:35
@Ryanwfile ok looked into it and it seems that you have to use the two String methods that are mentioned in the instructions. I know you did put a lot of effort into your solution and know that it is not wasted. However, you will benefit from solving the challenge with the mentioned methods either adding or subtracting 13 positions to get the need letters.
Brett Guillory
@kurzninja
Jun 04 2016 03:35
I'd have to see all your current code again
Everyone come join https://plug.dj/freecodecamp
Ryan Williams
@Ryanwfile
Jun 04 2016 03:40
@alexanderkopke Thank you very much. I will redo the problem with the helpful links, I am just wondering if my answers are actually correct or if there's something wrong I am missing.
CamperBot
@camperbot
Jun 04 2016 03:40
ryanwfile sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 661 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Chris Cullen
@123xylem
Jun 04 2016 03:41
This message was deleted
Cassidy Blay
@CBlay
Jun 04 2016 03:41

Instructions

Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.

the code

function myLocalScope() {
'use strict';

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

I'm not sure what I am supposed to do here. Help please

Chris Cullen
@123xylem
Jun 04 2016 03:41
Coding MYSTERY:
function pairElement(str) {
  var arr=str.split(""); 
  //Make str an array to be searched

  var newarr=[];
  var AT=["A","T"];
  var TA=["T","A"];
  var CG=["C","G"];
  var GC=["G","C"];
  //Create var that we can easily input pairs with

  for(i=0;i<arr.length;i++){
    switch(arr[i])
      {
         case "A" :
            arr.push(AT); break;

         case 'T' :
         arr.push(TA);    break;

         case 'C' :
          arr.push(CG); break;

         case 'G' :
                arr.push(GC);  break;


      }arr.shift();

    }return arr;


}

pairElement("GCT");
Why isnt shift shifting first ekeemnt
element
it shifts the middle element out
Alexander Køpke
@alexanderkopke
Jun 04 2016 03:46
@Ryanwfile as far as I can see you did solve the problem. It gives the correct answer for the other strings as well.
Ryan Williams
@Ryanwfile
Jun 04 2016 03:47
@alexanderkopke Awesome, thanks again for all of the help.
CamperBot
@camperbot
Jun 04 2016 03:47
ryanwfile sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:warning: ryanwfile already gave alexanderkopke points
Jon
@Antiphilous
Jun 04 2016 03:48
@123xylem what is the output you're hoping for?
@123xylem secondly you have created a new array which is what I think you want to be using for your pushes?
Chris Cullen
@123xylem
Jun 04 2016 03:50
@Antiphilous Yes I know it desnt work but the I am curious what the .shift is doing
I have to push the answers into newarr
but I dont know why shift only takes out the C case
rphares
@rphares
Jun 04 2016 03:51
@CBlay , you need to do two things,
you need to declare and initialise the var myVar (you can set it to anything, doesn't matter what) inside the function
and you need to remove the console.log that is outside the function
Brett Guillory
@kurzninja
Jun 04 2016 03:52
@123xylem I think I see what your problem is
you're traversing your array using your loop
AND you're also changing its length by popping off the first element
you should really do one or the other
so when you first enter the loop, you're looking at arr[0]
at the end of it, you're arr.shift()ing
which gets rid of arr[0]
then your loop starts again, except now you're looking at arr1
which previously was arr[2]
Ken Haduch
@khaduch
Jun 04 2016 03:54

@jwoo92 - did you review the video on the Roman Numeral conversion that they have on the site - I found it to be valuable (I might have mentioned this to you before?) After watching that video, it inspired me to figure out how to break the number down into the types of units that have corresponding "translations" into Roman Numerals - the number of units of 1000, the number of units of 100, the number of units of 10, and the number of units of 1. Then I basically made 'lookup tables' to translate the number of each unit value into the roman numeral equivalent - for example, my lookup table for the 1's values looks like this:

  var t1 = {
    1 : 'I',    2 : 'II',    3 : 'III',    4 : 'IV',    5 : 'V',
    6 : 'VI',    7 : 'VII',    8 : 'VIII',    9 : 'IX'  },

so if I have 7 units of ones, it just looks up VII, and I use that to build up the string for the Roman Numeral equivalent. I guess you could figure out some algorithm to generate the value, since there is a pattern, but I opted for the lookup table.

Jon
@Antiphilous
Jun 04 2016 03:55
@kurzninja Completely correct
Brett Guillory
@kurzninja
Jun 04 2016 03:55
@123xylem you could either get rid of the arr.shift()
or switch your loop to a while loop where it loops as long as arr.length != 0
Chris Cullen
@123xylem
Jun 04 2016 03:56
@kurzninja thanks
CamperBot
@camperbot
Jun 04 2016 03:56
123xylem sends brownie points to @kurzninja :sparkles: :thumbsup: :sparkles:
:cookie: 446 | @kurzninja |http://www.freecodecamp.com/kurzninja
Chris Cullen
@123xylem
Jun 04 2016 03:56
makes sense
Jon
@Antiphilous
Jun 04 2016 03:56
@123xylem One other thing I would do
@123xylem Put your variables into camelCase put the breaks on a line below
Justin Woodward
@jwoo92
Jun 04 2016 03:57
@khaduch i did watch it and it did help some what. i ended up creating two arrays holding numbers and roman numerals. i like how you made a 'lookup table', though i have not made too many myself like that using keys and key values.
Jon
@Antiphilous
Jun 04 2016 03:57
@123xylem It is a good idea to get into proper coding habits now, it will make things a lot easier as things go on\
Chris Cullen
@123xylem
Jun 04 2016 03:58
@Antiphilous yea camel case is good
I have another q
Jon
@Antiphilous
Jun 04 2016 03:59
@khaduch I did the same thing, except mine was in the form of an array instead of an object
@123xylem yeah?
Chris Cullen
@123xylem
Jun 04 2016 03:59

@Antiphilous ```js
function fearNotLetter(str) {
var al=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
str=str.split("");

if(str[0].test(al)){
return str;
}
return str;
}

fearNotLetter("abce");
```

Cassidy Blay
@CBlay
Jun 04 2016 03:59

@rphares I have done that but it still wouldn't work

function myLocalScope() {

'use strict';

console.log(myVar);

}

myLocalScope();

var myVar = "dome";

// Run and check the console

// myVar is not defined outside of myLocalScope

// Now remove the console log line to pass the test

Chris Cullen
@123xylem
Jun 04 2016 03:59
function fearNotLetter(str) {
var al=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
str=str.split("");
if(str[0].test(al)){
return str;
}
return str;
}
fearNotLetter("abce");
Why is this saying str[0].test is not a function?
rphares
@rphares
Jun 04 2016 04:00
@CBlay , the var has to be inside the function
Chris Cullen
@123xylem
Jun 04 2016 04:00
o its because test only works with strings
Jon
@Antiphilous
Jun 04 2016 04:00
@123xylem yes
@123xylem and no
rphares
@rphares
Jun 04 2016 04:01
then, after you move it there, you may need to refresh to pass tests... sometimes people get 'maximum call stack errors' @CBlay
Cassidy Blay
@CBlay
Jun 04 2016 04:02
@rphares thank you
CamperBot
@camperbot
Jun 04 2016 04:02
cblay sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 5024 | @rphares |http://www.freecodecamp.com/rphares
Jon
@Antiphilous
Jun 04 2016 04:02
@Antiphilous It's because .test is to be used with Regex
something which you will learn a bit later on
Cassidy Blay
@CBlay
Jun 04 2016 04:02
After I refreshed it worked @rphares
rphares
@rphares
Jun 04 2016 04:02
Anytime~ Congrats and happy coding, @CBlay :blush:
Jon
@Antiphilous
Jun 04 2016 04:03
@123xylem For now keep it simpler what challenge are you currently on?
Shusil Banjade
@shusil123
Jun 04 2016 04:05

I get my first quote by using an API. I don't know how to randomize the content on every click (of the button) ... A little help please. (Random quote machine).

Just the idea, not the code

Chris Cullen
@123xylem
Jun 04 2016 04:06
@Antiphilous missing letters... I fell like Ive got a good solutuion but my grammar is a lil off
function fearNotLetter(str) {
var al=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
  str=str.split("");
  var newarr=[];
 for (i=0;i<al.length;i++){
if(str[0] ==al[i]){
  for(j=al[i];j<str.length;j++){
    newarr.push(str[j]);
  }
   return newarr;
   }}

}

fearNotLetter("abce");
andyst81
@andyst81
Jun 04 2016 04:07
@shusil123 you can pull the first quote, right?
Chris Cullen
@123xylem
Jun 04 2016 04:07
Once str matches the al array. I get a loop to start at that bit of array and push all the correct letters out for the length of the str
Jon
@Antiphilous
Jun 04 2016 04:08
@123xylem ahh I haven't actually done this one yet, let me think for a moment
Connor Hastey-Palindat
@cpalindat
Jun 04 2016 04:08
Hi, I was wondering if anyone could give me a hand with using ajax?
Chris Cullen
@123xylem
Jun 04 2016 04:08
THinking about it its not perfect but
Giorgio
@gDelgado14
Jun 04 2016 04:08
Hi everyone
I'm looking for some regular expression help
Chris Cullen
@123xylem
Jun 04 2016 04:08
It wont output anything for meyet
Shusil Banjade
@shusil123
Jun 04 2016 04:08
Yes, @andyst81 . I can pull the first quote
Jon
@Antiphilous
Jun 04 2016 04:08
mmmm @123xylem
@123xylem brb
Norvin Burrus
@ndburrus
Jun 04 2016 04:10
@gDelgado14 which challenge?
Giorgio
@gDelgado14
Jun 04 2016 04:10
if i have a string like some text @mention1 @mention2 @mention3 what regex do i use to get an array that looks like ['mention1', 'mention2', 'mention3']
no challenge in particular, this has to do with a slack integration im making
andyst81
@andyst81
Jun 04 2016 04:10
I'm not an expert, so I'm sure some of the experts here can explain better, but what I did was make the "new quote" button call the same function that pulled the first quote
Giorgio
@gDelgado14
Jun 04 2016 04:10
i dont want to capture @
andyst81
@andyst81
Jun 04 2016 04:11
(I don't know how much sense that makes after reading it again @shusil123 )
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:13
@123xylem Have you tried to use the charCodeAt or fromCharCode?
vervaak
@vervaak
Jun 04 2016 04:14
it will not work if the string does not start with "a"
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:18
@123xylem You can use charCodeAt to compare the current index with the next one
For example, a would return 97, b 98, c 99, e 101
If there's a skip, then you know something's missing
Jon
@Antiphilous
Jun 04 2016 04:20
Ahh
yeah I just returned and just figured it out
@123xylem You want to used the two functions on the left hand side that they talk about
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:20
Just realized I replied to the wrong person lol
oops
Jon
@Antiphilous
Jun 04 2016 04:21
hahah no worries
@JackAndersonLee unless... no no it looks like you were replying to the right one I was going to help him out but then realized I hadn't even done the exercise yet
Chris Cullen
@123xylem
Jun 04 2016 04:22
@JackAndersonLee yea thanks
CamperBot
@camperbot
Jun 04 2016 04:22
123xylem sends brownie points to @jackandersonlee :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @jackandersonlee |http://www.freecodecamp.com/jackandersonlee
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:22
Ah
Chris Cullen
@123xylem
Jun 04 2016 04:22
Im doing that now
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:22
Seems like my reading comprehension isn't up to speed at the moment
Jon
@Antiphilous
Jun 04 2016 04:22
@JackAndersonLee It's alright you're a programmer you only have to comprehend code hahaha
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:23
Not yet, someday hopefully!
Thieu van Dijk
@Thieuvandijk
Jun 04 2016 04:24
I'm stuck with challenge 306..... I can't figure out what is meant with the functioncall: addTogether(2)(3) it's not the same as addTogether(2,3). How must addTogether(2)(3) be interpreted? Can anybody give me a hint?
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:26
That the closure one?
I think you need a function within the function
The second number (2)(3) would be the input for the second function...I think lol
Jon
@Antiphilous
Jun 04 2016 04:28
Yeah I don't recognize that one...
I tried searching it but unfortunately it doesnt number them for me
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:29
Arguments Optional
Is the name
Just looked it up
Norvin Burrus
@ndburrus
Jun 04 2016 04:30
@kaveshdgr8 how are we doing?
Chris Cullen
@123xylem
Jun 04 2016 04:32
@JackAndersonLee Is there a way to input an array or list of numbers into .fromCharCode?
function fearNotLetter(str) {
  var newArr=[];
  var string="";

var rangeLow= str.charCodeAt(0) ; //Define first letter
var rangeHi= str.charCodeAt(str.length-1); //And last of str via unicodes
 for(i=rangeLow;i<=rangeHi;i++){
   //go through the values
   newArr.push([i]);
   //outputting the range into an array
 string= newArr.join("");
   //output array to string
   string= String.fromCharCode([i]);
 }
  return string;
}

fearNotLetter("abce");
Trying to input my numbers into .fromcharCode
Srinivasan
@kksrini89
Jun 04 2016 04:37
can anyone help me to resolve "Diff two arrays" challenge?
I have done like this way
function diffArray(arr1, arr2) {
  var newArr = [];
  var length1 = arr1.length;
  var length2 = arr2.length;

  var firstArray = arr1;  
  var secondArray = arr2; 

    for(var i = 0; i < length1; i++){
      for(var j = 0; j < length2; j++){
        if(arr2[j] === arr1[i]){
          arr2.splice(j,1);
          arr1.splice(i,1);
        }        
      }      
    } 

  if(arr1.length > 0)
     newArr.concat(arr1);
  if(arr2.length > 0)
     newArr.concat(arr2);  

  return newArr;
}
Jon
@Antiphilous
Jun 04 2016 04:38
@123xylem ... well yes I believe from character code will take an array of numbers
Srinivasan
@kksrini89
Jun 04 2016 04:38
but getting empty array
Jon
@Antiphilous
Jun 04 2016 04:38
@Antiphilous but that would only remake the letters that you were first given if I am reading your code right
Chris Cullen
@123xylem
Jun 04 2016 04:39
@Antiphilous Im saying String.fromCharCoe(array variable) but it wont recognise it
Srinivasan
@kksrini89
Jun 04 2016 04:39
Need help guys?
..
Jon
@Antiphilous
Jun 04 2016 04:41
@123xylem ahh that is because I am incorrect, it does not appear that String .fromCharCode will take an array variable
however ..
Chris Cullen
@123xylem
Jun 04 2016 04:41
@Antiphilous I guess I have to do a function for it
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:42
hmm
What you could do is just run a for loop with the length of the str
Jon
@Antiphilous
Jun 04 2016 04:44
@123xylem @JackAndersonLee Jack Anderson is right you don't need to remake the string from the character code once you have them
You only need one #
Chris Cullen
@123xylem
Jun 04 2016 04:44
@JackAndersonLee @Antiphilous yea just realised that ><
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:44
in the for loop, i = 0
then str.charCodeAt(i)
that should give you the unicode value
Prayogo Cendra
@yogo-chen
Jun 04 2016 04:46

can I write

var obj = {
  item : "item"
}

instead

var obj = {
  "item" : "item"
}
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:46
So str.charCodeAt(0) (the first iteration) would give you 97 for a
98 b 99c 101 d
Jon
@Antiphilous
Jun 04 2016 04:47
@123xylem ```
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:48
Just through an if statement in the loop that checks if there's a missing number (i + 1) - (i) === 2
Jon
@Antiphilous
Jun 04 2016 04:50
@JackAndersonLee thats much more elegant than how I did it lol! I made a seperate variable equal to the first value in the array and counted up until it didn't match
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:50
Still worked! lol
Just realized through = throw
Ben Wongseelashote
@shichiriz
Jun 04 2016 04:51
hey guys i am doing tutorial generate random whole number with javascript
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:51
seems like my spelling is bleh too today
Ben Wongseelashote
@shichiriz
Jun 04 2016 04:51
asked me to return a random whole number between 0 to 9

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random() * 10);
}

Jon
@Antiphilous
Jun 04 2016 04:51
yeah hahah still counts!
Ben Wongseelashote
@shichiriz
Jun 04 2016 04:51
i did this..donno why it doesnt work
Jon
@Antiphilous
Jun 04 2016 04:52
@shichiriz That seems fine.... can you copy and paste your code?
Ben Wongseelashote
@shichiriz
Jun 04 2016 04:53
@Antiphilous i did copy the code
it says the result of randomWholeNum should be a whole number is not satisfied
how do i copy the code in a box like @yogo-chen
Jon
@Antiphilous
Jun 04 2016 04:54
code formatting
Ben Wongseelashote
@shichiriz
Jun 04 2016 04:55
@Antiphilous which is where pls?
Chris Cullen
@123xylem
Jun 04 2016 04:55
 for(j=0;j<str.length;j++){
    compare.push(str.charCodeAt([j]));
   }
THis is outputting the values 4 times
Jon
@Antiphilous
Jun 04 2016 04:55
/help explain format
CamperBot
@camperbot
Jun 04 2016 04:55
no wiki entry for: explain format
Chris Cullen
@123xylem
Jun 04 2016 04:55
97989910109798991010 etcetc
Jon
@Antiphilous
Jun 04 2016 04:55
/help
CamperBot
@camperbot
Jun 04 2016 04:55

CamperBot

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. e.g. find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

Jon
@Antiphilous
Jun 04 2016 04:56
@shichiriz bleh
ok see the lil M with a down arrow next to it where you're typing?
Chris Cullen
@123xylem
Jun 04 2016 04:57
help format
Jon
@Antiphilous
Jun 04 2016 04:57
click on that
/help format
CamperBot
@camperbot
Jun 04 2016 04:57

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Jon
@Antiphilous
Jun 04 2016 04:57
AHH
CamperBot
@camperbot
Jun 04 2016 04:57

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Jon
@Antiphilous
Jun 04 2016 04:57
that's how it works
Chris Cullen
@123xylem
Jun 04 2016 04:57
:)
Jon
@Antiphilous
Jun 04 2016 04:57
lol
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:57
@123xylem Don't think you need the brackets around [j]
Chris Cullen
@123xylem
Jun 04 2016 04:57
@JackAndersonLee ur right but it still repeats 4 times
:(
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:58
that a double for loop?
one with i, the next with j?
Ben Wongseelashote
@shichiriz
Jun 04 2016 04:58
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

  // Only change code below this line.

  return Math.floor(Math.random() * 10);
}
Jack Anderson
@JackAndersonLee
Jun 04 2016 04:58
Should only need one, and you don't need to push anything into an array
Jon
@Antiphilous
Jun 04 2016 04:59
@shichiriz Yeah that should be working....
Srinivasan
@kksrini89
Jun 04 2016 05:00
thank you guys finally I solved by myself.
Ben Wongseelashote
@shichiriz
Jun 04 2016 05:00
@jon i donno what happened
i closed the page and open it again..the click run..it now works
thanks
Jon
@Antiphilous
Jun 04 2016 05:01
@kksrini89 sorry man glad you solved it though!
@shichiriz sometimes that happens :/
Anyone feel like giving me a quick hand with the Where art thou challenge?
Srinivasan
@kksrini89
Jun 04 2016 05:02
@Antiphilous no sorry yaar.
Jon
@Antiphilous
Jun 04 2016 05:02
function whereAreYou(collection, source) {
// What's in a name?

  var arr = [];
  // Only change code below this line
  var key = Object.keys(source);
  var infoKey = Object.keys(collection[0]);

  for( i = 0; i < collection.length; i++){
   if(collection[i].hasOwnProperty(key)){ // if the collection contains the key continue
     if(collection[i][key] == source[key]){ // if the value of the object property is equal to the value of the source continue

       arr.push(collection[i]);
     }


   } 


  }

  // Only change code above this line
  return arr;
}
so right now it works great when the source only has one property to check but it needs to be able to handle two or more
Kyle W Pilkinton
@tadake
Jun 04 2016 05:10
hey guys im trying to make a random move ai on my tictactoe project. any advice??
http://codepen.io/tadake/pen/RRwzEj
Joshua Adams
@joshuatadams554
Jun 04 2016 05:12
hey guys, anyone have any issues with record collection? I checked what I have with reddit and gitHub and it matches both but I am still not passing
David
@davidmichaelhale
Jun 04 2016 05:14
@joshuatadams554 post code
Joshua Adams
@joshuatadams554
Jun 04 2016 05:15
function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
    collection[id][prop].push(value);
  } else if (value !== "") {
      collection[id][prop] = value;
  } else if (value === "") {
      delete collection[id][prop];
  }

  return collection;
}
Gogelescu
@Gogelescu
Jun 04 2016 05:15
Good morning.
1 little question, how can I make a screenshot to my code to send it here? just to my code?
Like the above ones. :D
Chris Cullen
@123xylem
Jun 04 2016 05:16
function fearNotLetter(str) {
  var newArr=[];
  var string="";
  var compare=[];

var rangeLow= str.charCodeAt(0) ; //Define first letter
var rangeHi= str.charCodeAt(str.length-1); //And last of str via unicodes

  for(i=rangeLow;i<=rangeHi;i++){
   //go through the values
   newArr.push(i);
   //outputting the range into an array

   for(j=0;j<str.length;j++){
    compare.push(str.charCodeAt(j));
   }

 string= newArr.join(",");
   //output array to string
 string= (String.fromCharCode.apply(null, newArr)); 

 }
  return compare;
}

fearNotLetter("abce");
Why isnt my compare loop running
It gives 4* unicodes
ANd not just the 4 unicodes
Jon
@Antiphilous
Jun 04 2016 05:18
@123xylem I haven't gone to test your code yet but are you sure you want so much of that within your first loop?
rphares
@rphares
Jun 04 2016 05:19
explain format
CamperBot
@camperbot
Jun 04 2016 05:19

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

rphares
@rphares
Jun 04 2016 05:19
@Gogelescu :point_up:
Gogelescu
@Gogelescu
Jun 04 2016 05:19
Thank you very much @rphares !
CamperBot
@camperbot
Jun 04 2016 05:19
gogelescu sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 5025 | @rphares |http://www.freecodecamp.com/rphares
Jon
@Antiphilous
Jun 04 2016 05:20
@123xylem yeah man move your } so that the second loop is not contained within the first one. then you will get on 4 unicodes
:D
rphares
@rphares
Jun 04 2016 05:20
Anytime~ (note: you may need to press command + enter (mac) or control + enter (pc) to send your code on you put it in, @Gogelescu :blush:
Joshua Adams
@joshuatadams554
Jun 04 2016 05:20
I think the freecoecamp tests must be broken somehow
David
@davidmichaelhale
Jun 04 2016 05:21
@joshuatadams554 which one is failing
is it After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Joshua Adams
@joshuatadams554
Jun 04 2016 05:21
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
David
@davidmichaelhale
Jun 04 2016 05:21
have you tried putting that down there and seeing what it spits out
Chris Cullen
@123xylem
Jun 04 2016 05:21
@Antiphilous ur a genius
David
@davidmichaelhale
Jun 04 2016 05:22
i think it will be informative
Joshua Adams
@joshuatadams554
Jun 04 2016 05:22
putting what down where?
Jon
@Antiphilous
Jun 04 2016 05:22
@123xylem hahaha thanks I don't know if I would go that far though
CamperBot
@camperbot
Jun 04 2016 05:22
antiphilous sends brownie points to @123xylem :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @123xylem |http://www.freecodecamp.com/123xylem
David
@davidmichaelhale
Jun 04 2016 05:23
after // Alter values below to test your code
put updateRecords(5439, "tracks", "Take a Chance on Me");
and see what the output is
Joshua Adams
@joshuatadams554
Jun 04 2016 05:24
collection[id][prop] is undefined
David
@davidmichaelhale
Jun 04 2016 05:24
tada
Joshua Adams
@joshuatadams554
Jun 04 2016 05:24
yes I know that
it just explicitly says what to check for. And checking that the category doesn't exist was not one of the things. So I am curious how seemingly everyone on reddit and github who had the same code as me got it to pass fine
Gogelescu
@Gogelescu
Jun 04 2016 05:28
So I have this:
David
@davidmichaelhale
Jun 04 2016 05:29
@joshuatadams554 you have to check to see if tracks exists, if it does your code works, if it doesnt you need to do something else
Gaston Lenotre
@GLenotre
Jun 04 2016 05:31
I'm looking for help with a JS exercise Golf Code
Gogelescu
@Gogelescu
Jun 04 2016 05:31
I still dont get it how to paste here my code with tutorial from here https://github.com/freecodecamp/freecodecamp/wiki/code-formatting :(
Gaston Lenotre
@GLenotre
Jun 04 2016 05:32

'''

function golfScore(par, strokes) {
// Only change code below this line
if (par, 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

return "Go Home!";
// Only change code above this line
}

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

CamperBot
@camperbot
Jun 04 2016 05:32
:bulb: to format code use backticks! ``` more info
David
@davidmichaelhale
Jun 04 2016 05:33
potato
backticks are to the left of the number one and above tab on most keyboards
rphares
@rphares
Jun 04 2016 05:34
if (par, 1) @GLenotre
should be checking if par is one... using an operator like the others :blush:
Gogelescu
@Gogelescu
Jun 04 2016 05:34
''' <example>,
CamperBot
@camperbot
Jun 04 2016 05:34
:bulb: to format code use backticks! ``` more info
Gogelescu
@Gogelescu
Jun 04 2016 05:35
``` <example>,
David
@davidmichaelhale
Jun 04 2016 05:35
if (strokes==1)
Justin Woodward
@jwoo92
Jun 04 2016 05:35
@khaduch i like how you used the lookup table. i see how that can make it work with ease during the conversion. i am currently trying to figure out how to convert by dividing num by 10 and grabbing the number in the tenths spot. i would set the rest of the decimal to 0 to get the correct number to convert and then repeat as needed. this is what i currently have and i was told to leave my result variable split to a string. i am trying to think of a plan with what i have so far.

function convertToRoman(num) {
 var number = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
 var roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
 var result = num.toString().split('');



  return result;
}

convertToRoman(36);
Gaston Lenotre
@GLenotre
Jun 04 2016 05:38
@rphares thanks. i just added ```
CamperBot
@camperbot
Jun 04 2016 05:38
glenotre sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 5026 | @rphares |http://www.freecodecamp.com/rphares
Gaston Lenotre
@GLenotre
Jun 04 2016 05:38
@rphares (strokes == 1) and it worked
i cu @Gogelescu
now
rphares
@rphares
Jun 04 2016 05:39
Anytime~
livonian-router
@livonian-router
Jun 04 2016 05:45
guys, is this efficient?
function largestOfFour(arr) {
  // You can do this!
  var largest = [];

  for (var i = 0; i < arr.length; i++)
    {
      largest.push(0);
      for (var j = 0; j < arr[i].length; j++)
        {
          if (arr[i][j] > largest[i])
            {
              largest.pop();
              largest.push(arr[i][j]);
            }
        }
    }

  return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Islam Abasov
@IslamA
Jun 04 2016 05:46
find Make Object Properties Private
CamperBot
@camperbot
Jun 04 2016 05:46

find make object properties private

:zero: challenge make object properties private

Gogelescu
@Gogelescu
Jun 04 2016 05:48

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



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

// Change the inputs below to test your code
convertToF(30);
So, I have this, where I am supposed to write my formula to convertToF(0) should return a number? I really need help because I don't get it and I want to learn :D
Frostyjayy
@Frostyjayy
Jun 04 2016 05:48
@Gogelescu try an if else statement
@Gogelescu you have your formula right?
Gogelescu
@Gogelescu
Jun 04 2016 05:51
I am at Convert Celsius to Fahrenheit challenge :worried:
Jon
@Antiphilous
Jun 04 2016 05:51
@livonian-router seems efficient compared to mine I had a very similar solution
@livonian-router

function largestOfFour(arr) {
 var newArr = [0,0,0,0];
  for(i = 0; i < arr.length; i++){
    for(j = 0; j < arr[i].length; j++){

      if(arr[i][j] >= newArr[i]){ // if the first number in the array is bigger than the next number store the value

        newArr[i] = arr[i][j];

      } else {

      }

    }

  }



  return newArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
@livonian-router you don't need to pop and then push the new value you can simply assign it like I did if you want but again your code is fine
Islam Abasov
@IslamA
Jun 04 2016 05:54
@Gogelescu try write "find" and name is your challenge
Frostyjayy
@Frostyjayy
Jun 04 2016 05:55
@Gogelescu first declare your variable fahrenheit which would be the formula
mesh1er
@meshler
Jun 04 2016 05:57
find Escape
Gogelescu
@Gogelescu
Jun 04 2016 06:00
Good, I understood that, and to convertToF(-30) should return a value of -22, I should write a formula for celsius below var fahrenheit?
Frostyjayy
@Frostyjayy
Jun 04 2016 06:01
@Gogelescu the variable fahrenheit needs to be
Declared
@Gogelescu Like var fahrenheit =???
@Gogelescu Keep convertToF at 30
@Gogelescu here is the for
Gogelescu
@Gogelescu
Jun 04 2016 06:03
I can assign more that 1 value for var fahrenheit?
Frostyjayy
@Frostyjayy
Jun 04 2016 06:03
the formula (celsius * (9/5)) + 32
Gogelescu
@Gogelescu
Jun 04 2016 06:04
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
Because I have this, or I need to make 3 formulas for every convert?
Frostyjayy
@Frostyjayy
Jun 04 2016 06:04
@Gogelescu var fahrenheit = (??? * (9/5)) + 32;
@Gogelescu you can change
the inputs
Gogelescu
@Gogelescu
Jun 04 2016 06:08
yeah, but if I change for one, then the next one will give me the wrong result :(
Gogelescu
@Gogelescu
Jun 04 2016 06:10
Thank you, @Frostyjayy !!! :D
CamperBot
@camperbot
Jun 04 2016 06:10
gogelescu sends brownie points to @frostyjayy :sparkles: :thumbsup: :sparkles:
:cookie: 90 | @frostyjayy |http://www.freecodecamp.com/frostyjayy
Frostyjayy
@Frostyjayy
Jun 04 2016 06:10
@Gogelescu no prob, Goodluck
Arpan
@sahooarpan
Jun 04 2016 06:20

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

result = lookup[val];
}

where z error
??
Joseph
@revisualize
Jun 04 2016 06:23
@sahooarpan Where's the rest of the FUNCTION?
Arpan
@sahooarpan
Jun 04 2016 06:24

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

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

result = lookup[val];
}

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

Joseph
@revisualize
Jun 04 2016 06:24
You're not returning anything.
Arpan
@sahooarpan
Jun 04 2016 06:24
my complete code
where to return n what??
@revisualize
Joseph
@revisualize
Jun 04 2016 06:25

@sahooarpan

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

  // Only change code below this line

// switch stuff

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

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

That's the code from the start

@sahooarpan The return statement was in the part of the code that you deleted.
Jon Grant
@jong649
Jun 04 2016 06:27
hint
CamperBot
@camperbot
Jun 04 2016 06:27
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Justin Woodward
@jwoo92
Jun 04 2016 06:29
has anyone in here completed the algorithm challenge 'roman numeral converter'?
SHREYA GUPTA
@shreyag020
Jun 04 2016 06:46
var myStr = "I am a\"double quoted\"string inside\"double quotes\".";
whats wrong in it.
Ken Nawrocki
@nawrockp
Jun 04 2016 06:49
@jwoo92 yeah, I did
Jamen Marz
@jamen
Jun 04 2016 06:49
@shreyag020 Maybe you meant to put spaces before your escaped symbols? var myStr = "I am a \"double quoted \"string inside \"double quotes\".";
There also isn't a proportional amount of quotes there, might want to recheck. I don't know whatever lesson you are doing, never used FCC.
Oh wait, I'm wrong, maybe you wanted the spaces like this: var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
Justin Woodward
@jwoo92
Jun 04 2016 06:57
@nawrockp would you have any tips on how i can convert my result string to the proper roman numeral based on what i have in my code already? when you look at my code, i know my if/else only goes up to the thousands if you could please try to over look that for now. i am working on fixing that to be a more proper function that will work with any index past 3. here is what i have so far:

function convertToRoman(num) {
 var number = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
 var roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
 var result = num.toString().split('').reverse();


  for(var i = 1; i < result.length; i++) {

  if (result[i] == result[1]) {
    result[i] += '0'; 
  } else if (result[i] == result[2]) {
    result[i] += '00';
  } else if (result[i] == result[3]) {
    result[i] += '000';
  } 
  } 


  console.log(result.reverse());


}
convertToRoman(3645);
@shreyag020 your spacing may be off.
Blauelf
@Blauelf
Jun 04 2016 07:12
@jwoo92 You could loop on number instead, from bigger to smaller values (so from smaller to larger index in your sorting!), and test whether you could use that literal with your number. And adjust num after putting a literal on your result string.
@jamen I don't think there should be a . at the end of the string.
Jamen Marz
@jamen
Jun 04 2016 07:14
It's inside the string.
Blauelf
@Blauelf
Jun 04 2016 07:14
Then that changed.
karanss
@karanss
Jun 04 2016 07:15
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0;i<contacts.lenght;i++){
    for (var j=0;j<contacts[j].lenght;j++){
      if (firstName===contacts[j].firstName){
        if (prop===contacts[j]){
          return contacts[j];
        }
        if (prop!==contacts[j]){
          return "No such property";
        }

    }
      if (firstName!==contacts[j].firstName){
        return "No such contact";
  }

    }
  }


// Only change code above this line
}
what is wrong in this code?
Blauelf
@Blauelf
Jun 04 2016 07:15
@jamen You are right :)
mesh1er
@meshler
Jun 04 2016 07:16
find Stand
Blauelf
@Blauelf
Jun 04 2016 07:18
@karanss https://www.freecodecamp.com/challenges/testing-objects-for-properties (also, return the property value, not the element, oh, that code looks even a bit worse than I thought, just look up the testing-for-properties and try to transfer that)
Also: If you have a list of people, and the first person's name does not match, would you say "Guy with that name is not on the list"? You might want to move that return statement to after your loop.
And last but not least, it's length, not lenght
Fourbits
@Fourbits
Jun 04 2016 07:20
I'm a bit confused about what the "Pairwise" challenge is asking for. What does it mean by "If multiple pairs are possible that have the same numeric elements but different indices, return the smallest sum of indices?"
Priyankar Kumar
@priyankark
Jun 04 2016 07:22

Can someone please help me understand whats going on with this for loop? (This is the where do I belong challenge)
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr=arr.sort();
var index=0;
for(var i=0;i<arr.length;i++)
{
if(arr[i]===num)
{return i;
}

if(arr[i]<num)
index=i+1;

}

return index;
}
The two test cases where its not working is getIndexToIns([3, 10, 5], 3) should return 0.
getIndexToIns([5, 3, 20, 3], 5) should return 2.

Blauelf
@Blauelf
Jun 04 2016 07:22
@Fourbits If you have [1,1,1],2, you could form the pair from indices 0+1, 0+2, or 1+2, you are meant to return 1 in this case.
Fourbits
@Fourbits
Jun 04 2016 07:23
@Blauelf Thanks! I've got it.
CamperBot
@camperbot
Jun 04 2016 07:23
fourbits sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1942 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Jun 04 2016 07:24
@priyankark You need to sort numerically. Read the description of https://www.freecodecamp.com/challenges/sort-arrays-with-sort
Priyankar Kumar
@priyankark
Jun 04 2016 07:25
@Blauelf whoops Forgot that it compares them as strings. Thanks!
CamperBot
@camperbot
Jun 04 2016 07:25
priyankark sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1943 | @blauelf |http://www.freecodecamp.com/blauelf
Ramesh syangtan
@rameshsyn
Jun 04 2016 07:27
@karanss correct below with length for lenght
for (var i=0;i<contacts.lenght;i++){
    for (var j=0;j<contacts[j].lenght;j++){
Blauelf
@Blauelf
Jun 04 2016 07:27
It's not that intuitive, I think, but probably consistent given the flexibility of Javascript (not "normalizing" the values in some way would lead to unstable sorting)
Islam Abasov
@IslamA
Jun 04 2016 07:29
find Filter Arrays with filter
CamperBot
@camperbot
Jun 04 2016 07:29

find filter arrays with filter

:zero: challenge filter arrays with filter

Blauelf
@Blauelf
Jun 04 2016 07:31
@rameshsyn There are so many errors in that code snippet (lenght instead of length, the second loop should be replaced by a call to hasOwnProperty, if contacts were a nested array (it is not) and the second loop should be there (it shouldn't), it would have to be j<contacts[i].length) :P
Ramesh syangtan
@rameshsyn
Jun 04 2016 07:32
:smile: @Blauelf :thumbsup: Yep !!!
Rajat Kumar Sinha
@sinharajatit
Jun 04 2016 07:38
can any one help me with falsy bouncer challenge..

toall challenge falsy bouncer

Ramesh syangtan
@rameshsyn
Jun 04 2016 07:39
I am here !!! @sinharajatit
Rajat Kumar Sinha
@sinharajatit
Jun 04 2016 07:40
@rameshsyn can you help bro.
Ramesh syangtan
@rameshsyn
Jun 04 2016 07:40
Okay wait :smile:
bor
bro *
This single line of code does everything :smile: return arr.filter(Boolean);
Rajat Kumar Sinha
@sinharajatit
Jun 04 2016 07:42
can you explain me how? @rameshsyn
Marco Mazzeo
@Doko85
Jun 04 2016 07:43
hello guys, I just solved the "queue" js challenge but I don't know why it works this way... can anybody please explain it to me?
Rajat Kumar Sinha
@sinharajatit
Jun 04 2016 07:43
Boolean is not a callBack ?? @rameshsyn
Blauelf
@Blauelf
Jun 04 2016 07:44
Boolean is a function passed as a "callback", yes. Used as a function, it converts its first argument to boolean. Falsy input gives false, truthy input true.
Joseph
@revisualize
Jun 04 2016 07:45
@sinharajatit
.filter() takes a function that returns true or false, and applies that to every element. The elements that it returns
false for get removed.
[true, true, false, false, true].filter(function(x) { return x });
// => [true, true, true]
Rajat Kumar Sinha
@sinharajatit
Jun 04 2016 07:46
@Blauelf @rameshsyn :+1:
Blauelf
@Blauelf
Jun 04 2016 07:47
filter will test the return value only for falsy/truthy, so the function above which just returns its argument will work here, too.
Joseph
@revisualize
Jun 04 2016 07:47
@Blauelf Like what I posted?
Blauelf
@Blauelf
Jun 04 2016 07:47
Yes, that one. Works for any input based on truthy/falsy, not just booleans.
Rajat Kumar Sinha
@sinharajatit
Jun 04 2016 07:48
@revisualize Do not use a Boolean object to convert a non-boolean value to a boolean value. Instead, use Boolean as a function to perform this task. @revisualize @rameshsyn thanks to all.
CamperBot
@camperbot
Jun 04 2016 07:48
sinharajatit sends brownie points to @revisualize and @rameshsyn :sparkles: :thumbsup: :sparkles:
:star2: 1217 | @revisualize |http://www.freecodecamp.com/revisualize
:cookie: 657 | @rameshsyn |http://www.freecodecamp.com/rameshsyn
Joseph
@revisualize
Jun 04 2016 07:48
@sinharajatit My code was just an example.
Ramesh syangtan
@rameshsyn
Jun 04 2016 07:48
:smile:
Rajat Kumar Sinha
@sinharajatit
Jun 04 2016 07:48
@revisualize ya thanks for your help.
CamperBot
@camperbot
Jun 04 2016 07:48
sinharajatit sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: sinharajatit already gave revisualize points
Justin Woodward
@jwoo92
Jun 04 2016 07:52
@Blauelf here is my current code. i am looking to convert each value in the array to the correct roman numeral format. sorry for the late response, i was correcting the previous if/else statement.

function convertToRoman(num) {
 var number = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
 var roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
 var result = num.toString().split('').reverse();  
 var add = 0;

  for(var i = 1; i < result.length; i++) {   
    while (add < i) {      
      if (result[i] === '0') {
      add++;
      } else {
      result[i] += '0'; 
      add++;
      }
    }    
    add = 0;     
  }


  console.log(result.reverse());

}
convertToRoman(36);
Blauelf
@Blauelf
Jun 04 2016 07:53
@jwoo92 Better work with the number num, not with some split('').reverse()ed number...
Justin Woodward
@jwoo92
Jun 04 2016 07:54
@Blauelf i was trying to avoid recursion.
Blauelf
@Blauelf
Jun 04 2016 07:54
No recursion needed.
@jwoo92 :point_up: 4. Juni 2016 09:12
mesh1er
@meshler
Jun 04 2016 08:03
find alpha
mesh1er
@meshler
Jun 04 2016 08:03
find case
mesh1er
@meshler
Jun 04 2016 08:04
find switch
Arpan
@sahooarpan
Jun 04 2016 08:24

var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

if(prop == 'tracks' & value != ""){
collection[id][prop].push(value);
}else if(value !== ''){
//value is non blank
collection[id][prop] = value;
}else if(value === ''){
//value is blank
delete collection[id][prop];
}

return collection;
}

// Alter values below to test your code
console.log(update(1245, "tracks", "Addicted to Love"));

where z error??
Zelite
@zelite
Jun 04 2016 08:25

Hi, why does this return false?

[1,2,3].filter(function(n) {return false;}) === []

the filter method will return false for every element of the array, so it returns an empty array
but comparing that with [] does not work
Blauelf
@Blauelf
Jun 04 2016 08:30
@zelite Arrays are objects, and objects are compared by comparing their references. So []!==[] is true.
Krishna
@krisskb
Jun 04 2016 08:30
Hello Friends, I would like to know the tool to do line by line debugging for JavaScript code. I am using Notepad++ as editor now. Many thanks
Zelite
@zelite
Jun 04 2016 08:30
what you mean by comparing the references? That they are the same object in memory?
Blauelf
@Blauelf
Jun 04 2016 08:30
@zelite Variables do not contain objects, they contain references to objects. That's why comparing them won't compare by content, but just compare whether they are pointing to the exact same object.
Zelite
@zelite
Jun 04 2016 08:31
so, if wanted to compare for example [1, 2] == [1, 2], what would be the common approach? make a loop and compare element by element?
Blauelf
@Blauelf
Jun 04 2016 08:32
Basically, yes.
Zelite
@zelite
Jun 04 2016 08:33
ok, thanks :) @Blauelf . The origin of this question was that I was trying to check if an array is empty. I already figured it out that I can check the length property, but was bugging me that the comparison with [] was not working :)
CamperBot
@camperbot
Jun 04 2016 08:33
zelite sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1944 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Jun 04 2016 08:48

You could write a helper function

Array.prototype.equals = function(arr2) {
  if (typeof arr2 !== "object" || typeof this.length !== "number" || typeof arr2.length !== "number") {
    throw new TypeError("Both objects must be array-like.");
  }
  if (this.length !== arr2.length) {
    return false;
  }
  // not a good way for sparse arrays, maybe have a comparison
  // between length property and amount of numeric property names
  // and switch to another algorithm on really sparse arrays?
  for (var i = 0, len = this.length; i < len; i++) {
    if (i in this !== i in arr2 || this[i] !== arr2[i]) { // first will ensure holes match and are not mistaken for undefined
      return false;
    }
  }
  return true;
}

and then use

[].equals([]) // true

(just typed that into chat, not tested)

Krishna
@krisskb
Jun 04 2016 08:50
@sahooarpan, here !== if(prop == 'tracks' & value != ""){
CiTi
@CiTiCagatay
Jun 04 2016 08:51

i am new on javascript and i need to do:
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
and my code is

var remainder;
remainder = 11 % 3;
but i cant pass
You should use the % operator.
WHAT IS THE PROBLEM?

Blauelf
@Blauelf
Jun 04 2016 08:54
@sahooarpan & is bitwise and, while && is logical and
theBembee
@theBembee
Jun 04 2016 08:55
hello guys! i'm stuck at Inventory Update. Anyone knows how to sort the updated inventory in alphabetical order by item?
Blauelf
@Blauelf
Jun 04 2016 08:55
@CiTiCagatay Maybe use the assignment as initialization to remainder, so combine them in the same line (var remainder = 11 % 3;)? Or reload the page, fixes some bugs (locally crashed/not properly loaded javascripts).
Krishna
@krisskb
Jun 04 2016 08:55
@CiTiCagatay Could you try initialize remainder to 0. var remainder=0;
CiTi
@CiTiCagatay
Jun 04 2016 08:56

i tried var remainder=0;

remainder = 11 % 3;
@krisskb

@Blauelf this one is correct one:
var remainder = 11%3;
Blauelf
@Blauelf
Jun 04 2016 08:57
So only one line instead of two. To be precise, only one statement (as JS is pretty flexible on whitespace, a "line" is not really a unit)
hoklaamc
@hoklaamc
Jun 04 2016 09:07
```
hey guys, I’m stuck on “record collection”. Here is what I have so far:

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  }
  else if (value !== "" && prop === "tracks") {
    var arr = collection[id].tracks;
    arr.push(value);
  }
  else if (value === "") {
    delete collection[id][prop];
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
I’m trying to cover the case when there is currently no tracks array, and have to create an array and push the value onto it
Zelite
@zelite
Jun 04 2016 09:12
so, before you push the track
you need to check if there is a tracks array there
you can do this with .hasOwnProperty() method
example: collection[0].hasOwnPropery("tracks")
if that is true, then you make collections[id][prop].push("thing")
if that is false, then you need to create the property
collections[id]["tracks"] = ["thing"] notice that the thing is inside brackets, which means I am making an array with that one thing already inside
hope that gets you in the right direction @hoklaamc
hoklaamc
@hoklaamc
Jun 04 2016 09:15
right, thanks @zelite !
CamperBot
@camperbot
Jun 04 2016 09:15
hoklaamc sends brownie points to @zelite :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @zelite |http://www.freecodecamp.com/zelite
Arpan
@sahooarpan
Jun 04 2016 09:20
but still nt running @Blauelf
Thomas
@TheCodyKnight
Jun 04 2016 09:40
can someone tell me why this is returning 0 (instead of the product of all the sub-array vars)?
https://codepen.io/TheCodyKnight/pen/ezNZbV?editors=0010
vervaak
@vervaak
Jun 04 2016 09:43
Because y starts at 0
anything multiply by 0 is 0
Mihajlo Krsmanović
@rektix
Jun 04 2016 09:45
hey can anyone help me with wikipedia viewer? :D
vervaak
@vervaak
Jun 04 2016 09:46
product = product * arr[x][y]; i think will work
Mihajlo Krsmanović
@rektix
Jun 04 2016 09:48
what api should i use to get text from wikipedia
Thomas
@TheCodyKnight
Jun 04 2016 09:49
@vervaak boom that did it. good game! how can i give you cookie points for your help?
Aleksander Gębicki
@Takumar
Jun 04 2016 09:51
@TheCodyKnight say: "Thank you @vervaak "
explain brownie
CamperBot
@camperbot
Jun 04 2016 09:52

:point_right: brownie points [wiki]

Brownie Points

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are two ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.

:pencil: read more about brownie points on the FCC Wiki

Thomas
@TheCodyKnight
Jun 04 2016 09:54
thank you @vervaak
CamperBot
@camperbot
Jun 04 2016 09:54
thecodyknight sends brownie points to @vervaak :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @vervaak |http://www.freecodecamp.com/vervaak
Thomas
@TheCodyKnight
Jun 04 2016 09:54
thank you @Takumar
CamperBot
@camperbot
Jun 04 2016 09:54
thecodyknight sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star2: 3215 | @takumar |http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Jun 04 2016 09:55
@TheCodyKnight you are welcome :-)
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 09:59
hey everyone
I have a question about factorial challenge
how do u think is this method ok:
var result = 1;
for (var i = 1; i <= num; i++) {
result *= i;
}
return result;
}
it works but i'm not quite sure if it's ok to do it that way
something is bodering me but I don't know what
:D
Aleksander Gębicki
@Takumar
Jun 04 2016 10:01
@TsenkoAleksiev87 it looks good, it should cover all cases 0! = 1 and others.
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:02
@Takumar thank you
CamperBot
@camperbot
Jun 04 2016 10:02
tsenkoaleksiev87 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star2: 3216 | @takumar |http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Jun 04 2016 10:02
@TsenkoAleksiev87 you are welcome :-)
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:02
but if the num is a bigger number let's say 50
wouldn't that slow a lot in that for loop?
Aleksander Gębicki
@Takumar
Jun 04 2016 10:03
@TsenkoAleksiev87 50 is not a big number in such algorithm for computer, even 50000 is not a big number :-)
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:04
i know but the result is getting really really big number in that case
i mean the result var is the factorial holder
does that matter or not?
I think I have read something about the memory but I am probably remembering it all wrong
I mean the bigger the number the more bytes it takes in the stack, am I right?
If I remember right in some languages there is something like BigInteger specially designed for such numbers
Aleksander Gębicki
@Takumar
Jun 04 2016 10:07
@TsenkoAleksiev87 I have to check how numbers are represented in JS, in strong typing languages you know for example that number from 0-255 takes always one byte for byte type and so on.
Jamen Marz
@jamen
Jun 04 2016 10:07
No, integers are allocated at a fixed size. There is a range of numbers you can use because JavaScript initializes a signed 64-bit integer.
You can, however, use Node.js's Buffer object, which initialize a fixed set of chars (bytes) in the memory with the C++ bindings.
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:08
@jamen aham thank you
CamperBot
@camperbot
Jun 04 2016 10:08
tsenkoaleksiev87 sends brownie points to @jamen :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jamen
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:08
I am starting to love JS :D
vervaak
@vervaak
Jun 04 2016 10:11
@TheCodyKnight Thanks for the brownie pt.
CamperBot
@camperbot
Jun 04 2016 10:11
vervaak sends brownie points to @thecodyknight :sparkles: :thumbsup: :sparkles:
:cookie: 199 | @thecodyknight |http://www.freecodecamp.com/thecodyknight
livonian-router
@livonian-router
Jun 04 2016 10:11
is there any more efficient than this (Chunky Monkey)?
  // Break it up.

  /*
  var arrTemp;
  var arrGroup = [];
  var start = 0;
  var end = size;
  while (start <= arr.length - 1)
    {
      arrTemp = arr.slice(start, end);
      arrGroup.push(arrTemp);
      start += size;
      end += size;
    }
   */


  var arrTemp;
  var arrGroup = [];
  for (var i = 0, j = size; i <= arr.length - 1; i += size)
    {
      arrTemp = arr.slice(i, j);
      arrGroup.push(arrTemp);
      j += size;
    }

//  arrGroup = arr.slice(8,10);

  return arrGroup;
Jamen Marz
@jamen
Jun 04 2016 10:13
I'm not willing to dedicate enough time to learn what you've done there in that code, but one pattern I notice is two loops... Do you think it would be possible to merge those two loops into one loop (I don't know the context because I haven't bothered to learn the code)?
I've been in multiple scenarios exactly like that one, merging two loops for optimization.
rouxfeur
@rouxfeur
Jun 04 2016 10:14
Performance-wise, is it better to have two simple loops or one nested loop?
livonian-router
@livonian-router
Jun 04 2016 10:14
@jamen the first while loop is commented, it's from the previous one while I use the second. You could also look at it too
kavesh pandit
@kaveshdgr8
Jun 04 2016 10:14
Can someone please explain to me the code of the counting cards question
Jamen Marz
@jamen
Jun 04 2016 10:15
@livonian-router Oh, haha, I didn't notice that. I thought those were both pieces of running code.
@lukasdinh Those aren't compatible. A scenario where you need nested loops isn't exchangeable with using two unested loops. That message I posted above though is still relevant. Im most of my scenarios I found that it was an area where I could turn a nested loop into one loop with the parent.
Carlos Pulido
@carlosfrontend
Jun 04 2016 10:17
Hello, good morning I need to know if it is possible to recover 10 random wikipedia entries with their respective titles , links to each and texts can not get get a json with that data.
kavesh pandit
@kaveshdgr8
Jun 04 2016 10:18

will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

Example Output
"-3 Hold"
"5 Bet"

Can any1 please help me
rouxfeur
@rouxfeur
Jun 04 2016 10:18
@jamen I just need to know what how should I design the code if I can choose between a nested loop and two loops ...
Carlos Pulido
@carlosfrontend
Jun 04 2016 10:20
hi @lukasdinh how are u ? can u help me?
Jamen Marz
@jamen
Jun 04 2016 10:20
The only time you will ever need a nested loop, is if your nested loop is based on the index or anything using the index (like an item from an array you selected with the index).
This message was deleted
kavesh pandit
@kaveshdgr8
Jun 04 2016 10:21
Why isnt
Jamen Marz
@jamen
Jun 04 2016 10:22
One exception to having two separate non-merged loops, is if one loop depends on the previous loop's end result, so they have to be separate.
But, anything other than those exceptions, I merge my loops together to optimize.
rouxfeur
@rouxfeur
Jun 04 2016 10:23
@jamen ok thank you for explanation
CamperBot
@camperbot
Jun 04 2016 10:23
lukasdinh sends brownie points to @jamen :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jamen
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:23
uuuum @jamen help? :)
ehekatlOf
@ehekatlOf
Jun 04 2016 10:23
hey guys, I'm learning react
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:24
I got stuck on Check for Palindromes challenge
ehekatlOf
@ehekatlOf
Jun 04 2016 10:24
but on the codeschool tutorial for react, there's a part that's making use of map that has me kind of confused
can anyone help me out?
Jamen Marz
@jamen
Jun 04 2016 10:24
I have never used FCC, so I can't help you with any specific challenge. Post code and a little explanation and I might be able to help.
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:24
the input is a string
Jamen Marz
@jamen
Jun 04 2016 10:25

there's a part that's making use of map that has me kind of confused

Can you post some Code? I have some knowledge with React, but I don't know what you're talking about specifically.

TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:25
you should remove all spaces and symbols and check if the string reversed is the same as the original

function palindrome(str) {
// Good luck!
str.replace(/\W/g, "").toLowerCase();
var strReversed = str.reverse();

if (str == strReversed) {
return true;
}
return false;
}

ehekatlOf
@ehekatlOf
Jun 04 2016 10:25
thanks @jamen
CamperBot
@camperbot
Jun 04 2016 10:25
ehekatlof sends brownie points to @jamen :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jamen
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:25
palindrome('eye')
Ramesh syangtan
@rameshsyn
Jun 04 2016 10:25
function palindrome(str) {
  // Good luck!
  str.replace(/\W/g, "").toLowerCase();
  var strReversed = str.reverse();

  if (str == strReversed) {
    return true;
  }
  return false;
}
Diego Mayer
@Chrono79
Jun 04 2016 10:25
@TsenkoAleksiev87 reverse is a method of arrays
ehekatlOf
@ehekatlOf
Jun 04 2016 10:26
basically
Jamen Marz
@jamen
Jun 04 2016 10:26
Correct, so, to hint on that, you will need to convert the string to an array in order to use .reverse().
glhf
ehekatlOf
@ehekatlOf
Jun 04 2016 10:26
  _getComments() {
    const commentList = [
      { id: 1, author: 'Clu', body: 'Just say no to love!', avatarUrl: 'images/default-avatar.png' },
      { id: 2, author: 'Anne Droid', body: 'I wanna know what love is...', avatarUrl: 'images/default-avatar.png' }
    ];    
    return commentList.map(() => {
      return <Comment />
    });
  }
}
Diego Mayer
@Chrono79
Jun 04 2016 10:26
another hint is that the regex, doesn't remove underscores
ehekatlOf
@ehekatlOf
Jun 04 2016 10:26
basically what has me stumped
is why you're allowed to map empty ()
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:27
@rameshsyn how to paste the code like that?
ehekatlOf
@ehekatlOf
Jun 04 2016 10:27
like I tried typing out the literal format
Ramesh syangtan
@rameshsyn
Jun 04 2016 10:27
wiki format
CamperBot
@camperbot
Jun 04 2016 10:27

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

ehekatlOf
@ehekatlOf
Jun 04 2016 10:27
instead of ES2015 =>
Ramesh syangtan
@rameshsyn
Jun 04 2016 10:27
check above @TsenkoAleksiev87
ehekatlOf
@ehekatlOf
Jun 04 2016 10:27
and it gave me an error
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 10:27
thanks @rameshsyn
CamperBot
@camperbot
Jun 04 2016 10:27
tsenkoaleksiev87 sends brownie points to @rameshsyn :sparkles: :thumbsup: :sparkles:
:cookie: 663 | @rameshsyn |http://www.freecodecamp.com/rameshsyn
Jamen Marz
@jamen
Jun 04 2016 10:28
@ehekatlOf They are calling map on commentList (an array of objects), the () => piece is a callback function, know specifically as an arrow function.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:28
so I'm actually a bit confused how the curly braces are returning properly
yeah
=> is just shorthand for function of return right
Diego Mayer
@Chrono79
Jun 04 2016 10:28
and str.replace doesn't modify the string it's applied to, you need to assign that to the same or another string
This method does not change the String object it is called on. It simply returns a new string.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
Jamen Marz
@jamen
Jun 04 2016 10:28

Yeah, something like:

() => "foo"

Is the same as

function() {
  return "foo"
}
ehekatlOf
@ehekatlOf
Jun 04 2016 10:28
oh
so when I do empty parenthesis
it's literally that
oh ok
Jamen Marz
@jamen
Jun 04 2016 10:29
No, the empty parens are to signify there are no function arguments.
Diego Mayer
@Chrono79
Jun 04 2016 10:29
:point_up: 4 de junio de 2016 7:28 @TsenkoAleksiev87
ehekatlOf
@ehekatlOf
Jun 04 2016 10:29
right
now I'm actually confused
doesn't map need a function with an argument paremeter?
Jamen Marz
@jamen
Jun 04 2016 10:30
There are two types of functions. function() {} and () => {}.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:30
how is it doing map if there's no argument passed along?
Diego Mayer
@Chrono79
Jun 04 2016 10:30
gotta go, bye
ehekatlOf
@ehekatlOf
Jun 04 2016 10:30
later
Jamen Marz
@jamen
Jun 04 2016 10:31
Because .map is being called on the array, it is a method. commentList.map(...)
ehekatlOf
@ehekatlOf
Jun 04 2016 10:32
right but how does it know the elements to iterate through?
like I just tried this as a test and it didn't seem to work properly
and return 2 undefined elements
var test = [
      { id: 1, author: 'Clu', body: 'Just say no to love!', avatarUrl: 'images/default-avatar.png' },
      { id: 2, author: 'Anne Droid', body: 'I wanna know what love is...', avatarUrl: 'images/default-avatar.png' }    
];

test.map( function (){return });
sorry if this seems like, super scrubby
Jamen Marz
@jamen
Jun 04 2016 10:33
You should look up Array.prototype.map and look into how to use that more.
['foo', 'bar', 'baz'].map(item => item.toUpperCase());
// => ['FOO', 'BAR', 'BAZ']
ehekatlOf
@ehekatlOf
Jun 04 2016 10:33
hm, alright
thanks!
oh I see
so when you map it actually constructs a new array based on the number of index positions of the original
so even with a blank argument the map will return the proper number of index positions
Jamen Marz
@jamen
Jun 04 2016 10:39
Hmm, I think you are confusing yourself more. You call .map on an array, and it iterates behind the scenes for you. You provide it one argument (a function) that maps each iteration's value to a new value, and in the end it returns the result of the mapping (a new array of the values).
ehekatlOf
@ehekatlOf
Jun 04 2016 10:40
oh right, it's just in this case there's no argument for the function inside map
Jamen Marz
@jamen
Jun 04 2016 10:42
Yeah, I can't really tell you anything about that. Typically when you map something, you use each iteration's data.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:42
yeah
that's what had me stumped
because like
test.map( key => key);
makes perfect sense
but test.map ( () => {});
Jamen Marz
@jamen
Jun 04 2016 10:43
They are just creating an array of components for each item in the array.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:43
had me scratching my head
yeah
Jamen Marz
@jamen
Jun 04 2016 10:43
I don't know based on the context, but maybe they make use of it later in the tutorial.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:43
and the <Comment /> is populating each array element with a react component based on that?
here's the component for reference
class Comment extends React.Component {
  render() {
    return(
      <div className="comment">
        <p className="comment-header">{this.props.author}</p>
        <p className="comment-body">
          {this.props.body}
        </p>
        <div className="comment-actions">
          <a href="#">Delete comment</a>
        </div>
      </div>
    );
  }
}
Jamen Marz
@jamen
Jun 04 2016 10:44
Well, they aren't use any data from the iteration, so they are basically just creating an array of components the same size as the commentList.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:44
I feel like I'm manually breaking down how ng-repeat works
Jamen Marz
@jamen
Jun 04 2016 10:46
lol
React is pretty meta. Everything is done mostly in JavaScript.
so yes, you loop in JavaScript.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:46
lol
well, thanks for that
Arpan
@sahooarpan
Jun 04 2016 10:46
function lookUp( firstName, prop ){
for( var i = 0; i < contacts.length; i++ )
{
if( contacts[i].firstName == firstName )
{
if( contacts[i].hasOwnProperty( prop ) )
{
return contacts[i].prop;
}
else {
return "No such property";
}
} 
  else {
  return "No such contact";
}
}
whwre z my error
Jamen Marz
@jamen
Jun 04 2016 10:47
lmao
ehekatlOf
@ehekatlOf
Jun 04 2016 10:49
I think I would have just kept going with angular instead of doing react if angular was allowed to be used on the challenges
not sure why the challenges need you to use react
Jamen Marz
@jamen
Jun 04 2016 10:50
If you want a simple-to-use MVVM framework (in the family of React's) you could check out Vue.js
karanss
@karanss
Jun 04 2016 10:50
@sahooarpan use [] instead of . in calling prop
ehekatlOf
@ehekatlOf
Jun 04 2016 10:50
oh I've never even heard of it
Taras Yaremkiv
@Y-Taras
Jun 04 2016 10:50

Hello everyone. Please review my code about "Flatten a nested array" assignment

function steamrollArray(arr) {
  var emptyArr = [];
  function checkArr(arr) {
    arr.map(function (elem) {
      if (Array.isArray(elem)){
        return checkArr(elem);
      }
      else {
        emptyArr.push(elem);
        return elem;
      }
    });  
  }
    return emptyArr;
}


steamrollArray([1, [2], [3, [[4]]]]);

It returns me an empty array.

Jamen Marz
@jamen
Jun 04 2016 10:50
It's the new popular thing.
Everyone loves it.
Haha.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:50
nice, thanks for the tip
I'll bookmark it
karanss
@karanss
Jun 04 2016 10:50
and rearrange your last statement
ehekatlOf
@ehekatlOf
Jun 04 2016 10:51
I mean I like angular, it's just I get the feeling you'd have to rewrite your own code several times
and it feels like unpacking a matroshka doll
like whatever you're doing, there's probably a better way to do it
Jamen Marz
@jamen
Jun 04 2016 10:51
Vue works through components (like React) except they are composed differently (not entirely in JS like React, you still get those fun props like in Angular).
ehekatlOf
@ehekatlOf
Jun 04 2016 10:52
ah ok
oh, Vue
as in View from MVC
man it's late
Arpan
@sahooarpan
Jun 04 2016 10:52
how @karanss
Jamen Marz
@jamen
Jun 04 2016 10:52
Kind of, It's an MVVM framework, different from MVC slightly.
ehekatlOf
@ehekatlOf
Jun 04 2016 10:52
ah ok
Jamen Marz
@jamen
Jun 04 2016 10:53
React is also an MVVM framework, they are in the same branch.
Blauelf
@Blauelf
Jun 04 2016 10:53
@Y-Taras Instead of return checkArr(elem);, use just checkArr(elem);, and remove the return elem; (otherwise you end your loop early).
karanss
@karanss
Jun 04 2016 10:54
@sahooarpan take out else statement outside of for loop
Jamen Marz
@jamen
Jun 04 2016 10:54
Vue would work something like this:
new Vue({
  el: '#app',
  data: {
    foo: 123
  },
  methods: {
    add: function() {
      this.foo += 100; // add 100
    }
  }
});
<div id='app' @click='add()'>
  {{foo}}
</div>
ehekatlOf
@ehekatlOf
Jun 04 2016 10:57
huh, so this is like a unique Vue module?
nicely self contained?
lol wow, ok yeah it is
it even uses expressions to inject it in the DOM
Arpan
@sahooarpan
Jun 04 2016 10:59
can u send complete code
@karanss
Richard Andrews
@Whiplash5057
Jun 04 2016 11:01
Guys need help
ehekatlOf
@ehekatlOf
Jun 04 2016 11:02
this is really cool @jamen
this is like simplified angular
I'll definitely check it out after I finish this react tutorial
Arpan
@sahooarpan
Jun 04 2016 11:02
what @Whiplash5057
Richard Andrews
@Whiplash5057
Jun 04 2016 11:03
I want to mute the background video of this pen
karanss
@karanss
Jun 04 2016 11:03
@sahooarpan no point in sending full code .u should check whether all bracket are closed or not .and take that no contact outside of for loop.
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 11:05
ummm help please :D
function palindrome(str) {
  // Good luck!

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

  var newStr = str.replace(/\W/g, "").toLowerCase().split('').reverse();
  if (str === newStr) {
    return true;
  }
  return false;
}
I'm not sure what I'm doing wrong here
I have to check if a string is a palindrome
I'm using split() to make the newStr an array
right?
Anacoder1
@Anacoder1
Jun 04 2016 11:07
Need help in 'Escape Sequences in Strings' challenge in Javascript..My code is
var myStr=" \"\\" \t \t \r \n "; ..still wont work
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 11:08
@Anacoder1 try "\ \t \t \r \n"
ehekatlOf
@ehekatlOf
Jun 04 2016 11:08
@Whiplash5057 I don't see that option in the youtube API
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 11:09
@Anacoder1 you are using too much double quotes
I think that's the problem
ehekatlOf
@ehekatlOf
Jun 04 2016 11:09
you can probably set that manually in script though
Anacoder1
@Anacoder1
Jun 04 2016 11:10
@TsenkoAleksiev87 This worked
var myStr="\ \t \t \r \n";
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 11:10
@Anacoder1 told ya :)
can you help me out ?
function palindrome(str) {
  // Good luck!

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

  var newStr = str.replace(/\W/g, "").toLowerCase().split('').reverse();
  if (str === newStr) {
    return true;
  }
  return false;
}
RITESH KUMAR MOHAPATRA
@RITESHMOHAPATRA
Jun 04 2016 11:20

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop

my soln-function updateRecords(id, prop, value)
{
if(value!==""&&prop!=="tracks")
collection[id].prop="value";
else if(value!==""&&prop==="tracks")
collection[id]. tracks.push(value);
else if(value==="")
delete collection[id].prop;

return collection;
}not working plz help

TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 11:22
function updateRecords(id, prop, value) {
  if(value !== "" && prop !== "tracks"){
    collection[id][prop] = value;
  }
  else if(prop === "tracks" && value !== "") {
    collection[id].tracks.push(value);
  }
  else if(value === ""){
    delete collection[id][prop];
  }

  return collection;
}
RITESH KUMAR MOHAPATRA
@RITESHMOHAPATRA
Jun 04 2016 11:22
can't we use dot operator?
TsenkoAleksiev87
@TsenkoAleksiev87
Jun 04 2016 11:24
@RITESHMOHAPATRA check the last couple of challenges and you will get the idea :)
RITESH KUMAR MOHAPATRA
@RITESHMOHAPATRA
Jun 04 2016 11:26
still 2nd condition not working
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Brendan Kinahan
@BKinahan
Jun 04 2016 11:29
@RITESHMOHAPATRA what does your code look like now?
RITESH KUMAR MOHAPATRA
@RITESHMOHAPATRA
Jun 04 2016 11:29

function updateRecords(id, prop, value) {
if(value !== "" && prop !== "tracks"){
collection[id][prop] = value;
}
else if(prop === "tracks" && value !== "") {
collection[id].tracks.push(value);
}
else if(value === ""){
delete collection[id][prop];
}

return collection;
}
// Alter values below to test your code