These are chat archives for FreeCodeCamp/HelpJavaScript

6th
May 2017
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:01 UTC
@Pagnito Math.round(num/10) * 10?
@Pagnito how did you do it?
Nguyen Hoang
@honnhien12h
May 06 2017 00:04 UTC
Help me Using Objects for Lookups in Javascript pls!
Moisés Man
@moigithub
May 06 2017 00:04 UTC
+((54+"").split("")[0]+"0") :p
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:05 UTC
@moigithub what if you want to round up?
@honnhien12h what problem you having?
Khoa Le
@Zacele
May 06 2017 00:05 UTC
hey guys
Nguyen Hoang
@honnhien12h
May 06 2017 00:06 UTC
i don't khow Use var to lookup val
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:06 UTC
@Zacele hi
@honnhien12h what have you tried?
Khoa Le
@Zacele
May 06 2017 00:06 UTC
how could we remove all the duplicate element inside an array
Nguyen Hoang
@honnhien12h
May 06 2017 00:07 UTC
@HeebieGeeBee ```js
Khoa Le
@Zacele
May 06 2017 00:07 UTC
@honnhien12h what do u want to look up
Nguyen Hoang
@honnhien12h
May 06 2017 00:07 UTC
function phoneticLookup(val) {
  var result = "";

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

    "bravo": "Boston",

     "charlie":  "Chicago",

     "delta": "Denver",

     "echo": "Easy",

   "foxtrot":  "Frank",
  };

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

// Change this value to test
phoneticLookup("charlie");
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:07 UTC
@Zacele do you want anything that has a double to completely removed or do you want only one of each kind left?
Khoa Le
@Zacele
May 06 2017 00:08 UTC
@HeebieGeeBee completely remove all of it
Nguyen Hoang
@honnhien12h
May 06 2017 00:08 UTC
@Zacele Use the variable to lookup val and assign the associated string to the result variable.
Khoa Le
@Zacele
May 06 2017 00:08 UTC
@HeebieGeeBee only the unique one
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:08 UTC
@Zacele i use filter and index Of
and last index of
Alexx Martínez
@AlexxMart
May 06 2017 00:08 UTC

Hello, I'm stuck in the exercise "Generate Random Whole Numbers within a Range"

my code:


// Example
function ourRandomRange(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

  return Math.floor(Math.random() * (myMax - myMin)) + myMin; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
I still don't get the part that says: "The highest random number that can be generated by randomRange should be equal to your maximum number, myMax."
Pagnito
@Pagnito
May 06 2017 00:09 UTC
@HeebieGeeBee i needed it round to the lowest number, so i used Math.floor(num/10)*10
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:09 UTC
@AlexxMart what are you missing from their example?
@Pagnito ok cool
Khoa Le
@Zacele
May 06 2017 00:10 UTC
function sym(args) {
  var newArr = Array.prototype.slice.call(arguments);
  var result = [];
  var goal = newArr.reduce(function(a,b){
    return a.concat(b);
  });
  goal.sort();
  for(var i=0;i<goal.length;i++){
    if(result.lastIndexOf(goal[i]) ==-1){
      result.push(goal[i]);
    }
  }
  return result;
  }
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:10 UTC
@honnhien12h do you remember how to access values in objects?
Alexx Martínez
@AlexxMart
May 06 2017 00:10 UTC
@HeebieGeeBee That part that myMax could be equal than my maximun number
Khoa Le
@Zacele
May 06 2017 00:10 UTC
@AlexxMart basically the goal is to create a serie of number from highest to lowest within the range of the test case
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:11 UTC
@AlexxMart youre missing the +1
Nguyen Hoang
@honnhien12h
May 06 2017 00:12 UTC
@HeebieGeeBee yes but i don't khow Use the variable to lookup val
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:12 UTC
@honnhien12h well val is a variable
that will contain an object key
Alexx Martínez
@AlexxMart
May 06 2017 00:12 UTC
what "+1"?
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:12 UTC
remember that we use brackets for variables? @honnhien12h
@AlexxMart look in their example
Alexx Martínez
@AlexxMart
May 06 2017 00:13 UTC
you're right, I found it
thanks @HeebieGeeBee
CamperBot
@camperbot
May 06 2017 00:13 UTC
alexxmart sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1575 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:13 UTC
@Zacele what challenge is that?
Khoa Le
@Zacele
May 06 2017 00:14 UTC
@HeebieGeeBee Symmetric Difference
HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:15 UTC
@Zacele ok right first read the chellenge carefully
im not sure you want to concat all the arguments straight away
or sort the array
Nguyen Hoang
@honnhien12h
May 06 2017 00:15 UTC
@HeebieGeeBee ```js
function phoneticLookup(val) {
  var result = "";

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

    "bravo": "Boston",

     "charlie":  "Chicago",

     "delta": "Denver",

     "echo": "Easy",

   "foxtrot":  "Frank",
  };

  // Only change code above this line
  var test = val[""];
  return result[test];
}

// Change this value to test
phoneticLookup("charlie");
Khoa Le
@Zacele
May 06 2017 00:16 UTC
@honnhien12h Object[key] =value
ergohub
@ergohub
May 06 2017 00:16 UTC

Still stuck on 'Profile Lookup'. Just got a real block on this one. Cannot get the switch between 'No such contact' & 'No such property' to work. everything else seems to be firing correctly:

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

// Change these values to test your function
lookUpProfile("Akira", "address");

HeebieGeeBee
@HeebieGeeBee
May 06 2017 00:17 UTC
@Zacele and if you have done the diff two arrays challenge youve already done an algorithm for symmetric difference so could come in handy
Khoa Le
@Zacele
May 06 2017 00:17 UTC
@honnhien12h why you want to assign the test to val[""] ???
Gabe Rotberg
@grotberg
May 06 2017 00:17 UTC
@honnhien12h in this case, "alpha" etc is the key in your object, "Adams" is the value you're trying to get back. so to val["alpha"] would = "Adams"
Nguyen Hoang
@honnhien12h
May 06 2017 00:21 UTC
@Zacele @grotberg i don't understand @@ i'am very stupid...
Khoa Le
@Zacele
May 06 2017 00:22 UTC
@honnhien12h val is the value we pass in to the function to make it work so you probaby just want to use it for testing case and not assign it to anything else
ergohub
@ergohub
May 06 2017 00:23 UTC
just realise I didn't have a capital 'N' on my return string so thats why it wasn't firing. It pays to be case sensitive :smile:
Nguyen Hoang
@honnhien12h
May 06 2017 00:25 UTC
@Zacele ```js
function phoneticLookup(val) {
  var result = "";

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

    "bravo": "Boston",

     "charlie":  "Chicago",

     "delta": "Denver",

     "echo": "Easy",

   "foxtrot":  "Frank",
  };

  // Only change code above this line
  var test= lookup[" charlie"];
  return result[test];
}

// Change this value to test
phoneticLookup("charlie");
haha i don't it understand.. :worried:
Gabe Rotberg
@grotberg
May 06 2017 00:29 UTC
@honnhien12h well, there are a few issue here. First of all, the brackets [] are needed when access an element from an array or an object.
Khoa Le
@Zacele
May 06 2017 00:30 UTC
@honnhien12h you don't need to pass the specific key to kest it and result is just an empty string, result[test] would return undefined
Gabe Rotberg
@grotberg
May 06 2017 00:30 UTC
@honnhien12h var test= lookup[" charlie"]; if you take a look at this line, it should assign the value of the charlie key to test however, you have an extra space in there, so it won't do that at all (it will be undefined). Spaces matter
@honnhien12h but that said, even that isn't quite right, because you dont want to assign based on a static string (" charlie") you want to assign using the val argument passed to the original function.
@honnhien12h also note that you've changed a bunch of code below the line that says 'only change code above this line'
Dovydas Stirpeika
@Giveback007
May 06 2017 00:38 UTC
I'm back with another one. This one is a head scratcher.
Capture.PNG
Dylan Demnard
@kulpio
May 06 2017 00:42 UTC
Hi there!
I am kind of stucked at one of the very first exercises of Javascript.
I have to make three lines with a string b y using \n and \r but I can't get it to work... what am I doing wrong? This is my code line :
var myStr= "\FirstLine\n\SecondLine\r\Thirdline\"; // Change this line
Manish Giri
@Manish-Giri
May 06 2017 00:43 UTC
you need to escape the \ too around SecondLine
and uppercase L in ThirdLine
@kulpio
Luke Sallmen
@LukeSallmen
May 06 2017 00:44 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
    return contacts[i].prop;
  }
  if (firstName != contacts[i].firstName && i == contacts.length-1) {
    return "No such contact";
  }
  if (false === contacts[i].hasOwnProperty(prop) && i == contacts.length-1) {
    return "No such property";
  }
}
// Only change code above this line
}
still confused by this; the first if statement is evidently flawed but I'm not sure which part
Dylan Demnard
@kulpio
May 06 2017 00:44 UTC
@Manish-Giri sorry I don't get it....
Manish Giri
@Manish-Giri
May 06 2017 00:45 UTC
@kulpio for this to work - \SecondLine\
you need to escape each \
so \\SecondLine\\
Cade Touchet
@Cade801
May 06 2017 00:45 UTC
Hey guys, I need some help if someone wouldn't mind helping me. So I did the challenge and I got everything correct except it said no spacing. I don't have spaces in my code so I don't know whats going on could someone help. The challenge is called "Escape Sequences in Strings"
heres my code var myStr = '\"Firstline\n\Secondline\\rThirdline\"';
luccascamp
@luccascamp
May 06 2017 00:45 UTC

Hi guys, can you help me, how do I convert celsius to fahrenheit?
I'm trying like this, but it's not right :/

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);
var fahrenheit = 30 * 9 / 5 + 32;

Nguyen Hoang
@honnhien12h
May 06 2017 00:46 UTC
@grotberg @Zacele Sorry i will try it but i don't understand...
Dylan Demnard
@kulpio
May 06 2017 00:46 UTC
@Manish-Giri like that?
var myStr= "\FirstLine\n\SecondLine\r\ThirdLine\"; // Change this line
Manish Giri
@Manish-Giri
May 06 2017 00:46 UTC
@luccascamp what does this say
// Only change code below this line
// Only change code above this line
fix this now r\ThirdLine\
@kulpio
luccascamp
@luccascamp
May 06 2017 00:48 UTC
@Manish-Giri hahaha :0 I was blind
Luke Sallmen
@LukeSallmen
May 06 2017 00:48 UTC
@luccascamp Also you should be multiplying celsius* 9/5, not 30. 30 is just a single instance, celsius is what you want in your formula
@luccascamp I think
Dylan Demnard
@kulpio
May 06 2017 00:48 UTC
@Manish-Giri ... it just won't work!...
Manish Giri
@Manish-Giri
May 06 2017 00:49 UTC
fix this now r\ThirdLine\
did you do this?
@kulpio
luccascamp
@luccascamp
May 06 2017 00:49 UTC
@LukeSallmen @Manish-Giri thanks :)
CamperBot
@camperbot
May 06 2017 00:49 UTC
luccascamp sends brownie points to @lukesallmen and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 221 | @lukesallmen |http://www.freecodecamp.com/lukesallmen
:star2: 5406 | @manish-giri |http://www.freecodecamp.com/manish-giri
Luke Sallmen
@LukeSallmen
May 06 2017 00:50 UTC
any help on my challenge ^ ?
this profile challenge is stumping me - not on theory, but on implementation :(
Dylan Demnard
@kulpio
May 06 2017 00:50 UTC
@Manish-Giri well I did that:
var myStr= "\FirstLine\n\SecondLine\r\ThirdLine\";
and that
var myStr= "\FirstLine\n\SecondLine\r\ThirdLine\"; and it still won't work.
and that :
var myStr= "\FirstLine\n\\SecondLine\\r\ThirdLine\";
Manish Giri
@Manish-Giri
May 06 2017 00:51 UTC
you're making the same mistake every single time
how is a carriage return supposed to look?
it's shown on the left.
Dylan Demnard
@kulpio
May 06 2017 00:51 UTC
\r ?
Manish Giri
@Manish-Giri
May 06 2017 00:52 UTC
yes
Nguyen Hoang
@honnhien12h
May 06 2017 00:52 UTC
@Zacele @grotberg
Manish Giri
@Manish-Giri
May 06 2017 00:52 UTC
and you have r\
Nguyen Hoang
@honnhien12h
May 06 2017 00:52 UTC
function phoneticLookup(val) {
  var result = "";

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

    "bravo": "Boston",

     "charlie":  "Chicago",

     "delta": "Denver",

     "echo": "Easy",

   "foxtrot":  "Frank"

    };


  // Only change code above this line

  return result;
}

// Change this value to test
phoneticLookup("alpha");
phoneticLookup("bravo");
phoneticLookup("charlie");
phoneticLookup("delta");
phoneticLookup("echo");
phoneticLookup("foxtrot");
Manish Giri
@Manish-Giri
May 06 2017 00:52 UTC
@honnhien12h lookup is the object from which you need to get the property of the value val and assign to result
Keon Samuel
@keonsam
May 06 2017 00:52 UTC
@Manish-Giri I have surpass you.
zahahahaha
Manish Giri
@Manish-Giri
May 06 2017 00:53 UTC
good job
Dylan Demnard
@kulpio
May 06 2017 00:53 UTC
so it should be that:
var myStr= "\FirstLine\n\SecondLine\rThirdLine\"; // Change this line
??
Keon Samuel
@keonsam
May 06 2017 00:53 UTC
Im just kidding.
Manish Giri
@Manish-Giri
May 06 2017 00:53 UTC
and you're back to square one
\\SecondLine\\
Dylan Demnard
@kulpio
May 06 2017 00:53 UTC
yep... I just don't get it....
DistinctWolf
@DistinctWolf
May 06 2017 00:53 UTC
I don't get what I'm supposed to do in DNA Pairing challenge
Manish Giri
@Manish-Giri
May 06 2017 00:53 UTC
you had this
and then you need \rThirdLine
that's all
Nguyen Hoang
@honnhien12h
May 06 2017 00:54 UTC
@Manish-Giri i don't khow get lookup of the value val
Khoa Le
@Zacele
May 06 2017 00:54 UTC
put the "val" inside your function to test it @honnhien12h
Keon Samuel
@keonsam
May 06 2017 00:54 UTC
that one is simple @FlashHero
Manish Giri
@Manish-Giri
May 06 2017 00:54 UTC
@honnhien12h aren't there examples on the page?
Khoa Le
@Zacele
May 06 2017 00:54 UTC
@FlashHero if "C" return "G" ;"G" return "C"
Dylan Demnard
@kulpio
May 06 2017 00:54 UTC
but it is funny because I have the double \ around SecondLine but it does not show when I copy it here
Khoa Le
@Zacele
May 06 2017 00:54 UTC
@FlashHero the same with "A" and "T"
Keon Samuel
@keonsam
May 06 2017 00:55 UTC
yeah what zacele said.
Khoa Le
@Zacele
May 06 2017 00:55 UTC
@FlashHero well is not exactly return but pair it with the other word
Nguyen Hoang
@honnhien12h
May 06 2017 00:55 UTC
@Manish-Giri is it here:
DistinctWolf
@DistinctWolf
May 06 2017 00:56 UTC
@Zacele ok thanks
CamperBot
@camperbot
May 06 2017 00:56 UTC
flashhero sends brownie points to @zacele :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @zacele |http://www.freecodecamp.com/zacele
Nguyen Hoang
@honnhien12h
May 06 2017 00:56 UTC
var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"
Dylan Demnard
@kulpio
May 06 2017 00:56 UTC
var myStr= "\FirstLine\n\SecondLine\\rThirdLine\"; // Change this line
@Manish-Giri should't this work??
Manish Giri
@Manish-Giri
May 06 2017 00:56 UTC
yes understand those examples
see how you're getting the values
Dylan Demnard
@kulpio
May 06 2017 00:56 UTC
damn it still erases the \ when I send it
Manish Giri
@Manish-Giri
May 06 2017 00:56 UTC
alpha[2]; // "Y"
alpha[24]; // "C"
@kulpio why a \ at the end here? ThirdLine\
Khoa Le
@Zacele
May 06 2017 00:57 UTC
@honnhien12h exactly , now try to impletment it to your assigment
Dylan Demnard
@kulpio
May 06 2017 00:57 UTC
because when I don't put it it does not close the string properly
@Manish-Giri
Manish Giri
@Manish-Giri
May 06 2017 00:58 UTC
huh?
post your challenge URL here, click "run tests" first
@kulpio
@Manish-Giri
Manish Giri
@Manish-Giri
May 06 2017 00:59 UTC
this is what you have
var myStr= "\FirstLine\nSecondLine\\\rThirdLine\\";
  1. why the \ at the beginning?
  2. why the \\ at the end?
  3. what happened to the \\ before SecondLine?
I fixed these 3 and it worked
Dylan Demnard
@kulpio
May 06 2017 01:01 UTC
1.Dunno...lol
  1. the // at the end are asked on the last checks
  2. I just tested it without....
Manish Giri
@Manish-Giri
May 06 2017 01:01 UTC

this is how it needs to look like

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

there's no \ at the beginning or at the end..
Dylan Demnard
@kulpio
May 06 2017 01:02 UTC
@Manish-Giri thank you, I just made it how you said above and it worked....
CamperBot
@camperbot
May 06 2017 01:02 UTC
kulpio sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5407 | @manish-giri |http://www.freecodecamp.com/manish-giri
Dylan Demnard
@kulpio
May 06 2017 01:02 UTC
the first \ and last \ killed me.
Manish Giri
@Manish-Giri
May 06 2017 01:02 UTC
:+1:
Dylan Demnard
@kulpio
May 06 2017 01:03 UTC
I feel like you are going to help me a lot on javascript lol....
thank you so much
Manish Giri
@Manish-Giri
May 06 2017 01:03 UTC
lol
anytime
Dylan Demnard
@kulpio
May 06 2017 01:03 UTC
@Manish-Giri you are the man
Manish Giri
@Manish-Giri
May 06 2017 01:03 UTC
:v:
Nguyen Hoang
@honnhien12h
May 06 2017 01:21 UTC
@Manish-Giri @Zacele @grotberg I did it, thank you so much!
CamperBot
@camperbot
May 06 2017 01:21 UTC
honnhien12h sends brownie points to @manish-giri and @zacele and @grotberg :sparkles: :thumbsup: :sparkles:
:star2: 5408 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 290 | @zacele |http://www.freecodecamp.com/zacele
:cookie: 337 | @grotberg |http://www.freecodecamp.com/grotberg
Khoa Le
@Zacele
May 06 2017 01:22 UTC
@honnhien12h very nice, try to keep the momentum going
DistinctWolf
@DistinctWolf
May 06 2017 01:24 UTC

function pairElement(str) {
var result=[];
  var arr=str.split('');
  for(var i=0;i<arr.length;i++){
    if(arr[i]=='G'){
      result.push(arr[i]+'C');
    }else if(arr[i]=='C'){
      result.push(arr[i]+'G');
    }else if(arr[i]=='T'){
      result.push(arr[i]+'A');
    }else if(arr[i]=='A'){
      result.push(arr[i]+'T');
    }
  }
  return result;
}

pairElement("GCG");
How do I put each pair in a sub array
kickkick479
@kickkick479
May 06 2017 01:25 UTC
@FlashHero Make a new array inside the for loop, and push it to result array.
Luke Sallmen
@LukeSallmen
May 06 2017 01:25 UTC
anyone help?
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
    return contacts[i].prop;
  }
  if (firstName != contacts[i].firstName && i == contacts.length-1) {
    return "No such contact";
  }
  if (false === contacts[i].hasOwnProperty(prop) && i == contacts.length-1) {
    return "No such property";
  }
}
// Only change code above this line
}
Nguyen Hoang
@honnhien12h
May 06 2017 01:25 UTC
@Zacele your heart is in the right place.
kickkick479
@kickkick479
May 06 2017 01:30 UTC
@LukeSallmen what is i == contacts.length-1 for ? I recommend you to separate name check and property check apart.
And if you use variable in order to access object's property, you need use brackes notation, not dot notation, like ` return contacts[i][prop];
@LukeSallmen besides, the position of return "No such contact"; is not correct. After checking all contacts have the passed firstName, we should return thta. So you need write that outside of for loop.
Luke Sallmen
@LukeSallmen
May 06 2017 01:32 UTC
@kickkick479 I'm not sure how to only return false if it is true in every iteration. I was trying to cover for that with if i == contacts.length-1, but I suppose that just tests for the last iteration
Val
@iAurora
May 06 2017 01:32 UTC
@LukeSallmen It's your return "No such property"; that is causing your pain most likely. You have it within the loop
Luke Sallmen
@LukeSallmen
May 06 2017 01:33 UTC
@iAurora What do I use rather than contacts[i[.hasOwnProperty(prop) if I'm putting it outside the loop
Also @kickkick479 why do I have to use bracket rather than dot? I don't understand
kickkick479
@kickkick479
May 06 2017 01:35 UTC
@LukeSallmen Cuz prop is variable in the challenge. contacts[i].prop means contacts[i]["prop"] . prop is interpreted as string literal.
Val
@iAurora
May 06 2017 01:36 UTC
there is no problem with contacts[i].hasOwnProperty. The problem is when the name does not match. It's a loop, so you are checking all the objects in the array. Imagine the contact is there but it's not the first object in your list. You check that firstName in first object does not match and return "No such contact" and bah you are out of the function, no further check happening
Loop your array for firstName that does match. If you find it, check for prop and return the property. If you don't find it, return No contact but do it after the loop. Don't kick yourself out of the function on first unsuccessful match
Coy Sanders
@coymeetsworld
May 06 2017 01:39 UTC
it doesn't kick him out on first unsuccessful match, because of the i == contacts.length-1 part, that part is causing issues too
kickkick479
@kickkick479
May 06 2017 01:41 UTC
@LukeSallmen I don't tihnk i == contacts.length-1 make sense. I recommend check like this.
  1. check the first name in the loop
    1-1. check the property
  2. out of the loop, return no such contacts.
Val
@iAurora
May 06 2017 01:42 UTC
Oh yeah, contacts.length-1 is basically a constant, which is a weird thing to check against
Coy Sanders
@coymeetsworld
May 06 2017 01:43 UTC
I think he's trying to check the end of the loop, but the logic doesn't work
easier to confirm no such contacts exist once you exit the for loop as @kickkick479 says, because if you're not returning anything within the loop that means you didn't find the contact
jhobotuck
@jhobotuck
May 06 2017 02:00 UTC
blob
blob
Just stumped on "Ceasar's Cipher" for some reason the code returns a majority of the right character but the odd character is wrong. A bit bamboolzed by it.

function rot13(str) { // LBH QVQ VG!

  var tempArray = [];
  var minus13Array = [];
  var resultString = "";

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

    tempArray.push(str.charCodeAt(i));

    if (tempArray[i] === 32) {
      minus13Array.push(tempArray[i]);
    } else {
      minus13Array.push(tempArray[i] + 13);
    }

    resultString += String.fromCharCode(minus13Array[i]);

  }

  return resultString;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Coy Sanders
@coymeetsworld
May 06 2017 02:03 UTC
why 32?
Moisés Man
@moigithub
May 06 2017 02:03 UTC
@jhobotuck if u have Z(90) +13 will be 103 (g)
www.asciitable.com
u need to keep ur range on A-Z (65 - 90)
jhobotuck
@jhobotuck
May 06 2017 02:05 UTC
Ohhh excuse that mistake. I was experimenting it is meant to be "- 13"
With the edition "SERR PBQR PNZC" returns "F8EE C5DE CAM6" instead of "FREE CODE CAMP"
Moisés Man
@moigithub
May 06 2017 02:06 UTC
same hapen if u have A - 13
65-13 = 52 (4)
jhobotuck
@jhobotuck
May 06 2017 02:08 UTC
Huh? Isn't that the point of the exericise to encrypt by moving the character values by thirteen places?
Nguyen Hoang
@honnhien12h
May 06 2017 02:09 UTC
@Zacele why it not work?
Khoa Le
@Zacele
May 06 2017 02:09 UTC
@honnhien12h ???
Nguyen Hoang
@honnhien12h
May 06 2017 02:09 UTC

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

function checkObj(checkProp) {
  // Your Code Here

 if(myObj)  { myObj.hasOwnProperty("gift");
   myObj.hasOwnProperty("pet");
   myObj.hasOwnProperty("house");
          return myObj[checkProp];
          }      
   else{    

 return "Not Found";}



}

// Test your code by modifying these values
checkObj("gift");
Testing Objects for Properties
Tegh
@teghmehta
May 06 2017 02:11 UTC

function spinalCase(str) {
  str = str.replace(/\s+/g, '-').toLowerCase();


  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  return str;
}

spinalCase('This Is Spinal Tap');
it doesnt work with thisIsSpinalTap or underscores
Moisés Man
@moigithub
May 06 2017 02:12 UTC
@jhobotuck yep.. but u need to keep the range A-Z
soo if it reach the limit.. ie Z it should go back to A and keep counting
jhobotuck
@jhobotuck
May 06 2017 02:12 UTC
@moigithub I missed your comment about the range. Thanks you.
CamperBot
@camperbot
May 06 2017 02:12 UTC
jhobotuck sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3193 | @moigithub |http://www.freecodecamp.com/moigithub
kickkick479
@kickkick479
May 06 2017 02:20 UTC
@teghmehta Regarding to uderscores, you can add it like eplace(/[\s_]+/g, '-').
RanDT1
@RanDT1
May 06 2017 02:21 UTC
hello everyone, I seem to be having an issue with one of my challenges. I don't exactly know what I'm supposed to do. Could someone give me a hand?
How exactly would I link you the code without it showing up like just plain text

function nextInLine(arr, item) {
testArr.shift(arr);
testArr.push(item);
return item; // Change this line
}

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

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

Coy Sanders
@coymeetsworld
May 06 2017 02:22 UTC
shift doesn't take in a parameter @RanDT1, and you should only be operating on the array param given to you in nextInLine (i.e. arr)
you also don't want to return item, item is what you're pushing into the array. you want to return the element you shifted off the array
RanDT1
@RanDT1
May 06 2017 02:23 UTC
ahh I see
trying to figure out how I would do that.
Coy Sanders
@coymeetsworld
May 06 2017 02:25 UTC
i would read the documentation for shift and push
RanDT1
@RanDT1
May 06 2017 02:25 UTC
I feel like I'm WAY overthinking it
Coy Sanders
@coymeetsworld
May 06 2017 02:25 UTC
so you know what its doing
no its close
RanDT1
@RanDT1
May 06 2017 02:33 UTC
so after removing the Parameter on the shift all I need to figure out is what to put into return? Thank you for the help @coymeetsworld :)!
CamperBot
@camperbot
May 06 2017 02:33 UTC
randt1 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2539 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Luke Sallmen
@LukeSallmen
May 06 2017 02:35 UTC
@kickkick479 Sorry this is from awhile ago, but what did you mean by
check the first name in the loop
1-1. check the property
out of the loop, return no such contacts.
Val
@iAurora
May 06 2017 02:36 UTC
@RanDT1 The purpose of a function is reusability of the code. You write logic once and then use it on any number of suitable arguments. In that challenge testArr is one of the possible arguments that you can feed to your nextInLine function. It should not be hard-coded inside that function, because testArr2, someOtherArray, arrrrrr should work equally well when passed as an arr argument
@RanDT1 Which means testArr is not a part of the solution
RanDT1
@RanDT1
May 06 2017 02:37 UTC
Ah so I shouldn't be calling on the testArr var at all
in the function
kickkick479
@kickkick479
May 06 2017 02:37 UTC
@LukeSallmen
1-1. check the property means that if the contact has the passed firstName, check the contact has the passed prop.
Luke Sallmen
@LukeSallmen
May 06 2017 02:38 UTC
@kickkick479 Do you mean inside or outside of the loop? And is my first if statement okay?
RanDT1
@RanDT1
May 06 2017 02:38 UTC
so it should be more like this this.shift();
this.push(item);?
Luke Sallmen
@LukeSallmen
May 06 2017 02:38 UTC
@kickkick479 I'm not sure if you're suggesting to change my whole loop structure or not
RanDT1
@RanDT1
May 06 2017 02:38 UTC
Thanks again for the help, I know I'm not the smartest cookie in the jar lol
wait a sec
kickkick479
@kickkick479
May 06 2017 02:39 UTC
@LukeSallmen out of the loop, return no such contacts. means after the loop without firstName match, return no such contacts, cuz nobody has the passed firstName.
Val
@iAurora
May 06 2017 02:39 UTC
@RanDT1 I don't think 'this' was even explained at that point of the course. You have a perfectly fine arr argument. It represents any array that you feed to that function...
kickkick479
@kickkick479
May 06 2017 02:40 UTC
@LukeSallmen Using for loop is Ok, I used to do that.

@LukeSallmen

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

if state is OK, but as I told , use bracket notation in order to retrieve property value.

I reccomended that we should not pack our logic into one certin if block. we can separate if statement.

Luke Sallmen
@LukeSallmen
May 06 2017 02:44 UTC
@kickkick479 Any reason not to keep it in one if block? It makes it more compact and still maintains readability imo
kickkick479
@kickkick479
May 06 2017 02:45 UTC
@LukeSallmen u r right, it is compact. But it is diffcult to agree with it's readable.
Sorry my typo.
Luke Sallmen
@LukeSallmen
May 06 2017 02:49 UTC
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];
  }
}
  return "No such contact";
like that?
Nguyen Hoang
@honnhien12h
May 06 2017 02:50 UTC
how to return "Not Found" if the property is fale :```js
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  myObj.hasOwnProperty("gift");
   myObj.hasOwnProperty("pet");
   myObj.hasOwnProperty("house");

     return myObj[checkProp]; 








}

// Test your code by modifying these values
checkObj("gift");
Luke Sallmen
@LukeSallmen
May 06 2017 02:50 UTC
@honnhien12h What do you mean "if the property is false"
you mean if it's not defined?
or if it actually is false
kickkick479
@kickkick479
May 06 2017 02:50 UTC
@LukeSallmen Allmost there.
Remainder is to put 'no such property'.
kickkick479
@kickkick479
May 06 2017 02:51 UTC
@LukeSallmen Oh sorry for my abbriviation. it was intended that hasOwnProperty is false.
AKSHAY R
@akshayr369
May 06 2017 02:51 UTC
how to clear this challenge
kickkick479
@kickkick479
May 06 2017 02:52 UTC
@akshayr369 You can reset with reset button placed below the Run tests button.
Luke Sallmen
@LukeSallmen
May 06 2017 02:52 UTC
@kickkick479 But then where does "No such property" go?
Nguyen Hoang
@honnhien12h
May 06 2017 02:52 UTC
@LukeSallmen Yes" if the property is false, return "Not Found"
AKSHAY R
@akshayr369
May 06 2017 02:52 UTC
@kickkick479 ya but whats the solution to it
kickkick479
@kickkick479
May 06 2017 02:53 UTC
@LukeSallmen When somebody has the passed firstName, but the person has no such property.
Luke Sallmen
@LukeSallmen
May 06 2017 02:53 UTC
@honnhien12h if (object.hasOwnProperty(property) == false) {return "Not Found";}
kickkick479
@kickkick479
May 06 2017 02:56 UTC
@akshayr369 What do you mean by that ? You cannot reset your code ? Or you are stacked at the challenge?
Nguyen Hoang
@honnhien12h
May 06 2017 02:56 UTC
@LukeSallmen Yes I will try id!!
Luke Sallmen
@LukeSallmen
May 06 2017 02:57 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];
  if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop) === false) {
return "No such property";}
  }
}
  return "No such contact";

// Only change code above this line
}
AKSHAY R
@akshayr369
May 06 2017 02:57 UTC
@kickkick479 i have reset the code but im stuck im not able to solve it
Luke Sallmen
@LukeSallmen
May 06 2017 02:57 UTC
@kickkick479 Still stuck
kickkick479
@kickkick479
May 06 2017 02:59 UTC
@LukeSallmen Last test is not passed... Let me see.
Luke Sallmen
@LukeSallmen
May 06 2017 02:59 UTC
@kickkick479 oh, I'm missing a bracket I think
kickkick479
@kickkick479
May 06 2017 02:59 UTC
@LukeSallmen Yeah, I agree with that.
Luke Sallmen
@LukeSallmen
May 06 2017 03:00 UTC
@kickkick479 Still doesn't work after that, though. My last return statement seems wrong.
Nguyen Hoang
@honnhien12h
May 06 2017 03:00 UTC
@LukeSallmen it do not
kickkick479
@kickkick479
May 06 2017 03:00 UTC
@LukeSallmen mabye you have unneeded closing bracket.
Nguyen Hoang
@honnhien12h
May 06 2017 03:02 UTC
@LukeSallmen Lots of bugs

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

function checkObj(checkProp) {
  // Your Code Here

  myObj.hasOwnProperty("gift") 
   myObj.hasOwnProperty("pet")
    return myObj[checkProp];




   if (myObj.hasOwnProperty("house")=== false){
     return " Not Found";
   }    






}

// Test your code by modifying these values
checkObj("gift");
Luke Sallmen
@LukeSallmen
May 06 2017 03:02 UTC
@kickkick479 Got it!
Patrick Koidal
@Koitis
May 06 2017 03:03 UTC
i'm stuck on this one Make Unique Objects by Passing Parameters to our Constructor
my code is
this.wheels = wheels; this.seats = seats; this.engines = engines; };
but it keeps saying wheels is not defined
i have values assigned via var myCar = new Car(3,1,2);
what am i missing?
AKSHAY R
@akshayr369
May 06 2017 03:05 UTC
someone helpme with challenge number 155:"wordblanks" in javascript
Luke Sallmen
@LukeSallmen
May 06 2017 03:05 UTC
@honnhien12h what are you trying to do with myObj.hasOwnProperty("house")? I'm not sure I understand your usage
kickkick479
@kickkick479
May 06 2017 03:05 UTC
@akshayr369 You need make a sentense, usinge passed arguments.
like Lazy Kim wakes-up late.
you can add string literal like result += myNoun + " "
noeloariola
@noeloariola
May 06 2017 03:06 UTC

var myStr ="FirstLine\n\SecondLine\r\ThirdLine"; // Change this line

myStr should have encoded text with the proper escape sequences and no spacing. any ide?

var myStr ="FirstLine\n\SecondLine\r\ThirdLine";
kickkick479
@kickkick479
May 06 2017 03:08 UTC
@honnhien12h Hi,
You can check if the object has the certain property, using myObj.hasOwnProperty(prop).
This return boolean value.
If true, return the property value, using bracket notation.
If false, return "Not Found". @honnhien12h
AKSHAY R
@akshayr369
May 06 2017 03:08 UTC
no result @kickkick479
kickkick479
@kickkick479
May 06 2017 03:09 UTC
@honnhien12h
Nguyen Hoang
@honnhien12h
May 06 2017 03:09 UTC
@LukeSallmen y0u tell me : if (object.hasOwnProperty(property) == false) {return "Not Found";}@@
Nirab Shrestha
@Nirav11
May 06 2017 03:10 UTC
Hello
I have a problem with escape sequence

var myStr; // Change this line

myStr = "FirstLine\n\SecondLine\r\ThirdLine";

It says myStr should have encoded text with the proper escape sequences and no spacing.
kickkick479
@kickkick479
May 06 2017 03:11 UTC
@akshayr369 you set constant string literal to result in the second sentence. You don't need assign any value at the sentence, cuz you do it in result +=myNoun+myAdjective+myVerb+myAdverb;.
Beside you need white space between words.
Manish Giri
@Manish-Giri
May 06 2017 03:12 UTC
myStr = "FirstLine\n\\SecondLine\r\\ThirdLine";
Mauro
@mauronml
May 06 2017 03:12 UTC
Hello everyone
Nirab Shrestha
@Nirav11
May 06 2017 03:12 UTC
@kickkick479 Could you help me
Manish Giri
@Manish-Giri
May 06 2017 03:12 UTC
@Nirav11 this is your code
Nirab Shrestha
@Nirav11
May 06 2017 03:12 UTC
Thank you Manish
Manish Giri
@Manish-Giri
May 06 2017 03:12 UTC
your \\ and \r are out of order
kickkick479
@kickkick479
May 06 2017 03:12 UTC
@mauronml Hi.
Nirab Shrestha
@Nirav11
May 06 2017 03:14 UTC
@Manish-Giri I still get problem with the spacing
Manish Giri
@Manish-Giri
May 06 2017 03:14 UTC
show code
format it
Nirab Shrestha
@Nirav11
May 06 2017 03:15 UTC
var myStr; // Change this line
myStr = "FirstLine\n\SecondLine\r\ThirdLine";
myStr = "FirstLine\n\SecondLine\r\ThirdLine";
kickkick479
@kickkick479
May 06 2017 03:15 UTC
\
Manish Giri
@Manish-Giri
May 06 2017 03:15 UTC
myStr = "FirstLine\n\\SecondLine\r\\ThirdLine";
same problem
\rfirst then \\
kickkick479
@kickkick479
May 06 2017 03:16 UTC
@Nirav11 ''' see more info below. plain text as interpreted as special characters in gitter. in triple backticks, your text is treated as codes.
CamperBot
@camperbot
May 06 2017 03:16 UTC
:bulb: to format code use backticks! ``` more info
Nguyen Hoang
@honnhien12h
May 06 2017 03:16 UTC
@kickkick479 how to get boolean by return
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

   myObj.hasOwnProperty("gift");
   myObj.hasOwnProperty("pet");
   myObj.hasOwnProperty("house");

 if ( myObj.hasOwnProperty("gift") === true){
   return myObj[checkProp];
 }
  else if (myObj.hasOwnProperty("pet") === true){
    return myObj[checkProp];
  }
   else if (myObj.hasOwnProperty("house") === false){
     return "Not Found";
   }
Manish Giri
@Manish-Giri
May 06 2017 03:17 UTC
@honnhien12h what's the use of checkProp if you don't use it anywhere in your code?
function checkObj(checkProp) {
kickkick479
@kickkick479
May 06 2017 03:18 UTC
@honnhien12h Humm. Before your question, you recieve checkProp. So use it with hasOwnProperty.

@honnhien12h

   myObj.hasOwnProperty("gift");
   myObj.hasOwnProperty("pet");
   myObj.hasOwnProperty("house");

That block is unnecessary for the challenge.

Nirab Shrestha
@Nirav11
May 06 2017 03:23 UTC
var myStr;
myStr = "FirstLine\n\\SecondLine\r\\ThirdLine";
Joseph
@revisualize
May 06 2017 03:24 UTC
Hello.
@Nirav11 You're escaping the backslash and carriage return backwards.
kickkick479
@kickkick479
May 06 2017 03:24 UTC
@Nirav11 TX. your second \\ need to be placed just before \r if I remember the instruction correctly.
CamperBot
@camperbot
May 06 2017 03:24 UTC
kickkick479 sends brownie points to @nirav11 :sparkles: :thumbsup: :sparkles:
:cookie: 145 | @nirav11 |http://www.freecodecamp.com/nirav11
Joseph
@revisualize
May 06 2017 03:25 UTC
@honnhien12h .hasOwnProperty() returns a boolean value back to the function caller.
Nirab Shrestha
@Nirav11
May 06 2017 03:25 UTC
Thank you so much guys :)
jay-dezotel
@jay-dezotel
May 06 2017 03:28 UTC
can someone help me with this error on something I'm working on?
TypeError: Cannot read property 'from' of undefined
at Object.module.exports.findNextMessage (/home/ubuntu/workspace/challenge-01.tar/funcs.js:90:49)
at /home/ubuntu/workspace/challenge-01.tar/index.js:29:27
at /home/ubuntu/workspace/challenge-01.tar/funcs.js:47:12
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
Here's the code

module.exports.findNextMessage = function (inbox, lastHash) {
// find the message which comes after lastHash

for (var i = 0; i < inbox.messages.length; i += 1) {
var found;
if (inbox.messages[i].lastHash === lastHash) {
found = i
break}
// read and decode the message
return 'from: ' + decode(inbox.messages[found].from) + '\n---\n' +
decode(fs.readFile(path.join(inbox.dir, inbox.messages[found].hash), 'utf8'))
}}

yiheng666
@yiheng666
May 06 2017 03:30 UTC
'''function lookUp(firstName, prop){
for (i=0;i<contacts.length;i++){
if (contacts[i].firstName===firstName){
if (prop=="lastName"){
return contacts[i][prop];
}
else if (prop=="number"){
return contacts[i][prop];
}
else if (prop=="likes"){
return contacts[i][prop];
}
else return "No such property";
}
else return "No such contact";
}
}
'''
CamperBot
@camperbot
May 06 2017 03:30 UTC
:bulb: to format code use backticks! ``` more info
kickkick479
@kickkick479
May 06 2017 03:30 UTC
@jay-dezotel I guess inbox.messages[found] is NOT an array, reading Cannot read property 'from' of undefined
from is one of Array's methods.
yiheng666
@yiheng666
May 06 2017 03:31 UTC
function lookUp(firstName, prop){
for (i=0;i<contacts.length;i++){
if (contacts[i].firstName===firstName){
if (prop=="lastName"){
return contacts[i][prop];
}
else if (prop=="number"){
return contacts[i][prop];
}
else if (prop=="likes"){
return contacts[i][prop];
}
else return "No such property";
}
else return "No such contact";
}
}
jay-dezotel
@jay-dezotel
May 06 2017 03:31 UTC
ahh I see
不吃猫的鱼
@n0ruSh
May 06 2017 03:32 UTC
any problem? @yiheng666
yiheng666
@yiheng666
May 06 2017 03:32 UTC
what's wrong?THX
kickkick479
@kickkick479
May 06 2017 03:32 UTC
@yiheng666 If code has proper intend, it would be grreate readable.
yiheng666
@yiheng666
May 06 2017 03:32 UTC
it can't return porp
Nguyen Hoang
@honnhien12h
May 06 2017 03:33 UTC
@revisualize .hasOwnProperty() returns a boolean value back to checkObj>
?
kickkick479
@kickkick479
May 06 2017 03:33 UTC
@yiheng666 you are expeted return prop value which the contact has the passed first name and the passed property. Use hasOwnProperty method.
Nguyen Hoang
@honnhien12h
May 06 2017 03:34 UTC
or myObj variable?
kickkick479
@kickkick479
May 06 2017 03:37 UTC
@honnhien12h .hasOwnProperty() returns a boolean, but it has no target. It just become boolean value and change anything else.
yiheng666
@yiheng666
May 06 2017 03:37 UTC
I have tried using hasOwnProperty method but it seems doesn't work.I think i should try again.THX @kickkick479
Nguyen Hoang
@honnhien12h
May 06 2017 03:38 UTC
@kickkick479 thank you, i did it
CamperBot
@camperbot
May 06 2017 03:38 UTC
honnhien12h sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 341 | @kickkick479 |http://www.freecodecamp.com/kickkick479
kickkick479
@kickkick479
May 06 2017 03:38 UTC
@yiheng666 How's your code so far? Maybe "No such contact"; is placed wrongly.
Nguyen Hoang
@honnhien12h
May 06 2017 03:38 UTC
@LukeSallmen thank you so much!
CamperBot
@camperbot
May 06 2017 03:38 UTC
honnhien12h sends brownie points to @lukesallmen :sparkles: :thumbsup: :sparkles:
:cookie: 223 | @lukesallmen |http://www.freecodecamp.com/lukesallmen
kickkick479
@kickkick479
May 06 2017 03:39 UTC
@honnhien12h :+1:
Pagnito
@Pagnito
May 06 2017 03:42 UTC
cant quite understand the definiton of values(), anyone care to explain?
kickkick479
@kickkick479
May 06 2017 03:43 UTC
@Pagnito Except for MDN description?
Pagnito
@Pagnito
May 06 2017 03:45 UTC
@kickkick479 yea i looked at the mdn description, i cant really understand it
kickkick479
@kickkick479
May 06 2017 03:46 UTC
@Pagnito You see object has properties, key-value thing. values() returns only values of the object as an array.
Pagnito
@Pagnito
May 06 2017 03:47 UTC
@kickkick479 ooooh yea,lol i actually remember using in one of the last challenges, forgot
Manny
@Alloffices
May 06 2017 03:47 UTC
Stuck on Confirm the Ending:

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

  var s = str.split(' ').join("");
  var t = target.split(' ').join("");
  if (str.substring(s.length, t.lenght).split(" ").join("") == t) {
    return true;
  }
  if (str.substring(s.length, t.lenght).split(" ").join("") !== t) {
    return false;
  }

//   console.log(t);
//   console.log(s);
//   return str.substr(str.length - target.length);
}

confirmEnding("Bastian", "n");
kickkick479
@kickkick479
May 06 2017 03:47 UTC
@Pagnito Same thing happens to me many times, lol
Pagnito
@Pagnito
May 06 2017 03:47 UTC
@kickkick479 lol
@kickkick479 glad to hear that lol
Armanis22
@Armanis22
May 06 2017 03:48 UTC
I am having a lot of problems with arguments objects. I can't find anything that is helping me work with them on the Seek and Destroy challenge in the basic algorithm scripting section. I've been on this one for a couple days and could really use some help
Vamp
@the-vampiire
May 06 2017 03:49 UTC
@Pagnito be aware that it is not compatible in all browsers
another way is to loop through passing keys or use map passing keys
Pagnito
@Pagnito
May 06 2017 03:50 UTC
@the-vampiire cool cool, thanks
CamperBot
@camperbot
May 06 2017 03:50 UTC
pagnito sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @the-vampiire |http://www.freecodecamp.com/the-vampiire
Alexander Nikitas Dimopoulos
@anikitasd
May 06 2017 03:50 UTC
Can anyone help me with making Object Properties Private? I don't understand what the public method setGear is supposed to do..
Pagnito
@Pagnito
May 06 2017 03:50 UTC
@kickkick479 thanks btw as well
CamperBot
@camperbot
May 06 2017 03:51 UTC
pagnito sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @kickkick479 |http://www.freecodecamp.com/kickkick479
kickkick479
@kickkick479
May 06 2017 03:51 UTC
@Alloffices I don't think we need split and join method for this challenge. Just compare the last few characteres of str and target. If they are same, return treu. If not, return same. Use substr() substring() and length .
Vamp
@the-vampiire
May 06 2017 03:52 UTC
@Pagnito
Object.keys(obj).map(function(key){

    console.log(obj[key]);
});
if you want to store the results in an array…
var arr = Object.keys(obj).map(function(key){

    return obj[key];
});
seems really silly to me that Object.keys() is compatible but values() isn’t…
Pagnito
@Pagnito
May 06 2017 03:54 UTC
@the-vampiire yea iwas about to say that
weird
Vamp
@the-vampiire
May 06 2017 03:54 UTC
I jumped into my IDE and tried values() and got a type error not a function
i was like wtf
kickkick479
@kickkick479
May 06 2017 03:54 UTC
@Armanis22 we can use filter() as the instruction tells.
Vamp
@the-vampiire
May 06 2017 03:54 UTC
it mkes sense if there is keys there should be values but whatever man I dont make the rules
Pagnito
@Pagnito
May 06 2017 03:55 UTC
@the-vampiire hehe
Armanis22
@Armanis22
May 06 2017 03:57 UTC
@kickkick479 yeah I have been able to hardcode out a single value, but I have been debugging with console.log and I just can't seem to access the arguments that are supposed to be filtered out
kickkick479
@kickkick479
May 06 2017 03:57 UTC
@Armanis22 Can you share code written so far?
Manny
@Alloffices
May 06 2017 03:58 UTC
I tried this but only get "true" to return:

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  if (str.substring(str.length, target.length) == str.substring(str.length, target.length)) {
    return true;
  }
}

confirmEnding("Bastian", "n");
ohh! one sec
Riley
@rilesmc13
May 06 2017 04:03 UTC

Hi guys, I need help for "Adding a default option in Switch statements." I'm getting dev = "ReferenceError: a is not defined" when I plug this in:
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = "apple";
break;
case b:
answer = "bird";
break;
case c:
answer = "cat";
break;
default:
answer = "stuff";
}
// Only change code above this line
return answer;
}

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

kickkick479
@kickkick479
May 06 2017 04:04 UTC
@Armanis22 You can retrieve all arguments,
using var args = Array.from(arguments); // var args = Array.from(arguments);
@rilesmc13 You need fix case sentence, like case "a":
@rilesmc13 Cuz you are comparing val as a string.
Joseph
@revisualize
May 06 2017 04:06 UTC
@rilesmc13 Switch cases can be variables. So, if you want them to be strings you need to specify strings.
@Alloffices Your function returns only true or undefined.
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
Armanis22
@Armanis22
May 06 2017 04:07 UTC
@kickkick479 I will look into that method. I am also apparently having trouble with my browser. I have been trying to get a working snippet for you, turns out I needed to copy, reset my code, paste
@kickkick479 wait is arguments an actual keyword?
kickkick479
@kickkick479
May 06 2017 04:09 UTC
@Armanis22 That's a keyword.
JMehrnaz92
@JMehrnaz92
May 06 2017 04:09 UTC

I cant find the problem in this code: var Car = function(wheels,seats,engines) {
//Change this constructor
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};

//Try it out here
var myCar=Car(3,1,2);

Armanis22
@Armanis22
May 06 2017 04:09 UTC
@kickkick479 thanks a bunch, I think that's all the direction I needed for at least a little bit.
CamperBot
@camperbot
May 06 2017 04:09 UTC
armanis22 sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @kickkick479 |http://www.freecodecamp.com/kickkick479
Joseph
@revisualize
May 06 2017 04:09 UTC
@rilesmc13 Make sense?
kickkick479
@kickkick479
May 06 2017 04:10 UTC
@JMehrnaz92 What is the challenge name? And what is your matter correctly?
Riley
@rilesmc13
May 06 2017 04:11 UTC
Hmm @kickkick479 I'm still getting that error but thank you for helping! And @revisualize I
CamperBot
@camperbot
May 06 2017 04:11 UTC
rilesmc13 sends brownie points to @kickkick479 and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 344 | @kickkick479 |http://www.freecodecamp.com/kickkick479
:star2: 3901 | @revisualize |http://www.freecodecamp.com/revisualize
albakali
@albakali
May 06 2017 04:11 UTC
Hi every one I need help FCC=>Profile Lookup
Riley
@rilesmc13
May 06 2017 04:11 UTC
@revisualize I'm looking into variables vs strings further
kickkick479
@kickkick479
May 06 2017 04:11 UTC
@rilesmc13 Can you share current code?
heroiczero
@heroiczero
May 06 2017 04:12 UTC
@albakali lets see your code?
albakali
@albakali
May 06 2017 04:12 UTC

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(i=0;i<contacts.length;i++){
for(g=0;g<contacts[i].length;g++){

if(contacts.firstName===firstName && contacts.hasOwnProperty(prop)===true){

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

else{
return "No such property";
}
}
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

JMehrnaz92
@JMehrnaz92
May 06 2017 04:12 UTC
@kickkick479 Make Unique Objects by Passing Parameters to our Constructor
error: this is undefined
Manny
@Alloffices
May 06 2017 04:12 UTC
@revisualize I added else return false but still only true pass
albakali
@albakali
May 06 2017 04:12 UTC
I use both with for loops and with out it
kickkick479
@kickkick479
May 06 2017 04:12 UTC
@JMehrnaz92 THX
CamperBot
@camperbot
May 06 2017 04:12 UTC
kickkick479 sends brownie points to @jmehrnaz92 :sparkles: :thumbsup: :sparkles:
:warning: @jmehrnaz92's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Riley
@rilesmc13
May 06 2017 04:12 UTC
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "a":
answer = "apple";
break;
case "b":
answer = "bird";
break;
case "c":
answer = "cat";
break;
default:
answer = "stuff";
}
// Only change code above this line
return answer;
}
// Change this value to test
switchOfStuff(a);
albakali
@albakali
May 06 2017 04:13 UTC
but didnt work
with loop and with out loops
also in if else
kickkick479
@kickkick479
May 06 2017 04:14 UTC
@JMehrnaz92 AS the instruction tells, you can make a new object like this var myCar = new Car(6, 3, 1);.
U missed new :smile:
albakali
@albakali
May 06 2017 04:14 UTC
I use every idea in my head
kickkick479
@kickkick479
May 06 2017 04:15 UTC
@rilesmc13 Cuz a is not defined in switchOfStuff(a);
JMehrnaz92
@JMehrnaz92
May 06 2017 04:15 UTC
@kickkick479 thanks a lot..too simple;)
Riley
@rilesmc13
May 06 2017 04:16 UTC
@kickkick479 yessssssss you got me haha I replaced it with (1) and it worked... thank you sooo much for your help!
CamperBot
@camperbot
May 06 2017 04:16 UTC
rilesmc13 sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:warning: rilesmc13 already gave kickkick479 points
albakali
@albakali
May 06 2017 04:17 UTC
Any one can help???!!!
kickkick479
@kickkick479
May 06 2017 04:17 UTC
@albakali I think single loop is enough. And remember contacts is an object. So contacts.firstName is wrong. Write contacts[i].firstName
@rilesmc13 u r welcome :wink:
Milad Mikeal
@miladmikeal
May 06 2017 04:18 UTC
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function checkFalsy(arr) {
    for (var i = 0; i < arr.length; i++) {
      if (arr[i] != false && arr[i] != null && arr[i] != 0 && arr[i] != "" && arr[i] != undefined && arr[i] != NaN) {
        return arr[i];
      }
    }
  }
  return arr.filter(checkFalsy);
}

bouncer([false, null, 0, NaN, undefined, ""]);
Can someone help me with my code?
Working on Falsy Bouncer
kickkick479
@kickkick479
May 06 2017 04:21 UTC

@albakali Also, hasOwnProperty returns boolean value, so no need === or !== in the if-conditions.

Beside,

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

in the loop is wrong.
When first person does not have the passed firstName, the function ends without checking all contacts.
Erase that and insert return "No such contact"; after end of the loop.

Mauro
@mauronml
May 06 2017 04:27 UTC
@noilddude I believe false, null 0 ”” and NaN will be considered as false values by arr.filter, meaning if you simply return that element it should not add it to the fildered array
albakali
@albakali
May 06 2017 04:27 UTC
how can i erase it and i have else after it
?
kickkick479
@kickkick479
May 06 2017 04:27 UTC
@noilddude filter() works as loop. All elements of the array are passed into the checkFalsy method, so you do not need for-loop in the checkFalsy method. Look more into MDN.
albakali
@albakali
May 06 2017 04:29 UTC

this is new cooooooode
check it also I will give you the question

//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(i=0;i<contacts.length;i++){

if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true){

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

}

else{
return "No such property";
}
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

We have an array of objects representing different people in our contacts lists.

A lookUpProfile function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

kickkick479
@kickkick479
May 06 2017 04:29 UTC
@noilddude Strictly speaking, function checkFalsy(arr) { is wrong. That recieves each element of the array. It's confusing, so I recommend replace it with function checkFalsy(val) { or function checkFalsy(element) {
Milad Mikeal
@miladmikeal
May 06 2017 04:30 UTC
@mauronml @kickkick479 Got it! Thank you!
CamperBot
@camperbot
May 06 2017 04:30 UTC
noilddude sends brownie points to @mauronml and @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @mauronml |http://www.freecodecamp.com/mauronml
:cookie: 345 | @kickkick479 |http://www.freecodecamp.com/kickkick479
kickkick479
@kickkick479
May 06 2017 04:32 UTC
@albakali Your description is right, but your code is NOT written like that.
return contacts.prop; need to be return contacts[i][prop];
Cuz you cannot use dot notation with variable. Maybe previous challenge tested that to you.
@albakali As i said, you should avoid returning "no such contact" in the loop. Cuz it happens when first person does not have the passed firstName.
albakali
@albakali
May 06 2017 04:39 UTC
i try but didnt work
!!!
kickkick479
@kickkick479
May 06 2017 04:39 UTC
@albakali How's current cod? Oh, what
albakali
@albakali
May 06 2017 04:40 UTC
how can I avoid returning and it in the question?
Mohamed Derhalli
@derhallim
May 06 2017 04:40 UTC
hello all, anyone familiar with React?
kickkick479
@kickkick479
May 06 2017 04:41 UTC
@albakali Return that outside the loop.
@derhallim Hi :wave: Not yet familiar with React. Sorry.
Mohamed Derhalli
@derhallim
May 06 2017 04:41 UTC
:v: no worries man
albakali
@albakali
May 06 2017 04:43 UTC

I have other loop next it????!!!!

for(i=0;i<contacts.length;i++){
if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true){
return contacts[i][prop];
} else if(contacts[i].firstName!==firstName){
return "No such contact";
}
else{
return "No such property";
}
}

I have other loop next it????!!!!

this give me wrong

for(i=0;i<contacts.length;i++){
if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true){
return contacts[i][prop];
} else if(contacts[i].firstName!==firstName){

}
return "No such contact";
else{
return "No such property";
}
}

kickkick479
@kickkick479
May 06 2017 04:44 UTC
@albakali
  • Move return "No such contact"; to outside of the loop
  • return "No such property"; should appear when there is the person who have the passed firstname and that person does NOT have the passed property.
albakali
@albakali
May 06 2017 04:44 UTC
@kickkick479 like you see
there is wrong if I but it out side
kickkick479
@kickkick479
May 06 2017 04:45 UTC
@albakali Wait, un-readable it is, give me sec. If you put indent properly, it would be very helpful.
albakali
@albakali
May 06 2017 04:48 UTC

@kickkick479
You mean like this
for(i=0;i<contacts.length;i++){

if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true){
return contacts[i][prop];
} else if(contacts[i].firstName!==firstName){

}else{
return "No such property";
}
}

return "No such contact";
????
kickkick479
@kickkick479
May 06 2017 04:49 UTC
@albakali There a few things to improve, but it looks to pass the challenge.
albakali
@albakali
May 06 2017 04:50 UTC
@kickkick479 can you give me this few things to improve
Vicky Lai
@vickylai
May 06 2017 04:54 UTC
2/5 yall!
albakali
@albakali
May 06 2017 04:54 UTC
I want understand not only pass
kickkick479
@kickkick479
May 06 2017 04:54 UTC

@albakali I prefer this

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

It is a matter of preference.
hasOwnProperty() returns boolean value, so we do not need compare that.
&& if-condition is same as double if. I prefer double this time.
Besides, I notice now that, we shoud avoid global variable in for block like for(i=0;i<contacts.length;i++){ , instead of that, we should use var i = 0

albakali
@albakali
May 06 2017 04:58 UTC
@kickkick479 thank you alot for this help you are great.
CamperBot
@camperbot
May 06 2017 04:58 UTC
albakali sends brownie points to @kickkick479 :sparkles: :thumbsup: :sparkles:
:cookie: 346 | @kickkick479 |http://www.freecodecamp.com/kickkick479
Peter Kay
@deuscode
May 06 2017 05:15 UTC
Hi campers, just finished my wikipedia viewer
grfraser
@grfraser
May 06 2017 05:21 UTC
@deuscode thats awesome man!
Alexandre Conrady
@Aberoom
May 06 2017 05:22 UTC
@deuscode looks good. Random button worked too. Feels fast.
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:22 UTC
Hi all, I am working on the wiki Look up and am getting an error. No 'Access-Control-Allow-Origin' header is present on the requested resource. How do I change my headers in a getJSON request ? or do I do a POST request ?
grfraser
@grfraser
May 06 2017 05:22 UTC
@deuscode is that a project we do? i am only like level 175 or so rn
Peter Kay
@deuscode
May 06 2017 05:22 UTC
@grfraser @Aberoom thanks!
CamperBot
@camperbot
May 06 2017 05:22 UTC
deuscode sends brownie points to @grfraser and @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @aberoom |http://www.freecodecamp.com/aberoom
:cookie: 177 | @grfraser |http://www.freecodecamp.com/grfraser
grfraser
@grfraser
May 06 2017 05:22 UTC
thank you @deuscode
CamperBot
@camperbot
May 06 2017 05:22 UTC
grfraser sends brownie points to @deuscode :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @deuscode |http://www.freecodecamp.com/deuscode
Peter Kay
@deuscode
May 06 2017 05:23 UTC
@grfraser yes, it is part of the intermediate front-end project
@Boolean-Operator hey Mark, maybe I can help I just finished mine. Can you post your AJAX call?
Josh Bivens
@joshbivens
May 06 2017 05:24 UTC
Is anyone here familiar with Vue? I have a quick question.
Alexandre Conrady
@Aberoom
May 06 2017 05:26 UTC
@joshbivens Nope, had to look it up just now.
Josh Bivens
@joshbivens
May 06 2017 05:28 UTC
@Aberoom You had to look up Vue?
Alexandre Conrady
@Aberoom
May 06 2017 05:29 UTC
@joshbivens yep hadn't heard of it til now.
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:29 UTC

@deuscode ```
$(document).ready(function() {
function getResults() {
link =
"https://en.wikipedia.org/w/api.php?action=query&titles=dragonfly&format=json";

$.getJSON(link, function(data) {
  console.log(data);
});

}
getResults();
});
```

Josh Bivens
@joshbivens
May 06 2017 05:29 UTC
@Aberoom It's a great js framework. A lot friendlier and easier to use than React.
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:31 UTC
@deuscode I copied my weather app get request, figured it would work. Now I have read some much stuff on CORS , I have confused myself.
Alexandre Conrady
@Aberoom
May 06 2017 05:32 UTC
@joshbivens Yeah seeing a lot of opinions going both ways on forums. I'm gonna have to mull this over at some point soon.
Juan David Corrales
@jdcorrales27
May 06 2017 05:32 UTC

Hello, i'm stoke in the challenge Comparisons with the Logical Or Operator of Javascript. My code is
```
function testLogicalOr(val) {
// Only change code below this line

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

// Only change code above this line

return "Inside";
}

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

Peter Kay
@deuscode
May 06 2017 05:32 UTC
@Boolean-Operator are you doing an AJAX call?
Juan David Corrales
@jdcorrales27
May 06 2017 05:32 UTC
Hello, i'm stoke in the challenge Comparisons with the Logical Or Operator of Javascript. My code is
function testLogicalOr(val) {
  // Only change code below this line

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

  // Only change code above this line

  return "Inside";
}

// Change this value to test
testLogicalOr(15);
rugano
@rugano
May 06 2017 05:32 UTC

function rot13(str) { // LBH QVQ VG!
  var newArr = [];
  var plus13Arr = [];
  var minus13Arr = [];

    var decoded = "";

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


    if(newArr[i] === A-M && A-M === 65-77){
      plus13Arr.push(newArr[i]);

    }else if(minus13Arr === N-Z && N-Z === 78-90){
      minus13Arr.push(newArr[i]-13);

    }else{
      newArr.push(character);

  }
  decoded += Str.fromCharCode(minus13Arr[i]);  

  }





  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
how do i correct this code?
Peter Kay
@deuscode
May 06 2017 05:33 UTC
@Boolean-Operator instead of doing a getjson method, It's easier to just do an $.ajax
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:33 UTC
@deuscode I thought the jQuery '$.getJSON' was an AJAX call
Looks like its time to do some more reading on AJAX calls
Alexandre Conrady
@Aberoom
May 06 2017 05:35 UTC
@rugano you're getting there, but let's say you get the charCode for 'A', say, 35 or something, and subtract 13. You get 22. This will return ´ or some other symbol, not the letter you want.
Juan David Corrales
@jdcorrales27
May 06 2017 05:35 UTC

Hello, i'm stoke in the challenge Comparisons with the Logical Or Operator of Javascript. My code is

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

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

  // Only change code above this line

  return "Inside";
}

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

dont return inside

Peter Kay
@deuscode
May 06 2017 05:36 UTC
@Boolean-Operator well $.ajax is shorthand
or I'm sorry $.getJson is shorthand
but I think you're having issues wit hthe datatype
you can specify a datatype with $.ajax
Juan David Corrales
@jdcorrales27
May 06 2017 05:37 UTC
Nobody helps me
:*
Peter Kay
@deuscode
May 06 2017 05:37 UTC
new updates to browsers limit json calls
Juan David Corrales
@jdcorrales27
May 06 2017 05:37 UTC
:c
rugano
@rugano
May 06 2017 05:38 UTC
@Aberoom ok,so how should i correct that?
Juan David Corrales
@jdcorrales27
May 06 2017 05:38 UTC
>
:C
Peter Kay
@deuscode
May 06 2017 05:38 UTC
@jdcorrales27 you don't have to spam, we're just helping people in order
Alexandre Conrady
@Aberoom
May 06 2017 05:38 UTC
@jdcorrales27 you've got one comparison that is incorrect
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:38 UTC
@deuscode Not much in the FCC section prior on AJAX. Any recommendations on resources and examples ?
Alexandre Conrady
@Aberoom
May 06 2017 05:39 UTC
@jdcorrales27 you want your val to be outside 10 and 20, so everything between 10 - 20 !== val. in order for that to happen you gotta change one of your ">" or "<"
Peter Kay
@deuscode
May 06 2017 05:40 UTC
@Boolean-Operator $.ajax({ url: https://en.wikipedia.org/w/api.php?action=opensearch&search=' + userInput + "&format=json&callback=?", dataType: 'json', type: 'GET', success: function (data) {
Nick Forlivio
@whackdev
May 06 2017 05:40 UTC
really stuck on the seek and destroy challenge with filter and arguments, any ideas?

function destroyer(arr) {

  function tester(val) {
    return val != arguments[1] || arguments[2];

  }
  var newArr= arr.filter(tester);

  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:40 UTC
@deuscode so instead of using getJSON use $.ajax ?
Peter Kay
@deuscode
May 06 2017 05:41 UTC
@Boolean-Operator you can use something like this
$.ajax({
            url: 'https://en.wikipedia.org/w/api.php?action=opensearch&search=' + userInput +
            "&format=json&callback=?",
            async: false,
            dataType: 'json',
            type: 'GET',
            success: function (data) {
Juan David Corrales
@jdcorrales27
May 06 2017 05:41 UTC
thanks muchas gracias y perdón por el spam @deuscode @Aberoom
CamperBot
@camperbot
May 06 2017 05:41 UTC
jdcorrales27 sends brownie points to @deuscode and @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @aberoom |http://www.freecodecamp.com/aberoom
:cookie: 276 | @deuscode |http://www.freecodecamp.com/deuscode
Ogundele Olumide
@Lumexralph
May 06 2017 05:42 UTC
@whackdev checking the presence of the remaining values in the first argument with indexOf ca help
Peter Kay
@deuscode
May 06 2017 05:42 UTC
@Boolean-Operator http://api.jquery.com/jquery.ajax/ you can read more here
rugano
@rugano
May 06 2017 05:42 UTC
@Aberoom how do i correct this mess?
Peter Kay
@deuscode
May 06 2017 05:42 UTC
@Boolean-Operator obviously after the success: function you would put in your code to populate what ever element with the results
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:43 UTC
@deuscode Thanks. I really appreciate all the help. I have seen this before format before. I see what you mean about 'shorthand'. I will read the info from the link you sent.
CamperBot
@camperbot
May 06 2017 05:43 UTC
boolean-operator sends brownie points to @deuscode :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @deuscode |http://www.freecodecamp.com/deuscode
rugano
@rugano
May 06 2017 05:43 UTC
@Lumexralph hi,have an idea on how to correct my Caesars cipher?
Peter Kay
@deuscode
May 06 2017 05:44 UTC
@Boolean-Operator hey no problem!
Alexandre Conrady
@Aberoom
May 06 2017 05:45 UTC
@rugano Sorry Ill get to you in a sec, at work :)
rugano
@rugano
May 06 2017 05:45 UTC
@Aberoom ok
Nick Forlivio
@whackdev
May 06 2017 05:47 UTC
@Lumexralph I'll try that thanks!
CamperBot
@camperbot
May 06 2017 05:47 UTC
whackdev sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1646 | @lumexralph |http://www.freecodecamp.com/lumexralph
Nic
@descriptionboxbelow
May 06 2017 05:49 UTC

Hey guys, anyone seeing something wrong with this piece of code?:

// 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("house");

I am working on « Testing Objects with properties ». The console does return the expected result (« Not found »), yet I can’t get it to pass the exercise.

Alexandre Conrady
@Aberoom
May 06 2017 05:50 UTC
@rugano You know the range of the charCodes that return the values you want? If your charCode - 13 returns a value below 65 I think, it won't return a symbol. So let's take 70, and let's assume the range is 65 to 92 (im not sure anymore but I think that's correct). 70 should return 85 based on the rot13.
@rugano now how would you get that to happen mathematically, and how can you translate that math into code, while pushing the correct values in order into an array during your loop.
@rugano once you have the correct values in the correct order it will be easy to make a loop to transform that array of numbers into a string of characters.
rugano
@rugano
May 06 2017 05:52 UTC
@Aberoom ok,when i run the code it says: A is not defined,how should i correct my range?
Alexandre Conrady
@Aberoom
May 06 2017 05:52 UTC
@rugano ´´´
Prateek Dabas
@dprateek11
May 06 2017 05:53 UTC
blob
Ogundele Olumide
@Lumexralph
May 06 2017 05:54 UTC
@descriptionboxbelow should it be Not found or Not Found ?
Prateek Dabas
@dprateek11
May 06 2017 05:54 UTC
i am stuck at this...how to do this??
rugano
@rugano
May 06 2017 05:54 UTC
@Aberoom so i should have the charCode instead of letters?
Ogundele Olumide
@Lumexralph
May 06 2017 05:54 UTC
@rugano think @Aberoom is already helping out
Alexandre Conrady
@Aberoom
May 06 2017 05:54 UTC

@rugano my bad

if(newArr[i] === A-M && A-M === 65-77){
      plus13Arr.push(newArr[i]);

    }else if(minus13Arr === N-Z && N-Z === 78-90){
      minus13Arr.push(newArr[i]-13);

can't enter characters like that in an if() statement unless you've assigned them as a variable. You'll have to remove the A-M and N-Z comparisons and just trust in the CharCode.

Ogundele Olumide
@Lumexralph
May 06 2017 05:56 UTC
@dprateek11 FirstLinenewline backslashSecondLinebackslash carriage-return ThirdLine
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:57 UTC
@deuscode Just wanted to say thanks again. I read some of the jQuery API documentation and then did a quick search and found an article on SitePoint. It provided an alphabetized list of all the option parameters and datatype is one of the options I can specify. headers was also listed. I should have this up and running real soon.
CamperBot
@camperbot
May 06 2017 05:57 UTC
:warning: boolean-operator already gave deuscode points
boolean-operator sends brownie points to @deuscode :sparkles: :thumbsup: :sparkles:
Mark T. Graybill
@Boolean-Operator
May 06 2017 05:58 UTC
Peter Kay
@deuscode
May 06 2017 05:59 UTC
@Boolean-Operator awesome, I'm about to hit the hay, but send me a message with your completed project and I'll be able to see it the next time I log in. cheers!
Nick Forlivio
@whackdev
May 06 2017 05:59 UTC
@Lumexralph that fixed it thanks!!
function destroyer(arr) {

  var params = arr.slice.call(arguments);  // Call function arguments
  var newArr = params[0]; // Get array to filter
  var args = [];
  // Create array of arguments to test values
  for (var i=1; i < params.length; i++) {
    args.push(params[i]);
  }

  function checkArr(element) {
    if (args.indexOf(element) === -1){
      return element;
    }
  }

  return newArr.filter(checkArr);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
CamperBot
@camperbot
May 06 2017 05:59 UTC
whackdev sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: whackdev already gave lumexralph points
Ogundele Olumide
@Lumexralph
May 06 2017 06:00 UTC
@dprateek11 you need to escape those characters newline \n backslash \\ carriage-return \r, make sure to eliminate any space in between your string
@whackdev :+1:
Alexandre Conrady
@Aberoom
May 06 2017 06:00 UTC
@rugano I checked and the codes do go up to 92. so basically you have to check, is str.charCodeAt(i) <= 65, is str.charCodeAt(i) < 78, and if not either of those just apply rot13 directly to the charCode.
Prateek Dabas
@dprateek11
May 06 2017 06:00 UTC
thanks @Lumexralph
CamperBot
@camperbot
May 06 2017 06:00 UTC
dprateek11 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1647 | @lumexralph |http://www.freecodecamp.com/lumexralph
Nic
@descriptionboxbelow
May 06 2017 06:01 UTC
thanks ^ 100 @Lumexralph aka Inspector Case :+1: :shipit:
CamperBot
@camperbot
May 06 2017 06:01 UTC
descriptionboxbelow sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1648 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 06 2017 06:02 UTC
@descriptionboxbelow :laughing:
Nguyen Hoang
@honnhien12h
May 06 2017 06:04 UTC
Explain me this Example :
CamperBot
@camperbot
May 06 2017 06:04 UTC

freeCodeCamp Wiki:

:point_right: The freeCodeCamp wiki can be found on our forum.
Please follow the link and search there.
Nguyen Hoang
@honnhien12h
May 06 2017 06:04 UTC
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}
ourTotal = ???
Ogundele Olumide
@Lumexralph
May 06 2017 06:05 UTC
@honnhien12h what seems to be the challenge?
Nguyen Hoang
@honnhien12h
May 06 2017 06:06 UTC
@Lumexralph i don't understand this example
The end ourTotal = how much
Alexandre Conrady
@Aberoom
May 06 2017 06:07 UTC
@honnhien12h on every iteration of the loop, it is taking the current value of ourTotal, and adding it to the indexed vallue in the ourArr array.
Ogundele Olumide
@Lumexralph
May 06 2017 06:08 UTC
@honnhien12h the sum of all the elements in the ourArr array using a for loop to iterate through the elements and using ourTotal variable to hold the product of the sum of the elements per iteration
WSCQSDADADAD
@WSCQSDADADAD
May 06 2017 06:09 UTC
blob
blob
Alexandre Conrady
@Aberoom
May 06 2017 06:10 UTC
ourtotal += ourArr[i] can be translated to ourTotal = ourTotal + ourArr[i], where i is the index of the array (for i = 0 ourArr[i] == 9, the first position in the array)
Nguyen Hoang
@honnhien12h
May 06 2017 06:10 UTC
@Aberoom "ourArr.length" for what?
Alexandre Conrady
@Aberoom
May 06 2017 06:11 UTC
@honnhien12h so you don't go past the last value of the ourArr array and start returning undefined, or creating an infinite loop.
Nguyen Hoang
@honnhien12h
May 06 2017 06:12 UTC
@Aberoom why we can not get i<12 ?
Alexandre Conrady
@Aberoom
May 06 2017 06:14 UTC
@honnhien12h 4 indexes in that array, going from 0, 1, 2, 3. in this case, ourArr.length = 4. so var i will loop from 0-3, and on each loop ourArr[i] = a stored value in the array. if you went and said i < 12 instead or ourArr.length, i would loop from 0-12, but ourArr[4-12] would return undefined because there aren't any stored values at those indexes, which would screw up your function.
Mario A. Carlos
@MarioC3
May 06 2017 06:18 UTC
ok What the hell am I doing wrong?
function multiply(a, b){
  return a * b;
}

multiply(2,3);
The code should exceute properly right?
execute*
Ogundele Olumide
@Lumexralph
May 06 2017 06:18 UTC
@MarioC3 nothing
Alexandre Conrady
@Aberoom
May 06 2017 06:18 UTC
@honnhien12h the .length method is great in for loop conditions, because now even if the array is altered by the user or yourself, the for loop will still access every indexed value.
Ogundele Olumide
@Lumexralph
May 06 2017 06:19 UTC
@MarioC3 it should
Ming
@MingHill
May 06 2017 06:19 UTC
can someone help me
Mario A. Carlos
@MarioC3
May 06 2017 06:19 UTC
Stupid CodeWars bug....
Nguyen Hoang
@honnhien12h
May 06 2017 06:19 UTC
@Aberoom okay thank you Alexandre Conrady
CamperBot
@camperbot
May 06 2017 06:19 UTC
honnhien12h sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @aberoom |http://www.freecodecamp.com/aberoom
Mario A. Carlos
@MarioC3
May 06 2017 06:19 UTC
I refresh it and put exactly the same and it accepted it
Alexandre Conrady
@Aberoom
May 06 2017 06:19 UTC
@MarioC3 yeah doesn't make sense.
Ogundele Olumide
@Lumexralph
May 06 2017 06:20 UTC
@MarioC3 i really don't like codewars when it comes to testing your code, it can stress you out
Mario A. Carlos
@MarioC3
May 06 2017 06:20 UTC
It's the initiation
lol
Ming
@MingHill
May 06 2017 06:20 UTC
does anyone know the make object properties private one
Ogundele Olumide
@Lumexralph
May 06 2017 06:21 UTC
@MarioC3 they have good challenges but annoying with their instructions and expected results
Mario A. Carlos
@MarioC3
May 06 2017 06:21 UTC
I need to get good at Algorithms....
Ogundele Olumide
@Lumexralph
May 06 2017 06:21 UTC
@MingHill what have you done?
Mario A. Carlos
@MarioC3
May 06 2017 06:21 UTC
Basic Algorithms is kicking my but so I'm going to practice in codewars and Hacker Rank
Ming
@MingHill
May 06 2017 06:21 UTC

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {
var gear = 0;
  // Only change code below this line.

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

var myCar = new Car();

var myBike = new Bike();
Ogundele Olumide
@Lumexralph
May 06 2017 06:21 UTC
@MarioC3 it's still a good resource
@MingHill this.Getgear=f should be getGear
Ming
@MingHill
May 06 2017 06:22 UTC
ok
it still doesnt work though
Alexandre Conrady
@Aberoom
May 06 2017 06:23 UTC
@MingHill looks good to me, so maybe the var gear = 0 should be below the comment line (don't know if that can fail a test).
Ogundele Olumide
@Lumexralph
May 06 2017 06:23 UTC
@MingHill show your code
rugano
@rugano
May 06 2017 06:24 UTC

function rot13(str) { // LBH QVQ VG!
  var newArr = [];
  var plus13Arr = [];
  var minus13Arr = [];

    var decoded = "";

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


    if(plus13Arr[i] == 65-77){
      plus13Arr.push(newArr[i]);

    }else if(minus13Arr == 78-90){
      minus13Arr.push(newArr[i]-13);

    }else{
      newArr.push([i]);

  }
  decoded += str.fromCharCode(plus13Arr[i]);  

  }





  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
still stuck
Ming
@MingHill
May 06 2017 06:24 UTC

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.
  var gear = 0;
this.getgear=function(){
  return gear;
};
  this.setGear=function(x){
    gear = x;
  };
};

var myCar = new Car();

var myBike = new Bike();
Ogundele Olumide
@Lumexralph
May 06 2017 06:25 UTC
@MingHill getGear not getgear
Ming
@MingHill
May 06 2017 06:25 UTC
jeez i feel dumb
thanks
Ogundele Olumide
@Lumexralph
May 06 2017 06:26 UTC
@MingHill :+1:
Alexandre Conrady
@Aberoom
May 06 2017 06:28 UTC
@rugano You're getting closer, however 65-77 is not a range, but just 12. if you want to create a range your values can have, you have to use comparisons.
rugano
@rugano
May 06 2017 06:28 UTC
Someone can write comments into my code so i correct it
@Aberoom ok,can you show me with an example how to write a range?
Alexandre Conrady
@Aberoom
May 06 2017 06:30 UTC
@rugano Yeah sure I can show you. You remember the >,<, <==, >==, and the logical operators like && || right?
Baderfahad
@Baderfahad
May 06 2017 06:31 UTC
hey guys I have a question about Factorialize a Number what does n! or with any number mean ?
rugano
@rugano
May 06 2017 06:32 UTC
@Aberoom yes
Alexandre Conrady
@Aberoom
May 06 2017 06:34 UTC
@rugano well you want your if statement to compare the charCode value to "fence" values, in this case 65 and 77. So if the charCode >= 65, and(&&) the charCode<=77, then you want to execute a special bit of code. All of this pieced together looks like if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77) { bit of code to execute}
@Baderfahad whenever the ! is after a number, the math it wants you to execute is nn-1n-2...1
iso
@iso1048
May 06 2017 06:36 UTC
@Baderfahad 6! is 6 factorial. 6! = 6 x 5 x 4 x 3 x 2 x 1. so n! is n x (n-1) x (n-2)....x 1
Alexandre Conrady
@Aberoom
May 06 2017 06:36 UTC
@Baderfahad man that didn't work.
n x n-1 x n-2 x ... x 1. aka
Baderfahad
@Baderfahad
May 06 2017 06:39 UTC
ok thank you :+1:
youUnion619
@youUnion619
May 06 2017 06:43 UTC
hi can anyone help me with this "Word Blanks" i didn't understand what should be done
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:44 UTC
@youUnion619 Hello.
youUnion619
@youUnion619
May 06 2017 06:44 UTC
hi
Alexandre Conrady
@Aberoom
May 06 2017 06:44 UTC
@youUnion619 you want to return a variable result as a sentence containing the arguments passed in the function.
will
@uhohtrouble
May 06 2017 06:45 UTC
hello all, does anyone remember the stand in line tutorial?
ahmad
@woat
May 06 2017 06:45 UTC
no
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:45 UTC
@youUnion619 A big dog ran quickly. <— return this, with the arguments passed in!
ahmad
@woat
May 06 2017 06:45 UTC
@uhohtrouble rephrase it
Ogundele Olumide
@Lumexralph
May 06 2017 06:45 UTC
@uhohtrouble yes
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:45 UTC
@uhohtrouble Yes.
Markus Kiili
@Masd925
May 06 2017 06:46 UTC
@Lumexralph Morning.
will
@uhohtrouble
May 06 2017 06:46 UTC
So you're trying to take the last number in the array and add it to the front, correct?
youUnion619
@youUnion619
May 06 2017 06:46 UTC
@ivancsicsmarkus how can i do this?
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:46 UTC
@uhohtrouble You should use push, and shift.
will
@uhohtrouble
May 06 2017 06:46 UTC
not pop and unshift?
Ogundele Olumide
@Lumexralph
May 06 2017 06:47 UTC
@youUnion619 you need to make a string(sentence) by concatenating the strings held by the 4 parameters of your function and remember to seaparate them with spaces " " you can add strings if you want, then assign it to result
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:47 UTC
@uhohtrouble Not really. You have to remove the first element...
Ogundele Olumide
@Lumexralph
May 06 2017 06:47 UTC
@Masd925 Morning, slept well?
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:47 UTC
@youUnion619 You can use arguments like variables.
will
@uhohtrouble
May 06 2017 06:47 UTC
@ivancsicsmarkus alright, thanks
CamperBot
@camperbot
May 06 2017 06:47 UTC
uhohtrouble sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 420 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Markus Kiili
@Masd925
May 06 2017 06:48 UTC
@Lumexralph Always. How was your night?
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:48 UTC

@youUnion619 You can add strings like this:

‘A ‘ +myVariable1+’ ‘+myVariable2+’.’

...

Ogundele Olumide
@Lumexralph
May 06 2017 06:49 UTC
@uhohtrouble you need to add item to the end of arr that's why you need push, then you need to remove the first element in arr array which you also have to return in your function, that's why you need shift
Markus Ivancsics
@ivancsicsmarkus
May 06 2017 06:49 UTC
@youUnion619 You should add the arguments. Like this:
"A "+myAdjective+" "+myNoun+" "+myVerb+" "+myAdverb;
Ogundele Olumide
@Lumexralph
May 06 2017 06:49 UTC
@Masd925 great though didn't want to stand from the bed.... going for practice today ?
Markus Kiili
@Masd925
May 06 2017 06:50 UTC
@Lumexralph Gotta watch kids today. Maybe something in the evening.
will
@uhohtrouble
May 06 2017 06:50 UTC
@Lumexralph thanks
CamperBot
@camperbot
May 06 2017 06:50 UTC
uhohtrouble sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1649 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
May 06 2017 06:51 UTC
@Masd925 hmmm... daddy! have fun
Markus Kiili
@Masd925
May 06 2017 06:51 UTC
@Lumexralph I read through my hobby code I have been writing with java for a few years. It took 2,5 months to read through it with thought.
Gonçalo Pedro
@gpedro34
May 06 2017 06:51 UTC
can someone help me with this? I don't really get it... o.O
Ogundele Olumide
@Lumexralph
May 06 2017 06:51 UTC
@Masd925 :laughing: why? commented it ?
Markus Kiili
@Masd925
May 06 2017 06:52 UTC
@Lumexralph There are some bugs in it. Had to read it and now maybe some testing ahead.
CraZy biRd
@Preeetrockz
May 06 2017 06:52 UTC
hey guys !! wassup ? :)
Baderfahad
@Baderfahad
May 06 2017 06:52 UTC
so what can we do it Factorize number I still did not figure this out :/ !
Ogundele Olumide
@Lumexralph
May 06 2017 06:53 UTC
@Masd925 i can imagine..... even the calculator project i'm working on requires some time to zip in anytime I decide to work on it
Markus Kiili
@Masd925
May 06 2017 06:53 UTC
@Lumexralph Very hard to test own code.
Ogundele Olumide
@Lumexralph
May 06 2017 06:54 UTC
@Baderfahad tried anything?
will
@uhohtrouble
May 06 2017 06:54 UTC

@Lumexralph
arr.shift(item);
arr.push(item);

like this?

Baderfahad
@Baderfahad
May 06 2017 06:54 UTC
@Lumexralph I tried with if statment but it did not work haha
Ogundele Olumide
@Lumexralph
May 06 2017 06:54 UTC
@Masd925 i think i'll agree with that
jhcshakil
@jhcshakil
May 06 2017 06:54 UTC

function convertToF(celsius) {

var celcius;
var fahrenhite;
// Only change code below this line

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

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

Ogundele Olumide
@Lumexralph
May 06 2017 06:54 UTC
@uhohtrouble push before shift
jhcshakil
@jhcshakil
May 06 2017 06:54 UTC
whtas the problem with this code
Alexandre Conrady
@Aberoom
May 06 2017 06:55 UTC
@Baderfahad look up the do while loops or just while loops.
jhcshakil
@jhcshakil
May 06 2017 06:55 UTC

what's

will
@uhohtrouble
May 06 2017 06:55 UTC
@Lumexralph alright, thank you
CamperBot
@camperbot
May 06 2017 06:55 UTC
uhohtrouble sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: uhohtrouble already gave lumexralph points
Alexandre Conrady
@Aberoom
May 06 2017 06:55 UTC
@jhcshakil you gotta correct your spelling of celsius, maybe it will work then.
jhcshakil
@jhcshakil
May 06 2017 06:55 UTC

function convertToF(celsius) {

var celcius;
var fahrenhite;
// Only change code below this line

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

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

Baderfahad
@Baderfahad
May 06 2017 06:55 UTC
@Aberoom ahhh I though about that :) well ok I will figure this out :) !
Ogundele Olumide
@Lumexralph
May 06 2017 06:55 UTC
@jhcshakil var fahrenheit=(celcius*(9/5))+32; that's the problem, change celcius to the celsius parameter, remove the var there, it's already declared
Baderfahad
@Baderfahad
May 06 2017 06:56 UTC
@Aberoom thank you :+1:
CamperBot
@camperbot
May 06 2017 06:56 UTC
baderfahad sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @aberoom |http://www.freecodecamp.com/aberoom
Gonçalo Pedro
@gpedro34
May 06 2017 06:57 UTC
@jhcshakil what @Lumexralph said plus erase the two first lines where you declare both vars ;D
Ogundele Olumide
@Lumexralph
May 06 2017 06:57 UTC
@Baderfahad you need to do something like this x * (x -1) * (x -2)..... you'll need a loop for that, if you understand recursion you can use it too
Gonçalo Pedro
@gpedro34
May 06 2017 06:58 UTC
can someone explain to me how the smallest common multiple of [1,5] have to be 60? it is supposed to be 5 no?
rugano
@rugano
May 06 2017 06:58 UTC

function rot13(str) { // LBH QVQ VG!
  var newArr = [];
  var plus13Arr = [];
  var minus13Arr = [];

    var decoded = "";

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


    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
    plus13Arr.push(newArr[i] + 13);

    }else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
      minus13Arr.push(newArr[i]-13);

    }else{
      newArr.push([i]);

  }
  decoded += str.fromCharCode(newArr[i]);  

  }





  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Markus Kiili
@Masd925
May 06 2017 06:58 UTC
@gpedro34 Smallest integer evenly divisible by the range 1,2,3,4,5
Alexandre Conrady
@Aberoom
May 06 2017 06:58 UTC
@gpedro34 it's the multiples of all the numbers between 1 and 5, so 1,2,3,4,5
rugano
@rugano
May 06 2017 06:59 UTC
can't figure out what to return
Gonçalo Pedro
@gpedro34
May 06 2017 07:01 UTC
@Aberoom @Masd925 what? the test result i should get it says it should be 60 but in fact the smallest multiple of [1,5] is 5 not 60, or am i wrong? it should just return the smallest common... I don't really get it
Markus Kiili
@Masd925
May 06 2017 07:01 UTC
@gpedro34 60 is the smallest integer evenly divisible by numbers 1,2,3,4,5
Gonçalo Pedro
@gpedro34
May 06 2017 07:02 UTC
oh ok i think i get it now xD thanks
Markus Kiili
@Masd925
May 06 2017 07:02 UTC
[1,5] here means range 1,2,3,4,5
Amir Saleem
@amirsaleem96
May 06 2017 07:02 UTC
Any javascript expert online?
Gonçalo Pedro
@gpedro34
May 06 2017 07:02 UTC
yeah i get it now
Markus Kiili
@Masd925
May 06 2017 07:03 UTC
@amirsaleem96 If you ask for experts you usually get no responses.
Alexandre Conrady
@Aberoom
May 06 2017 07:03 UTC
@rugano there are still some issues. if rot13 is always charCode -13, then why are you adding 13 to values between 65 and 78? lets say you get a char code of A at 65. if you add 13, you get a charCode at 78. however what you want is the car code at 79, because you want to loop from 65 to 92, and then keep going numbers until you've subtracted 13 from charCodeAt(A). do you see what I mean_
Markus Kiili
@Masd925
May 06 2017 07:03 UTC
@amirsaleem96 Just ask your question.
Amir Saleem
@amirsaleem96
May 06 2017 07:03 UTC
@Masd925
I got one now, wait for a minute , let me post it
rugano
@rugano
May 06 2017 07:04 UTC
@Aberoom how should i return my if statements?
Baderfahad
@Baderfahad
May 06 2017 07:04 UTC
@Lumexralph ok :smile:
Amir Saleem
@amirsaleem96
May 06 2017 07:05 UTC

@Masd925
There are two ways of doing the same task, one is by using a closure and another is by using a regular function

Here is the code using a regular function

function changeColor(colorName){
  document.getElementsByClassName('container')[0].style.backgroundColor = colorName;
}
document.getElementById('btn-color-one').addEventListener('click',function(){
  changeColor('crimson');
});
document.getElementById('btn-color-two').addEventListener('click',function(){
  changeColor('black');
});
document.getElementById('btn-color-three').addEventListener('click',function(){
  changeColor('teal');
});
document.getElementById('btn-color-four').addEventListener('click',function(){
  changeColor('gold');
});

And here is the code to same solution using closure,

function changeColor(colorName){
  return function(){
    document.getElementsByClassName('container')[0].style.backgroundColor = colorName;
  }
}
var crimson = changeColor('crimson');
var black = changeColor('black');
var teal = changeColor('teal');
var gold = changeColor('gold');
document.getElementById('btn-color-one').addEventListener('click',crimson);
document.getElementById('btn-color-two').addEventListener('click',black);
document.getElementById('btn-color-three').addEventListener('click',teal);
document.getElementById('btn-color-four').addEventListener('click',gold);

which one is better and why?

Alexandre Conrady
@Aberoom
May 06 2017 07:06 UTC
@rugano so let's look at the code from the beginning. You created a new array that stores all of the charCodes of the str by looping through each character and assigning it to newArr. Now you have to translate each of those char code values into the correct value to decode the cipher. Your range of char code values are 65 - 92 to include spaces and some punction probably.
@rugano so at this point, you want to loop through newArr, checking with if statements if the value you are currently looking at (newArr[i]) needs to subtracted by 13, or if it passes the minimum value (65) and needs to start back from the top at 92.
Markus Kiili
@Masd925
May 06 2017 07:08 UTC
@amirsaleem96 Second way removes some repeating code. You could remove even more I think by making a function that binds the given color change to given element (id).
rugano
@rugano
May 06 2017 07:09 UTC
@Aberoom let me correct that
Amir Saleem
@amirsaleem96
May 06 2017 07:10 UTC
@Masd925
Thanks for you suggestion
CamperBot
@camperbot
May 06 2017 07:10 UTC
amirsaleem96 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4012 | @masd925 |http://www.freecodecamp.com/masd925
Alexandre Conrady
@Aberoom
May 06 2017 07:10 UTC
@rugano what you want to return in your if statements isn't really a push into a new array, you want to assign a new value to the index you are looking at. so for example
```
if (newArr[i] < 78) {
Markus Kiili
@Masd925
May 06 2017 07:11 UTC
@amirsaleem96 You could maybe just have an array of color names and then code that gets those button elements (children of some div maybe?) and binds the events automatically.
Amir Saleem
@amirsaleem96
May 06 2017 07:12 UTC
@Masd925
Yes, there are many ways,
But here I am trying to differentiate between a function with closure and a regular function. I am learning about clousre on MDN .
@Masd925
Markus Kiili
@Masd925
May 06 2017 07:13 UTC
@amirsaleem96 ok. Closure here allows the function to remember the color it binds to.
Amir Saleem
@amirsaleem96
May 06 2017 07:13 UTC
@Masd925
Aren't we creating global variables in the second approach? Which is bad I think
Markus Kiili
@Masd925
May 06 2017 07:14 UTC
@amirsaleem96 Yes. Room to improve there.
Amir Saleem
@amirsaleem96
May 06 2017 07:16 UTC
@Masd925
Do let me know if you have a good resource on closures
Markus Kiili
@Masd925
May 06 2017 07:17 UTC
@amirsaleem96 MDN has a closure page. There are some JS books you can read free online that discuss closure too.
Amir Saleem
@amirsaleem96
May 06 2017 07:18 UTC
@Masd925
I have read Javascript the good parts and MDN page, but still I have many doubts
Vivek
@vivekmittal7
May 06 2017 07:18 UTC

function truncateString(str, num) {
  var result = "";
  if (num<3){
   return result =  str.slice(0,num)+ "...";
  }

  // Clear out that junk in your trunk
  else if (num>=3){return result = str.slice(0, num-3)+ "...";
}}

truncateString("A-tisket a-tasket A green and yellow basket", 1);
why doesn't this code work for these arguments:-
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) should return "A-tisket a-tasket A green and yellow basket".
@amirsaleem96 eloquent javascript is a good book for javascript
and it's free too.
Markus Kiili
@Masd925
May 06 2017 07:20 UTC
@amirsaleem96 Try to google some articles about closure and try to write some code that uses it.
Amir Saleem
@amirsaleem96
May 06 2017 07:20 UTC
@Masd925
okay, many thanks
CamperBot
@camperbot
May 06 2017 07:20 UTC
amirsaleem96 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: amirsaleem96 already gave masd925 points
Vivek
@vivekmittal7
May 06 2017 07:23 UTC
@Masd925 could you please see whats wrong with my code
its doing everything instruction mentioned
Alexandre Conrady
@Aberoom
May 06 2017 07:27 UTC
@vivekmittal7 I'm not catching anything, maybe try num <= 3 in your first if statement.
Jonathanwam
@Jonathanwam
May 06 2017 07:29 UTC
Hey guys, having problems with the Title Case a Sentence algorithm challenge. I know my solution is correct, cause well it shows the correct answer for each test case in the console. But it's not recognizing it's right when attempting to submit.
Vivek
@vivekmittal7
May 06 2017 07:29 UTC
@Aberoom ok
Jonathanwam
@Jonathanwam
May 06 2017 07:29 UTC

function getWord(str) {
return str[0].toUpperCase() + str.slice(1);
}

function titleCase(str) {
str = str.toLowerCase();
var arrayOfStrings = str.split(' ');
var newString = "";

for (var i = 0; i < arrayOfStrings.length; i++) {
newString += getWord(arrayOfStrings[i]);
newString += ' ';
}

return newString;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");

Markus Kiili
@Masd925
May 06 2017 07:29 UTC
@Jonathanwam Maybe you have an extra space at the end of result string?
Jonathanwam
@Jonathanwam
May 06 2017 07:29 UTC
ah my bad I don't know how to format it in this chat
rugano
@rugano
May 06 2017 07:30 UTC
@Aberoom should i return like this: str.charCodeAt(i) === 65 && str.charCodeAt(i) <= 77;
Jonathanwam
@Jonathanwam
May 06 2017 07:30 UTC
@Masd925 that would be it actually lmao
like this?
Alexandre Conrady
@Aberoom
May 06 2017 07:31 UTC
@rugano Nope.
rugano
@rugano
May 06 2017 07:31 UTC

function rot13(str) { // LBH QVQ VG!
  var newArr = [];
  var plus13Arr = [];
  var minus13Arr = [];

    var decoded = "";

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


    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
    str.charCodeAt(i) === 65 && str.charCodeAt(i) <= 77;

    }else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
      minus13Arr.push(newArr[i]-13);

    }else{
      newArr.push([i]);

  }
  decoded += str.charCodeAt([i]);  

  }





  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Markus Kiili
@Masd925
May 06 2017 07:31 UTC
@Jonathanwam You could just return newString.trim();
rugano
@rugano
May 06 2017 07:32 UTC
@Aberoom how should it be,i mean the code to execute inside {}
Alexandre Conrady
@Aberoom
May 06 2017 07:37 UTC
@rugano No you want to change the value of the charCode that you have.
so
if (newArr[i] >= 65  && newArr[i] <= 77) {
newArr[i] = (92 - (65 -(newArr[i] -13)));
$%&/(
Alexandre Conrady
@Aberoom
May 06 2017 07:42 UTC
@rugano you're going to want to tweak those fences and values to make the rot13 work, I can't remember exactly what they are, sorry xD
rugano
@rugano
May 06 2017 07:43 UTC
@Aberoom i will give it a try,thanks
CamperBot
@camperbot
May 06 2017 07:43 UTC
rugano sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @aberoom |http://www.freecodecamp.com/aberoom
Anyul Rivas
@anyulled
May 06 2017 07:43 UTC
anyone knows the regex to replace non alphanumeric characters?
Markus Kiili
@Masd925
May 06 2017 07:44 UTC
@anyulled Look at metacharacters \w and \W.
Alexandre Conrady
@Aberoom
May 06 2017 07:44 UTC
@anyulled I keep this page open when using regex, it's got a table of everything useful to know. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
Anyul Rivas
@anyulled
May 06 2017 07:47 UTC
@Masd925 thanks, but it doesn't works, I tried with \s and \S and now i'm using /[â-z]/gi
CamperBot
@camperbot
May 06 2017 07:47 UTC
anyulled sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4013 | @masd925 |http://www.freecodecamp.com/masd925
Anyul Rivas
@anyulled
May 06 2017 07:47 UTC
@Aberoom thanks, I'll take a look
kefah elhelou
@kefelhelou
May 06 2017 07:56 UTC
hello all
I need help please
I am stuck with challenge 146
Understand String Immutability
what the solution might be ??
Vivek
@vivekmittal7
May 06 2017 07:59 UTC
string immutability means once a value is assigned to a string you cant change a particular part of a string
@kefelhelou so you have to change it all if you want to make some changes
like
var str = "whats up""
str[0] = "r";
above code wont do anything
you have to write
str = "rhats up"
rugano
@rugano
May 06 2017 08:05 UTC
@Aberoom should i include this and what is its purpose ? $%&/(
Alexandre Conrady
@Aberoom
May 06 2017 08:05 UTC
@rugano haha no i just messed up, not part of the code.
srikanthdasari66
@srikanthdasari66
May 06 2017 08:06 UTC
how to do this
rugano
@rugano
May 06 2017 08:06 UTC

function rot13(str) { // LBH QVQ VG!
  var newArr = [];



    var decoded = "";

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


    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
    newArr[i] = (92-65-(newArr[i] - 13));

    }else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
      newArr[i] = (92-78-(newArr[i]-13));

    }else{
      newArr.push([i]);

  }
  decoded += str.charCodeAt([i]);  

  }





  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
srikanthdasari66
@srikanthdasari66
May 06 2017 08:07 UTC
studlyCapVar should use camelCase in both declaration and assignment sections.
how to do this
can any one help
Tobey
@cybairfly
May 06 2017 08:08 UTC

G'day everyone. Do you have a nicer solution than this one? Thanks.

Spinal Tap Case

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

  function camel(match) {
    return "-" + match;
  }

  return str.replace(/\W|_/g, "-").replace(/\B[A-Z]\B/g, camel).toLowerCase();
}

spinalCase('This Is Spinal Tap');
Alexandre Conrady
@Aberoom
May 06 2017 08:09 UTC
@rugano your second if statement doesn't need the complicated calculation in its expression. applying rot13 to 78 is 65, and 65 is still a letter. 92-13 is 79, which is also inside the range of used letters.
rugano
@rugano
May 06 2017 08:11 UTC
@Aberoom what about the decoded and return statement,how should i correct this?
scwilbanks
@scwilbanks
May 06 2017 08:12 UTC

function convertToF(celsius) {var fahrenheit;
fahrenheit = fahrenheit * 9.0 / 5.0 + 32;

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

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

Can anyone show me why this doesn't work?
Vicky Lai
@vickylai
May 06 2017 08:15 UTC
array.indexOf(x) but search the whole array, not just return the first x. What can I use?
srikanthdasari66
@srikanthdasari66
May 06 2017 08:16 UTC
can any one help me out about camel case in java script
Alexandre Conrady
@Aberoom
May 06 2017 08:18 UTC
@rugano You're getting closer. You want to find a way to convert an array of numbers into a string. I found that String.fromCharCode.apply was the best method to use.
james umali
@indefinite0212
May 06 2017 08:20 UTC
@scwilbanks The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
Rajkumar Tiwari
@rajqumar
May 06 2017 08:20 UTC
@rajqumar
Math.random() can return a 0 but never quite return a 1
what does this mean ?
Alexandre Conrady
@Aberoom
May 06 2017 08:20 UTC
@vickylaiio what are you searching the whole array for? The methods .map or .filter iterate through arrays, otherwise a for loop will as well.
Vivek
@vivekmittal7
May 06 2017 08:20 UTC
@scwilbanks var Fahrenheit = " ";
Rajkumar Tiwari
@rajqumar
May 06 2017 08:21 UTC
@rajqumar
Math.random() can return a 0 but never quite return a 1
what does this mean ?
Alexandre Conrady
@Aberoom
May 06 2017 08:22 UTC
@srikanthdasari66 camelcase is when variables that are multiple words are written likeThis. var manyWordsInCamelCaseLookLikeThis. every word after the first has the first letter cpaitalized.
Sulaiman
@suli-g
May 06 2017 08:24 UTC

@rajqumar It always returns 0<x<1. To use it to get an integer - use

Math.floor(Math.random()* min + max)

Math.floor : will make it 0.
*min: will make it >0
+max: will put it somewhere between min and max

I think

Rajkumar Tiwari
@rajqumar
May 06 2017 08:27 UTC
@suli-g okay
Sulaiman
@suli-g
May 06 2017 08:27 UTC
Hi, so I was directed here to report an inconsistency:
The Drop it challenge validates incorrectly for these two arrays:
dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1]

dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}) should return [3, 9, 2]
Rajkumar Tiwari
@rajqumar
May 06 2017 08:27 UTC
thanks
@suli-g
rugano
@rugano
May 06 2017 08:28 UTC
@Aberoom look at this code
Alexandre Conrady
@Aberoom
May 06 2017 08:28 UTC
@rugano im looking
rugano
@rugano
May 06 2017 08:28 UTC

function rot13(str) { // LBH QVQ VG!
  var newArr = [];



    var decoded = "";

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


    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
    newArr[i] = (92-65-(newArr[i] - 13));

    }else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
      newArr[i] = (92-78-(newArr[i]-13));

    }else{
      newArr.push([i]);

  }
  decoded += String.fromCharCode().apply();  

  }





  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Vicky Lai
@vickylai
May 06 2017 08:29 UTC
@Aberoom find how many times a specific variable occurs in an array... my brain is pooped
rugano
@rugano
May 06 2017 08:29 UTC
@Aberoom how should it be corrected?
Vivek
@vivekmittal7
May 06 2017 08:30 UTC
can anyone explain me whats a two dimensional array
rugano
@rugano
May 06 2017 08:30 UTC
@vickylaiio post your code here
Alexandre Conrady
@Aberoom
May 06 2017 08:31 UTC

```

function rot13(str) { // LBH QVQ VG!
var newArr = [];

var decoded = "";

for(var i = 0;i < str.length;i++) {
newArr.push(str.charCodeAt(i));
if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
newArr[i] = 91-(65-(newArr[i] - 13)); //changed some values here on the fences, this works better.

}else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
  newArr[i] = (92-78-(newArr[i]-13)); // this section here needs to be changed. Decoded charCodes have to be between 65 and 92, these new values are too low. you want just newArr[i] = newArr[i] -13;

} /*else{
  newArr.push([i]); This part in the comments can be removed, there should be any other values besides the ones between 65 and 92.

}*/
decoded += String.fromCharCode().apply();
}
return decoded;
}

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

```

rugano
@rugano
May 06 2017 08:31 UTC
@vivekmittal7 like this [[1,2,3],5]
Vivek
@vivekmittal7
May 06 2017 08:33 UTC
@rugano ok thanks
CamperBot
@camperbot
May 06 2017 08:33 UTC
vivekmittal7 sends brownie points to @rugano :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @rugano |http://www.freecodecamp.com/rugano
Javier Pons
@JavierPons
May 06 2017 08:33 UTC
Hi guys!
Whats wrong with this short code?
/start writing code below/
var i = 0;
while(i <5){
console.log("capullo català");
}
Alexandre Conrady
@Aberoom
May 06 2017 08:34 UTC
@vivekmittal7 in order to iterate through a 2d array, you have two indexes. The first index is which array inside the array you are accessing, the second index will give you the value of the array within an array.
This means that if arr = [[1,2,3],[4,5,6]]
arr[0] = [1,2,3]
arr[1] = [4,5,6]
arr[0][0] = 1
arr[0][1] = 2
etc.
Sulaiman
@suli-g
May 06 2017 08:35 UTC
@JavierPons You need to update i
i++
otherwise i<5 will always be true
Javier Pons
@JavierPons
May 06 2017 08:36 UTC
Thanks
Alexandre Conrady
@Aberoom
May 06 2017 08:38 UTC
@rugano did you catch those changes? The formatting got screwed up when I tried to change your code :S

function rot13(str) { // LBH QVQ VG!
  var newArr = [];

    var decoded = "";

  for(var i = 0;i < str.length;i++) {
    newArr.push(str.charCodeAt(i));
    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
    newArr[i] = 91-(65-(newArr[i] - 13)); //changed some values here on the fences, this works better.

    }else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
      newArr[i] = (92-78-(newArr[i]-13)); // this section here needs to be changed. Decoded charCodes have to be between 65 and 92, these new values are too low. you want just newArr[i] = newArr[i] -13;

    } /*else{
      newArr.push([i]); This part in the comments can be removed, there should be any other values besides the ones between 65 and 92.
  }*/ 
  }
  return String.fromCharCode.apply(0, newArr);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
This should work.
RahulP248
@RahulP248
May 06 2017 08:40 UTC
Hello , i'm newbie to Java script. I'm stuck at a point where code needs to return undefined if a or b are less than 0

function abTest(a, b) {
// Only change code below this line

if(a<0 | b<0)
{

}

// Only change code above this line

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

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

Vivek
@vivekmittal7
May 06 2017 08:41 UTC
@Aberoom thanks
CamperBot
@camperbot
May 06 2017 08:41 UTC
vivekmittal7 sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @aberoom |http://www.freecodecamp.com/aberoom
Alexandre Conrady
@Aberoom
May 06 2017 08:42 UTC
@RahulP248 || is the logical operator "or". You need one extra bar. Then in the expression of your if() statement { the part between these brackets } you need to write the code you want the function to return in this scenario.
RahulP248
@RahulP248
May 06 2017 08:43 UTC
@Aberoom Thanks much.. it worked:)
CamperBot
@camperbot
May 06 2017 08:44 UTC
rahulp248 sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 320 | @aberoom |http://www.freecodecamp.com/aberoom
Muthu Kumar
@MKRhere
May 06 2017 08:44 UTC
Guys I'm at a problem where I need to create a lookup table
How do I create one?
Alexandre Conrady
@Aberoom
May 06 2017 08:44 UTC
@MKRhere link your code buddy.
james umali
@indefinite0212
May 06 2017 08:45 UTC
@RahulP248 || you typed |
Muthu Kumar
@MKRhere
May 06 2017 08:45 UTC
https://www.freecodecamp.com/challenges/using-objects-for-lookups#?solution=%0A%2F%2F Setup%0Afunction phoneticLookup(val) {%0A var result %3D ""%3B%0A%0A %2F%2F Only change code below this line%0A switch(val) {%0A case "alpha"%3A %0A result %3D "Adams"%3B%0A break%3B%0A case "bravo"%3A %0A result %3D "Boston"%3B%0A break%3B%0A case "charlie"%3A %0A result %3D "Chicago"%3B%0A break%3B%0A case "delta"%3A %0A result %3D "Denver"%3B%0A break%3B%0A case "echo"%3A %0A result %3D "Easy"%3B%0A break%3B%0A case "foxtrot"%3A %0A result %3D "Frank"%3B%0A }%0A%0A %2F%2F Only change code above this line%0A return result%3B%0A}%0A%0A%2F%2F Change this value to test%0AphoneticLookup("charlie")%3B%0A
This one ^ :D
rugano
@rugano
May 06 2017 08:47 UTC
@Aberoom typeerror:string.fromCharCode is not a function
Khoa Le
@Zacele
May 06 2017 08:47 UTC
wow
sennator
@sennator2
May 06 2017 08:47 UTC
hi guys
rugano
@rugano
May 06 2017 08:49 UTC
@Aberoom i did catch them,but it says typeerrer:string.fromCharCode is not a function,how do we correct that?
Muthu Kumar
@MKRhere
May 06 2017 08:49 UTC
Guys I'm at a problem where I need to create a lookup table
Figured it out, thanks anyway :)
sennator
@sennator2
May 06 2017 08:50 UTC

I'm doing arguments optional algorithm challenge and I'm stuck.

function addTogether() {
    var args = Array.prototype.slice.call(arguments);
    var final = args.reduce(function(a,b){
      return a+b
    })
return final;
}

addTogether(2)(3);

How does calling a function like this works.?

Alexandre Conrady
@Aberoom
May 06 2017 08:50 UTC
@rugano capitalize String. JS is case sensitive
rugano
@rugano
May 06 2017 08:51 UTC
@Aberoom ok
@Aberoom still the same error
Alexandre Conrady
@Aberoom
May 06 2017 08:52 UTC
@rugano show me
rugano
@rugano
May 06 2017 08:52 UTC
@Aberoom ok

function rot13(str) { // LBH QVQ VG!
  var newArr = [];



    var decoded = "";

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


    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
    newArr[i] = 92-(65-(newArr[i] - 13));

    }else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
      newArr[i] = newArr[i]-13;

    }

  decoded += String.fromCharCode().apply();  




}


  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
@Aberoom that's it
Alexandre Conrady
@Aberoom
May 06 2017 08:55 UTC
@rugano delete the decoded part. just return String.fromCharCode.apply(0, newArr);
Muthu Kumar
@MKRhere
May 06 2017 08:59 UTC

This should return the object property, but it doesn't.. Can anyone help?
'''

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp) == 'true') {
return myObj[checkProp];
}
else
return "Not Found";
}

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

CamperBot
@camperbot
May 06 2017 08:59 UTC
:bulb: to format code use backticks! ``` more info
Muthu Kumar
@MKRhere
May 06 2017 09:00 UTC
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp) == 'true') {
return myObj[checkProp];
}
else
return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
Why doesn't this return the property of myObj["gift"]?
rugano
@rugano
May 06 2017 09:02 UTC
@Aberoom we are inching closer,only this time the output is FSEE CPDE CAMQ
gheorghiank
@gheorghiank
May 06 2017 09:09 UTC
@HeebieGeeBee hi! long time no see :)
rugano
@rugano
May 06 2017 09:10 UTC
@Aberoom Thanks,it worked
CamperBot
@camperbot
May 06 2017 09:10 UTC
:cookie: 321 | @aberoom |http://www.freecodecamp.com/aberoom
rugano sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
khanvuthy88
@khanvuthy88
May 06 2017 09:13 UTC
Any idea with this code :
function largestOfFour(arr) {
  // You can do this!
  var rs=[];
  for(var i=0;i<arr.length;i++){
    var largNumber=0;
    for(var j=0;j<arr[i].length;j++){
      if(arr[i][j]>largNumber){
        largNumber=arr[i][j];
      }
    }
    rs.push(largNumber);
  }
  return rs;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
can i use ' reduce ' or ' map ' function instead ?
Javier Pons
@JavierPons
May 06 2017 09:16 UTC
Why doesnt work this short code?

/start writing code below/
for(var i=0; i>10; i++){
console.log(i + " MEZERES");

}

Alexandre Conrady
@Aberoom
May 06 2017 09:16 UTC
@rugano awesome :)
khanvuthy88
@khanvuthy88
May 06 2017 09:17 UTC

@JavierPons

for(var i=0; i>10; i++){

not run that block.

Javier Pons
@JavierPons
May 06 2017 09:17 UTC
?
khanvuthy88
@khanvuthy88
May 06 2017 09:18 UTC
@JavierPons
```
Zero never larger than 10, Zero is smaller than 10
Javier Pons
@JavierPons
May 06 2017 09:18 UTC
Yes, now I see the error. Thanj
Nguyen Hoang
@honnhien12h
May 06 2017 09:48 UTC
Help me challenge "Nesting For Loops", this code:

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++){
      product += arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Alexandre Conrady
@Aberoom
May 06 2017 09:49 UTC
@honnhien12h you want to multiply, not add :)
Nguyen Hoang
@honnhien12h
May 06 2017 09:51 UTC
@Aberoom Ah ha :smile: thank you!!
CamperBot
@camperbot
May 06 2017 09:51 UTC
honnhien12h sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @aberoom |http://www.freecodecamp.com/aberoom
Alexandre Conrady
@Aberoom
May 06 2017 09:52 UTC
@honnhien12h my pleasure :)
Nguyen Hoang
@honnhien12h
May 06 2017 09:54 UTC
:dancers: :dancers:
Vivek
@vivekmittal7
May 06 2017 09:58 UTC
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var result = [];
  for (var i = 0; i <arr.length; i=i+size){
   result.push(arr.slice(i,size));
  } return result;
}


chunkArrayInGroups(["a", "b", "c", "d"], 2);
i have to chunk the array(1st argument) in the subarrays with length = size(2nd argument). How can i update the value of size in line 6 when value of i becomes equal to size.
sorry in line 5
never mind. solved it
bilaal-s
@bilaal-s
May 06 2017 10:06 UTC
anyone familiar with nodejs around?
Abhishek Tiwari
@fillopfy
May 06 2017 10:12 UTC
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

  var lookup={

    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"

  };



  // Only change code above this line

  return result;
}

// Change this value to test
phoneticLookup("charlie");
what is wrong in this code
Aizaz Shahid
@aizazshahid
May 06 2017 10:13 UTC
@fillopfy you need to use the argument with lookup to get the value !
Abhishek Tiwari
@fillopfy
May 06 2017 10:14 UTC
@forwebtech how to do that?
Aizaz Shahid
@aizazshahid
May 06 2017 10:14 UTC
@fillopfy task name ?
Abhishek Tiwari
@fillopfy
May 06 2017 10:15 UTC
Using Objeccts for Lookups

@forwebtech this is Instructions: Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.

Run tests (ctrl + enter)

Aizaz Shahid
@aizazshahid
May 06 2017 10:16 UTC
@fillopfy result = lookup[val];
you need to assign the value to your result with the help of the argument, which is key name in this case !
Abhishek Tiwari
@fillopfy
May 06 2017 10:17 UTC
@forwebtech the code worked but I didn't understand
Aizaz Shahid
@aizazshahid
May 06 2017 10:18 UTC
@fillopfy did you know how to get properties from object ??
Abhishek Tiwari
@fillopfy
May 06 2017 10:19 UTC
yes like this: objectname.propertyname or objectname[propertyname]
@forwebtech am i right?
Aizaz Shahid
@aizazshahid
May 06 2017 10:19 UTC
@fillopfy indeed !
Vivek
@vivekmittal7
May 06 2017 10:19 UTC
is this argument, howMany == !NaN,correct if i want to check whether howMany is a number or not
Aizaz Shahid
@aizazshahid
May 06 2017 10:19 UTC
now the task is that, user provides the key name, when calling the function like: foo( "keyname")
@fillopfy so you just get the value by using the argument variable which is val in your function, as lookup[val]
and storing in the variable result = ... then it just returns that result !
the functions is just made to get the values from object with just passing the key name !
Abhishek Tiwari
@fillopfy
May 06 2017 10:22 UTC
@forwebtech okay, so basically val is the argument provided by user and I have to refer that argument to return object values to val through result??
Alexandre Conrady
@Aberoom
May 06 2017 10:22 UTC
hey @forwebtech :)
Aizaz Shahid
@aizazshahid
May 06 2017 10:22 UTC
@vivekmittal7 no you need to check its type
@Aberoom :wave:
@fillopfy :+1: indeed !
Abhishek Tiwari
@fillopfy
May 06 2017 10:22 UTC
@forwebtech thanks!
CamperBot
@camperbot
May 06 2017 10:22 UTC
fillopfy sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 424 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
May 06 2017 10:22 UTC
@Aberoom How are you !
Alexandre Conrady
@Aberoom
May 06 2017 10:23 UTC
@forwebtech I'm at work trying not to blow my brains out over my keyboard.
@forwebtech how about you :D
Aizaz Shahid
@aizazshahid
May 06 2017 10:23 UTC
@Aberoom :)
am fine. what's the job ?
Hugo Papier
@HugoPapier
May 06 2017 10:23 UTC
Hello everyone, I have to factorialize a number with a loop I think, but I don't find the formule of this, can you help me please ? :)

function factorialize(num) {
  for ( i = 1; i <= num; i++) {
    return 
  }
}

factorialize(5);
Vivek
@vivekmittal7
May 06 2017 10:24 UTC
@forwebtech how?
i thought == checks that
Alexandre Conrady
@Aberoom
May 06 2017 10:24 UTC
@forwebtech hotel reception...
Aizaz Shahid
@aizazshahid
May 06 2017 10:24 UTC
@vivekmittal7 that operator is ok but at the left side use typeof varName
@Aberoom good !
Vivek
@vivekmittal7
May 06 2017 10:24 UTC
ok
Alexandre Conrady
@Aberoom
May 06 2017 10:24 UTC
@HugoPapier well factorializing is taking n x n-1 x n-2 x ... x 1
Aizaz Shahid
@aizazshahid
May 06 2017 10:25 UTC
@HugoPapier @Aberoom is right, further details can be found there Factorial
Hugo Papier
@HugoPapier
May 06 2017 10:26 UTC
@Aberoom Yes I know but is how can I use this in a loop ?
Alexandre Conrady
@Aberoom
May 06 2017 10:26 UTC
@HugoPapier well your i value is incrementing on each loop right? so on the first loop, i = 1, then i=2, all the way up to num, right?
Hugo Papier
@HugoPapier
May 06 2017 10:28 UTC
Ok this I understand :)
Alexandre Conrady
@Aberoom
May 06 2017 10:28 UTC
ugh I gotta do some stuff. brb 10 mins
Aizaz Shahid
@aizazshahid
May 06 2017 10:28 UTC
tyt.
Lola
@smokingboudicca
May 06 2017 10:30 UTC
it's all a hot mess in here, but I'm trying to get on the right track without deleting anything. anybody see anything they like?

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

var giftValue = myObj.gift;
function trueOrFalse(wasThatTrue) {


if (myObj.hasOwnProperty(checkProp)) {
  // Your Code Here

  return "";
}
return "Not Found";
}
// Test your code by modifying these values
checkObj("gift");
Hugo Papier
@HugoPapier
May 06 2017 10:30 UTC
@Aberoom I try this :

function factorialize(num) {
  for ( i = 1; i <= num; i++) {
    num! = i * (num! - 1);
  }
}

factorialize(5);
Aizaz Shahid
@aizazshahid
May 06 2017 10:31 UTC
@HugoPapier why are you using num!
Alexandre Conrady
@Aberoom
May 06 2017 10:31 UTC
@HugoPapier well tell me exactly what's happening on every loop, and what do you think should be happening on every loop.
Aizaz Shahid
@aizazshahid
May 06 2017 10:31 UTC
@Aberoom he is thinking like 4! automatically evaluates :) but if that work then there no use of loop
Hugo Papier
@HugoPapier
May 06 2017 10:32 UTC
@forwebtech the "!" notation is the factorialize notation no ? :/
Alexandre Conrady
@Aberoom
May 06 2017 10:32 UTC
@smokingboudicca what should it return if myObj.hasOwnProperty(checkProp) returns true?
abraham anak agung
@padunk
May 06 2017 10:32 UTC
it won't work in js
Aizaz Shahid
@aizazshahid
May 06 2017 10:32 UTC
@HugoPapier indeed but the JS can't understand that,
! means not in programming
@HugoPapier
Alexandre Conrady
@Aberoom
May 06 2017 10:33 UTC
@HugoPapier also if you assign a larger value to num while it's in your incrementing for loops condition, you will create an infinite loop.
Aizaz Shahid
@aizazshahid
May 06 2017 10:33 UTC
suppose you get the number 6 so you have to do that 1 x 2 x 3 x 4 x5 x6
Hugo Papier
@HugoPapier
May 06 2017 10:33 UTC
@Aberoom I don't see how to do that, so I try, I've already try that :

function factorialize(num) {
  for ( i = 1; i <= num; i++) {
    num *= i * num;
  }
}

factorialize(5);
Lola
@smokingboudicca
May 06 2017 10:33 UTC
@Aberoom I was kind of hoping to find a way to hit all the y variables
i thought maybe this var giftValue = myObj.gift; could be used in there somewhere
heebee beat it out of me last night
Aizaz Shahid
@aizazshahid
May 06 2017 10:35 UTC
@smokingboudicca the user can put any value to the parameter, so why are you making static code ?
Lola
@smokingboudicca
May 06 2017 10:35 UTC
@forwebtech not sure how to make it for all the variables tbh
Alexandre Conrady
@Aberoom
May 06 2017 10:35 UTC
@HugoPapier one of the things that will serve you in every algorithm challenge is knowing when to make new variables. Try making one here called var result, and assign the product of your loop to it.
Aizaz Shahid
@aizazshahid
May 06 2017 10:35 UTC
it pass the key value so just by using the argument you have to find the value !
@smokingboudicca first reset your code, then will tell you
and paste here
abraham anak agung
@padunk
May 06 2017 10:36 UTC
num *= you can't use this. try to make new var as a result
Lola
@smokingboudicca
May 06 2017 10:36 UTC
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
Aizaz Shahid
@aizazshahid
May 06 2017 10:36 UTC
@padunk that is a correct operator indeed
@smokingboudicca now tell me how to access object property ?
Lola
@smokingboudicca
May 06 2017 10:37 UTC
@forwebtech just a sec
Aizaz Shahid
@aizazshahid
May 06 2017 10:37 UTC
@padunk @HugoPapier num = num * 1 is equal to num *= 1
Alexandre Conrady
@Aberoom
May 06 2017 10:38 UTC
@forwebtech yeah but @padunk is saying that using that variable in the for loop will make an infinite loop is all :)
Hugo Papier
@HugoPapier
May 06 2017 10:38 UTC
@Aberoom Ok thank's, so now I have to do the formule of this ahah
CamperBot
@camperbot
May 06 2017 10:38 UTC
hugopapier sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @aberoom |http://www.freecodecamp.com/aberoom
Lola
@smokingboudicca
May 06 2017 10:38 UTC
@forwebtech var hatValue = testObj.hat; - I have to plug the right variables in the right places here
abraham anak agung
@padunk
May 06 2017 10:38 UTC
yes sorry, but that going to make infinite loop
Aizaz Shahid
@aizazshahid
May 06 2017 10:38 UTC
@smokingboudicca you don't need to store it first , and when you are accessing the object from argument value you have to use [] bracket notation !
Lola
@smokingboudicca
May 06 2017 10:39 UTC
@forwebtech yeeks, I was very wrong. k, gimme a sec!!
Vivek
@vivekmittal7
May 06 2017 10:39 UTC
function mutation(first, second) {

var one = first.toLowerCase() ; 


  return first;
}

mutation(["Hello", "hey"]);
whats wrong here in my code
Aizaz Shahid
@aizazshahid
May 06 2017 10:39 UTC
@padunk indeed but am just talking about the syntax.
abraham anak agung
@padunk
May 06 2017 10:39 UTC
your return your Hello @vivekmittal7
Lola
@smokingboudicca
May 06 2017 10:40 UTC
@forwebtech I guess I am plugging everything in here? var entreeValue = testObj["an entree"];
Aizaz Shahid
@aizazshahid
May 06 2017 10:40 UTC
@vivekmittal7 return your argument not that one
@smokingboudicca you just need to return the property, so add that code after return
Alexandre Conrady
@Aberoom
May 06 2017 10:40 UTC
@smokingboudicca you just want to make a method accessible to all user input. So what is the variable called that the user is giving you with his input?
Aizaz Shahid
@aizazshahid
May 06 2017 10:41 UTC
@smokingboudicca and also why are you putting key values by your self, you need to use that argument name
Vivek
@vivekmittal7
May 06 2017 10:41 UTC
i tried using return one but result says first.toLowerCase is not a function
@forwebtech
Alexandre Conrady
@Aberoom
May 06 2017 10:42 UTC
@vivekmittal7 you are returning the argument, not the variable you just created.
Vivek
@vivekmittal7
May 06 2017 10:42 UTC
@Aberoom its not working even if i return one
Aizaz Shahid
@aizazshahid
May 06 2017 10:43 UTC
@vivekmittal7 actually the thing is that you are just passing an array
just look at your function call carefully .
Lola
@smokingboudicca
May 06 2017 10:43 UTC
@Aberoom testObj?
Hugo Papier
@HugoPapier
May 06 2017 10:43 UTC
@Aberoom I try this
function factorialize(num) {
  var number;
  for ( i = 1; i <= num; i++) {
    number = i * (num-1);
    return number;
  }

}

factorialize(5);
Lola
@smokingboudicca
May 06 2017 10:43 UTC
@forwebtech kk!!