These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Jun 2017
Christopher McCormack
@cmccormack
Jun 14 2017 00:00
@JLuboff see ya - try VS code sometime, I like it a lot more than Atom and Sublime Text
mackyking
@mackyking
Jun 14 2017 00:00
myStr should have encoded text with the proper escape sequences and no spacing.
Christopher McCormack
@cmccormack
Jun 14 2017 00:00
@Giveback007 hey sorry I gotta run and start making dinner but you can ask your question and either someone will respond or I can when I get back
Jason Luboff
@JLuboff
Jun 14 2017 00:00
@cmccormack but I love Atom. I have it all themed out and everything! :) We'll pick this up further tomorrow
Christopher McCormack
@cmccormack
Jun 14 2017 00:00
@JLuboff haha ok
Dovydas Stirpeika
@Giveback007
Jun 14 2017 00:01
@cmccormack tnx man, enjoy diner
CamperBot
@camperbot
Jun 14 2017 00:01
giveback007 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 884 | @cmccormack |http://www.freecodecamp.com/cmccormack
Christopher McCormack
@cmccormack
Jun 14 2017 00:01
@Giveback007 thanks
Justin Ketterman
@jkketts
Jun 14 2017 00:02
It's Stand in Line. my solution is: var numRemoved = 0;
testArr.push(item);
numRemoved = testArr.shift();
return numRemoved;
NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:03
can someone help me with a code?
Justin Ketterman
@jkketts
Jun 14 2017 00:04
what are you working on Niel?
NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:04
@jkketts Change the code to use the ++ operator on myVar.

@jkketts var y = 88;

// Only change code below this line
y = x++; // y = 87, x = 1
this is what i have

Justin Ketterman
@jkketts
Jun 14 2017 00:05
which exercise?
NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:07
@jkketts Increment a Number with JavaScript 130
Justin Ketterman
@jkketts
Jun 14 2017 00:09
Ah, got it. I think I see what you're tryin to do... Really all you need to do to increment a number is the variable and ++. So you would do, for example, myVar++;
it's really useful for when you get to loops.
Hello911
@Hello911
Jun 14 2017 00:12
How do I integrate API into my quote generator? Where can I learn to do this?
NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:13
@jkketts so how would it look?
Frank McCroy
@fmccroy
Jun 14 2017 00:13
@Hello911 Are you using the API for the twitter part?
It said your callback can also include arguments for the index and array being acted on.
i wonder how to include the index in the callback?
Thx in advance.
Justin Ketterman
@jkketts
Jun 14 2017 00:18
@EkweviIkeobi it's literally just myVar++;
that's it.
E.g., if you had
myVar = 0; myVar++; myVar would return 1
NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:19

@jkketts so like var y = 88;

// Only change code below this line
y = myVar++; // y = 87, x = 1

Joseph
@revisualize
Jun 14 2017 00:19
about @revisualize
CamperBot
@camperbot
Jun 14 2017 00:19
:star2: 4156 | @revisualize |http://www.freecodecamp.com/revisualize
Ir1dXD
@Ir1d
Jun 14 2017 00:20
about @Ir1d
CamperBot
@camperbot
Jun 14 2017 00:20
:cookie: 148 | @ir1d |http://www.freecodecamp.com/ir1d
Justin Ketterman
@jkketts
Jun 14 2017 00:20
@EkweviIkeobi In that example, instead of y = myVar++;, it would just be y++;
@EkweviIkeobi Think of the ++ as being like = y + 1; so y++ would turn in to y = y + 1;
Dan Couper
@DanCouper
Jun 14 2017 00:21

@Ir1d

[1,2,3].map(function(theValue, theIndex, theArray) {
  console.log(`Value: ${theValue}, Index: ${theIndex}, Array: ${theArray});
});

will give you

Value: 1, Index: 0, Array: [1,2,3]
Value: 2, Index: 1, Array: [1,2,3]
Value: 3, Index: 2, Array: [1,2,3]

first argument to the callback gives you the current value, next the current index, next the current array. Currently you're only using the first value; you can use the others if you need them (index can be very useful, the current array can be occasionally useful)

pursuitgit
@pursuitgit
Jun 14 2017 00:21

function palindrome(str) {

  var comparison = str;
  replacedString = str.replace("[^a-zA-Z0-9]+","");
  replacedString.toLowerCase();
  // I still have to reverse it with an arrray, I can do this after removing characters
  splitString = replacedString.split("");
  reversedString = splitString.reverse();
  palindromeTest = reversedString.join("");


  if(comparison === palindromeTest){
    return true;
  }
  else {
    return palindromeTest ;
  }
}



palindrome("_eye");
if i run this
it returns eye_
Guderian Raborg
@hypercuber
Jun 14 2017 00:22

Hey, yall, I got myself into a bit of a pickle. I have something like

arrId[j][i] = document.getElementById(j + ' ' + i);

then for each element in arr I added the same event, function thingy like this

arrId.forEach(ele => ele.addEventListener('click', moves));

How would I get console.log the id when I click each element?

NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:22

@jkketts like this
var y = 88;

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

Ir1dXD
@Ir1d
Jun 14 2017 00:23
@DanCouper Thx. I found the parameters here: http://devdocs.io/javascript/global_objects/array/map
CamperBot
@camperbot
Jun 14 2017 00:23
ir1d sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 769 | @dancouper |http://www.freecodecamp.com/dancouper
Ir1dXD
@Ir1d
Jun 14 2017 00:23
You really helped a lot!
Justin Ketterman
@jkketts
Jun 14 2017 00:23
@EkweviIkeobi deleted the y=
NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:24
@jkketts on which line?
Justin Ketterman
@jkketts
Jun 14 2017 00:25
@EkweviIkeobi y = myVar++; change it to y++;
@EkweviIkeobi any luck?
NielEXXCRO
@EkweviIkeobi
Jun 14 2017 00:28

@jkketts var y = 88;

// Only change code below this line
y = y++; // y = y + 1, x = 1

this?
Pagnito
@Pagnito
Jun 14 2017 00:30
hey does anyone know about using high def images for their site while optimizing its quality and size and saving load speed?
Justin Ketterman
@jkketts
Jun 14 2017 00:30
@EkweviIkeobi delete everything below "// Only change code below this line" Write only "y++;" 4 characters.
Leya
@leyaabebe
Jun 14 2017 00:30
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var i = 0;
  while (i < arr.length){
    if (arr[i] === false || arr[i] === null || arr[i] === 0 || arr[i] === undefined) {
      arr.splice(i, 1);
      i++;
//     } else if (isNaN(arr[i]) === true){
//       return arr[i];
//       arr.splice(i,1);
//       i++;
    } else if (arr.indexOf("")>-1){
      arr.splice(arr.indexOf(""),1);
      i++;
    } else {
      i++;
    }
  }
  return arr;
}

bouncer([7, "ate", "", false, 9]);
I’m having trouble checking if the value at arr[i] is a NaN. Using isNaN() —the commented out part — also cuts out strings, and I don’t want it to do that. Any advice?
pursuitgit
@pursuitgit
Jun 14 2017 00:32
This returns amanaPlanacanalpanamA but it should return true, can anyone help me figure out why?

function palindrome(str) {

  replacedString = str.replace(/[^a-zA-Z0-9]/g, "");
  replacedString.toLowerCase();
  var comparison = replacedString;
  // I still have to reverse it with an arrray, I can do this after removing characters
  splitString = replacedString.split("");
  reversedString = splitString.reverse();
  palindromeTest = reversedString.join("");


  if(comparison === palindromeTest){
    return true;
  }
  else {
    return palindromeTest;
  }
}



palindrome("A man, a plan, a canal. Panama");
Frank McCroy
@fmccroy
Jun 14 2017 00:33
@leyaabebe I had the same problem and was recommended to either check to see if it’s a string first, or the Boolean function will filter out all of the bad stuff for you without all of the hassle. It’s described in the Hints section.
Hello911
@Hello911
Jun 14 2017 00:33
@fmccroy I know you need API for twitter. But no, its for quotes
Leya
@leyaabebe
Jun 14 2017 00:34
ok! I’ll try that. thanks @fmccroy
CamperBot
@camperbot
Jun 14 2017 00:34
leyaabebe sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @fmccroy |http://www.freecodecamp.com/fmccroy
Frank McCroy
@fmccroy
Jun 14 2017 00:34
@Hello911 You don’t need an API for the quote part. Just put the quotes you want into an array, then have the program pick one at random to display.
Keon Samuel
@keonsam
Jun 14 2017 00:40
no
learn to use api.
Frank McCroy
@fmccroy
Jun 14 2017 00:44
I’m trying to do the weather app now, and it looks like I have a lot to learn to finish it, including how to call the dark sky website and how to use whatever it provides back.. but there is no API to use on Quotes until he does the Twitter part, is there?
Keon Samuel
@keonsam
Jun 14 2017 00:45
you can use api for all of those projects.
well that is the point mostly.
api is very important in programming.
Dan Couper
@DanCouper
Jun 14 2017 00:46
@leyaabebe the exercise is try to introduce how JS treats values it thinks are 'falsey' or 'truthy' - all of the ones there are falsey, and the Boolean function will convert them as @fmccroy says. isNaN is not for testing if a value is literally NaN: if you are doing it the way you are, you need to understand that NaN doesn't equal anything else, even itself, so if you do arr[i] !== arr[i], that will be true if the value is NaN (eg if arr[i] is 1, 1 is equal to 1, so that would be false. if arr[i] is NaN, NaN is not equal to NaN, so that would be true)
Dan Couper
@DanCouper
Jun 14 2017 00:52
edit: as an explanation, NaN is something that JS thinks should be a number, but isn't - JS doesn't keep a record of what it actually is, it just says that the value is Not a Number. And as it doesn't know what the actual value is, it can't really say it's equal to anything else, because it doesn't know that for sure. It isn't actually something you test for directly like in this exercise (the exercise is just to demonstrate what JS considers 'falsey' values)
Anthony Cortez
@Morralito
Jun 14 2017 01:04

function titleCase (str) {
  var dividir  =  str.toLowerCase().split(" ");
  var newstring  =  dividir.map( x => x.replace(x[0],  x[0].toUpperCase()));
  newstring = newstring.join(" ");
    return newstring;
}
is there a better way to do that?
drewwzzy
@drewwzzy
Jun 14 2017 01:06
hey what am I doing wrong here still on the Fahrenheit challenge
fahrenheit *= 1.8;
fahrenheit += 32;
Justin Ketterman
@jkketts
Jun 14 2017 01:08
@drewwzzy think you need to be taking in celsius and doing your operations on that.
in your example, fahrenheit is empty. it hasn't been set as anything. null * 1.8 is null
drewwzzy
@drewwzzy
Jun 14 2017 01:09
ohhhh ok the instructions say to only change code below the line
so let me try this again
thanks
thanks @jkketts
CamperBot
@camperbot
Jun 14 2017 01:10
drewwzzy sends brownie points to @jkketts :sparkles: :thumbsup: :sparkles:
:cookie: 220 | @jkketts |http://www.freecodecamp.com/jkketts
Justin Ketterman
@jkketts
Jun 14 2017 01:10
happy to help!
David
@davidr1992
Jun 14 2017 01:26
doing the palindromes challenge

function palindrome(str) {
var comparison = str.replace(/!@#$%^&*(),./g,'');
  comparison.toLowerCase();

  if (comparison === str) {
  return true;
  }

  else {
  return false;
  }
}


palindrome("nope");
still returns true on false statements
but everything else is working
William Dayton
@Mortichar
Jun 14 2017 01:28
that's not how palindromes work
you need to reverse the string for one
you can't just replace lowers
function removeSpecial(str){
  var tempStr = str.replace(/\W/g, '');
  return tempStr.replace('_', '');
}
Ccs99817
@ccs99817
Jun 14 2017 01:29

Seek and Destroy
Here is my code which can pass the challenge:


function destroyer(arr) {
  // Remove all the values
  var argumentsLength = arguments.length;
  //var checker1 = arguments[1];
  var checkerList = [];
  for (var i=1; i<argumentsLength; i++){
    checkerList.push(arguments[i]);
  }

  var newArr = arr.filter(function(char){
    return char != checkerList[0] && char!= checkerList[1] && char!= checkerList[2];
  });



  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

I tried to use the following code to replace line 11-13, but it won't work . WHY? (only the value of first arguments after the array is removed from the array)

  var newArr = arr.filter(function(char){
    for (var i=0; i<argumentsLength-1; i++){
      return char != checkerList[i];
    }
  });
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:30
i am doing this reverse lookup problem what am i doing wrong anyone help please

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

// Only change code below this line
var lookup ={

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

};
var result="val";
lookup[result];

}

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

David
@davidr1992
Jun 14 2017 01:30
@Mortichar how do I add more functions to my comparison var?
William Dayton
@Mortichar
Jun 14 2017 01:30
just add another function and call it from inside palindrome()
Anthony Cortez
@Morralito
Jun 14 2017 01:30
@pursuitgit replacedString.toLowerCase(); you can use the same variable and assing it a modified version of itself replacedString = replacedString.toLowerCase();
now you have a string all lower case . you are no declaring reversedString or palindromeTest the if-else is unnecessary you can return the normal string === reversed string
William Dayton
@Mortichar
Jun 14 2017 01:30
function palindrome(str) {
  var reverseString = str.split('');
  reverseString = reverseString.reverse();
  var reversedString = reverseString.join('');
  if(removeSpecial(reversedString.toLowerCase()) == removeSpecial(str.toLowerCase())){
    return true;
  } else{
    return false;
  }
}

function removeSpecial(str){
  var tempStr = str.replace(/\W/g, '');
  return tempStr.replace('_', '');
}



palindrome("eye");
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:31
@Mortichar please help me in this

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

// Only change code below this line
var lookup ={

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

};
var result="val";
lookup[result];

}

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

William Dayton
@Mortichar
Jun 14 2017 01:32
your fields need quotes, for one, ie
"alpha":"Adams",
and lookup[result] will give you the value but you're not assigning it to anything or returning it
canoid
@canoid
Jun 14 2017 01:33
hi everyone can somebody help me with the profile Lookup challenge? I have no idea of what to do .-.
William Dayton
@Mortichar
Jun 14 2017 01:33
@lucky73 so your return should be return lookup[result]
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:34
@Mortichar but i am assiging var result ="val"
Anthony Cortez
@Morralito
Jun 14 2017 01:34
function palindrome(str) {
  // Good luck!
   var cleanword = str.toLowerCase().replace(/[^a-z0-9]/g,"");
   var checkpal = cleanword.split("").reverse().join("");
   return cleanword === checkpal;
}
palindrome("eye");
William Dayton
@Mortichar
Jun 14 2017 01:34
@lucky73 "val" is your index, it's not the result of the lookup
@lucky73 you're looking up the index of "val" inside of your "lookup" json
Anthony Cortez
@Morralito
Jun 14 2017 01:35
that was my approach to the palindrome challenge
William Dayton
@Mortichar
Jun 14 2017 01:35
@lucky73 you need to store the result of that lookup, simply naming your variable result* won't do that
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:36
@Mortichar so should i write lookup=lookup["result"]
William Dayton
@Mortichar
Jun 14 2017 01:36
@lucky73 rename your result variable, then make a new var result, then result = lookup["newVarName"]; return result;
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:40
@Mortichar it says return not in function

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

// Only change code below this line
var lookup ={

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

};
var result="val";
result=lookup['result1'];

}

// Only change code above this line
return result;

William Dayton
@Mortichar
Jun 14 2017 01:41
Well yeah, it's not. Your return is outside of the function's scope brackets {}
canoid
@canoid
Jun 14 2017 01:41
nobody knows?
William Dayton
@Mortichar
Jun 14 2017 01:41
@canoid Have you attempted it first?
canoid
@canoid
Jun 14 2017 01:42
well i tried beginning with if statemensts but, I don't know what to do exactly ..
William Dayton
@Mortichar
Jun 14 2017 01:43
you need a loop, to loop through all of the contacts within the contacts array
canoid
@canoid
Jun 14 2017 01:43
mmmm.. but inside the loop I need a condition isn't it?
William Dayton
@Mortichar
Jun 14 2017 01:43
Yup :)
You need a condition to check for the name
then a condition to check for the property
canoid
@canoid
Jun 14 2017 01:45
ok I gonna try thanks @Mortichar
CamperBot
@camperbot
Jun 14 2017 01:45
canoid sends brownie points to @mortichar :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @mortichar |http://www.freecodecamp.com/mortichar
SAIDI YASSINE
@Nero00
Jun 14 2017 01:45
@canoid use for loop it will slov the problem
William Dayton
@Mortichar
Jun 14 2017 01:46
@canoid don't forget you'll also need to return if you find the name, but not the property, or you don't even find the name. good luck.
canoid
@canoid
Jun 14 2017 01:47
ok :)
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 01:47

function findLongestWord(str) {
  return str.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Can someone help explain how to use the .split() method here?
I need a refresher
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:48
@JonathonLLopez str.split(" "), that methods needs a separator, which it will use to separate the string.
William Dayton
@Mortichar
Jun 14 2017 01:48
Split has a parameter for the character to split on. i.e. ' ' is space, '' is split every character up.
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:49
@JonathonLLopez so it returns the array, it should be store in some variable.
William Dayton
@Mortichar
Jun 14 2017 01:49
@JonathonLLopez In that case, you can split on a space and then check for string length in the new array ;-)
Cynthia Clinton
@Cynth42
Jun 14 2017 01:49
Hi everyone!
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:49

@Mortichar still my variable is already defined and if i change the variable test case does not satisfied
// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup ={

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

};
var result="val";
result=lookup[result];

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

Cynthia Clinton
@Cynth42
Jun 14 2017 01:50
my code is failing please tell me why:

function mutation(arr) {
//Change both string inputs to lowercase for comparison purposes
var firstWord = arr[0].toLowerCase;
var secWord = arr[1].toLowerCase;
//Using the length of the second word to iterate thru its letters to see if they //contain the same letters
for (var i = 0; i < secWord.length; i++) {
//this checks to see if the letters of the secWord exist in the firstWord
if (firstWord.indexOf(secWord[i]) < 0) {
return false;
}
}
return true;
}

mutation(["hello", "hey"]);

William Dayton
@Mortichar
Jun 14 2017 01:50
@lucky73 Changed result = lookup[resukt]; to var newResult = lookup[result]; then return newResult;
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 01:50

So, for example, it should look like this?

str.split([separator[, limit]])

Aizaz Shahid
@aizazshahid
Jun 14 2017 01:50
@lucky73 you are actually doing it wrong you have to take the property of lookup with the help of parameter and assign in to result.
Lenarey S. Torririt
@Lengzki
Jun 14 2017 01:51

I got an error, don't know what to do, can you help me?

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

Code:

function myLocalScope() {
'use strict';
var myVar; // I've added this one.

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

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

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

William Dayton
@Mortichar
Jun 14 2017 01:51
@JonathonLLopez It should look like str.split(' ');
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:51

@Cynth42

:bulb: To format your code, please follow:
```
put your code here
```

More details..

:bulb: To get more commands:
ctrl + shift + m
you can edit your comment.

Mohak Chaturvedi
@lucky73
Jun 14 2017 01:51
@forwebtech means
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 01:51
@Mortichar so it doesn't necessarily need a limit?
William Dayton
@Mortichar
Jun 14 2017 01:51
@JonathonLLopez No, just the separator.
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:52
@lucky73 str.split(" ") returns the array so store it in a variable.
Cynthia Clinton
@Cynth42
Jun 14 2017 01:52
put my code where @forwebtech ?
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:52
```
between those backticks
```
SamyFarahat
@SamyFarahat
Jun 14 2017 01:53
hey
Cynthia Clinton
@Cynth42
Jun 14 2017 01:53

function mutation(arr) {
//Change both string inputs to lowercase for comparison purposes
var firstWord = arr[0].toLowerCase;
var secWord = arr[1].toLowerCase;
//Using the length of the second word to iterate thru its letters t see if they //contain the same letters
for (var i = 0; i < secWord.length; i++) {
//this checks to see if the letters of the secWord exist in the firstWord
if (firstWord.indexOf(secWord[i]) < 0) {
return false;
}
}
return true;
}

mutation(["hello", "hey"]);

Anthony Cortez
@Morralito
Jun 14 2017 01:53
@JonathonLLopez you first need to split it to then use the length of the new array that split created to iterate through it
SamyFarahat
@SamyFarahat
Jun 14 2017 01:53
i am doing javascript right now

// Setup
var a;
var b = 2;
a = b;

// Only change code below this line
a = 7;
b = 7;
a = b;

Aizaz Shahid
@aizazshahid
Jun 14 2017 01:54
@Lengzki remove the console.log at the end.
SamyFarahat
@SamyFarahat
Jun 14 2017 01:54
a have to be equal to b
hoe to of that?
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:55
@forwebtech i am not using str.split anywhere in this program
SamyFarahat
@SamyFarahat
Jun 14 2017 01:55
I think I did it but it still says I didn't't
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:55
what are the instructions ? @SamyFarahat
Cynthia Clinton
@Cynth42
Jun 14 2017 01:55
somebody please help me
SamyFarahat
@SamyFarahat
Jun 14 2017 01:55
Do not change code above the line
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:55
@lucky73 oh sorry, i though you did ask another challenge.
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:56
i asked for lookup challenge @forwebtech
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:56
@lucky73 well you need to get the value from lookup table, with val parameter and needs to store it in result
SamyFarahat
@SamyFarahat
Jun 14 2017 01:56
I did everything except the last line
@forwebtech can you help me
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:56
@SamyFarahat well it says assign a to b not b to a, got it ?
William Dayton
@Mortichar
Jun 14 2017 01:57
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";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Sorry for the lengthy post, folks.
Lenarey S. Torririt
@Lengzki
Jun 14 2017 01:57
@forwebtech thanks :)
CamperBot
@camperbot
Jun 14 2017 01:57
lengzki sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 679 | @forwebtech |http://www.freecodecamp.com/forwebtech
SamyFarahat
@SamyFarahat
Jun 14 2017 01:57
@forwebtech I'll try
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 01:57
@Morralito that's essentially the logic of this exercise then?
Lenarey S. Torririt
@Lengzki
Jun 14 2017 01:57
oh sorry
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:57
@Mortichar you shouldn't put contacts array :)
Mohak Chaturvedi
@lucky73
Jun 14 2017 01:57

i am doing it but it says result variable is already declared then i changed the variable but then none of the use case fits here is the code @forwebtech // Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup ={

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

};
var result1=['val'];
result=lookup[result1];

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

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

Cynthia Clinton
@Cynth42
Jun 14 2017 01:57
I need help out here
SamyFarahat
@SamyFarahat
Jun 14 2017 01:58
@forwebtech you're right!
@forwebtech thanks!
CamperBot
@camperbot
Jun 14 2017 01:58
samyfarahat sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 680 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:58
@lucky73 yes because you are redeclaring it as var result1=['val']; so remove that line
@SamyFarahat :+1:
Cynthia Clinton
@Cynth42
Jun 14 2017 01:58
@forwebtech i need help here
William Dayton
@Mortichar
Jun 14 2017 01:58
@forwebtech If you mean for privacy or something, it's the fake one.
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:58
@Mortichar what ?
Anthony Cortez
@Morralito
Jun 14 2017 01:59
@JonathonLLopez take a look
function findLongestWord(str) {
  var cadena = str;
  cadena = cadena.split(" ");
  var stringSizes = [];
  for (var i = 0; i < cadena.length; i++) {
     stringSizes.push(cadena[i].length);
  }
  var hallarMaximo = Math.max(...stringSizes);
  return hallarMaximo;
}
William Dayton
@Mortichar
Jun 14 2017 01:59
@forwebtech I guess you meant for space. :eyes: ``
Aizaz Shahid
@aizazshahid
Jun 14 2017 01:59
@Mortichar i just said it becomes so long that's why.
@Cynth42 paste your code again with formatting.
Cynthia Clinton
@Cynth42
Jun 14 2017 02:01
how do i do paste the code with formatting
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:01
@Mortichar please check the spelling of return statements from instructions.
Mohak Chaturvedi
@lucky73
Jun 14 2017 02:01
@Mortichar @forwebtech thank you i got this one :)
CamperBot
@camperbot
Jun 14 2017 02:01
lucky73 sends brownie points to @mortichar and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 681 | @forwebtech |http://www.freecodecamp.com/forwebtech
:cookie: 268 | @mortichar |http://www.freecodecamp.com/mortichar
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:01
@Cynth42
```
paste your code here
```
Anthony Cortez
@Morralito
Jun 14 2017 02:01
you put it betwern 3 backticks
William Dayton
@Mortichar
Jun 14 2017 02:01
@forwebtech ?
@forwebtech I wasn't asking for help, I was putting it there for someone who was stuck.
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:02
my bad.
William Dayton
@Mortichar
Jun 14 2017 02:02
np :)
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:02
@Mortichar well try to give hints rather giving solutions, it will be more helpful to users.
Cynthia Clinton
@Cynth42
Jun 14 2017 02:03
screen shot the code?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:04
@Cynth42 that's not screen shot, you just need to put ``` backticks while pasting your code, at first line and at last line.
William Dayton
@Mortichar
Jun 14 2017 02:04
@Cynth42 If you put your code with ``` at the top and ``` at the bottom it will format it in chat here, like
this
  which
    makes
      it
        easier
          to
            read
SamyFarahat
@SamyFarahat
Jun 14 2017 02:04
@forwebtech hey
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:05
@SamyFarahat yes ?
SamyFarahat
@SamyFarahat
Jun 14 2017 02:05

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

studlyCapVar is defined and has a value of 10
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:05
@SamyFarahat do you know camel case ?
Cynthia Clinton
@Cynth42
Jun 14 2017 02:05

function mutation(arr) {
//Change both string inputs to lowercase for comparison purposes
var firstWord = arr[0].toLowerCase;
var secWord = arr[1].toLowerCase;
//Using the length of the second word to iterate thru its letters to see if they //contain the same letters
for (var i = 0; i < secWord.length; i++) {
//this checks to see if the letters of the secWord exist in the firstWord
if (firstWord.indexOf(secWord[i]) < 0) {
return false;
}
}
return true;
}

mutation(["hello", "hey"]);

SamyFarahat
@SamyFarahat
Jun 14 2017 02:05
i don't understand
no
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:06

@SamyFarahat

Camel Case: in that case first word should be lower case and after that all words first character should be capitalized as: myVariableName

SamyFarahat
@SamyFarahat
Jun 14 2017 02:07
can you do it for me, that I can look how to do it and apply it again by myself
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:07
@Cynth42 toLowerCase() is a method, you missed () paranthesis.
@SamyFarahat i gave you an example how camel case written, so just change all the variable names with that casing.
Nikolas Pinon
@NikolasP98
Jun 14 2017 02:08
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
don't get this!

function nextInLine(arr, item) {

arr.push(item);
arr.shift();
return item;
}

Cynthia Clinton
@Cynth42
Jun 14 2017 02:09
Oh yes - thank you @forwebtech
CamperBot
@camperbot
Jun 14 2017 02:09
cynth42 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 682 | @forwebtech |http://www.freecodecamp.com/forwebtech
Nikolas Pinon
@NikolasP98
Jun 14 2017 02:09
added the arr.push(item); and arr.shift();
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:09
@NikolasP98 shift also returns the removed element, and you need to return the removed one :)
Nikolas Pinon
@NikolasP98
Jun 14 2017 02:10
@forwebtech so 'return shift'?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:10
@NikolasP98 no, return arr.shift() because it can only be called on arrays.
@NikolasP98 further mdn.io/shift
Nikolas Pinon
@NikolasP98
Jun 14 2017 02:11
thanks, @forwebtech . I'll check the link out
CamperBot
@camperbot
Jun 14 2017 02:11
nikolasp98 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 683 | @forwebtech |http://www.freecodecamp.com/forwebtech
c6c6c
@c6c6c
Jun 14 2017 02:11
function chunk(arr, size) {
arr=arr.join();
arr=arr.split(",");
var lang=Math.ceil(arr.length/size);
var arr1=[];
var k=0;
for(var i=0;i<lang;i++){
var arr2=[];
for(var j=0;j<size;j++){
if(k<arr.length){
var can=arr[k++];
arr2.push(can);
}else{
break;
}
}
arr1.push(arr2);
}
return arr1;
}
chunk(["a", "b", "c", "d"], 2);
求解?哪里出错了,感觉没问题呀?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:12

@c6c6c

:bulb: To format your code, please follow:
```
put your code here
```

More details..

:bulb: To get more commands:
ctrl + shift + m

it will be more readable if you paste it, as formatted.
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:12
function findLongestWord(str) {
  var splitString = str.split('');
  for(var i = 0; i < str.length, i++) {
    splitString.push(str[i].length);
  }
  return str.length;
}
This is what I got so far. Am I missing something?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:13
@JonathonLLopez if you don't put space in split('') then it makes the letter array, but you need a word array.
str = "test test";
str.split('');    // ["t", "e", ... ]

str.split(' ');    // ["test", "test"]
Moisés Man
@moigithub
Jun 14 2017 02:15
split
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:15
oh hahaha yes
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:15
@forwebtech okay that makes sense
I'm still getting errors though
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:15
@moigithub thanks mate :+1:
@JonathonLLopez you are running your loop on the length of str but you need to run it on your array length.
This message was deleted
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:17
@forwebtech So do I need to create a seperate variable and store the array in it?
SamyFarahat
@SamyFarahat
Jun 14 2017 02:18
@forwebtech hey
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:18
@JonathonLLopez no sorry you doing it correct but your loop condition should be correct as i < array.length
SamyFarahat
@SamyFarahat
Jun 14 2017 02:18
I still don't understand how
can you help me?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:18
@SamyFarahat what ?
SamyFarahat
@SamyFarahat
Jun 14 2017 02:19
studlyCapVar is defined and has a value of 10

// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = StUdLyCapVaR.toLowerCase();
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:19
@forwebtech i < splitString.length?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:19
@JonathonLLopez now you have to store the array lengths, here you can make a new array or store it in your previous array because after that you don't need those words :)
@JonathonLLopez yes !
@SamyFarahat just correct all the cases to camelCase as StudlyCapVar
don't re write, you need to correct their cases just.
@SamyFarahat reset your challenge page and then try to correct it.
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:22
@forwebtech this is what I have now:

function findLongestWord(str) {
  var splitString = str.split(' ');
  for(var i = 0; i < splitString.length, i++) {
    splitString.push(str[i].length);
  }
  var newArray = splitString.push(str[i].length);

  return str.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
SamyFarahat
@SamyFarahat
Jun 14 2017 02:22
I cant't, they didn't;t explainthe camelcase
@JonathonLLopez how did you mark that?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:23
@SamyFarahat but i did explain you what is camelcase ? don't you get it ?
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:24
@SamyFarahat what do you mean?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:24
@JonathonLLopez don't push the values to your array you need to reassign the values as arr[i] = your array length

@SamyFarahat

:bulb: To format your code, please follow:
```
put your code here
```

More details..

:bulb: To get more commands:
ctrl + shift + m

veeeeeee
@veeeeeee
Jun 14 2017 02:25
I have a question on the "Using Objects for Lookups" lesson
for the line to assign the value of val to result, the answer I got was result = lookup[val]; --why is it the brackets for [val]?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:27
@veeeeeee that is the notation to access object properties, you have two notations, one is . dot and other one is [] bracket, as dot will not work with parameters, but bracket will work fine with parameters.
CamperBot
@camperbot
Jun 14 2017 02:27
:bulb: to format code use backticks! ``` more info
SamyFarahat
@SamyFarahat
Jun 14 2017 02:28
'''
CamperBot
@camperbot
Jun 14 2017 02:28
:bulb: to format code use backticks! ``` more info
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:28
@SamyFarahat the button is on the left of your key 1
veeeeeee
@veeeeeee
Jun 14 2017 02:28
@forwebtech Thanks! So if I were to rewrite that line with dot notation, it would be result = lookup.val?
CamperBot
@camperbot
Jun 14 2017 02:28
:cookie: 684 | @forwebtech |http://www.freecodecamp.com/forwebtech
veeeeeee sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:bulb: to format code use backticks! ``` more info
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:29
@veeeeeee but then it becomes lookup."someproperty" that will not work
SamyFarahat
@SamyFarahat
Jun 14 2017 02:29
// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;
studlyCapVar is defined and has a value of 10
properCamelCase is defined and has a value of "A String"
titleCaseOver is defined and has a value of 9000
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections.
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:30

function findLongestWord(str) {
  var splitString = str.split(' ');
  for(var i = 0; i < splitString.length; i++) {
    splitString.push(splitString[i].length);
  }
  splitString[i] = splitString.length;

  return str.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
This is where I'm at now and still getting errors
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:30
@SamyFarahat you just need to correct all variable names with camel casing.
veeeeeee
@veeeeeee
Jun 14 2017 02:30
@forwebtech ahh, ok. so to make sure I understand correctly: because the value is a string, I need to use the brackets (since dot notation won't work here)
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:31
@veeeeeee yes ! . only works with direct access like obj.propertyName
and also if your property name has a space, then bracket will be usefull as obj.["prop Name"]
K L Bhanu
@klbm9999
Jun 14 2017 02:32
@JonathonLLopez you are trying to find the longest word right?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:32
@JonathonLLopez why are you pushing your lengths to that array ?
SamyFarahat
@SamyFarahat
Jun 14 2017 02:32
@forwebtech idk how!
can you do it for me?
Anthony Cortez
@Morralito
Jun 14 2017 02:32
@JonathonLLopez create a new empty array to push the strings lengths in to
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:33
@SamyFarahat do you know what is proof reading ?
SamyFarahat
@SamyFarahat
Jun 14 2017 02:33
no
I just started js yet
but the doesn't explain anything
K L Bhanu
@klbm9999
Jun 14 2017 02:33
@JonathonLLopez you dont even need another array, take a variable max=0, in the for loop check if it is larger, if yes, assigns splitstring[i].length to max
SamyFarahat
@SamyFarahat
Jun 14 2017 02:34
they*
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:34
@SamyFarahat suppose i said correct this sentence:
"this is not a sentence correct " how will you do that ?
SamyFarahat
@SamyFarahat
Jun 14 2017 02:34
OK thanks
i am bad in English
sorry
how would you do that?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:35

@SamyFarahat ok just showing you one line,

var StUdLyCapVaR;

should be change to:

var studlyCapVar;

@JonathonLLopez

for(var i = 0; i < splitString.length; i++) {
    splitString[i] = splitString[i].length;
  }

after that you just need to get the longest number from that array.

no need of new array.
veeeeeee
@veeeeeee
Jun 14 2017 02:41
@forwebtech Thanks again!
CamperBot
@camperbot
Jun 14 2017 02:41
veeeeeee sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: veeeeeee already gave forwebtech points
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:42
@veeeeeee :+1:
Joseph
@revisualize
Jun 14 2017 02:43
yo.
meslance
@meslance
Jun 14 2017 02:43
What is an identifier in If Else statements?
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:43
@forwebtech I'm not sure how to go about finding the longest number from the array
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:43
@JonathonLLopez well you can sort the array with ascending so the first element should be the longest.
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:43
I haven't coded in months, so I'm very rusty
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:44
@revisualize :wave:
CreateTheHype
@CreateTheHype
Jun 14 2017 02:44
can someone spot my error?

var count = 0;

function cc(card) {
  // Only change code below this line
 switch (card) {
   case 2:
   case 3:
   case 4:
   case 5:
   case 6:
  return count +1;

  case 7:
  case 8:
  case 9:
  return count +0;

   case 10:
   case 'J':
   case 'Q':
   case 'K':
   case 'A':
     return count -1;
 }
  return count + " " + (count > 0 ? " Bet" : " Hold");
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Anthony Cortez
@Morralito
Jun 14 2017 02:44
  var cadena = str;
  cadena = cadena.split(" ");
  var stringSizes = 0;
  for (var i = 0; i < cadena.length; i++) {
     if ( stringSizes < cadena[i].length){
       stringSizes = cadena[i].length;
     }
  }
  return  stringSizes;
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:44
@CreateTheHype you are missing = operator with +
Dillon Orr
@dillorr
Jun 14 2017 02:45
hello! I'm not sure what I'm doing wrong here for the escape question 145 var myStr = "FirstLine '\n' '\' SecondLine '\' '\r' ThirdLine";
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:45
or you could use -- or ++ with variable.
@dillorr why are you putting quotes in your string.
Dillon Orr
@dillorr
Jun 14 2017 02:46
because I thought it was correct to do so, is the proper syntax \n\?
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:46
@dillorr it should not contain any quotes in string and also space.
@dillorr \ that is a escape character. you need to also print the \ so before the second line and after the second line so remember to escape them also
CreateTheHype
@CreateTheHype
Jun 14 2017 02:47
@forwebtech its still not changing my count
Anthony Cortez
@Morralito
Jun 14 2017 02:48
@JonathonLLopez split the string, iterate over the items in the array and make it store the length of the biggest array in a variable, then return that variable
CreateTheHype
@CreateTheHype
Jun 14 2017 02:48

var count = 0;

function cc(card) {
  // Only change code below this line
 switch (card) {
   case 2:
   case 3:
   case 4:
   case 5:
   case 6:
  return count +=1;

  case 7:
  case 8:
  case 9:
  return count +=0;

   case 10:
   case 'J':
   case 'Q':
   case 'K':
   case 'A':
     return count -=1;
 }
  return count + " " + (count > 0 ? " Bet" : " Hold");
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:48
@CreateTheHype don't use return in switch block
@CreateTheHype mdn.io/switch
Nicholas Brown
@znicholasbrown
Jun 14 2017 02:51
looking for some feedback on the final front end project: https://codepen.io/znicholasbrown/full/YQzgbO/
Dillon Orr
@dillorr
Jun 14 2017 02:53
what's the best way to include a shot of the code like @CreateTheHype just did?
Nicholas Brown
@znicholasbrown
Jun 14 2017 02:53
@dillorr copy and paste it with ``` before and after the code (on their own lines)
CreateTheHype
@CreateTheHype
Jun 14 2017 02:53

Dillon Orr
@dillorr
Jun 14 2017 02:54
'''
CamperBot
@camperbot
Jun 14 2017 02:54
:bulb: to format code use backticks! ``` more info
CreateTheHype
@CreateTheHype
Jun 14 2017 02:54
@forwebtech thx man. i think I'm headed in the right direction
CamperBot
@camperbot
Jun 14 2017 02:54
createthehype sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 685 | @forwebtech |http://www.freecodecamp.com/forwebtech
Dillon Orr
@dillorr
Jun 14 2017 02:54
var myStr = "FirstLine\n\\SecondLine\\\\rThirdLine"; // Change this line
Still having trouble with this assignment, not sure what I'm supposed to be doing exactly
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:55
@dillorr \r here r is already escaped so remove one backslash from it.
Dillon Orr
@dillorr
Jun 14 2017 02:55
thanks @forwebtech !
CamperBot
@camperbot
Jun 14 2017 02:55
dillorr sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 686 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:56
@dillorr :+1:
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:57

function findLongestWord(str) {
  var splitString = str.split(' ');
  var max = 0;
  for(var i = 0; i < splitString.length; i++) {
    if(max < splitString.length) {
      max = splitString.length;
    }
  }
  return max;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Close, but no cigar
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:58
@JonathonLLopez you are accessing array element so use bracket arr[i]
Haseeb Arshad
@haseebuchiha
Jun 14 2017 02:58

`
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0; i<multiplyAll.lenght; i++){
for(var j=0; j<multiplyAll[i].length; j++){
product *= multiplyAll[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]]);

`

Aizaz Shahid
@aizazshahid
Jun 14 2017 02:58
@JonathonLLopez logic is good :)
Haseeb Arshad
@haseebuchiha
Jun 14 2017 02:58
this keeps returning one instead of multiplying the sub arrays
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:59
@forwebtech -__- I feel dumb
Totally knew that
Aizaz Shahid
@aizazshahid
Jun 14 2017 02:59
@haseebuchiha you need three backticks ```
CreateTheHype
@CreateTheHype
Jun 14 2017 02:59
logic Kappa
slertka
@slertka
Jun 14 2017 02:59
var Bike = function() {

  // Only change code below this line.
var gear;

  this.getGear = function(gear) {
    return gear;
  };
  this.setGear = function(gear) {
    return gear;
  };
};
Haseeb Arshad
@haseebuchiha
Jun 14 2017 02:59
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i=0; i<multiplyAll.lenght; i++){
    for(var j=0; j<multiplyAll[i].length; j++){
      product *= multiplyAll[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]]);
@forwebtech finally xD
slertka
@slertka
Jun 14 2017 02:59
i'm stuck here -- can't figure out how to setGear/getGear as public method
Joseph
@revisualize
Jun 14 2017 02:59
@slertka Why is setGear only returning gear?
Jonathon Lopez
@JonathonLLopez
Jun 14 2017 02:59
@forwebtech @Morralito thank you for your help
CamperBot
@camperbot
Jun 14 2017 02:59
jonathonllopez sends brownie points to @forwebtech and @morralito :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @morralito |http://www.freecodecamp.com/morralito
:cookie: 687 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:00
@haseebuchiha multiplyAll is your function name not array.
Joseph
@revisualize
Jun 14 2017 03:00
@slertka How do you set a variable?
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:00
@forwebtech nnnnnnnnnnnnnnooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:00
@haseebuchiha also you have typo use arr.length
CreateTheHype
@CreateTheHype
Jun 14 2017 03:00
i think just var example;
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:00
@forwebtech how could I be so stupid :(
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:00
@haseebuchiha its ok !
Gurpreet SIngh
@Gurpreet3131
Jun 14 2017 03:00
any mongodb user here?
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:00
@forwebtech thanks dude
CamperBot
@camperbot
Jun 14 2017 03:00
haseebuchiha sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 688 | @forwebtech |http://www.freecodecamp.com/forwebtech
slertka
@slertka
Jun 14 2017 03:01
@revisualize using var?
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:02

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i=0; i<arr.lenght; 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]]);
CreateTheHype
@CreateTheHype
Jun 14 2017 03:02
@haseebuchiha @Gurpreet3131 @forwebtech @revisualize @JonathonLLopez @slertka @dillorr thx for being a great community
CamperBot
@camperbot
Jun 14 2017 03:02
createthehype sends brownie points to @haseebuchiha and @gurpreet3131 and @forwebtech and @revisualize and @jonathonllopez and @slertka and @dillorr :sparkles: :thumbsup: :sparkles:
:cookie: 311 | @jonathonllopez |http://www.freecodecamp.com/jonathonllopez
:cookie: 229 | @slertka |http://www.freecodecamp.com/slertka
:cookie: 218 | @haseebuchiha |http://www.freecodecamp.com/haseebuchiha
:cookie: 192 | @gurpreet3131 |http://www.freecodecamp.com/gurpreet3131
:cookie: 150 | @dillorr |http://www.freecodecamp.com/dillorr
:star2: 4157 | @revisualize |http://www.freecodecamp.com/revisualize
:warning: createthehype already gave forwebtech points
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:02
@forwebtech still having issues
len lee
@45lenlee
Jun 14 2017 03:02
hey can anyone help me out with this function: I'm trying to get the biggerst number but the output is 8 instead of 10

function my_max(arr) {
var x = 0;
for(var i = 0; i < arr.length; i++){
if (arr[i] > x) {
x = arr[i];
}
}
return x;
}

console.log(my_max(["3", "4", "10", "8"]))

Aizaz Shahid
@aizazshahid
Jun 14 2017 03:02
@haseebuchiha code ?
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:03

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i=0; i<arr.lenght; 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]]);
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:03
@haseebuchiha you have typo in the condition of first loop.
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:03
@forwebtech NNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!
Joseph
@revisualize
Jun 14 2017 03:03
@slertka Don't over complicate the question
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:03
@forwebtech What is wrong with me :(
Joseph
@revisualize
Jun 14 2017 03:04
@slertka Let's say there is already a variable declared.
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:04
@haseebuchiha i think you have spent too much time :) so take rest.
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:04
@forwebtech thanks dude. You the best
CamperBot
@camperbot
Jun 14 2017 03:04
haseebuchiha sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: haseebuchiha already gave forwebtech points
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:04
@haseebuchiha :+1:
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:04
@forwebtech Some more and then maybe :D
slertka
@slertka
Jun 14 2017 03:05
@revisualize thanks -- figured it out! major brain fart
CamperBot
@camperbot
Jun 14 2017 03:05
slertka sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4158 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 14 2017 03:05
@slertka It's all good.
Addison
@addisonday
Jun 14 2017 03:10

var myVar = 87;

// Only change code below this line
myVar = myVar++;
Not sure how to increment to 88
MidnightAria
@MidnightAria
Jun 14 2017 03:10
function fun1();
// Assign 5 to oopsGlobal Here
Sorry, let me retype with markdown.
Joseph
@revisualize
Jun 14 2017 03:11

@addisonday

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

MidnightAria
@MidnightAria
Jun 14 2017 03:12
function fun1();
  // Assign 5 to oopsGlobal Here
Joseph
@revisualize
Jun 14 2017 03:12
@MidnightAria The ; is the statement terminator.
MidnightAria
@MidnightAria
Jun 14 2017 03:12
Super basic question - any ideas how to 'assign' a value to 'oopsGlobal'?
Joseph
@revisualize
Jun 14 2017 03:13
@MidnightAria This is how you make a function:
function functionName(parameterValue) {


}
Austin Butler
@theaustin
Jun 14 2017 03:13
What's wrong here? It wants me to add the 2nd argument to the end, then pop the first argument off.

function nextInLine(arr, item) {
var myArray = [1,2,3];
nextInLine(myArray, 4);
myArray.push(4);
var poppedFromMyArray = myArray.pop();

return poppedFromMyArray; // Change this line
}

MidnightAria
@MidnightAria
Jun 14 2017 03:13
@revisualize Thank you so much <3
CamperBot
@camperbot
Jun 14 2017 03:13
midnightaria sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4159 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 14 2017 03:13
@theaustin That isn't correct.
meslance
@meslance
Jun 14 2017 03:13
What is an identifier in an Else If statement?
Austin Butler
@theaustin
Jun 14 2017 03:14
What needs to be fixed?
Joseph
@revisualize
Jun 14 2017 03:14
@theaustin A lot
@theaustin Reset the challenge and read this:
https://gist.github.com/revisualize/ced4a3a6611c6c74bcab34a07eaa4ebf
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:14
@theaustin you are calling your function within that function. and why are you making new array as you have passed array as arguments.
Joseph
@revisualize
Jun 14 2017 03:15
@theaustin By having the recursive function call within the function like you do. Your function isn't ever going to stop.
@theaustin I suggest resetting the challenge and starting over. Then read what I linked
Austin Butler
@theaustin
Jun 14 2017 03:16
@forwebtech Considering the comment is Test Setup above the array already there, along with no word to use that array, not sure how I'm supposed to know to use that array
@revisualize Thank you
CamperBot
@camperbot
Jun 14 2017 03:16
theaustin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4160 | @revisualize |http://www.freecodecamp.com/revisualize
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:16
@theaustin you just need to use parameters arr and item
@theaustin that challenge also tries to teach, how to use the functions to modify the array, by passing the reference to the functions.
verdandi28
@verdandi28
Jun 14 2017 03:19
Could someone help me with this line of code? (learning about switch statments) function chainToSwitch(val) { var answer = "";
What does (val) mean and then what does it mean when the variable answer = ""?
Joseph
@revisualize
Jun 14 2017 03:19
@verdandi28 What do you need help
@verdandi28 Okay.
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:20
@verdandi28 that is a parameter, where we pass the value as argument when calling that function. it stores the value like
foo( "some value" ) that string can be accessed with val
Joseph
@revisualize
Jun 14 2017 03:20

@verdandi28
If I have this code:

function addThree (num) { }

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
If you then make another function call..

addThree(39);

You can use the same function to follow the operation:
When we do addThree(39) then the value of the parameter num is passed the argument value of ... 39

If you make the function call of addThree(21) the value of num inside the function is 21.
If you make the function call of addThree(1000) the value of num inside the function is 1000.
If you make the function call of addThree(123456) the value of num inside the function is 123456.

eldarmammadov
@eldarmammadov
Jun 14 2017 03:21
@twindual Thanks
Joseph
@revisualize
Jun 14 2017 03:21
@verdandi28 var answer = ""; ... That's just creating a variable local to the function.
eldarmammadov
@eldarmammadov
Jun 14 2017 03:21
worked at end
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:21
@verdandi28 further read http://mdn.io/parameters
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:24

function bouncer(arr) {
// Don't show a false ID to this bouncer.
var falseArray = [false, null ,0,"",undefined,NaN];
var newArray =[];
for(var i=0; i <arr.length;i++){
if(arr[i] !== null){
if (falseArray.indexOf(arr[i]) === -1){
newArray.push(arr[i]);
}
}
}
return newArray;
}

bouncer([7, "ate", "", false, 9]);
bouncer([false, 0, NaN, undefined, ""]);
bouncer([1, null, NaN, 2, undefined]);

hi I wonder how can I get rid of null ???
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:24

@sonnguyen2603 it will be help ful if paste as formatted:

:bulb: To format your code, please follow:
```
put your code here
```

More details..

:bulb: To get more commands:
ctrl + shift + m

VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:25
Palindrome test. Unable to remove ' '. Have tried str.replace(/\W^\s/gi, '');
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 14 2017 03:25
Which books should I study for jquery
Long Nguyen
@longnt80
Jun 14 2017 03:25
@VinayVijayJoshi test your regexp here http://regexr.com/
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:26
@VinayVijayJoshi use bracket in your regex, /[\W\s]/g
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:26
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var falseArray = [false, null ,0,"",undefined,NaN];
  var newArray =[];
  for(var i=0; i <arr.length;i++){
    if(arr[i] !== null){
    if (falseArray.indexOf(arr[i]) === -1){
      newArray.push(arr[i]);
      }
    }
  }
  return newArray;
}

bouncer([7, "ate", "", false, 9]);
bouncer([false, 0, NaN, undefined, ""]);
bouncer([1, null, NaN, 2, undefined]);
so I wonder how can I get rid of null
verdandi28
@verdandi28
Jun 14 2017 03:26
@forwebtech @revisualize Thank you!
CamperBot
@camperbot
Jun 14 2017 03:26
verdandi28 sends brownie points to @forwebtech and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 689 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 4161 | @revisualize |http://www.freecodecamp.com/revisualize
Tatwamsiddha
@Tatwamsiddha-Nanda
Jun 14 2017 03:26
Anyone?
meslance
@meslance
Jun 14 2017 03:27

  if (par, 1){
    return "Hole-in-one!";
  } else if (par, <= par-2){
    return "eagle";
  } else if (par, par-1){
    return "Birdie";
  } else if (par, par) {
    return "Par";
  } else if (par, par+1){
    return "Bogey";
  } else if (par, par +2) {
    return "Double Bogey";
  } else if (par, >=par+3){
    return "Go Home!";
  }

}
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:27

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


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

    }
    else {
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "likes");
Long Nguyen
@longnt80
Jun 14 2017 03:27
@VinayVijayJoshi you don't need ^\s because \W target the spaces also
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:27
keeps returning the else statement. It doesn't even go through the if statement
Long Nguyen
@longnt80
Jun 14 2017 03:28
@VinayVijayJoshi \W: non-word characters
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:28
@haseebuchiha
Here's an outline, if you follow it step-wise it'll help a great deal in telling you what to do or step you missed
1. you need a loop to pick each objects in the contacts array
    1.1  in the loop you need to 
         1.1.1  check if the objects picked has the firstName property equal to the firstName parameter
                  1.1.1.1 you need to check if it has a property prop
                                  return the value of prop in the object
                 1.1.1.2  return no such property if  1.1.1.1 is false
2.  when your loop is done looking through  contacts return no such contact
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:28
@haseebuchiha because return stops the function immediately by returning the statement.
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:28
@longnt80 I tried not resolving
palindrome("race car") should return true.
meslance
@meslance
Jun 14 2017 03:28
Can someone point out my error for the Golf Code exercise?
Shivam Mishra
@codifiedzio
Jun 14 2017 03:29
Add the number to the end of the array, then remove the first element of array.
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:29
@VinayVijayJoshi and \W does not contain underscore _ so add it into your regex [\W_]
Shivam Mishra
@codifiedzio
Jun 14 2017 03:29
how to perform this??
Aakash Bhusal
@aakashbhusal7
Jun 14 2017 03:29
var myStr="My name is Aakash\n I am awesome \r hey \this is me\a";
problem: myStr should have encoded text with the proper escape sequences and no spacing.
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:29
@haseebuchiha moreover prop is a parameter, use bracket notation to access the object contacts[i] with it
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:29
@codifiedzio see mdn.io/shift and mdn.io/push
Long Nguyen
@longnt80
Jun 14 2017 03:29
@VinayVijayJoshi str.replace(/\W/g, "");
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:29
@aakashbhusal7 use the string given on FCC
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:30
@longnt80 he also need to remove the underscore, so, str.replace(/[\W_]/g, "")
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:30
@codifiedzio you need 2 array methods, push and shift
Long Nguyen
@longnt80
Jun 14 2017 03:30
@VinayVijayJoshi you also need to convert the original string to 2 strings:
  • One in normal direction
  • One in reversed direction
    Then compare them
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:31
@longnt80 below is my code. Not helping with ' ' or
function palindrome(str) {
// Good luck!
str = str.toLowerCase();
str.replace(/\W
/gi, '');
console.log("####" + str);
var rstr = "";
for (i = str.length-1; i>=0 ; i--) {
rstr += str[i];
}
if (str == rstr) {
return true;
} else {
return false;
}
}
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:31
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var falseArray = [false, null ,0,"",undefined,NaN];
  var newArray =[];
  for(var i=0; i <arr.length;i++){
    if(arr[i] !== null){
    if (falseArray.indexOf(arr[i]) === -1){
      newArray.push(arr[i]);
      }
    }
  }
  return newArray;
}

bouncer([7, "ate", "", false, 9]);
bouncer([false, 0, NaN, undefined, ""]);
bouncer([1, null, NaN, 2, undefined]);
Can anyone help me how to get rid of null please?
Long Nguyen
@longnt80
Jun 14 2017 03:31
@VinayVijayJoshi :point_up: June 14, 2017 10:30 AM
Ravi Kishore Thella
@ravikishorethella
Jun 14 2017 03:31
@VinayVijayJoshi that regex will not help you to pass the challenge
@VinayVijayJoshi use this regex /[\W_]/g
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:32
@ravikishorethella he pointing to the correct one :)
Ravi Kishore Thella
@ravikishorethella
Jun 14 2017 03:33
@forwebtech I meant the regex which he used in his code. :smile:
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:34
@ravikishorethella /[\W_]/g does not work
wiljeamps Saint-louis
@TooClutch
Jun 14 2017 03:34
need help with celsius converting problem here is the code

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

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

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

VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:34
have posted my code
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:34
@sonnguyen2603 you can use filter method to filter out the falsy values.
Long Nguyen
@longnt80
Jun 14 2017 03:34
@VinayVijayJoshi it does, your logic after it is what makes it not working
Brew
@cooltactician
Jun 14 2017 03:34
@forwebtech Can you tell me what the "RangeError: Maximum call stack size exceeded " means?
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:35
@longnt80 let me have a look again
wiljeamps Saint-louis
@TooClutch
Jun 14 2017 03:35
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Ravi Kishore Thella
@ravikishorethella
Jun 14 2017 03:35
@VinayVijayJoshi that regex should work . I think you messed up with the code
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:35
@cooltactician i think it happens due to lots of recursion.
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:35
@forwebtech how exactly can I use that? can you explain more please?
meslance
@meslance
Jun 14 2017 03:35
Have tried rearranging my code for Golf Code and still having the same errors. Help?
Moisés Man
@moigithub
Jun 14 2017 03:35
@VinayVijayJoshi replace return a NEW string.. u not doing anything with it
u probably should store it somewhere
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:36

@sonnguyen2603

arr.filter( (val) => val );

or

arr.filter( function(val) {
  return val;
});
Ravi Kishore Thella
@ravikishorethella
Jun 14 2017 03:36
@TooClutch var fahrenheit=9/5 +32; Don't you think you are missing celsius here
var fahrenheit = (celsius * 9/5) + 32;
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:37
@sonnguyen2603 filter will take care of the wrong values.
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:37
@forwebtech oh okay thank you
CamperBot
@camperbot
Jun 14 2017 03:37
sonnguyen2603 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 690 | @forwebtech |http://www.freecodecamp.com/forwebtech
Duffy125
@Duffy125
Jun 14 2017 03:38

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

I feel that the product should be arr?
Long Nguyen
@longnt80
Jun 14 2017 03:38
@sonnguyen2603 with your method, the only one which escape your test is the NaN
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:38
@Duffy125 multiplyAll is your function name use arr[i][j]
Long Nguyen
@longnt80
Jun 14 2017 03:38
you should have special case for it
wiljeamps Saint-louis
@TooClutch
Jun 14 2017 03:39
@ravikishorethella thank you sorry im not very intelligent
CamperBot
@camperbot
Jun 14 2017 03:39
tooclutch sends brownie points to @ravikishorethella :sparkles: :thumbsup: :sparkles:
:cookie: 530 | @ravikishorethella |http://www.freecodecamp.com/ravikishorethella
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:39
@longnt80 null is the one that escaped my test, and I don't how to right the special case for it
Brew
@cooltactician
Jun 14 2017 03:39
@forwebtech thanks
CamperBot
@camperbot
Jun 14 2017 03:39
cooltactician sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 691 | @forwebtech |http://www.freecodecamp.com/forwebtech
Long Nguyen
@longnt80
Jun 14 2017 03:39
@sonnguyen2603 no it's NaN
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:39
@cooltactician :+1:
Ravi Kishore Thella
@ravikishorethella
Jun 14 2017 03:40
@TooClutch :+1:
Long Nguyen
@longnt80
Jun 14 2017 03:40
@sonnguyen2603 check your final arr newArray
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:40
btw, how to post screenshot, it says error uploading file in chat
Kaustubh Mishal
@kaustubhmishal
Jun 14 2017 03:40

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

testArr.push(item);
var removedItem = testArr.shift();
return removedItem;
}

// 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));

Aizaz Shahid
@aizazshahid
Jun 14 2017 03:40

@VinayVijayJoshi that's not screen shot its formatting

:bulb: To format your code, please follow:
```
put your code here
```

More details..

:bulb: To get more commands:
ctrl + shift + m

@kaustubhmishal you are using global array so what's the use of arguments that you pass ? or the parameter ?
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:41
@longnt80 so how can I write the special case for it ?
Long Nguyen
@longnt80
Jun 14 2017 03:41
@sonnguyen2603 https://repl.it/ISo5/5
Kaustubh Mishal
@kaustubhmishal
Jun 14 2017 03:41
am getting crossamark here "nextInLine([5,6,7,8,9], 1) should return 5"
Long Nguyen
@longnt80
Jun 14 2017 03:42
@sonnguyen2603 click Run
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:42
something is a miss
my code
'
function palindrome(str) {
// Good luck!
str = str.toLowerCase();
console.log("@@@@" + str);
str = str.replace(/\W_/g, '');
console.log("####" + str);
var rstr = "";
for (i = str.length-1; i>=0 ; i--) {
rstr += str[i];
}
if (str == rstr) {
return true;
} else {
return false;
}
}
'
Long Nguyen
@longnt80
Jun 14 2017 03:42

@sonnguyen2603

@longnt80 so how can I write the special case for it ?

use isNaN https://www.w3schools.com/jsref/jsref_isnan.asp

VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:43
console output
@@@@_eye
VM11516 check-for-palindromes:8 ####_eye
Andrea Mammoliti
@AndreusSH
Jun 14 2017 03:43
Hi evertyone, I don't understand the exercise Stand in Line
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

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

return item; // Change this line
}

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

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

does nyone can help to understand this?
Manish Giri
@Manish-Giri
Jun 14 2017 03:43
@kaustubhmishal use arr not testArr.
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:43
@AndreusSH you need an array method to add a value to the end of the array
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:43
@AndreusSH you need to add the item to arr with push mdn.io/push and then returns the removed element with shift mdn.io/shift
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:44
'''
function palindrome(str) {
// Good luck!
str = str.toLowerCase();
console.log("@@@@" + str);
str = str.replace(/\W_/g, '');
console.log("####" + str);
var rstr = "";
for (i = str.length-1; i>=0 ; i--) {
rstr += str[i];
}
if (str == rstr) {
return true;
} else {
return false;
}
}
'''
CamperBot
@camperbot
Jun 14 2017 03:44
:bulb: to format code use backticks! ``` more info
sonnguyen2603
@sonnguyen2603
Jun 14 2017 03:44
@longnt80 That's kind of weird because when I am doing the Falsy Bouncer in Freecodecamp it showed me null is the one that escaped not NaN so it's quite confusing about that
Long Nguyen
@longnt80
Jun 14 2017 03:44
@sonnguyen2603 try to do it yourself, if you're stuck, come back here
@sonnguyen2603 did you check the repl.it
it's NaN
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:45
@AndreusSH you also need an array method to remove the first element in the array, so push item to arr and remove the first element in arr
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:45
function palindrome(str) {
  // Good luck!
  str = str.toLowerCase();
  console.log("@@@@" + str);
  str = str.replace(/\W_/g, '');
  console.log("####" + str);
  var rstr = "";
  for (i = str.length-1; i>=0 ; i--) {
    rstr += str[i];
  }
  if (str == rstr) {
    return true;
  } else {
    return false;
  } 
}
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:45
@Manish-Giri ggggggggggggm :smiling_imp:
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:45
finally was able to post in code mode :)
but my issue remains
madeep
@madib
Jun 14 2017 03:45
guys help with this! it just won't..```
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:45
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i=0; i<contacts.length ; i++){
    if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)){
      return prop;

    }
  }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "likes");
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:46
@VinayVijayJoshi you need to correct you regex /[\W_]/g that is a character class [ ]
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:46
@Lumexralph Followed your instructions and got to here but I can't understand how to access the value of the prop
madeep
@madib
Jun 14 2017 03:46
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

var propName = "";

for(var i = 0; i < contacts.length; i++){
  if(firstName == contacts[i].firstName)
    {

      propName = contacts[i][prop];
    }

  return propName;

  }
// Only change code above this line
}
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:47
@forwebtech that did it, what did it change :+1:
madeep
@madib
Jun 14 2017 03:47
help guys, cant get it...
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:47
@VinayVijayJoshi it actually search for the letters not whole words one by one with character class.
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:48
@forwebtech oh, thanks a lot...
CamperBot
@camperbot
Jun 14 2017 03:48
vinayvijayjoshi sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 692 | @forwebtech |http://www.freecodecamp.com/forwebtech
intervolver
@intervolver
Jun 14 2017 03:49
could anyone help me with pulling json from an api using jquery?
Andrea Mammoliti
@AndreusSH
Jun 14 2017 03:49
@Lumexralph ok, sure thanks. How about item? Should I create a variable item or is referring to an element of the array?
CamperBot
@camperbot
Jun 14 2017 03:49
andreussh sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1930 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ragnar
@raggy833
Jun 14 2017 03:49
Hey all, howcome my code doesnt work? Thought this should be good...
switch (answer){
case 1:
case 2:
case 3:
answer = "Low";
break;
case 4:
case 5:
case 6:
answer = "Mid";
break;
case 7:
case 8:
case 9:
answer = "High";
break;
}
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:50
@haseebuchiha no need of caching or storing anything in the propName variable, just return contacts[i][prop]but you still need to check if the property/key held by theprop parameter is property of the object, that will be your second check which is nested into the first conditional statement
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:50
sorry, my mistake.
@VinayVijayJoshi
why don't you short your code as:
str = str.toLowerCase().replace( ....
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:51
@AndreusSH item already exist it's a parameter(like a local variable) in the function
@raggy833 do you have a function?
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:51
@forwebtech good one
Kaustubh Mishal
@kaustubhmishal
Jun 14 2017 03:52
function nextInLine(arr, item) {
  // Your code here

   testArr.push(item);
  var removedItem = testArr.shift();
  return removedItem;
}

// 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));
`
missing this outputnextInLine([5,6,7,8,9], 1) should return 5
Ragnar
@raggy833
Jun 14 2017 03:52

@Lumexralph

function sequentialSizes(val) {
var answer = "";
// Only change code below this line
switch (answer){
case 1:
case 2:
case 3:
answer = "Low";
break;
case 4:
case 5:
case 6:
answer = "Mid";
break;
case 7:
case 8:
case 9:
answer = "High";
break;
}

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

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

Ogundele Olumide
@Lumexralph
Jun 14 2017 03:53
@kaustubhmishal don't use testArr use arr holding the array for the function
@raggy833 what are you to do from the instruction?
intervolver
@intervolver
Jun 14 2017 03:54
could anyone help me with pulling json from an api using jquery?
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:54

@VinayVijayJoshi also just return:

return str === rstr;

because that condition will return the true or false

VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:54
@forwebtech will try, btw "==" passed the challenge
Kaustubh Mishal
@kaustubhmishal
Jun 14 2017 03:55
@Lumexralph @Manish-Giri helped :)
Ragnar
@raggy833
Jun 14 2017 03:55
@Lumexralph
Write a switch statement to set answer for the following ranges:
1-3 - "Low"
4-6 - "Mid"
7-9 - "High"
Thought this code should be good but doesnt work for some reason...
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:55
@VinayVijayJoshi yes it will pass with == but === that is a strict equallity checking.
VinayVijayJoshi
@VinayVijayJoshi
Jun 14 2017 03:55
@forwebtech yup
Junou Cui
@FIRESTROM
Jun 14 2017 03:55
Hi guys, any hint for the Seek and Destroy problem?
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:56
@FIRESTROM any code did you come up ?
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:56
@raggy833 what error are you getting?
Junou Cui
@FIRESTROM
Jun 14 2017 03:56
I'm still thinking about it...I'm actually trying to use filter to delete all elements that I should
But there must be several filter functions
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:57
yes you can use it
marsmag
@marsmag
Jun 14 2017 03:57
Hi everybody, Im trying to pass this challenge and I can't figure out whats wrong, I review the example and did it exactly the same, any thoughts?

// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

intervolver
@intervolver
Jun 14 2017 03:57
@FIRESTROM what problem are you having with seek and destroy?
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:57
@raggy833 oh! your switch(expression) should check for value stored in val not answer
Junou Cui
@FIRESTROM
Jun 14 2017 03:57
because there are more than one elements that I should delete
Ragnar
@raggy833
Jun 14 2017 03:58
@Lumexralph
omg, silly mistake. Thank you!! :)
CamperBot
@camperbot
Jun 14 2017 03:58
raggy833 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1931 | @lumexralph |http://www.freecodecamp.com/lumexralph
Junou Cui
@FIRESTROM
Jun 14 2017 03:58
And then I tried to use loop, but it says functions shouldn't be in the loop..
Aizaz Shahid
@aizazshahid
Jun 14 2017 03:58
@FIRESTROM every function has arguments array type object, which stores the arguments, try to console it in your funciton console.log(arguments).
Haseeb Arshad
@haseebuchiha
Jun 14 2017 03:58
```

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


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

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "likes");
@Lumexralph Still having problems. Can't really seem to get my head around the false check
Ogundele Olumide
@Lumexralph
Jun 14 2017 03:59
@marsmag you can't mutate a string you can only return or process a new form of it, remove the remaining 2 lines below your code
Manish Giri
@Manish-Giri
Jun 14 2017 03:59
@marsmag myStr[0] = "H"; // Fix Me - delete this line
@Lumexralph :smiling_imp: ggggggm
:sun_with_face:
marsmag
@marsmag
Jun 14 2017 04:00
@Lumexralph and @Manish-Giri thank you!! I'll try that!
CamperBot
@camperbot
Jun 14 2017 04:00
marsmag sends brownie points to @lumexralph and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 1932 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 5979 | @manish-giri |http://www.freecodecamp.com/manish-giri
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:00
@marsmag strings are immutable as the strings parts can't be change directly but it can be change as whole.
madeep
@madib
Jun 14 2017 04:00
guys a littlehelp with Profile lookup...
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line

var propName = "";

for(var i = 0; i < contacts.length; i++){
  if(firstName == contacts[i].firstName && contacts.hasOwnProperty(prop))
    {
      propName = contacts[i][prop];
      return propName;

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

// Change these values to test your function
lookUpProfile("Akira", "likes");
Ogundele Olumide
@Lumexralph
Jun 14 2017 04:00
@haseebuchiha if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) the second condition should be nested to the first
Junou Cui
@FIRESTROM
Jun 14 2017 04:00
@forwebtech then I get the list..which is the first element
verdandi28
@verdandi28
Jun 14 2017 04:00
Could someone tell me why this code isn't returning the value of property Pony?
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {

if (myObj.hasOwnProperty(checkProp) == 'true') {
  return myObj[checkProp];
} else return "Not Found";
}


// Test your code by modifying these values
checkObj('pony');
Ogundele Olumide
@Lumexralph
Jun 14 2017 04:01
@Manish-Giri yesterday was super stressful and annoying for me, still is
Maximino V. Jardin III
@ma5one1
Jun 14 2017 04:01
function titleCase(str) {
str = str.toLowerCase().split(' ');
for (var i = 0; i < str.length; i++) {
str[i] = str[i].charAt(0).toUpperCase() + str[i].slice(1);
}
return str.join(' ');
}
titleCase("I'm a little tea pot"); // can someone explain why the method needs to be declared .toLowerCase when you could just use .toUpperCase(). ???? Im not conecting with this solution. HALP.
Junou Cui
@FIRESTROM
Jun 14 2017 04:01
I should also get the rest numbers to filter
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:01
@FIRESTROM well you can store all the arguments with Array.from(arguments) and then remove the first element with arrName.shift()
intervolver
@intervolver
Jun 14 2017 04:01
@FIRESTROM two hints: you can put all the arguments after the array into their own array by slicing them like this: var newArray = Array.prototype.slice.call(arguments,1), and you can run .filter on arr to do everything you need at once - filter is an iterator
Haseeb Arshad
@haseebuchiha
Jun 14 2017 04:02
@Lumexralph YOU DA BEST !!! THANK YOU !!
CamperBot
@camperbot
Jun 14 2017 04:02
haseebuchiha sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1933 | @lumexralph |http://www.freecodecamp.com/lumexralph
Brew
@cooltactician
Jun 14 2017 04:02

@forwebtech


function golfScore(par, strokes) {
  // Only change code below this line
  if (golfScore(4,1)){
    return "Hole-in-one!";
  }
  else if (golfScore(4,2 || 5,2)){
    return "Eagle";

  }
  else if (golfScore(4,3)){
    return "Birdie";
  }
  else if (golfScore(4,4 || 5,5)){
    return "Par";
  }
  else if (golfScore(1,1)){
    return "Hole-in-one!";
  }

  else if (golfscore(4,5)){
    return "Bogey";
  }
  else if (golfScore(4,6)){
    return "Double Bogey";
  }
  else if (golfScore(4,7 || 5,9)){
    return "Go Home!";
  }


  else

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

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

Can you help me fix my error? I have tried to alter the else statement, but it hasn't had any effect.

madeep
@madib
Jun 14 2017 04:02
got it!!!
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:02

@FIRESTROM you can get :

var newArray = Array.from(arguments);

or

var newArray = [...arguments];
Ogundele Olumide
@Lumexralph
Jun 14 2017 04:02
@verdandi28 true is a boolean in JS not string remove it or remove the quotes
Junou Cui
@FIRESTROM
Jun 14 2017 04:03
@intervolver Do u mean that I can actually filter all elements in a list?
intervolver
@intervolver
Jun 14 2017 04:03
@forwebtech that way will also include arguments[0]
verdandi28
@verdandi28
Jun 14 2017 04:03
@Lumexralph Thank you!!!!
CamperBot
@camperbot
Jun 14 2017 04:03
verdandi28 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1934 | @lumexralph |http://www.freecodecamp.com/lumexralph
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:03
@intervolver yes he can remove the first element in that case.
Ogundele Olumide
@Lumexralph
Jun 14 2017 04:03
@verdandi28 i'll say remove comparing the result to boolean true cos the hasOwnProperty method returns a boolean already and if will check that
Junou Cui
@FIRESTROM
Jun 14 2017 04:04
I know how to get the arguments lol, I just don't know how to filter it one by one
intervolver
@intervolver
Jun 14 2017 04:04
@FIRESTROM to filter multiple elements at once, you can use .indexOf()
Junou Cui
@FIRESTROM
Jun 14 2017 04:05
oh I forget about that
Dhernandez25
@Dhernandez25
Jun 14 2017 04:05
Can anyone help me please: A should be assigned to B with =
Junou Cui
@FIRESTROM
Jun 14 2017 04:05
Thanks!
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:05
@FIRESTROM well so make a condition in filter callback method or use .indexOf() as @intervolver told.
intervolver
@intervolver
Jun 14 2017 04:07
@FIRESTROM so that for each index in arr, indexOf can check if any of the numbers are in it, and if the result is ===-1, filter will get true
@intervolver just remember, it's the remaining arguments you want to be taking an index of
is anyone here familiar with using jquery to grab json from an api?
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:10
@intervolver yes ?
intervolver
@intervolver
Jun 14 2017 04:12
@forwebtech I was going to ask someone to take a look at my function, but someone in help just gave me a different api url that worked
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:12
good :+1:
sonnguyen2603
@sonnguyen2603
Jun 14 2017 04:13
can anyone help me how to show the Falsy Bouncer problem please
*solve
Brew
@cooltactician
Jun 14 2017 04:14
@Lumexralph I am trying to fix my RangeError in the Golf Code challenge. I have tried altering my else statement in a variety of ways, but the error remains the same. I also combined some of the statements with an or operator. The error still remains.

function golfScore(par, strokes) {
  // Only change code below this line
  if (golfScore(4,1)){
    return "Hole-in-one!";
  }
  else if (golfScore(4,2 || 5,2)){
    return "Eagle";

  }
  else if (golfScore(4,3)){
    return "Birdie";
  }
  else if (golfScore(4,4 || 5,5)){
    return "Par";
  }
  else if (golfScore(1,1)){
    return "Hole-in-one!";
  }

  else if (golfscore(4,5)){
    return "Bogey";
  }
  else if (golfScore(4,6)){
    return "Double Bogey";
  }
  else if (golfScore(4,7 || 5,9)){
    return "Go Home!";
  }


  else

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

// Change these values to test
golfScore(5, 4);
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:14
@sonnguyen2603 did you solve it ?
penguio
@penguio
Jun 14 2017 04:15
Can anyone help me understand where the issue is with my ajax. im trying to make interdependent drop downs
def ajax_get_department(request):
    if request.POST['company_name'] == "":
        return HttpResponse('<option value=""></option>')
    Company_Name = request.POST['company_name']
    departments = Department.objects.filter(company_name=Company_Name).filter(status="Enabled")
    return render(request,
                  'application_settings/filter_department.html',
                  {'departments': departments})
function updateDepartment(control){
            var department_sel = $("#{{form.department.auto_id }}").find(':selected').val();
            $.ajax({
                type: 'POST',
                url: (location.href.includes('modify_dept') ? '../../filter_department': 'filter_department'),
            data: {'department': $(control).find(':selected').val() },
            success: function(departmentHTML){
                $('#{{form.department.auto_id }}').html(departmentHTML);
                $('#{{form.department.auto_id }}').val(department_sel);
            }
            });
        }
        $(document).ready(function(){
            $('#{{form.department.auto_id }}').change(function(){
                updateDepartment(this);
            });
            updateDepartment('#{{form.department.auto_id }}');
        });
intervolver
@intervolver
Jun 14 2017 04:15
@forwebtech do you happen to have a guide handy for understanding what .getJson() expects out of a url? I've looked at some of the official documentation, but I'm not sure what I'm missing
lceballos97
@lceballos97
Jun 14 2017 04:15
var myStr; = "I am a \"double quoted\" string inside \"double quotes\".";
is my code correct?
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:15
intervolver
@intervolver
Jun 14 2017 04:16
yeah, it didn't give me what I'm missing
sonnguyen2603
@sonnguyen2603
Jun 14 2017 04:16
@forwebtech not yet I couldn't
intervolver
@intervolver
Jun 14 2017 04:16
mind if I link you the pen I'm working on @forwebtech
Junou Cui
@FIRESTROM
Jun 14 2017 04:16
wait..i still don't get it..
new_arr.filter(new_arr.indexOf(newArray[i]));
Dhernandez25
@Dhernandez25
Jun 14 2017 04:16
Can anyone please help me

Instructions
Assign the value 7 to variable a.

Assign the contents of a to variable b.

Aizaz Shahid
@aizazshahid
Jun 14 2017 04:17
@sonnguyen2603 https://repl.it/Ik1Q/1
@intervolver sure !
Nrupen
@inrupen
Jun 14 2017 04:17

var count = 0;

function cc(card) {
// Only change code below this line

if(card==2 || card==3 || card==4 || card==5 || card==6)
  {count++ ;}
else if(card==7 || card==8 || card==9)
  {count+=0 ;}
else if(card==10 || card=="J" || card=="Q" || card=="K" || card=="A")
  {count--; }  
else 
  {return "Change Me"; }

if(count>=1)
  return ("\"" +count+ " Bet\"");
else
  return ("\"" +count+ " Hold\"");

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc("J"); cc(10);

y doesnt it work?
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:18
@FIRESTROM filter requires callback method.
@FIRESTROM
arr.filter( function() {
 // statements
} );
Moisés Man
@moigithub
Jun 14 2017 04:19
@inrupen u NO need those extra escaped quotes
Nrupen
@inrupen
Jun 14 2017 04:19
@moigithub tried tht method too
Moisés Man
@moigithub
Jun 14 2017 04:19
how ? @inrupen
sonnguyen2603
@sonnguyen2603
Jun 14 2017 04:20
@forwebtech thank you so much though it's a little bit confusing for me =))
CamperBot
@camperbot
Jun 14 2017 04:20
sonnguyen2603 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: sonnguyen2603 already gave forwebtech points
mackyking
@mackyking
Jun 14 2017 04:20
Help me i can't move forward with my lesson....
wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
Curtis Turner
@curtis-turner
Jun 14 2017 04:20
anyone working on the seek and destroy algorithm challenge?
Nrupen
@inrupen
Jun 14 2017 04:20
@moigithub ..on im sry..it worked
oh*
thanku
thanku @moigithub
Long Nguyen
@longnt80
Jun 14 2017 04:22
@sonnguyen2603 https://repl.it/ISo5/6
intervolver
@intervolver
Jun 14 2017 04:22
@FIRESTROM one way to do what seek and destroy wants out of you is this: First, get everything after the array in arguments into a new array. Then, you want to filter arr. Filter requires true to keep each item it checks, otherwise it removes that item. So inside of .filter({});, you want to take an .indexOf the new array you made of the extra arguments in arr. index off will return -1 if it doesn't find a match. So if newArray.indexOf(val) === -1;, filter gets true which means nothing in newArray is in arr, and that value will be kept. If it does find a match, it will return false, and filter will remove the object
Curtis Turner
@curtis-turner
Jun 14 2017 04:24
@intervolver Thanks I am working on this challenge as well that helps clear it up some
CamperBot
@camperbot
Jun 14 2017 04:24
curtis-turner sends brownie points to @intervolver :sparkles: :thumbsup: :sparkles:
:cookie: 262 | @intervolver |http://www.freecodecamp.com/intervolver
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:25
@sonnguyen2603 it can be much simpler as:
function bouncer(arr) {
  return arr.filter( value => value );
}
intervolver
@intervolver
Jun 14 2017 04:25
@forwebtech here is my pen. Currently, this pen is returning the json stringified correctly, so it's working. However, when I try other apis, like "http://ip.jsontest.com/?callback=showMyIP", it doesn't work, and I don't why one url works and the other doesn't
https://codepen.io/intervolver/pen/awmzyg
sonnguyen2603
@sonnguyen2603
Jun 14 2017 04:26
@longnt80 thank you so much
CamperBot
@camperbot
Jun 14 2017 04:26
sonnguyen2603 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 370 | @longnt80 |http://www.freecodecamp.com/longnt80
intervolver
@intervolver
Jun 14 2017 04:26
don't understand *
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:26
@intervolver try to use https with other links and check.
Adam Bohannon
@abohannon
Jun 14 2017 04:26
Evening everyone. I'm having trouble understanding obj.hasOwnProperty() can anyone help me out? I'm testing and this is returning false.

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line



  // Only change code above this line
  return collection.hasOwnProperty("Romeo");
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Long Nguyen
@longnt80
Jun 14 2017 04:26
@sonnguyen2603 you should play around with it to make sure you understand it though
sonnguyen2603
@sonnguyen2603
Jun 14 2017 04:26
@forwebtech yup I think I understand you code now thanks so much
CamperBot
@camperbot
Jun 14 2017 04:26
sonnguyen2603 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: sonnguyen2603 already gave forwebtech points
intervolver
@intervolver
Jun 14 2017 04:27
@forwebtech so is the problem specifically https?
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:29
@intervolver yes because codepen prefers https on http
intervolver
@intervolver
Jun 14 2017 04:30
@forwebtech ah, I guess I didn't understand this. So codepen will reject a regular http link on json request as a rule. Thanks, back to work for me
CamperBot
@camperbot
Jun 14 2017 04:30
intervolver sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 693 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:30
@intervolver wait, why don't you use js panel of codepen for your js ?
intervolver
@intervolver
Jun 14 2017 04:31
@forwebtech I've just been following along with the challenges, this is my second time using codepen. Can I just move the contents of <script></script> into that panel?
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:31
and you don't need html and head elements just use body content without body tag.
@intervolver yes move that internal JS to JS panel.
intervolver
@intervolver
Jun 14 2017 04:32
@forwebtech will do, that should clean things up. I thought that panel was for an external script, I've not been sure on what codepen wants or doesnt
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:32
@intervolver and also the linking system is dynamic, go to settings, in js panel link the jquery. there you can get the link with quick-add option. same will go to css
intervolver
@intervolver
Jun 14 2017 04:33
when I do that (in chrome), it doesn't work
I ran into that problem on the tribute site project
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:34
@intervolver did you linked the Bootstrap and JS through settings ?
intervolver
@intervolver
Jun 14 2017 04:34
yeah
Gurpreet SIngh
@Gurpreet3131
Jun 14 2017 04:34
Has anyone added js script in handlebars?
using expressjs framework
intervolver
@intervolver
Jun 14 2017 04:34
I wasn't putting my script in the right panel though... Hmm! I'll see if that cleans up properly.
Brew
@cooltactician
Jun 14 2017 04:35
Anyone out there willing to help? I think I have the RangeError fixed, but I still cannot get the else statement. I've gone back and reviewed chaining if else statements.
I am working on the Golf Code challenge.
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:35
you should do that because it will be better for you, as you are working in codepen.
Mukul Agrawal
@mukul09
Jun 14 2017 04:35
can anybody help me understand this line . this is regular expression
(1\s?)? checks allows for a "1" or a "1 " at the beginning
Brew
@cooltactician
Jun 14 2017 04:36

function golfScore(par, strokes) {
  // Only change code below this line
  if (4,1 || 1,1){
    return "Hole-in-one!";
  }
  else if (4,2 || 5,2){
    return "Eagle";

  }
  else if (4,3){
    return "Birdie";
  }
  else if (4,4 || 5,5){
    return "Par";
  }

  else if (4,5){
    return "Bogey";
  }
  else if (4,6){
    return "Double Bogey";
  }
  else if  (4,7 || 5,9);{
    return "Go Home!";
  }

else; {
  return "change me";
}


  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
intervolver
@intervolver
Jun 14 2017 04:36
@forwebtech loading jquery does work in settings now that the script is in the right panel, but bootstrap doesn't work when loaded in settings
Adam Bohannon
@abohannon
Jun 14 2017 04:37
Can anyone explain how to use .hasOwnProperty? I can't get it to return anything.
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:37
@intervolver because you didn't link the bootstrap through css tab
Adam Bohannon
@abohannon
Jun 14 2017 04:37
ive definitely been on that page for an hour already, but thanks anywas.
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:38
@cooltactician your conditions are wrong, please visit mdn.io/if
@abohannon so where you stuck ?
intervolver
@intervolver
Jun 14 2017 04:38
@forwebtech ! Hahaha, you're awesome, thanks again for your patient help
CamperBot
@camperbot
Jun 14 2017 04:38
intervolver sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:warning: intervolver already gave forwebtech points
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:38
@intervolver that's your kind !
@BigWootWoot put ``` in new line
intervolver
@intervolver
Jun 14 2017 04:39
now I can focus on formatting this json :)
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:39
@intervolver :+1:
BigWootWoot
@BigWootWoot
Jun 14 2017 04:39
function factorialize(num) {
  var array = [];

  if (num > 0) {
  for (var n = 1; n <= num; n++) {
    array.push(n);
  } var fact = array.reduce(function(previousVal, currentVal){
    return previousVal * currentVal;
  });
  return fact;
}  else {
  return 1;
}
}
factorialize(5);
Adam Bohannon
@abohannon
Jun 14 2017 04:39
I'm trying to test it in the console to see how it work, but I can't get it to return anything unless i put an integer in. It's always false. I don't understand why this won't work. The MDN doesn't say the prop has to be an integer. Shouldn't this return true because source array has the property "last"?

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

  return source.hasOwnProperty(last);

  // Only change code above this line

}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
BigWootWoot
@BigWootWoot
Jun 14 2017 04:40
@cooltactician has anyone helped you yet
Curtis Turner
@curtis-turner
Jun 14 2017 04:40
@intervolver how do we check the val in callback function
Brew
@cooltactician
Jun 14 2017 04:40
@BigWootWoot I can use some more help.
intervolver
@intervolver
Jun 14 2017 04:41
@curtis-turner still in Seek and Destroy?
Curtis Turner
@curtis-turner
Jun 14 2017 04:41
@intervolver yeah I am
Manish Giri
@Manish-Giri
Jun 14 2017 04:41
@cooltactician what does this do? if (4,1 || 1,1){
intervolver
@intervolver
Jun 14 2017 04:41
@curtis-turner have you got the arguments after the array in their own variable?
they should be in a new array
Brew
@cooltactician
Jun 14 2017 04:42
@Manish-Giri I was told it does not do anything. It appears I need to add more specificity to my conditions.
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:42
@abohannon hasOwnProperty("last") it should be put in string.
chrisharris007
@chrisharris007
Jun 14 2017 04:43
hai
Manish Giri
@Manish-Giri
Jun 14 2017 04:43
@cooltactician read the table on the left..the first column is strokes and the second one is what you should compare strokes to, in each comparison.
BigWootWoot
@BigWootWoot
Jun 14 2017 04:43

@cooltactician it look like you would benefit from making a math problem in your statements

if (strokes - par == 1);
return boogey

Manish Giri
@Manish-Giri
Jun 14 2017 04:43
like if(strokes === 1), etc
@cooltactician
rugano
@rugano
Jun 14 2017 04:43
Hello campers,what can i do to my Simon dame to align the inner contents to the center? here: https://codepen.io/Njue/full/OgXggy
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:43
@chrisharris007 that is a increment operator ++ use it with variable name.
chrisharris007
@chrisharris007
Jun 14 2017 04:44
but when i do i get wrong
Brew
@cooltactician
Jun 14 2017 04:44
@BigWootWoot @Manish-Giri Thanks . . . I will try both ways. I like the versatility.
CamperBot
@camperbot
Jun 14 2017 04:44
cooltactician sends brownie points to @bigwootwoot and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 239 | @bigwootwoot |http://www.freecodecamp.com/bigwootwoot
:star2: 5980 | @manish-giri |http://www.freecodecamp.com/manish-giri
BigWootWoot
@BigWootWoot
Jun 14 2017 04:45
@cooltactician best of luck
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:45
@chrisharris007 paste the code !
chrisharris007
@chrisharris007
Jun 14 2017 04:46
var myVar = 87;
myVar = myVar++;
Curtis Turner
@curtis-turner
Jun 14 2017 04:46
@intervolver yeah I got that let me send you the code I have so far
Max
@maxiwer
Jun 14 2017 04:46
Hello, everyone. I'm wandering here is it OK to attach my pens from Codepen.io to my CV?
rugano
@rugano
Jun 14 2017 04:46
@abohannon hi,which challenge?
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:47
@maxiwer its fine, if you like to add it !
rugano
@rugano
Jun 14 2017 04:47
@forwebtech hi,
Aizaz Shahid
@aizazshahid
Jun 14 2017 04:47
@maxiwer just attach the profile https://codepen.io/yourid/
@rugano :wave:
intervolver
@intervolver
Jun 14 2017 04:48
@curtis-turner ah, you don't need that if/else statement
Curtis Turner
@curtis-turner
Jun 14 2017 04:49
@intervolver so just do the comparison in the call and that will give the function the true or false value
intervolver
@intervolver
Jun 14 2017 04:49
@curtis-turner newArr.indexOf(val) === -1; will return true or false on its own
yes
you just need to return that line like this return newArr.indexOf(val) === -1;
that will send true or false to filter
Curtis Turner
@curtis-turner
Jun 14 2017 04:50
@intervolver ahh thanks I'm new to javascript but have been coding for awhile so I am just trying to learn the ins and outs of JS
CamperBot
@camperbot
Jun 14 2017 04:50
curtis-turner sends brownie points to @intervolver :sparkles: :thumbsup: :sparkles:
:warning: curtis-turner already gave intervolver points
intervolver
@intervolver
Jun 14 2017 04:51
if indexOf sees a match, it will return a value higher than -1, and send false instead, which filter will see and use to remove that index @curtis-turner
chrisharris007
@chrisharris007
Jun 14 2017 04:51

var myVar = 87;

// Only change code below this line
var count = myVar;
count++;
myVar = count;

getting error Use the ++ operator
Curtis Turner
@curtis-turner
Jun 14 2017 04:51
@intervolver awesome thank you again for your help
CamperBot
@camperbot
Jun 14 2017 04:51
:warning: curtis-turner already gave intervolver points
curtis-turner sends brownie points to @intervolver :sparkles: :thumbsup: :sparkles:
chrisharris007
@chrisharris007
Jun 14 2017 04:52
???
rugano
@rugano
Jun 14 2017 04:54
@abohannon let me check it,

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

  var pro = Object.keys(source);//command returns the property names.

  var n;
  var m = 0;

  for(var j = 0;j<collection.length;j++){
    n = 0;

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

      //the if below checks what elements in the object have the property and value of the source.
      if(collection[j].hasOwnProperty(pro[i]) && collection[j][pro[i]] == source[pro[i]]){
        n += 1;
      }
    }

    if(n == pro.length){

      arr[m] = collection[j];
      m += 1;
    }
  }


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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
@abohannon there we go
Curtis Turner
@curtis-turner
Jun 14 2017 04:57
@intervolver so for the val inside of the indexOf() that needs to be the values from the given array to check if any values match
Adam Bohannon
@abohannon
Jun 14 2017 04:57
man, these intermediate algorithms make me feel like an idiot
fdemaa
@fdemaa
Jun 14 2017 04:58
@abohannon basics js make me feel like an idiot :worried:
Adam Bohannon
@abohannon
Jun 14 2017 05:00
@rugano thanks for the help, but at the moment i'm having a hard time understanding the logic of that solution. I might need to try again fresh tomorrow.
CamperBot
@camperbot
Jun 14 2017 05:00
abohannon sends brownie points to @rugano :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @rugano |http://www.freecodecamp.com/rugano
intervolver
@intervolver
Jun 14 2017 05:02
@curtis-turner when using .filter, val automatically switches between indexes of the array. It will iterate through each index once, in order. You are defining a variable to represent this when you enter "val" into .filter(val) - you could put any variable name you want in those brackets.
Curtis Turner
@curtis-turner
Jun 14 2017 05:02
alrigh
intervolver
@intervolver
Jun 14 2017 05:03
@curtis-turner think of newArray.filter(val) as reading newArray.filter(whatever index filter is currently checking)
then you can use "val" inside of filter to refer to that index
Curtis Turner
@curtis-turner
Jun 14 2017 05:04
@intervolver ahhh I think I had the wrong array using the filter method
fdemaa
@fdemaa
Jun 14 2017 05:04

@intervolver how can i use the .hasOwnProperty() method, and how i return the value of the property ?

Whats the point of using that method, if its only return true or false?

intervolver
@intervolver
Jun 14 2017 05:05
@fdemaa what challenge are you on?
fdemaa
@fdemaa
Jun 14 2017 05:05
@intervolver Testing Objects for Properties
M-C-Haker
@M-C-Haker
Jun 14 2017 05:05
@chrisharris007 you're doing a lot there... "do less" syntax is i++; where i is the number we need to add one to in order to make 88. That number is set to myVar above the line
Manish Giri
@Manish-Giri
Jun 14 2017 05:05
@fdemaa it can tell you if your object has a certain property or not.
as for how to use it, check out MDN.
fdemaa
@fdemaa
Jun 14 2017 05:06
@Manish-Giri hey man! you change your profile photo :) thanks
CamperBot
@camperbot
Jun 14 2017 05:06
fdemaa sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5981 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 14 2017 05:06
I did, haha :smile:
chrisharris007
@chrisharris007
Jun 14 2017 05:06
@M-C-Haker can you do it. i am weak js
fdemaa
@fdemaa
Jun 14 2017 05:06
i had to read the name and remember xd haha
Manish Giri
@Manish-Giri
Jun 14 2017 05:06
lol
M-C-Haker
@M-C-Haker
Jun 14 2017 05:07
mVar++;
myVar++; * myVar=87
fdemaa
@fdemaa
Jun 14 2017 05:08
@Manish-Giri this bs js is already being tough for me, i will died on the next exercises haha
Manish Giri
@Manish-Giri
Jun 14 2017 05:08
lol
intervolver
@intervolver
Jun 14 2017 05:08
@fdemaa you would do something like var a = objectName.hasOwnProperty(property);, which will assign true or false to the variable a. Once you have that, you can do all sorts of things, like check a in an if/else loop
chrisharris007
@chrisharris007
Jun 14 2017 05:08
thanks
Manish Giri
@Manish-Giri
Jun 14 2017 05:08
all the best :sparkles: @fdemaa
fdemaa
@fdemaa
Jun 14 2017 05:08
@intervolver thanks man! i will try one more time and go to the bed
CamperBot
@camperbot
Jun 14 2017 05:08
fdemaa sends brownie points to @intervolver :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @intervolver |http://www.freecodecamp.com/intervolver
M-C-Haker
@M-C-Haker
Jun 14 2017 05:08
@chrisharris007 np
fdemaa
@fdemaa
Jun 14 2017 05:09
@Manish-Giri :+1:
intervolver
@intervolver
Jun 14 2017 05:09
@fdemaa no problem, I hope that makes it clearer
fdemaa
@fdemaa
Jun 14 2017 05:10
@intervolver it is taking me more time than i thought it would this whole section , it pisse me off
mackyking
@mackyking
Jun 14 2017 05:14
Anybody can help me?
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
Anybody can help me?
Sarah F-K
@sfarnsworthkum
Jun 14 2017 05:15
hey can I get some help with adding to an array?
I'm trying to do this
[5] + [4]
intervolver
@intervolver
Jun 14 2017 05:17
@fdemaa sometimes you just need to stand up, and take 5 minutes to let the problem settle. If you let yourself get wound up, it will become harder and harder to solve. Don't get caught in a frustration loop!
mackyking
@mackyking
Jun 14 2017 05:18
I need some help...
How to solve this section?
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
intervolver
@intervolver
Jun 14 2017 05:22
@mackyking you need to change the variable var result = "";, defined above the first comment to a string that contains a sentence with all those variables in it
rugano
@rugano
Jun 14 2017 05:22
@sfarnsworthkum which challenge?
intervolver
@intervolver
Jun 14 2017 05:23
@mackyking you can add different strings together, like this: ```result = "the " + myNoun + " ran very ";
@mackyking you need to make result = all the variables in wordblanks added together, and separated by bits of strings, using +
fdemaa
@fdemaa
Jun 14 2017 05:26
@intervolver you are right bro! 3 am here, will go sleep and keep tomorrow fresh ;)
too much for today hah
Joseph
@revisualize
Jun 14 2017 05:32

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

Here's an example of this:

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

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

When you have the function declaration of:

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

and you make the function call of:
wordBlanks("dog", "big", "ran", "quickly");
The parameter myNoun gets the first argument from the function call of a string "dog"
The parameter myAdjective gets the second argument from the function call of a string "big"
The parameter myVerb gets the third argument from the function call of a string "ran"
The parameter myAdverb gets the second argument from the function call of a string "quickly"

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

So, you need to use the parameters to create a string and assign that string value to the variable result. (String Concatenation)

intervolver
@intervolver
Jun 14 2017 05:32
@fdemaa night :)
mackyking
@mackyking
Jun 14 2017 05:43
Let me try @intervolver ...
mackyking
@mackyking
Jun 14 2017 05:49
Thanks so much Joseph
sarthakcoder
@sarthakcoder
Jun 14 2017 05:56

// Setup
var a= 7;
var b = a;

// Only change code below this line
Do not change code above the line??

Niklas Hegnelt
@phl3x0r
Jun 14 2017 05:57
What's the question @sarthakcoder?
hda
@whdhli
Jun 14 2017 05:57
how do i do this ?
is 11 % 3 = 2 right?
Niklas Hegnelt
@phl3x0r
Jun 14 2017 05:58
@whdhli yes. It's called modulus
sarthakcoder
@sarthakcoder
Jun 14 2017 05:58
@whdhli its right
hda
@whdhli
Jun 14 2017 05:59
@phl3x0r but it says the = sign is a bad assignement and says Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
oops i meants
meant
it said reference error: invalid let hand side in assignment
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:00
@whdhli show what you've got
sonnguyen2603
@sonnguyen2603
Jun 14 2017 06:00
can anyone help me solve the Seek and Destroy problem please
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:00
@sarthakcoder what have you tried?
hda
@whdhli
Jun 14 2017 06:00
// Only change code below this line
11 % 3 = 2;
var remainder;
sarthakcoder
@sarthakcoder
Jun 14 2017 06:00
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:01
@whdhli you need to assign to a variable. You cannot assign to a statement
Eg. var x = 11 % 3
Haseeb Arshad
@haseebuchiha
Jun 14 2017 06:02
can someone please explain to me the theory of regular expression
I can't quite seem to get my head around hit
it*
sarthakcoder
@sarthakcoder
Jun 14 2017 06:04

// Setup
var a= 7;
var b = a;

// Only change code below this line
plz HELP??

Haseeb Arshad
@haseebuchiha
Jun 14 2017 06:04
@phl3x0r sssssssssssooooooooooooooooooo difficult to understand :/
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:05
@sarthakcoder plz help is a bad question. What do you need help with? What have you tried so far?
Joseph
@revisualize
Jun 14 2017 06:05
@sarthakcoder You changed code above the line
@sarthakcoder By not following directions you broke the challenge.
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:06
@haseebuchiha well, computer science is not meant to be easy ;-)
Tegan Ambrosa
@Spambrah
Jun 14 2017 06:06
@haseebuchiha hey Haseeb - from my understanding, regular expression are prebuilt code we developers can paste into our code to do something. I.e. For example, you might use a regular expression to make sure that a user hasn't type in 2 @ symbols when asking for their email. Or you can use a regular expression to grab everything that is uppercase and then make another function to make those lowercase. Or you can use a regular expression to make a credit card check (make sure their numbers look like a valid credit card).
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:07
@Spambrah he asked about the theory of regex, not application
Joseph
@revisualize
Jun 14 2017 06:08
@haseebuchiha https://regexone.com/
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:10
Regex is basically a DFA so to understand the theory of how it works, that would be a good place to start
Joseph
@revisualize
Jun 14 2017 06:13
But, it's easy to learn the basics of Regex. So, why not?
I'm glad I had spent some time learning regex because I had to use it at my job.
Even just knowing that I could use regex and not exactly which regex that I needed made my life a LOT easier
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:15
@revisualize yes, you don't need to know how a combustion engine works to drive a car, but if you want to know how it works, you need to know something about combustion engines
mackyking
@mackyking
Jun 14 2017 06:17
Thanks a lot @revisualize and @intervolver ....
CamperBot
@camperbot
Jun 14 2017 06:17
mackyking sends brownie points to @revisualize and @intervolver :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @intervolver |http://www.freecodecamp.com/intervolver
:star2: 4162 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 14 2017 06:17
Anyhow. I'm off to bed.
mackyking
@mackyking
Jun 14 2017 06:17
Sleep we'll... Aloha @revisualize
Tegan Ambrosa
@Spambrah
Jun 14 2017 06:18
@phl3x0r Apologies - just trying to helpful.
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:18
@Spambrah no need to apologize
Cynthia Clinton
@Cynth42
Jun 14 2017 06:23
i need help here. my code is not working
can somebody help me here
Mukul Agrawal
@mukul09
Jun 14 2017 06:25
@Cynth42 what's the challenge name and your code
Cynthia Clinton
@Cynth42
Jun 14 2017 06:26
ceasers cipher

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

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

if (num >= 65 && num <= 77) {
  num += 13;

} else if (num >= 78 && num <= 90){
  num -= 13;

}
finalVal.push(String.fromCharCode(num));

}

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

Cynthia Clinton
@Cynth42
Jun 14 2017 06:32
i figured it out - i left out the return method :smile: Thanks for reaching out
Andrew
@uandrew
Jun 14 2017 06:36

hello!

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

  return collection;
}

I am getting and error "Cannot read property "push" of underfined". Can't figure it out

Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:38
@uandrew you can only use the push() function on an array
Kamal
@kpbro
Jun 14 2017 06:39
need help.. i m stuck on finding longest word in the sentence
sarthakcoder
@sarthakcoder
Jun 14 2017 06:39
studlyCapVar should use camelCase in both declaration and assignment sections??
Kamal
@kpbro
Jun 14 2017 06:40
@sarthakcoder yes..
Andrew
@uandrew
Jun 14 2017 06:40
@phl3x0r I see..my Object doesn't have an array. Probably I should create it
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:40
@kpbro you probably need to split the sentence up in words, then sort the result by the length of the words
Kamal
@kpbro
Jun 14 2017 06:41
@phl3x0r I splitted them in words. but how do i find length of each word in array and compare lengths of each of them?
sarthakcoder
@sarthakcoder
Jun 14 2017 06:42
@kpbro can u tell me the syntax
Manish Giri
@Manish-Giri
Jun 14 2017 06:42
you can create a variable outside the loop, set it to zero
@kpbro
in the loop, compare length of each word against that.
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:42
@kpbro "hello".length
Kamal
@kpbro
Jun 14 2017 06:43
@sarthakcoder @Manish-Giri i have created array outside loop in which i am storing length of all words..
then i am thinking to use .sort function
Manish Giri
@Manish-Giri
Jun 14 2017 06:44
that will work, but it's more complicated than the approach I suggested
Kamal
@kpbro
Jun 14 2017 06:44
function findLongestWord(str) {

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

  }

  return wordLen;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Here I have returned wordLen just to check its output value
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:44
@kpbro a naive implementation would be declare a empty string variable, then loop over the list of words assigning the word to the variable if it has a greater length
Manish Giri
@Manish-Giri
Jun 14 2017 06:45
you'll need to map the lengths back to the words and find out the largest
Kamal
@kpbro
Jun 14 2017 06:46
@Manish-Giri how I compare their lengths
Manish Giri
@Manish-Giri
Jun 14 2017 06:46
.length
@kpbro
Kamal
@kpbro
Jun 14 2017 06:47
i know that (.length).., but cant figure out the logic to compare with all array elements
@Manish-Giri
8veLTStory
@8veLTStory
Jun 14 2017 06:47
hello everyone this is just some basic stuff but i'm not quite sure why this doesn't work (trying to input the value of a prompt at the end to call a function which logs an object but it returns ("cannot read property of'firstName' of 'undefined")). I'd really appreciate it if anyone could help
https://codepen.io/anon/pen/GEjqKz?editors=1111
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:48
var longestWord = "";
for(i = 0; i<str2arr.length; i++){
  longestWord = str2arr[i].length > longestWord ? str2arr[i] : longestWord;
}
longestWord.length, obviously
Manish Giri
@Manish-Giri
Jun 14 2017 06:48
@phl3x0r why're you giving away answers?
MidnightAria
@MidnightAria
Jun 14 2017 06:49
function myLocalScope() {
  'use strict';
  var myVar = "a";

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

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

// Now remove the console log line to pass the test
Manish Giri
@Manish-Giri
Jun 14 2017 06:49
@kpbro start with a for loop, inside each iteration of the loop, you can check the length of the current word against the variable outside the loop
Kamal
@kpbro
Jun 14 2017 06:49
@Manish-Giri is right.. i want to learn myself
MidnightAria
@MidnightAria
Jun 14 2017 06:49
Any ideas how to fulfil the requirement: 'No global myVar variable'>
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:49
@kamal there are other possible solutions ;)
Kamal
@kpbro
Jun 14 2017 06:49
@Manish-Giri ok... trying
Manish Giri
@Manish-Giri
Jun 14 2017 06:49
for(var ....) {
 if(length of current word > variable) {
    // make variable equal to length of this word
}
@kpbro
Newton
@NewtonZheng
Jun 14 2017 06:49
Screen Shot 2017-06-14 at 2.48.37 PM.png
Manish Giri
@Manish-Giri
Jun 14 2017 06:50
@kpbro here's some pseudocode
Kamal
@kpbro
Jun 14 2017 06:50
@Manish-Giri yup.
MidnightAria
@MidnightAria
Jun 14 2017 06:50
  • Sorry my message and code did not send together :(
Newton
@NewtonZheng
Jun 14 2017 06:50
Hello everyone, I'm stuck on the stand in line challenge. Does anyone have any advice? It would be greatly appreciated :) https://www.freecodecamp.com/challenges/stand-in-line
Manish Giri
@Manish-Giri
Jun 14 2017 06:50
@MidnightAria I think they want you to comment out this line
console.log(myVar);
Saif Ur Rahman
@saifsmailbox98
Jun 14 2017 06:50
@NewtonZheng you need to use method push() on the array arr and the method shift on the same array to remove and return the first element.
Manish Giri
@Manish-Giri
Jun 14 2017 06:51

@MidnightAria as is said here

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

MidnightAria
@MidnightAria
Jun 14 2017 06:51
@Manish-Giri Ah, that's exactly what I tried, but it just comes up with the error: 'No global myVar variable'
  • oops, I meant:
Niklas Hegnelt
@phl3x0r
Jun 14 2017 06:52
@NewtonZheng what do you need help with?
MidnightAria
@MidnightAria
Jun 14 2017 06:52
'console.log never called'
Newton
@NewtonZheng
Jun 14 2017 06:52
@saifsmailbox98 thanks! I'll check out the resource
CamperBot
@camperbot
Jun 14 2017 06:52
newtonzheng sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 461 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 14 2017 06:52
@MidnightAria remove the console.log that is outside of the function
Manish Giri
@Manish-Giri
Jun 14 2017 06:53
@MidnightAria but you didn't comment it at all
console.log(myVar);
or if you did, your code here doesn't show that.
Saif Ur Rahman
@saifsmailbox98
Jun 14 2017 06:53
@NewtonZheng check out the docs on MDN related to push and shift method on array
HappyRedditor59
@HappyRedditor59
Jun 14 2017 06:54
how do i remove all instances of spaces, underscore, commas and periods from a string?
Ketto
@ketxorange
Jun 14 2017 06:54

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

function checkObj(checkProp) {
// Your Code Here
var a = myObj.hasOwnProperty("checkProp");
var b = myObj.checkProp;
if (a === true) {
console.log(b);
} else
return "Not Found";

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

CamperBot
@camperbot
Jun 14 2017 06:54
:bulb: to format code use backticks! ``` more info
Ken Haduch
@khaduch
Jun 14 2017 06:54
@HappyRedditor59 - you can use a regular expression and the .replace() method.
Ketto
@ketxorange
Jun 14 2017 06:55
Hi guys, a little help please
For exercise "Testing Objects for Properties"
Ken Haduch
@khaduch
Jun 14 2017 06:55
@ketxorange - use ``` as your code block delimiter
Ketto
@ketxorange
Jun 14 2017 06:55
Oh, sorry I missed that
I am not sure what I did wrong with the code, I kept getting "Not Found" as the output
Saif Ur Rahman
@saifsmailbox98
Jun 14 2017 06:56
@ketxorange myObj.hasOwnProperty(checkProp);
not "checkProp"
Ken Haduch
@khaduch
Jun 14 2017 06:56
@ketxorange - okay. Now, if you want to access the variable checkProp - you should not write it as "checkProp" in the .hasOwnProperty("checkProp") - remove the quotes from there.
then if you have the property, you have to use a return statement, and not console.log
Ketto
@ketxorange
Jun 14 2017 06:57
Okay, let me try that
Saif Ur Rahman
@saifsmailbox98
Jun 14 2017 06:58
@HappyRedditor59 /([_\s,.])+/g
MidnightAria
@MidnightAria
Jun 14 2017 06:58
@saifsmailbox98 @Manish-Giri thank you to both of you! I was doing exactly what you suggested, but for some reason, it's only after I refreshed the page (since the Hint said 'Refreshing the page may help if you get stuck') that it worked. Any idea why that is?
CamperBot
@camperbot
Jun 14 2017 06:58
midnightaria sends brownie points to