These are chat archives for FreeCodeCamp/HelpJavaScript

31st
May 2016
OceanMountains
@OceanMountains
May 31 2016 00:00
Nevermind, I understand what you meant now. Thanks as always @sjames1958gm.
CamperBot
@camperbot
May 31 2016 00:00
oceanmountains sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1384 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jonathan Coleman
@jondcoleman
May 31 2016 00:00
@mdbailin how is that an array?
I think you can use that notation on strings which is why it seems like it is an array. Try using the typeof operator on it to ensure
Matthew Bailin
@mdbailin
May 31 2016 00:02
ok will check
Tiffany White
@twhite96
May 31 2016 00:07
Hey guys.
Need some help with Truncate a String
function truncateString(str, num) {

  if (str.length > num) {
    return str.slice(0, (num - 3)) + "...";
  } else {
    if (num <= 3) {
     str.slice(num);
    }
  }
   return str;
}


truncateString("A-tisket a-tasket A green and yellow basket", 11);
That is my code
Jordan Shackelford
@JordanShackelford
May 31 2016 00:08
Are the npm challenges fixed?
Nick Bailey
@nbailey20
May 31 2016 00:09

Hey all, I'm working on the Missing Letters JS Algorithms challenge, and for one of the test cases my function is supposed to output the string "i", which it does. There are no other space characters - the length is 1 as expected. Does anybody know why the case won't pass?

function fearNotLetter(str) {
var result;
var firstCharCode = str.charCodeAt(0);
for (var i = firstCharCode; i < firstCharCode+str.length; i++) {
if (str[i-firstCharCode] != String.fromCharCode(i)) {
result = String.fromCharCode(i);
}
}
if (result !== "") {
return result;
}
else {
return undefined;
}
}

storatus
@storatus
May 31 2016 00:09
please format
Nick Bailey
@nbailey20
May 31 2016 00:09
the test case is fearNotLetter("abcdefghjklmno");
storatus
@storatus
May 31 2016 00:09
@nbailey20
Tiffany White
@twhite96
May 31 2016 00:09
I am getting stuck on the last part of the instructions
Isaac Pak
@pak11273
May 31 2016 00:10
@twhite96 how many tests fail?
Tiffany White
@twhite96
May 31 2016 00:10
@shamgar The last two
Nick Bailey
@nbailey20
May 31 2016 00:11
<script src="https://gist.github.com/nbailey20/348ac3484a0c1e023353ad38c9aa27eb.js"></script>
wow that didn't work at all lol
Isaac Pak
@pak11273
May 31 2016 00:12
@twhite96 you might try adding another condition to your first if statement
Tiffany White
@twhite96
May 31 2016 00:12
Okay. Will look @pak11273
Jonathan Coleman
@jondcoleman
May 31 2016 00:13
@storatus what about this:
var arr = [1,2,3,4];

for (var i = 0; i < arr.length - 1; i++) {
  console.log(arr[i], arr[i+1]);
}
Rodrigo San Miguel
@Rodrigoxsm25
May 31 2016 00:15
Hi Guys!
I'm having a little trouble to understand the way Nesting For Loops works
Jonathan Coleman
@jondcoleman
May 31 2016 00:18
@Rodrigoxsm25 for each iteration of the outer loop, the inner loop runs completely
Isaac Pak
@pak11273
May 31 2016 00:18

@twhite96
for the test:

truncateString('A-', 1);

it returns "...", you need to account for when num is less than 3

ALMY91
@ALMY91
May 31 2016 00:19
hello guys
i need your help
is anybody here
Isaac Pak
@pak11273
May 31 2016 00:19
@ALMY91 hi, what's your issue?
ALMY91
@ALMY91
May 31 2016 00:20
Attempting to set a property on null or undefined causes a TypeError
could u come up with a simple code illustration on this?
Much appreciated
@pak11273
Isaac Pak
@pak11273
May 31 2016 00:21
@ALMY91 hard to follow your question. please paste your code here.
help format
CamperBot
@camperbot
May 31 2016 00:21

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Isaac Pak
@pak11273
May 31 2016 00:21
@twhite96 if you are still stuck let me know. i can show you my solution...
ALMY91
@ALMY91
May 31 2016 00:22
@pak11273 i just need a code illustration on what this sentence means. Attempting to set a property on null or undefined causes a TypeError
@pak11273 a code example i meant
Isaac Pak
@pak11273
May 31 2016 00:22
@ALMY91 sounds like you are trying to set a property to an object
ALMY91
@ALMY91
May 31 2016 00:24
@pak11273 are u able to come up with a code example on this?
Isaac Pak
@pak11273
May 31 2016 00:25
@ALMY91 no srry. i am unfamiliar with this, but you might try looking at this link: https://davidwalsh.name/fix-javascript-errors
Nick Bailey
@nbailey20
May 31 2016 00:25
Could anybody tell me why this function returns 'i' for fearNotLetter("abcdefghjklmno") but doesn't pass the console test that expects 'i'?
function fearNotLetter(str) {
  var result;
  var firstCharCode = str.charCodeAt(0);
  for (var i = firstCharCode; i < firstCharCode+str.length; i++) {
    if (str[i-firstCharCode] != String.fromCharCode(i)) {
      result = String.fromCharCode(i);
    }
  }
  if (result !== "") {
    return result;
  }
  else {
    return undefined;
  } 
}
for the missing letter algorithm challenge
Isaac Pak
@pak11273
May 31 2016 00:27
@nbailey20 i can look at it...
Nick Bailey
@nbailey20
May 31 2016 00:28
@pak11273 thanks!
CamperBot
@camperbot
May 31 2016 00:28
nbailey20 sends brownie points to @pak11273 :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @pak11273 |http://www.freecodecamp.com/pak11273
Rodrigo San Miguel
@Rodrigoxsm25
May 31 2016 00:28
@jondcoleman Thank you! ... I'm kind of slow at this thing, but I got it, thanks
CamperBot
@camperbot
May 31 2016 00:28
rodrigoxsm25 sends brownie points to @jondcoleman :sparkles: :thumbsup: :sparkles:
:cookie: 758 | @jondcoleman |http://www.freecodecamp.com/jondcoleman
Isaac Pak
@pak11273
May 31 2016 00:30
@nbailey20 what is this function suppose to do?
Christian Todd
@chrstntdd
May 31 2016 00:31

So Im having a little trouble setting up the jQuery for a search function I'm trying to implement.

$(document).ready(function() {
  var searchQuery
  $('#searchQuery').keypress(function(e) {
    if (e.which == 13) {
      searchQuery = $('#searchQuery').val;
    }
  });
});

Basically I want the value entered in input with id of searchQuery to be stored as a variable so that I can use it elsewhere in my jQuery, but every time I console.log out searchQuery it doesnt return the input.

Nick Bailey
@nbailey20
May 31 2016 00:31
it takes a string and looks for the character that is "missing", like in the example case the letter "i" is missing from the string "abcd...o"
@pak11273
and returns the missing char. if nothing is missing, returns undefined
Isaac Pak
@pak11273
May 31 2016 00:33
@nbailey20 for starters, your var i = 97 in the first iteration.
@nbailey20 try changing var i = firstCharCode to var i = 0;
Nick Bailey
@nbailey20
May 31 2016 00:33
@pak11273 yes, which is the character code for the first letter in the string - "a"
i subtract off the character code when actually indexing the string
Moisés Man
@moigithub
May 31 2016 00:34
@chrstntdd are u sure is .val
not val()
or value() ?
or .value
Nick Bailey
@nbailey20
May 31 2016 00:35
@pak11273 all of the other tests pass, and the output is as expected for the other test case, but it's still triggering a fail for some reason
Isaac Pak
@pak11273
May 31 2016 00:36
@nbailey20 it's returning 'n' on my side
Moisés Man
@moigithub
May 31 2016 00:38
@nbailey20 if u have
"abcz"
for (var i = firstCharCode; i < firstCharCode+str.length; i++) {
first char code is 97
last char should be 122 (z)
firstCharCode+str.length give u 97+4
Luis Ulua
@uluawebdev
May 31 2016 00:39
function palindrome(str) {
  // Good luck!
  var re = /\W\s/g;

  var newStr = str.replace(re, '');

  if(newStr){
    return true;
  }
  else {
    return false;
  }


}



palindrome("palindrome");
No Answers please, just a nudge in the right direction thanks
Nick Bailey
@nbailey20
May 31 2016 00:40
@pak11273 @moigithub good point, I'll try changing when I'm adding the character codes. thanks!
CamperBot
@camperbot
May 31 2016 00:40
nbailey20 sends brownie points to @pak11273 and @moigithub :sparkles: :thumbsup: :sparkles:
:warning: nbailey20 already gave pak11273 points
:star2: 1299 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
May 31 2016 00:40
Luis Ulua
@uluawebdev
May 31 2016 00:41
Thanks @moigithub
CamperBot
@camperbot
May 31 2016 00:41
uluawebdev sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1300 | @moigithub |http://www.freecodecamp.com/moigithub
DJ
@qualitymanifest
May 31 2016 00:42
@uluawebdev \s is unnecessary in the regex since replacing \W already does that. the only thing \W doesn't replace is underscores, so you'll need to do that. also you need to change your if's condition, to compare the string to itself backwards
Tiffany White
@twhite96
May 31 2016 00:46
@pak11273 not sure about that. I am thinking about where to add one but whatever I think of isn’t right.
Nate Mallison
@NJM8
May 31 2016 00:46
Can anyone help me with the title case sentence challenge? My code when run is showing all the correct answers but the website is failing it.

function titleCase(str) {
  // convert passed string to all lower case
  var lowerStr = str.toLowerCase();
  // split the string by the spaces in it to fill an array
  var splitStr = lowerStr.split(' ');
  // create string to return 
  var rebuiltStr = '';

  // walk up the string array
  for ( i = 0; i < splitStr.length; i++) {
    // set a string variable to our current step
    var currentStr = splitStr[i];
    // concat the fist letter of the current word converted to uppercase
    rebuiltStr += currentStr.charAt(0).toUpperCase() + 
      // then concat the rest of the word and a space
        currentStr.substring(1,currentStr.length) + ' ';
  }

  // return final string
  return rebuiltStr;      
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Isaac Pak
@pak11273
May 31 2016 00:47
@twhite96 can we see what you got so far
Tiffany White
@twhite96
May 31 2016 00:47
This message was deleted
@pak11273
function truncateString(str, num) {
 if (str.length > num) {
    return str.slice(0, (num - 3)) + "...";
  } else if (num <= 3) {
     return str.slice(num) + "...";
  }
  return str;
}


truncateString("A-tisket a-tasket A green and yellow basket", 11);
Moisés Man
@moigithub
May 31 2016 00:48
@NJM8 could u plz edit ur code and add js after the 3 backticks
```js <-- like this
Nate Mallison
@NJM8
May 31 2016 00:49
This message was deleted
Tiffany White
@twhite96
May 31 2016 00:49

Someone explained it to me like this:

If the length of str is longer than the value of num then shorten str to be as long as the value of num minus three. Unless the value of num is less than or equal to three. In that case, just shorten str to be as long as the value of num. Either way, then add '...' to the end of str and give it back to us. Otherwise, just give us back str.

Moisés Man
@moigithub
May 31 2016 00:49
@NJM8 sorry forgot to say.. at start :P
Nate Mallison
@NJM8
May 31 2016 00:49
yeah just realized that lol
Tiffany White
@twhite96
May 31 2016 00:49
I get that. But the last two sentences of this explanation are throwing me
Nate Mallison
@NJM8
May 31 2016 00:50

function titleCase(str) {
  // convert passed string to all lower case
  var lowerStr = str.toLowerCase();
  // split the string by the spaces in it to fill an array
  var splitStr = lowerStr.split(' ');
  // create string to return 
  var rebuiltStr = '';

  // walk up the string array
  for ( i = 0; i < splitStr.length; i++) {
    // set a string variable to our current step
    var currentStr = splitStr[i];
    // concat the fist letter of the current word converted to uppercase
    rebuiltStr += currentStr.charAt(0).toUpperCase() + 
      // then concat the rest of the word and a space
        currentStr.substring(1,currentStr.length) + ' ';
  }

  // return final string
  return rebuiltStr;      
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
better?
Moisés Man
@moigithub
May 31 2016 00:50
:+1: :)
Clancy Avila
@clavila
May 31 2016 00:50
@twhite96 If the string length is less than num, it doesn't need to be truncated
Isaac Pak
@pak11273
May 31 2016 00:50
@twhite96 in your code, when num < 3 , it will return '...'
Moisés Man
@moigithub
May 31 2016 00:51
@NJM8 ok.. ur final result have a extra space at the end
Clancy Avila
@clavila
May 31 2016 00:51
@twhite96 so in that case it wouldn't need ...
bsandusky
@bsandusky
May 31 2016 00:51
@NJM8 I think you’re adding a space to every word, which would include the last word in the string. That may be what is failing the tests. The string would end "… Spout "
Tiffany White
@twhite96
May 31 2016 00:51
Ohhhh okay @clavila
Moisés Man
@moigithub
May 31 2016 00:52
@NJM8 u can use trim() method to remove the extra space
on ur return
return rebuiltStr.trim();
http://www.w3schools.com/jsref/jsref_trim_string.asp
Nate Mallison
@NJM8
May 31 2016 00:53
Ahhh, thanks @moigithub and @bsandusky
CamperBot
@camperbot
May 31 2016 00:53
njm8 sends brownie points to @moigithub and @bsandusky :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @bsandusky |http://www.freecodecamp.com/bsandusky
:star2: 1301 | @moigithub |http://www.freecodecamp.com/moigithub
Luis Ulua
@uluawebdev
May 31 2016 00:53
Thanks @qualitymanifest
CamperBot
@camperbot
May 31 2016 00:53
uluawebdev sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1182 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Nate Mallison
@NJM8
May 31 2016 00:53
.trim() also very helpful, I just wrote:
return rebuiltStr.substring(0, rebuiltStr.length - 1)
;
Tiffany White
@twhite96
May 31 2016 00:54
@pak11273 so..I tried making it equal to three and no dice.
Isaac Pak
@pak11273
May 31 2016 00:59
@twhite96 try reversing the order of your if statements...
Riley Brazell
@rileybrazell
May 31 2016 00:59
Hey all, having some trouble with the Seek and Destroy challenge https://www.freecodecamp.com/challenges/seek-and-destroy
Peter Weinberg
@no-stack-dub-sack
May 31 2016 00:59
can somebody tell me why this isn't looping? I originally had both the if and else returning true and false respectively, but I realized having returns on both would break the loop after one condition or the other was met. Is this essentially the same thing?
 for (i = 0; i < str1.length; i++) {
   if (str1.indexOf(str2[i]) !== -1) {
     output = true; 
   } else {
     output = false;
   }
    return output;
  }
Riley Brazell
@rileybrazell
May 31 2016 01:00
I can filter the array but not sure how to check it against the other arguments passed, really how to access those arguments
Justin Woodward
@jwoo92
May 31 2016 01:00
@chrstntdd for the wiki viewer?
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:00
this is all within the context of a function in which output is defined as a var
Justin Woodward
@jwoo92
May 31 2016 01:00
@chrstntdd nice seeing you back on by the way.
bitgrower
@bitgrower
May 31 2016 01:02
@rileybrazell -- look up the recommended page on the Arguments Object ...
@rileybrazell -- not sure which challenge you are referring to -- but the way to access other arguments being passed is via the Arguments Object -- and there is more info on that on the MDN page for Arguments Object ...
DJ
@qualitymanifest
May 31 2016 01:03
@twhite96 see what @pak11273 said. you will also need to modify one of your slices a little bit - you're telling it to begin the slice at num, but you want to begin the slice at the beginning of the string and end it at num
Riley Brazell
@rileybrazell
May 31 2016 01:04
@bitgrower > Hey all, having some trouble with the Seek and Destroy challenge https://www.freecodecamp.com/challenges/seek-and-destroy
DJ
@qualitymanifest
May 31 2016 01:05
the reason for reversing the order of your if/else if is because, for both the failing cases, str.length is still longer than num so it takes that route @twhite96
bitgrower
@bitgrower
May 31 2016 01:05
okay --- @rileybrazell -- that's what I thought -- I just couldn't find that comment again ... but arguments object is key ... I love seek and destroy -- not because it was a breeze for me (it wasn't) ...but because I learned so much in working on it ...
Isaac Pak
@pak11273
May 31 2016 01:05
@twhite96 when using if statements you want to go with the strictest condition first. And once you catch what @qualitymanifest just said, you should have it.
@twhite96 this line needs to be looked at:
 return str.slice(num) + "...";
Riley Brazell
@rileybrazell
May 31 2016 01:07
@bitgrower thank you for the help I think I see what I need. loop through from (arguments[1]) to (arguments.length) and compare to values of array in arguments[0]?
CamperBot
@camperbot
May 31 2016 01:07
rileybrazell sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1071 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 31 2016 01:08
you do need to do something along those lines ... but it's important to understand the difference between an arguments object (which gets re-defined for each new scope -- eg each function call) and an array ...
Isaac Pak
@pak11273
May 31 2016 01:09
can someone tell me why my twitch api request is being considered "offline"?
bitgrower
@bitgrower
May 31 2016 01:09
once you have the values in the a.o. into another array, that is, a local variable ... things like slice, splice and filter can be handy ...
Jonathan Cutner
@jcutner
May 31 2016 01:10
evening folks, doing the Stand In Line challenge
im somewhat lost, i feel like this is supposed to use the push and pop modifiers?
or no
im not quite sure how to get myself started on this one
bitgrower
@bitgrower
May 31 2016 01:10
@jcutner -- if you have not reviewed the preceding 4 challenges on push pop shift and unshift ... I would do that first ...
Jonathan Cutner
@jcutner
May 31 2016 01:11
i did, that's why i'm thinking that's what it's supposed to use
but i dont know how to write the function properly
bitgrower
@bitgrower
May 31 2016 01:11
well, that's what Mozilla Developer's Network is good for ... they include examples ... :)
Isaac Pak
@pak11273
May 31 2016 01:11
@jcutner give it a shot , do what you think
Riley Brazell
@rileybrazell
May 31 2016 01:11
ahh for sure I think I see I can splice the filtering values away from the initial array and then filter against each other
Jonathan Cutner
@jcutner
May 31 2016 01:12
im thinking something like
testArr.push(5) to add something to the back, then testArr.unshift(0) remove something from the front
because it shows var testArr as the array of 1,2,3,4,5
so 5 would be the "6"
being that 1 is the 0
Isaac Pak
@pak11273
May 31 2016 01:12
@jcutner try it dude
@jcutner i'm thinking your on the right track
bitgrower
@bitgrower
May 31 2016 01:13
however -- I will tell you this ... @jcutner -- you need two (and only two) of those array functions ... and you can "solve" the challenge in a max of 3 lines ... (2 without too much additional work) ... you can also use something like pythontutor.com/javascript.html and throw some code in there using the various array functions and see how they operate
Jonathan Cutner
@jcutner
May 31 2016 01:13
but i need to use the function nextinline
array function being push pop shift and unshift right?
bitgrower
@bitgrower
May 31 2016 01:14
that is what the challenge gives you -- then you add code ... the code you write within nextInLine can contain additional functions...
Jonathan Cutner
@jcutner
May 31 2016 01:14
since they modify whats going on with the array
bitgrower
@bitgrower
May 31 2016 01:15
yes push pop shift & unshift are the relevant array functions ... there are certainly many others, but these are pretty basic array manipulation functions ...
Jonathan Cutner
@jcutner
May 31 2016 01:15
i worry that it's not sinking in for me, and i'm just going through the motions of the instructions
and i'm not actually getting it, when it comes to challenges
maybe it'll just take more time, or more revision
Subh Samal
@subhsamal
May 31 2016 01:16
function largestOfFour(arr) {
  // You can do this!
  var result = [0,0,0,0];

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

        }
         result.push(largest);
    }

   return result;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
what is wrong in my code
bitgrower
@bitgrower
May 31 2016 01:16
@rileybrazell -- something like that -- yes ... :)
Isaac Pak
@pak11273
May 31 2016 01:16
@jcutner keep thinking it through, you'll get it
Subh Samal
@subhsamal
May 31 2016 01:16
topic : Return Largest Numbers in Arrays
joshuaTsmith
@joshuaTsmith
May 31 2016 01:16
function titleCase(str) {
  var words = str.split(' ');
  var theAnswer = "";

  for (var i = 1; i < words.length; i++) {
    words[i] = words[i].charAt(0).toUpperCase() + words[i].substr(1);
  } 
  theAnswer = words.join(' ');

  return theAnswer;
}

titleCase("I'm a little tea pot");
I only need the first letter uppercase of each word uppercase... Trying to get the rest lower case but it's not working the way I want it to when the computer submits an option with everything uppercase... I feel like I'm missing something obvious but the more I look at it the more it stops looking like it makes any sense to me. plz help!
Jonathan Cutner
@jcutner
May 31 2016 01:16
thanks for the support guys, at least i think im on the right track
appreciate it!
Isaac Pak
@pak11273
May 31 2016 01:16
@jcutner keep applying the functions you are learning.
Diego Mayer
@Chrono79
May 31 2016 01:17
@subhsamal lenght is misspelled
Isaac Pak
@pak11273
May 31 2016 01:17
@jcutner this example just needs 2 lines added to make it work
@jcutner and you already stated the functions needed.
Subh Samal
@subhsamal
May 31 2016 01:18
@joshuaTsmith start your loop from 0 and check if it works?
Ken Haduch
@khaduch
May 31 2016 01:18
@joshuaTsmith - how about lower-casing the word first, or lower-casing the part that you substr out?
Isaac Pak
@pak11273
May 31 2016 01:18
@twhite96 did you ever resolve your challenge?
Jonathan Cutner
@jcutner
May 31 2016 01:19
does it make sense to start my code with function? if i want to use push or pop?
im thinking i should re-do the lessons before i get too frustrated
Subh Samal
@subhsamal
May 31 2016 01:19
@Chrono79 oops..corrected. still some refine required.
Isaac Pak
@pak11273
May 31 2016 01:19
@jcutner the challenge already starts the function for you. You just need to fill the "guts"
Ken Haduch
@khaduch
May 31 2016 01:19
@subhsamal - you have array.length misspelled, for one thing?
Tiffany White
@twhite96
May 31 2016 01:19
@pak11273 I got all but one passing
I figured I need to start the slice at 0, but finding out where to end it has me troubled @pak11273
Diego Mayer
@Chrono79
May 31 2016 01:20
@subhsamal var result = [0,0,0,0]; should be var result= [];
Isaac Pak
@pak11273
May 31 2016 01:20
@twhite96 can i see what you got so far?
Tiffany White
@twhite96
May 31 2016 01:20
function truncateString(str, num) {
 if (num <= 3) {
    return str.slice(0, 2) + "...";
  } else if (str.length > num) {
     return str.slice(0, (num - 3)) + "...";
  }
  return str;
}


truncateString("A-", 1);
Isaac Pak
@pak11273
May 31 2016 01:21
@twhite96 yeah thats' basically it, but why did you change num to 2?
Tiffany White
@twhite96
May 31 2016 01:22
Because it still wasn’t passing. I will change it back and see what happens
Subh Samal
@subhsamal
May 31 2016 01:22
@Chrono79 I changed it a little, see below
function largestOfFour(arr) {
  // You can do this!
  var result = [0,0,0,0];

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

        }
         result[i] = largest;
    }

   return result;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Ken Haduch
@khaduch
May 31 2016 01:22
@no-stack-dub-sack :point_up: May 30, 2016 8:59 PM - the way I'm reading it, you have your return statement within the for loop, so it will do one pass through and then return. (I couldn't see another answer or further discussion, so I hope this helps.)
Subh Samal
@subhsamal
May 31 2016 01:22
though it works, do you suggest better ? @Chrono79
Tiffany White
@twhite96
May 31 2016 01:22
@pak11273 nevermind. Addes extra parentheses
Removed them and got it
Isaac Pak
@pak11273
May 31 2016 01:23
@twhite96 :+1:
Tiffany White
@twhite96
May 31 2016 01:23
Thanks @pak11273 and @qualitymanifest
CamperBot
@camperbot
May 31 2016 01:23
twhite96 sends brownie points to @pak11273 and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @pak11273 |http://www.freecodecamp.com/pak11273
:star2: 1183 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
vsmith72
@vsmith72
May 31 2016 01:23
stuck on convertycelsius to fahrenheit any help would be welcome
Subh Samal
@subhsamal
May 31 2016 01:23
I tried your way too. I understood my mistake :smile: @Chrono79
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:23
@khaduch Yeah, I actually just caught that and moved it outside, thanks. But I'm still failing tests. There must be a fundamental problem with my algorithm though I thought I had that part down
CamperBot
@camperbot
May 31 2016 01:23
no-stack-dub-sack sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1234 | @khaduch |http://www.freecodecamp.com/khaduch
Diego Mayer
@Chrono79
May 31 2016 01:24
@subhsamal it works either way
Subh Samal
@subhsamal
May 31 2016 01:24
yup.. thanks @Chrono79
CamperBot
@camperbot
May 31 2016 01:24
subhsamal sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 959 | @chrono79 |http://www.freecodecamp.com/chrono79
Isaac Pak
@pak11273
May 31 2016 01:24
@vsmith72 did you attempt it yet?
Subh Samal
@subhsamal
May 31 2016 01:24
Can I ask one more help @Chrono79
Diego Mayer
@Chrono79
May 31 2016 01:24
yes, why not
Subh Samal
@subhsamal
May 31 2016 01:25
Suppose to the above question, I want to return the entire sub array which contains largest number !! @Chrono79
Ken Haduch
@khaduch
May 31 2016 01:25
@no-stack-dub-sack - well, a second problem is that you are using the index (str1.length) of str1, but you are then using it as an index into str2[i]. That might work some of the time? Which challenge is this? It would help me if I knew what you were working on... :)
Subh Samal
@subhsamal
May 31 2016 01:25
I hope my question is clear.
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:26
@khaduch sorry, this is the Mutations basic algo challenge
Isaac Pak
@pak11273
May 31 2016 01:26
@vsmith72 paste your code here so we can see what you've done so far
Subh Samal
@subhsamal
May 31 2016 01:26
eg : [1000, 1001, 857, 1] @Chrono79
vsmith72
@vsmith72
May 31 2016 01:26
@pak11273 sort of I just cant get my mind around this function. I understand how to covert c to f but don't get the convert to F();
Diego Mayer
@Chrono79
May 31 2016 01:27

@subhsamal

function largestOfFour(arr) {
  // You can do this!
  var maxSubarrayIndex;

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

        }
    }

   return arr[maxSubarrayIndex];
}

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

wait, I'll fix it

Subh Samal
@subhsamal
May 31 2016 01:28
what is the return value in this case ? @Chrono79
I want the output to be [1000, 1001, 857, 1] and plz don't paste the answer :smile:
vsmith72
@vsmith72
May 31 2016 01:29

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

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

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

rphares
@rphares
May 31 2016 01:29
@vsmith72 , close but dont use the values form the tests (like -30)
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:29
@khaduch so within the context of a loop, shouldn't str1.indexOf(str2[i]) check if any letter contained in the array str2 is an element of the array str1 by proving it has an idex within that array or am i misunderstanding the .indexOf method?
Isaac Pak
@pak11273
May 31 2016 01:29
@vsmith72 so you know how to get Celsius. Then without thinking about functions or anything like that. write out what the expression Fahrenheit would be...
rphares
@rphares
May 31 2016 01:30
fahrenheit is the temperate in celsius times 9/5 + 32 @vsmith72
Isaac Pak
@pak11273
May 31 2016 01:30
@vsmith72 oh nvm. lol i missed that you posted your code.
@vsmith72 yeah your on the right track, now exchange your Celsius figure with a variable.
Ken Haduch
@khaduch
May 31 2016 01:32
@no-stack-dub-sack - yes, but if you are trying to look at each letter in str2, you cannot safely use as the loop control the length of str1, that was the point I wanted you to pick up on. You really don't care about the length of str1 at all! You are only checking if all of the letters in str2 are found in str1 - as soon as you find one that isn't you're done. If you run out of letters in str2, then you've checked them all, and you know the answer...
Diego Mayer
@Chrono79
May 31 2016 01:32
@subhsamal don't look at it, but you have to compare each item with a variable where you store the max value and use the i index to get that subarray
Isaac Pak
@pak11273
May 31 2016 01:32
@vsmith72 they already supply you with the variable (hint)
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:33
@khaduch right... but shouldn't the length of str1 set as the loop control ensure it loops long enough the check every letter in str2?
Subh Samal
@subhsamal
May 31 2016 01:33
I am able to get the max value , but unable to print entire sub array containing the max value. @Chrono79 Can you give some more hint for it.
Diego Mayer
@Chrono79
May 31 2016 01:34
@subhsamal when you save the max value (inside the if) store the index i in another var
Ken Haduch
@khaduch
May 31 2016 01:34
@no-stack-dub-sack - it might, unless str1 is shorter than str2. And it will probably die a horrible death if str1 is longer than str2... :boom:
vsmith72
@vsmith72
May 31 2016 01:34
Thanks I got it!
Isaac Pak
@pak11273
May 31 2016 01:34
@vsmith72 :+1:
Subh Samal
@subhsamal
May 31 2016 01:35
ok. trying it @Chrono79
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:36
@khaduch well for arguments sake, no str1within the challenge is shorter than str2, because I had thought of that which is why I thought I could safely use it... but you're saying I shouldn't use the length of any array as a loop control?
@khaduch str2.length does not seem to work either... it passes most challenges, but not all, trying to figure out why now
Ken Haduch
@khaduch
May 31 2016 01:38

@no-stack-dub-sack - no, I didn't say that. I just said that you don't want to use the length of str1. You really only want to check that each letter in str2 exists in str1, so you only want to look at the count of letters in str2, and no more.

Which challenge are you failing? What is different about it compared to the others?

Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:39
@khaduch failing the last 2 using str2.length. trying to play around with it now to figure out what's causing it to fail
Subh Samal
@subhsamal
May 31 2016 01:40
function largestOfFour(arr) {
  // You can do this!
 // var result = [];
  var resultIndex;
  var largest = 0;
  for (var i=0; i < arr.length; i++)
    {

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

        }
         //result.push(largest);
    }

   return arr[resultIndex];
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
@Chrono79 got it :smile:
Thank you once again.
Ken Haduch
@khaduch
May 31 2016 01:41
@no-stack-dub-sack - oh, are you still starting your for loop with i = 1? I think that someone pointed that out before...
David Halls
@DavidHalls
May 31 2016 01:41
how do you post a codepen?
Ken Haduch
@khaduch
May 31 2016 01:41
@Byzgig - just copy and paste the URL of the codepen you are working on
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:41
@khaduch no, it was always i = 0
Ken Haduch
@khaduch
May 31 2016 01:42
@no-stack-dub-sack - okay, it must have been another post that I saw here...
Tati
@tdoyle01
May 31 2016 01:43

Anyone know why this is an infinite loop?


function chunkArrayInGroups(arr, size) {
  var newArr = [];
  for (var i=0; i < arr.length; i+size) {
    var tempArr = [];
    tempArr = arr.slice(i,i+size);
    newArr.push(tempArr);
    tempArr = [];
  }
  return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

the purpose is to split the array into groups the length of size and return them as a 2D array

Not sure how my for loop can be infinite, the i+size seems to be the issue
Ken Haduch
@khaduch
May 31 2016 01:44
@no-stack-dub-sack - oh, I know what it is... you are setting the value of your output variable for each letter, so you have to do something different, because if one letter doesn't match, and the next one does, you will first set false, and then true, and if you end up with the wrong letter...
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:45
@khaduch ahhhh, that explains why the last two challenges are failing, ending up with the wrong letter at the end.
that makes sense.
@khaduch back to the drawing board, lemme play around a bit more I guess
Diego Mayer
@Chrono79
May 31 2016 01:46
@tdoyle01 i+size is fixed, if that is < arr.length you have an infinite loop, maybe you meant i += size
Ken Haduch
@khaduch
May 31 2016 01:47
@no-stack-dub-sack - here's a hint, or rather a question - if one letter isn't found, what could you do?
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:48
@khaduch well if one letter isn't found, there's no need to continue the loop, so you could safely break at that point...
Tati
@tdoyle01
May 31 2016 01:49
@Chrono79 Yep, I did mean i += size. Still getting familiar with the syntax, haha. Thank you!
CamperBot
@camperbot
May 31 2016 01:49
tdoyle01 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 960 | @chrono79 |http://www.freecodecamp.com/chrono79
David Halls
@DavidHalls
May 31 2016 01:49
@tdoyle01 use i++
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:49
@khaduch not sure if I'm catching the hint though...
Diego Mayer
@Chrono79
May 31 2016 01:50
@Byzgig no, i += size is ok with what she's doing, i++ only increments i in 1
David Halls
@DavidHalls
May 31 2016 01:50
@Chrono79 i used i++ when i did that problem
Diego Mayer
@Chrono79
May 31 2016 01:51
@Byzgig yes, but your code is different too
Ken Haduch
@khaduch
May 31 2016 01:51
@no-stack-dub-sack - you have to return true if all of the letters in str2 can be found in str1. So if you find that any of the letters in str2 are not in str1 - you can just ______________. (fill in the blank)
@no-stack-dub-sack - oh, I didn't see your comment two comments ago - you are correct! :point_up: May 30, 2016 9:48 PM
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:56

@khaduch gotcha, yeah I had just thought about reversing my logic a bit... but if I return false on that, how do I get it to return true without adding a second return that will break the loop too early?

  for (var i = 0; i < str2.length; i++) {
   if (str1.indexOf(str2[i]) === -1) {
     return false; 
   }
  }

This passes the tests that are supposed to return false but still doesn't account for the true tests. I feel like I'm missing something very simple.

@khaduch wait. I might have thought of something...
Marty
@martyav
May 31 2016 01:58
i've been lost in the weeds trying to figure out how to make a call to openweather for the weather project. help: https://codepen.io/martyav/pen/MegKBE/
Ken Haduch
@khaduch
May 31 2016 01:58
@no-stack-dub-sack - you just have to return true somewhere...
Diego Mayer
@Chrono79
May 31 2016 01:59
@no-stack-dub-sack remember the profile lookup challenge
Peter Weinberg
@no-stack-dub-sack
May 31 2016 01:59
@khaduch that's what I had just thought of per my previous comment! As I thought, something very simple. It passes now!
Dylan
@dhcodes
May 31 2016 02:00
@martyav are you on chrome?
you might check it in a different browser
html5 location won't work on chrome 50+ unless it's over https
which the openweather api is not
Ken Haduch
@khaduch
May 31 2016 02:00
@martyav - geolocation is no longer working on Chrome unless you use https, and the free openweather api does not support https. People have been switching to use http://ip-api.com/json for the location.
@no-stack-dub-sack - great!
Peter Weinberg
@no-stack-dub-sack
May 31 2016 02:03
@khaduch Hey Ken, thanks for helping talk me through that... I'm at least comforted in knowing the basic logic behind my algorithm worked, I just had to switch it around a bit. I'm hoping these are the things I will begin to pick up on as I keep practicing!
CamperBot
@camperbot
May 31 2016 02:03
no-stack-dub-sack sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: no-stack-dub-sack already gave khaduch points
Peter Weinberg
@no-stack-dub-sack
May 31 2016 02:04
@Chrono79 Were you the one that helped me with that challenge? I'm trying to remember if I got tripped up behind that same sort of logic there too...
@Chrono79 I know we've chatted before, just can't remember specifically if you helped me with that one or not
Diego Mayer
@Chrono79
May 31 2016 02:05
I don't remember :P I was referring to it, because you have to return something after a loop there too
Ken Haduch
@khaduch
May 31 2016 02:05
@no-stack-dub-sack - it was a good exercise for learning - simple enough that there were only a few ways to go wrong :) and yet with enough possibilities to make you think! Good work to get through it, and learn from it! The practice makes it easier to think more deeply about the problems and the coding as you go along... good luck, and you're welcome!
Peter Weinberg
@no-stack-dub-sack
May 31 2016 02:06
@Chrono79 Gotcha... I looked back at it and saw that, just wasn't sure if you had a super memory or something haha
Marty
@martyav
May 31 2016 02:06
@dhcodes @khaduch damn, really? thanks
CamperBot
@camperbot
May 31 2016 02:06
martyav sends brownie points to @dhcodes and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1235 | @khaduch |http://www.freecodecamp.com/khaduch
:cookie: 913 | @dhcodes |http://www.freecodecamp.com/dhcodes
Marty
@martyav
May 31 2016 02:07
i actually work off of a chromebook
this project has been driving me nuts!
Ken Haduch
@khaduch
May 31 2016 02:08
@martyav - yes, things are changing all the time! That is what makes it hard to keep up with this stuff...
Jonathan Cutner
@jcutner
May 31 2016 02:08
back again!
still stuck with Stand In Line :(
i think needing to modify the other lines are throwing me to
so im trying things like testArr.shift(); and testArr.push(); and i think that's bringing me closer, MAYBE
but for return item; it says change this line, but i really don't know to what
and it wants me to modify the console log for testing
Diego Mayer
@Chrono79
May 31 2016 02:09
@jcutner don't use testArr inside your function, use the parameter
Jonathan Cutner
@jcutner
May 31 2016 02:09
but im curious if im supposed to store the shift in something
what do you mean by parameter?
the function itself?
wait no, cause thats not defined
Diego Mayer
@Chrono79
May 31 2016 02:11
look at the line that starts with function yourFunctionName (parameter1, parameter2) {
Jonathan Cutner
@jcutner
May 31 2016 02:11
ah
Miguel López
@miguelopezv
May 31 2016 02:11
Hi, i'm trying to resolve the Chunky Monkey challenge but I don't know hot to begin with... somebody told me here that the best approach is a while loop + array but I've been trying to think and write how to begin with this challenge but has been impossible, I'm really stuck and any help would be greatly appreciated.
Jonathan Cutner
@jcutner
May 31 2016 02:11
arr.shift(0,0);
arr.push(0,5);
is what im toying with
to see if i can remove the front of the array, and add to the back of it
Diego Mayer
@Chrono79
May 31 2016 02:12
@jcutner shift doesn't take arguments, and push should use item
Stephen James
@sjames1958gm
May 31 2016 02:13
@miguelopezv Review the Array.slice() link for how to take parts of an array
Jonathan Cutner
@jcutner
May 31 2016 02:13
oh man :( im so confused
maybe i should take a break from it today and come back tomorrow
i tried to go through the push / pop / shift modules again for a refresher
but they were very simplistic
Diego Mayer
@Chrono79
May 31 2016 02:14
@jcutner read the mdn docs then
Stephen James
@sjames1958gm
May 31 2016 02:14
@jcutner Often a good idea, also it is good to go to the MDN site on Array and review the functions, the parameters it takes and the values returned.
Jonathan Cutner
@jcutner
May 31 2016 02:14
oh wow, never knew about mdn!
Diego Mayer
@Chrono79
May 31 2016 02:15
they're (almost always) the helpful links in the challenges
Marty
@martyav
May 31 2016 02:15
anyway, I've been trying to make the call like so (sample url included): $.ajax({ url: 'http://api.openweathermap.org/data/2.5/weather?lat=40.7206845&lon=-73.863514&appid=cacc1c6b16e50925611d5fbe4afc58b9', jsonp: 'callback', dataType: 'jsonp', success: function (response) { $('#condition').text(response.weather[0].description); $('#temperature').text(response.main.temp); } });
but i'm not even sure if that's correct
this is for the weather project
Diego Mayer
@Chrono79
May 31 2016 02:16
@martyav better use ``` for multiline code
Marty
@martyav
May 31 2016 02:17
oh, ok
Chelsea M
@cgmccallum
May 31 2016 02:17
Hey guys. I'm stuck on Counting Cards. I tried setting up a shift function to modify count based on card values, and then used a set of if...else statements to determine the value of count and return the correct output. Am I on the right track or is that totally the wrong way to go about it?
Diego Mayer
@Chrono79
May 31 2016 02:18
@cgmccallum did you mean switch instead of shift?
Dylan
@dhcodes
May 31 2016 02:18
@cgmccallum i'm not sure about the shift part, but the if ... else sounds right
Chelsea M
@cgmccallum
May 31 2016 02:18
Oh geez. Yes I did.
Diego Mayer
@Chrono79
May 31 2016 02:18
it sounds ok
Dylan
@dhcodes
May 31 2016 02:18
ah, then yes. Just remember to add/subtract from count based on the instructions
Stephen James
@sjames1958gm
May 31 2016 02:19
@martyav Do you have the devtools console open to see any errors?
Marty
@martyav
May 31 2016 02:21
yes. cosnole's not showing any messages, but the call isn't doing anything either
rphares
@rphares
May 31 2016 02:21
Sounds like a good track to be on, @cgmccallum ... without looking at your code... another common error, when the logic is pretty good, is to trip up on the strings at the end, so they print things like 5Bet instead of 5 Bet... might check that if you've incremented and decremented count already :blush:
Stephen James
@sjames1958gm
May 31 2016 02:21
@martyav I took your code above and ran it in jsbin and it does get back JSON.
Chelsea M
@cgmccallum
May 31 2016 02:21

This is what I have
`
var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
var count = count + 1;
break;
case 7:
case 8:
case 9:
count = count + 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
count = count - 1;
break;
}

if (count > 0) {
return count + " Bet";
}
else if (count <= 0) {
return count + " Hold";
}
else {
return "Change Me";
}
// 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');
`

Marty
@martyav
May 31 2016 02:21
so it's working
Toni Shortsleeve
@KoniKodes
May 31 2016 02:21
@sjames1958gm I'm having issues as well. How did you test the code?
Marty
@martyav
May 31 2016 02:21
i'm so lost
Toni Shortsleeve
@KoniKodes
May 31 2016 02:21
@martyav me too.
Chelsea M
@cgmccallum
May 31 2016 02:22
Ok that didn't work. My bad.
Diego Mayer
@Chrono79
May 31 2016 02:22
@cgmccallum don't redeclare count
delete var here: var count = count + 1;
and you forgot card A
Stephen James
@sjames1958gm
May 31 2016 02:23
@KoniKodes I went to jsbin.com where you can have js / html / css and there is a console and output tabs
@cgmccallum three backticks - shift-enter - paste - three backticks enter
@martyav Are you using codepen - do you have a link?
Toni Shortsleeve
@KoniKodes
May 31 2016 02:24
@sjames1958gm Thank you. I will look at it. It has to be better than jslint.
CamperBot
@camperbot
May 31 2016 02:24
konikodes sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1385 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Chelsea M
@cgmccallum
May 31 2016 02:24
For some reason I thought I had to redeclare it inside the function or it wouldn't recognize it. Thank you! And definitely missed the A. Clearly I need to take a break.
Stephen James
@sjames1958gm
May 31 2016 02:24
@KoniKodes :+1:
Diego Mayer
@Chrono79
May 31 2016 02:24
no problem
Chelsea M
@cgmccallum
May 31 2016 02:25
Thanks @Chrono79 ! And thank you @sjames1958gm I haven't actually done it before haha
CamperBot
@camperbot
May 31 2016 02:25
cgmccallum sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1386 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 961 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
May 31 2016 02:25
@cgmccallum Most challenges break if globals - this one requires. I think it is a bad idea to have this challenge
Chelsea M
@cgmccallum
May 31 2016 02:26
Ok so I'm not completely crazy!
Stephen James
@sjames1958gm
May 31 2016 02:26
@martyav Were you looking in the devtools console or the codepen provided console?
Marty
@martyav
May 31 2016 02:27
codepen
Stephen James
@sjames1958gm
May 31 2016 02:29
@martyav With these APIs you need to use the browser devtools console as the codepen console does not show network errors. getLocation only works for https:// but openweatherapi only works for http:// so you have to choose a different location mechaism. ip-api.com is one. Since openweatherapi is http:// only you have to open your codepen page with http://codepen ...
@martyav devtools on chrome is F12 - and your frustration is justified
@Chrono79 Are you online for a bit?
Robson Beaudry
@Robson-Beaudry
May 31 2016 02:32
Hi guys, my code below works fine for the falsy bouncer challenge, except for null, which gets pushed to the new array no matter what I do. Could someone explain why this is?

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  newArr = [];
  for (i=0;i<arr.length;i++){
      switch(arr[i]){
        case false:
        case 0:
        case undefined:
        case NaN:
        case null:
        case "":  
          break;

        default:
          newArr.push(arr[i]);
      }  
  }


  return newArr;
}

bouncer([1, null, NaN, 2, undefined]);
Marty
@martyav
May 31 2016 02:32
@sjames1958gm ok, thanks. i'm going to get myself a drink and try again
CamperBot
@camperbot
May 31 2016 02:32
martyav sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1387 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 31 2016 02:33
@martyav Cheers
Bryan Gomez
@bgomez95
May 31 2016 02:36
What am I missing here in order to call object's properties correctly??
David Halls
@DavidHalls
May 31 2016 02:36
@Robson-Beaudry your not using the references from the problem, that might help
Diego Mayer
@Chrono79
May 31 2016 02:37
@sjames1958gm yes?
Bryan Gomez
@bgomez95
May 31 2016 02:41

var Car = function(wheels, seats, engines) {
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};

var myCar = new Car(3, 1, 2); {
myCar.wheels = ();
myCar.seats = ();
myCar.engines = ();
}

Lesson is Make Unique Objects by Passing Parameters
Diego Mayer
@Chrono79
May 31 2016 02:44
@bgomez95 delete this:
 {
myCar.wheels = ();
myCar.seats = ();
myCar.engines = ();
}
Bryan Gomez
@bgomez95
May 31 2016 02:45
Ok
Marty
@martyav
May 31 2016 02:51
are there any similar quirks i should know about for the project after the weather app, the wikipedia viewer?
Jason Shoemaker
@kutsuya1
May 31 2016 02:52
I'm creating a local object inside a function, and then I try returning that object. The returned object is empty. How should I be creating the object to persist?
Rada
@Radascript
May 31 2016 02:52
guys what's wrong with my code, function isn't firing. Oversimplified:
//HTML PART:
<button onlick="start()">START!</button>

//JS part:
function start() {
  console.log("start");
};
Diego Mayer
@Chrono79
May 31 2016 02:53
@Radascript onlick
David Halls
@DavidHalls
May 31 2016 02:53
<3
CamperBot
@camperbot
May 31 2016 02:53

:point_right: challenge get json with the jquery getjson method [wiki]

Challenge Get JSON with the jQuery getJSON Method

Application Programming Interfaces - are tools that computers use to communicate with one another.

Most web APIs transfer data in a format called JSON. JSON stands for JavaScript Object Notation. JSON is nothing more than object properties and their current values, sandwiched between a { and a }.

These properties and their values are often referred to as "key-value pairs".

Here is a sample of what it looks like.

$.getJSON("/json/cats.json", function(json) {

   $(".message").html(JSON.stringify(json));

 });

:pencil: read more about challenge get json with the jquery getjson method on the FCC Wiki

Rada
@Radascript
May 31 2016 02:53
@Chrono79 jesus f christ I've been sitting on this for like 20 mins
thanks man
Diego Mayer
@Chrono79
May 31 2016 02:54
no problem
what do you think?
Gerardo Paniagua
@igerardoh
May 31 2016 02:56
Hello guys. I am having a hard time with a keyword on Javascript. have you ever used the "insteadOf" keyword inside a IF function
Capture.PNG
? this is really freacking me out :D
David Halls
@DavidHalls
May 31 2016 03:00
@igerardoh what problem are you on?
Rada
@Radascript
May 31 2016 03:01
@Byzgig Pros: satisfies all points, shows ability in both design and animation. Cons: that animation hurts my eyes, the default quote is sexist, doesn't shorten the quote / mute the tweet button when it's too long to tweet, Facebook button just takes me to facebook.
David Halls
@DavidHalls
May 31 2016 03:02
thanks @Radascript
CamperBot
@camperbot
May 31 2016 03:02
byzgig sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
:cookie: 353 | @radascript |http://www.freecodecamp.com/radascript
Angelo Ryndon
@AIRyndon
May 31 2016 03:02
Halo everyone! what does this keyword mean in Js =>?? Is it the same to goes to in C# Lambda?
Gerardo Paniagua
@igerardoh
May 31 2016 03:02
I do not know what insteadOf means in Javascript. How dos it works?
Diego Mayer
@Chrono79
May 31 2016 03:03
@AIRyndon some context would help
Rada
@Radascript
May 31 2016 03:03
@igerardoh I think he is trying to say "instanceOf"
David Halls
@DavidHalls
May 31 2016 03:04
@Radascript what do you mean doesn't shorten the quote / mute the tweet button when it's too long to tweet
@Radascript facebook is not part of the problem, i just added it
@Radascript i don't twitter
Gerardo Paniagua
@igerardoh
May 31 2016 03:04
Thanks @Radascript it is instanceOf indeed
CamperBot
@camperbot
May 31 2016 03:04
igerardoh sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @radascript |http://www.freecodecamp.com/radascript
Rada
@Radascript
May 31 2016 03:06
@Byzgig when the quote is over 140 characters, twitter doesn't let me publish it. It only allows you to post things 140 char or less. So if your quote is over 140 characters, preferably it would either shorten it with "..." in the end or ideally just maybe grey out the twitter button. Or you could just only allow your quote machine to display shorter quotes. Many possible choices.
David Halls
@DavidHalls
May 31 2016 03:06
thanks @Radascript double brownies
CamperBot
@camperbot
May 31 2016 03:06
byzgig sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
:warning: byzgig already gave radascript points
Angelo Ryndon
@AIRyndon
May 31 2016 03:06
@Chrono79 Just saw a code snippet in StackOverflow, like x.reduce(( {array here}) => {return e.concat();},[])
Diego Mayer
@Chrono79
May 31 2016 03:07
@AIRyndon that's arrow notation
David Halls
@DavidHalls
May 31 2016 03:07
@Radascript apparently not
Rada
@Radascript
May 31 2016 03:07
sick I can always use extra brownies thanks @Byzgig
CamperBot
@camperbot
May 31 2016 03:07
radascript sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @byzgig |http://www.freecodecamp.com/byzgig
Rada
@Radascript
May 31 2016 03:07
@Byzgig it's cool I feel it in my soul
Angelo Ryndon
@AIRyndon
May 31 2016 03:07
yeah is the arrow notation much like the one in c# lambda =>
Miguel López
@miguelopezv
May 31 2016 03:07
Guys, I finally managed to solve the Chunky Monkey Challenge!! this is the function I've used, is it ok, can it be more simple or was that just luck?
function chunkArrayInGroups(arr, size) {
    var array = [];
    var i = 0;
    var f = size;
    while (array.length < arr.length/size) {
        array.push(arr.slice(i, f));
        i += size;
        f += size;
    }
    return array;
}
Angelo Ryndon
@AIRyndon
May 31 2016 03:07
in c# it shortens an anonymous function
Diego Mayer
@Chrono79
May 31 2016 03:08
I don't know c#, but if you say it is... ;)
David Halls
@DavidHalls
May 31 2016 03:08
can you open a codepen in a full sized window?
Angelo Ryndon
@AIRyndon
May 31 2016 03:08

@miguelopezv function chunkArrayInGroups(arr, size) {
// Break it up.
var newArray = [];

while(arr.length !== 0)
{
newArray.push(arr.splice(0,size));
}

Rada
@Radascript
May 31 2016 03:09
@miguelopezv don't get too hung up on perfecting your ziplines imo :) If you want to find the most elegant solutions, you can google the zipline's name and see how the devs solved it
Angelo Ryndon
@AIRyndon
May 31 2016 03:10
@Chrono79 does the arrow notation do the same behavior? shorten some function call or something? :)
@miguelopezv Rada is correct. Reading about built-in functions is a great addition to the toolbox though :)
Subh Samal
@subhsamal
May 31 2016 03:11
Hi guys.. somehow I managed to write this code on own effort which works fine. But I feel it might not be perfect. can someone have a look on this ?
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  var myArray = [];
  var myVal;

  myArray = str.split(" "); 
  myVal = str.substr(str.length -1);
  //return myVal;

 if (myArray[myArray.length - 1] === target)
    {
  return true;
    }
  else if (myArray[myArray.length - 1].match (/me/g) == target)
    {
      return true;
    }
 else if (myVal === target)
    {
     return true;
    }
  else 
     return false;
  }


confirmEnding("Bastian", "n");
Diego Mayer
@Chrono79
May 31 2016 03:11
@AIRyndon I guess so, instead of writing
function test (a) {
  return 2*a;
}
you write:
var test = a => 2*a;
Anshul Sanghi
@anshap1719
May 31 2016 03:11

function destroyer(arr) {
  // Remove all the values
  var array = [];
  var index = 0;

 for ( var j = 1; j <= arguments.length; j++) {

    for (var i = 0; i < arr.length; i++) {
      if (arr.indexOf(arguments[j]) !== -1) {
        index = arr.indexOf(arguments[j]);
        arr.splice(index, 1);
      }
    }
}

  return arr;
}

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

The task is "You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments."

This returns a single 3 when It should return a empty array... Can anyone tell me where my code is wrong??

Omid
@omidqayoumi
May 31 2016 03:12
    var quotes= [
    {
        "quote": "Never give up what you want most for what you want today."
        "quoteCreator": "Neal A. Maxwell"
    },
]
Omid
@omidqayoumi
May 31 2016 03:12
is this an okay way to initialize an object array?
with repeating that same pattern over and over again
Michael J Cooper
@ballermjc
May 31 2016 03:13

Anybody know why I can't pass this challenge? function myLocalScope() {
'use strict';
var myVar = 3;

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

// Run and check the console
// myVar is not defined outside of myLocalScope

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

Anshul Sanghi
@anshap1719
May 31 2016 03:13

@subhsamal

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

}

confirmEnding("Bastian", "n");

here is a much shorter version that I did :smile:

Omid
@omidqayoumi
May 31 2016 03:13
I think there's something wrong with it since it keeps messing up my file
Angelo Ryndon
@AIRyndon
May 31 2016 03:13
@Chrono79 I was reading that and googled arrow functions..They are somewhat the same, as always though..C# is the strict mom.Javascript is lenient
Diego Mayer
@Chrono79
May 31 2016 03:14
@AIRyndon hahaha, yes, almost anything is stricter than JS
David Halls
@DavidHalls
May 31 2016 03:14
@Radascript does #quotes count toward the twitter 140 limit?
Subh Samal
@subhsamal
May 31 2016 03:15
I was looking for hint. you put the solution :smile: @anshap1719 It won't help the other person to think.
Max Cady
@vegemouse
May 31 2016 03:15
Hi all. I’m working on Javascript and am having issues with #189. Trying to store the deleted element and have it returned.
Anshul Sanghi
@anshap1719
May 31 2016 03:15
oh is that so :worried: Sorry didn't think that through :-P
David Halls
@DavidHalls
May 31 2016 03:16
@vegemouse what is the name of the project
Diego Mayer
@Chrono79
May 31 2016 03:16
@ballermjc did you try this:
Hint
Refreshing the page may help if you get stuck.
Subh Samal
@subhsamal
May 31 2016 03:16
yes. don't feel bad. @anshap1719
Anshul Sanghi
@anshap1719
May 31 2016 03:17
@subhsamal Thanks mate... I'll never do that again :-D
CamperBot
@camperbot
May 31 2016 03:17
anshap1719 sends brownie points to @subhsamal :sparkles: :thumbsup: :sparkles:
:cookie: 261 | @subhsamal |http://www.freecodecamp.com/subhsamal
Max Cady
@vegemouse
May 31 2016 03:17
@Byzgig Stand in Line
Subh Samal
@subhsamal
May 31 2016 03:17
:+1: carry on :smile: @anshap1719
Anshul Sanghi
@anshap1719
May 31 2016 03:18
@subhsamal by the way, can you help me with my code??
David Halls
@DavidHalls
May 31 2016 03:18
@vegemouse I am at attention, Sir!
Max Cady
@vegemouse
May 31 2016 03:18

here is the code i entered:
function nextInLine(arr, item) {
arr.push(item);
arr.shift();

return item; // Change this line
}

Subh Samal
@subhsamal
May 31 2016 03:18
let me see @anshap1719
Anshul Sanghi
@anshap1719
May 31 2016 03:18
ok
:smile:
Max Cady
@vegemouse
May 31 2016 03:18
I am trying to get the shifted item returned
if im even doing this right so far lol
Rada
@Radascript
May 31 2016 03:20
@Byzgig yes, hashtags count towards the limit. So does punctuation
Subh Samal
@subhsamal
May 31 2016 03:20
can you tell the topic name @anshap1719
Diego Mayer
@Chrono79
May 31 2016 03:20
@vegemouse simply return arr.shift();
or use item to store it and return it
Anshul Sanghi
@anshap1719
May 31 2016 03:20
@subhsamal Yes, its Seek and Destroy.
Miguel López
@miguelopezv
May 31 2016 03:21
@Radascript @AIRyndon thanks for your advices! I'm not trying to write the 'most beautiful and simple code ever in my life' yet, maybe someday.... but I think is kind of a good way to learn to see how other people will take your aproach and modify it, or even start on a different way. I will check on google and read the MDN docs too!
CamperBot
@camperbot
May 31 2016 03:21
miguelopezv sends brownie points to @radascript and @airyndon :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @airyndon |http://www.freecodecamp.com/airyndon
:cookie: 355 | @radascript |http://www.freecodecamp.com/radascript
Subh Samal
@subhsamal
May 31 2016 03:22
ohh.. I am yet to reach there. still I will try to help you out. @anshap1719
Max Cady
@vegemouse
May 31 2016 03:22
thank you @Chrono79 i deleted the first shift and just returned it and that returned it. didnt know i could do that haha
CamperBot
@camperbot
May 31 2016 03:22
vegemouse sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 962 | @chrono79 |http://www.freecodecamp.com/chrono79
Anshul Sanghi
@anshap1719
May 31 2016 03:22
ok :smile: Thanks @subhsamal
CamperBot
@camperbot
May 31 2016 03:22
anshap1719 sends brownie points to @subhsamal :sparkles: :thumbsup: :sparkles:
:warning: anshap1719 already gave subhsamal points
Sirisha Kindigeri
@Sirisha30
May 31 2016 03:23

var count = 0;

function cc(card) {
// Only change code below this line
if(card>1&&card<7) return "5 Bet"; if(card>6&&card<10)
return "0 Hold"
if(card==10||card=='J'||card=='Q'||card=='K'||card=='A')
return "-5 Hold"
if(card==3||card==7||card=='Q'||card==8||card=='A')
return "-1 Hold"
if(card==2||card=='J'||card==9||card==2||card==7)
return "1 Bet"
if(cars==2||card==2||card==10)
return "1 Bet"
if(card==||card==2||card=='A')
return "-1 Hold"
return "Change Me";

Any one can please help me
Counting Cards -----------lesson
CamperBot
@camperbot
May 31 2016 03:26
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Sirisha Kindigeri
@Sirisha30
May 31 2016 03:27
 if(card==3||card==7||card=='Q'||card==8||card=='A')
  return "-1 Hold"
if(card==2||card=='J'||card==9||card==2||card==7)
return "1 Bet"
if(cars==2||card==2||card==10)
return "1 Bet"
if(card==||card==2||card=='A')
return "-1 Hold"
return "Change Me";
Anshul Sanghi
@anshap1719
May 31 2016 03:29
@subhsamal alright thanks :smile:
CamperBot
@camperbot
May 31 2016 03:29
anshap1719 sends brownie points to @subhsamal :sparkles: :thumbsup: :sparkles:
:warning: anshap1719 already gave subhsamal points
Diego Mayer
@Chrono79
May 31 2016 03:29
@Sirisha30 you're doint it wrong, evaluate card value and modify count value, after that evaluate count and return count + bet or hold
Sirisha Kindigeri
@Sirisha30
May 31 2016 03:31
sry i can'r understand
Anshul Sanghi
@anshap1719
May 31 2016 03:33
@subhsamal Lol, you know what, I just had to use i <= arr.length instead of i < arr.length :-P
@Sirisha30 Also, I would suggest using switch case... and what @Chrono79 means is that First declare a variable count. Then based on the conditions of what your card is, increment or decrement count. Then you can evaluate this count to check whether to hold or bet...
Diego Mayer
@Chrono79
May 31 2016 03:39
@anshap1719 count is already declared above the function as global
Anshul Sanghi
@anshap1719
May 31 2016 03:39
cool then :smile:
Andrew Forbes
@aforbe2
May 31 2016 03:44
Hey is anyone on? I'm having trouble with one of the sections on my FCC, it's the stand in line task
Anshul Sanghi
@anshap1719
May 31 2016 03:45
yes?
Andrew Forbes
@aforbe2
May 31 2016 03:47
I actually just have no idea how to do it. In all of the other tasks so far they have built on the previous few, but I feel like the instructions on this one are vague.
Subh Samal
@subhsamal
May 31 2016 03:48
hehe , it happens @anshap1719 I was stuck on a problem due to spelling mistake :smile:
Andrew Forbes
@aforbe2
May 31 2016 03:49
Has anyone done the Stand in line task? Any pointers?
elarouche
@elarouche
May 31 2016 03:53
Anyone do LookUpProfile task?
elarouche
@elarouche
May 31 2016 03:59
@aforbe2 You looking for the answer?
dwebz
@dwebz
May 31 2016 04:00
Hey everyone, stuck on Accessing Nested Objects in JSON
elarouche
@elarouche
May 31 2016 04:01
@aforbe2
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // Change this line
}
UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:01
@elarouche yes
dwebz
@dwebz
May 31 2016 04:02

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line
myStorage.car.inside["glove box"];
var gloveBoxContents = ""; // Change this line

Eldar Tinjić
@EldarT90
May 31 2016 04:02
https://codepen.io/EldarT/pen/YWzgQN why is my modal not working
dwebz
@dwebz
May 31 2016 04:02
sorry, how do you post code?
UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:02
help format
CamperBot
@camperbot
May 31 2016 04:02

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:02
@dwebz ^^^
dwebz
@dwebz
May 31 2016 04:02
Thank you!
Andrew Forbes
@aforbe2
May 31 2016 04:03
Thank you @elarouche I wasn't specifically looking for the answer, I was looking for someone to point me in the right direction, but after looking at your answer I understand the code. I think the directions could be more clear on this challenge. Thank you! I appreciate the help!
CamperBot
@camperbot
May 31 2016 04:03
aforbe2 sends brownie points to @elarouche :sparkles: :thumbsup: :sparkles:
:cookie: 101 | @elarouche |http://www.freecodecamp.com/elarouche
UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:03
np @dwebz
elarouche
@elarouche
May 31 2016 04:04
@aforbe2 Oh sorry about that, but ya no problem! If you ever need answers, most of them are located in the 'Wiki'.
dwebz
@dwebz
May 31 2016 04:04

'''

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line
myStorage.car.inside["glove box"];
var gloveBoxContents = ""; // Change this line

I also tried:
myStorage.car.["inside"].glove box;

CamperBot
@camperbot
May 31 2016 04:04
:bulb: to format code use backticks! ``` more info
dwebz
@dwebz
May 31 2016 04:05
'''
test
'''
CamperBot
@camperbot
May 31 2016 04:05
:bulb: to format code use backticks! ``` more info
dwebz
@dwebz
May 31 2016 04:05
lol, sorry everyone
elarouche
@elarouche
May 31 2016 04:05
@dwebz top left button
@dwebz `
ALMY91
@ALMY91
May 31 2016 04:06
hi guys
i have this code here
dwebz
@dwebz
May 31 2016 04:06
thank you @elarouche
CamperBot
@camperbot
May 31 2016 04:06
dwebz sends brownie points to @elarouche :sparkles: :thumbsup: :sparkles:
:cookie: 102 | @elarouche |http://www.freecodecamp.com/elarouche
elarouche
@elarouche
May 31 2016 04:06
@dwebz Np!
ALMY91
@ALMY91
May 31 2016 04:06
o = {x:1}; // o has own property x and inherits property toString
i understand that o has own property x
but i do not quite understand how did o inherit property toString
dwebz
@dwebz
May 31 2016 04:07

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line
myStorage.car.inside["glove box"];
var gloveBoxContents = ""; // Change this line
there you go...
UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:08
@dwebz var gloveBoxContents = myStorage.car.inside["glove box"];
dwebz
@dwebz
May 31 2016 04:09
thank you @UtkarshShukla7
CamperBot
@camperbot
May 31 2016 04:09
dwebz sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 545 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:10
@dwebz np
dwebz
@dwebz
May 31 2016 04:11
not much explanation on the exercises
UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:11
@ALMY91 I think toString property is present for every object
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
Andrew Forbes
@aforbe2
May 31 2016 04:12
@elarouche Oh Thank you! I had never checked out the wiki, I don't know why. I didn't even really notice that it was there.
CamperBot
@camperbot
May 31 2016 04:12
aforbe2 sends brownie points to @elarouche :sparkles: :thumbsup: :sparkles:
:warning: aforbe2 already gave elarouche points
ALMY91
@ALMY91
May 31 2016 04:13
@UtkarshShukla7 okay thanks!
CamperBot
@camperbot
May 31 2016 04:13
almy91 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 546 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
May 31 2016 04:14
@ALMY91 :+1:
Afolabi Kolawole
@Afolabi28
May 31 2016 04:16
This message was deleted
Jesse Nuese Yaker
@JesseNuese
May 31 2016 04:24

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true,

    "artist": "Kanye",
    "title": "Graduation",
    "release_year": 2005,
    "formats":[
      "CS",
      "LP"]
    "gold": true

  }
];
none of my second artist values are returning, can anyone tell me why this is?
Sarah Meyer
@sarmeyer
May 31 2016 04:29
possibly because your second artist isn't in a separate object...
Zach Sosana
@SOSANA
May 31 2016 04:30
@JesseNuese inside your array you need to separate your second object with curly brackets alongside a coma and also need a comma after your "formats" in the second object
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
  {
    "artist": "Kanye",
    "title": "Graduation",
    "release_year": 2005,
    "formats":[
      "CS",
      "LP"],
    "gold": true

  }
];
Jesse Nuese Yaker
@JesseNuese
May 31 2016 04:35
thanks @SOSANA
CamperBot
@camperbot
May 31 2016 04:35
jessenuese sends brownie points to @sosana :sparkles: :thumbsup: :sparkles:
:cookie: 48 | @sosana |http://www.freecodecamp.com/sosana
Zach Sosana
@SOSANA
May 31 2016 04:38
@JesseNuese np, glad to help
Isaac Pak
@pak11273
May 31 2016 04:44
@atharris2015 can you read this?
@atharris2015 lol, i accidently closed my browser, im in some other channel now
Afolabi Kolawole
@Afolabi28
May 31 2016 04:45
This message was deleted
Jesse Nuese Yaker
@JesseNuese
May 31 2016 04:49

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

// Only change code below this line

myPlants[1].type[1].list[1];
Why is my 1 undefined in this lesson?
Sarah Meyer
@sarmeyer
May 31 2016 04:52
@JesseNuese The objects and arrays in JS start with an index of 0, so there is no element or value at index 1 within the "type" property. You don't need to access the "type" prop to get to the "list" property
Afolabi Kolawole
@Afolabi28
May 31 2016 04:53
function lookUpProfile(firstName, prop){
// Only change code below this line
  var i = 0;
   while (i < contacts.length){
    if (firstName == contacts[i].firstName){

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

      if(contacts[i].hasOwnProperty(prop) !== true){
        return "No such property"; }   
    }
     i++;

  }
I'm having trouble setting up the condition where firstName is not found
Vale
@hophuochoanggia
May 31 2016 04:57
This message was deleted
if (value != '') {
if (prop == 'tracks') {
collection[id][prop].push(value);
} else {
collection[id][prop] = value;
}
}
This is my code to problem 211, Does anybody know why it doesn't let me pass.
rahildar
@rahildar
May 31 2016 05:00
@hophuochoanggia check ur if condition its is with single quote
i guess that might be the fault
Vale
@hophuochoanggia
May 31 2016 05:01
i use a single quote for string
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
After updateRecords(2548, "artist", ""), artist should not be set
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2548, "tracks", ""), tracks should not be set
i failed the 2nd and 4th
rahildar
@rahildar
May 31 2016 05:03
can you paste any link to actual problem or may be a screen shot
@hophuochoanggia
ALMY91
@ALMY91
May 31 2016 05:04
hello what are properties which has configurable attribute of false mean?
does*
500seeds
@500seeds
May 31 2016 05:04
constructor function
Vale
@hophuochoanggia
May 31 2016 05:07
Screenshot 2016-05-31 01.06.54.png
Sarah Meyer
@sarmeyer
May 31 2016 05:07
@hophuochoanggia you need another if statement to account for a blank value - and delete the property
Vale
@hophuochoanggia
May 31 2016 05:08
oh I missed the last requirement
@sarmeyer thanks
CamperBot
@camperbot
May 31 2016 05:08
hophuochoanggia sends brownie points to @sarmeyer :sparkles: :thumbsup: :sparkles:
:cookie: 135 | @sarmeyer |http://www.freecodecamp.com/sarmeyer
Sarah Meyer
@sarmeyer
May 31 2016 05:09
Of course! I did the same thing...
CP
@lubere0102
May 31 2016 05:13
could you guys help me with this

Counting Cards
In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A'
You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.

Example Output
"-3 Hold"
"5 Bet"

Hint
Do NOT reset count to 0 when value is 7, 8, or 9.


var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count += 1;
      break;
    case 7:
    case 8:
    case 9:  
      count += 0;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count -= 1;
      break;
  }

  if (count > 0){
    return "Bet";
  }
  else {
    return "Hold";
  }
  }

  return "Change Me";
  // 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');
how should i proceed after this..
Naguib Bouchibi ⚡️
@naguib101
May 31 2016 05:14

Hello everyone !

I searched for two days now and I still can't find anything on it .. I'm just trying to find a way to get which input is being typed in. Because I have multiple append of input , they all have a different class name thanks to an index. But I still can't get which one is being used ..

Thank you very much if you help me with this guys

Apoorve
@apugoneappu
May 31 2016 05:15
This message was deleted
Ahmad Jamaly Rabib
@rabibsust
May 31 2016 05:15

Can anyone tell what is wrong with my for loop?

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

    if(contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else
      {
        return "No such property";
      }

  }
else{
  return "No such contact";
}

}

Deepak Yadav
@ydeepk
May 31 2016 05:17

Challange Wikipedia API
Help me with this JS / Jquery Problem or probably Codepens,
My code works fine on my development machine i.e. Local Environment.

It's when i search for wikipedia in search bar and result gets load ON CODEPEN.
Clear button on the right side of result when clicked for clearing the result
And it should load refreshed page of the Wikipedia search which I have created.
But the Codepen diaplays 404 error .

It should load Refreshed page of Wikipedia Seacrh Page that I created.

Here Is The Link http://codepen.io/ydeepk/pen/BKXjXR

Apoorve
@apugoneappu
May 31 2016 05:21
var result = "";
for (var counter = 0; counter < 20; counter++) {
  result += " ";
  result += "#";
  if (result.length % 8 == 0) {
    result += "\n";
  }
  counter++;
}
return result;
The output is
" # # # #"
" # # # # # #"
Why isn't it inserting a newline every time the length of the variable string is divisible by 8?
Markus Kiili
@Masd925
May 31 2016 05:21
@rabibsust Returning no such contact should be after the loop block.
@lubere0102 The return value is composed of the value of count and Bet/Hold.
OceanMountains
@OceanMountains
May 31 2016 05:26

Working on the Weather App project here. I am trying to pass a weather icon URL through AJAX so that it displays in the html. Instead of the image, the URL for the weather icon appears but not the image itself. I believe I followed the documentation correctly based on what I'm reading below:

Icon Set #3

Icon URL example

http://icons.wxug.com/i/c/c/partlycloudy.gif
To use the icon path, insert the icon value in the in the image URL path:

http://icons.wxug.com/i/c/c/ICON.gif

I would appreciate it if a more experienced set of eyes can look over my codepen and identify why the image won't show up.

https://codepen.io/OceanMountains/pen/aZbYMm

Ryan Malm
@Rybar
May 31 2016 05:31
@oceanmountains line 14. Json returns a url, you're replacing your img tag.
$('#image').html('<img src=' + icon + ' alt="Weather Icon" style="width:80px;height:80px;">');
^ hacky fix.
César
@ICesarI
May 31 2016 05:31
@apugoneappu, because your code is wrong.
Apoorve
@apugoneappu
May 31 2016 05:32
@ICesarI And?
OceanMountains
@OceanMountains
May 31 2016 05:32

When I debug in the console, the error message points to this line in the HTML.

 <img src= "https://icons.wxug.com/i/c/c/ICON.gif"

But as you can see above, that's the exact line the API instructs me to place in the image URL path.

Good stuff @Rybar . Let me try it.
Markus Kiili
@Masd925
May 31 2016 05:33
@apugoneappu You increment counter twice per loop.
OceanMountains
@OceanMountains
May 31 2016 05:34
BOOYAHHHHH!!!! That did the trick @Rybar. Thank you, you're tha man!!!!!
CamperBot
@camperbot
May 31 2016 05:34
oceanmountains sends brownie points to @rybar :sparkles: :thumbsup: :sparkles:
:cookie: 2 | @rybar |http://www.freecodecamp.com/rybar
César
@ICesarI
May 31 2016 05:34
var result = "";
for (var counter = 0; counter < 20; counter++) {
  result += " ";
  result += "#";
  if (result.length % 8 == 0) {
    result += "\n"; // you are adding one character! and this will change the legth.
  }
  counter++; // for (var counter = 0; counter < 20; counter+=2)  it's the same 
}
return result;
Apoorve
@apugoneappu
May 31 2016 05:34
@ICesarI Thanks!
CamperBot
@camperbot
May 31 2016 05:34
apugoneappu sends brownie points to @icesari :sparkles: :thumbsup: :sparkles:
:cookie: 416 | @icesari |http://www.freecodecamp.com/icesari
Naguib Bouchibi ⚡️
@naguib101
May 31 2016 05:37

Hello everyone !

I searched for two days now and I still can't find anything on it .. I'm just trying to find a way to get which input is being typed in. Because I have multiple append of input , they all have a different class name thanks to an index. But I still can't get which one is being used ..

Thank you very much if you help me with this guys

Ryan Malm
@Rybar
May 31 2016 05:37
@OceanMountains less hacky more correct jquery would be to give your img tag an ID and then do $('#imageid').attr('src' , urlDataVariable)
Chris Cullen
@123xylem
May 31 2016 05:39
help Where art thou
CamperBot
@camperbot
May 31 2016 05:39

:point_right: algorithm where art thou [wiki]

Algorithm Where Art Thou

Problem Explanation

Write an algorithm that will take an array for the first argument and return an array with all the objects that matches all the properties and values in the Object passed as second parameter.

:pencil: read more about algorithm where art thou on the FCC Wiki

ALMY91
@ALMY91
May 31 2016 05:40
how do u test
if the following cannot be deleted?
OceanMountains
@OceanMountains
May 31 2016 05:40
Always good to know different methods to accomplish the same goal! I like it. Appreciate the explanation as well.
ALMY91
@ALMY91
May 31 2016 05:41
delete Object.prototype;
okay nvm
found the answer alr
Ahmad Jamaly Rabib
@rabibsust
May 31 2016 05:42
@Masd925 Where should I put the condition?
César
@ICesarI
May 31 2016 05:43
@skyrunner176, I don't know exactly what you are trying to do but the event emitter can give you a lot of data, like the attribute outerHTML.
Zach
@Moose1551
May 31 2016 05:43
I'm trying desperately to return the unicode value for all of the elements in a string. I have no idea if that's even possible. I'm trying to use a for loop to iterate through the string (which I've turned into an array), but I can only return one unicode value, "S". This code is driving me crazy. Can anyone, please, give me some advice?
function rot13(str) { // LBH QVQ VG!
//var myArray = str.charCode
var strArray = str.split('');
var newString = [];
for (var i = 0; i < strArray.length; i++) {
newString = strArray[i].charCodeAt(0);
return newString;
}
 // return strArray;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Chris Cullen
@123xylem
May 31 2016 05:46
Can I get some help on this please? I dont know howto get the prop names to compare eachother. Im really confused on this even though it looks easy
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var keys= Object.keys(source); //THe prop name of source
  var target =Object.keys(collection);//thge

  function match(value) {
  return value == keys;
}
  for (var i=0;i<target.length;i++){

var filtered = collection.filter(match);

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


whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { first: "Montague", last: "Capulet" });
César
@ICesarI
May 31 2016 05:47
@Moose1551
newString = strArray[i].charCodeAt(0); // you are saving only one character.
Markus Kiili
@Masd925
May 31 2016 05:47
@ALMY91 You can get the property descriptor of the property which tells if the property can be deleted. The delete operation also has a return value that tells if the property was non-configurable (cannot be deleted).
Zach
@Moose1551
May 31 2016 05:48
@ICesarI , I understand that, but even if I leave that blank, I get the same return.
newString = strArray[i].charCodeAt();
I tried to use the code so that it would start at index 0 and continue to the end of the string, but I get 83 for all three examples I've provided.
newString = strArray[i].charCodeAt(0, -1);
Markus Kiili
@Masd925
May 31 2016 05:50
@rabibsust Your conditions seem fine. Just put return no such contact after the loop block.
César
@ICesarI
May 31 2016 05:53
You didn't get it @Moose1551.
Everytime that statement is executed is changing newString for the value returned from strArray[i].charCodeAt();
If you want to concatenate the values, try the operator +=
var newString = ''; //Initialize the var.
(...)
newString += strArray[i].charCodeAt(); //add the new charcode.
Naguib Bouchibi ⚡️
@naguib101
May 31 2016 05:53
This message was deleted
César
@ICesarI
May 31 2016 05:54
-.-
Zach
@Moose1551
May 31 2016 05:55
@ICesarI, thanks for working with me through this. Tried what you suggested and still got 83.
CamperBot
@camperbot
May 31 2016 05:55
moose1551 sends brownie points to @icesari :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @icesari |http://www.freecodecamp.com/icesari
Markus Kiili
@Masd925
May 31 2016 05:55
@skyrunner176 Could you use the event object on event callback function?
Naguib Bouchibi ⚡️
@naguib101
May 31 2016 05:58
@Masd925 I have a keyup that can I can fire on a callback but I will not be able to get the class of which input it was, right ?
Ahmad Jamaly Rabib
@rabibsust
May 31 2016 05:58

I have used the below code. It does not solve the condition for "Bob", "number" should return "No such contact". What I am missing?
for(i=0; i <= contacts.length; i++) {
if(firstName == contacts[i].firstName)
{

    if(contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else
      {
        return "No such property";
      }

  }

}
return "No such contact";

César
@ICesarI
May 31 2016 05:58
@Moose1551
function rot13(str) { // LBH QVQ VG!
//var myArray = str.charCode
var strArray = str.split('');
var newString = '';
for (var i = 0; i < strArray.length; i++) {
newString += strArray[i].charCodeAt(0);
}
 return newString; // Return at the end (:
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Asma
@asma8867
May 31 2016 06:01
I have some mistake in this code, around .push I think. I would be thankful if someone help me.
Tati
@tdoyle01
May 31 2016 06:01
Why is this not checking for null correctly? It takes everything but null out of the array.
function isFalse(value) {
  if (value === false || value === null || value === 0 || value === "" || value === undefined || 
     value.isNaN) {
    return false;
  } else return true;
}

function bouncer(arr) {
  var filtered = [];
  filtered = arr.filter(isFalse);
  return filtered;
}

bouncer([false, null, 0, NaN, undefined, ""]);
Asma
@asma8867
May 31 2016 06:01

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

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


var test=collection[id];

  if (value!=="" && prop!=="tracks"){
    test[prop]=value;
  }

    if (prop==="tracks" && value!=="") {
    prop.push(value);
  }

  if (value===""){
    delete test[prop];
  }


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Markus Kiili
@Masd925
May 31 2016 06:02
@skyrunner176 You can put the event object as the parameter of the callback function. Then inside the callback event.target will be the target element of the event (most specific element). Then you can use .className property for getting the classname. Try something like that.
Victor Velasquez
@victorinspace
May 31 2016 06:02
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if ( value !== "" && prop !== "tracks" ) {

  } else if ( prop === tracks && value > 0 ) {
    push(value);
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Asma
@asma8867
May 31 2016 06:02
I think my push command has something wrong but I do not know whats the problem.
Victor Velasquez
@victorinspace
May 31 2016 06:02
I'm on the Recore Collection problem
*record
Asma
@asma8867
May 31 2016 06:03
@tacoSurprise so may be you could help me with that ;)
Zach
@Moose1551
May 31 2016 06:03
@ICesarI , dude, thank you. I've been asking for help on this one for two weeks now. You're the only one who responded! Thanks!
CamperBot
@camperbot
May 31 2016 06:03
moose1551 sends brownie points to @icesari :sparkles: :thumbsup: :sparkles:
:warning: moose1551 already gave icesari points
Victor Velasquez
@victorinspace
May 31 2016 06:03
I can't remember how to get information to "push" into the necessary arrays
@asma8867 I'll take a look!
Asma
@asma8867
May 31 2016 06:04
@tacoSurprise ok.
Ahmad Jamaly Rabib
@rabibsust
May 31 2016 06:04
@asma8867 I didn't used push I used collection[id][prop] = value;
César
@ICesarI
May 31 2016 06:05
@Moose1551 you are welcome (:
Asma
@asma8867
May 31 2016 06:05
@rabibsust if I insist to use push then what should I do?!
Tati
@tdoyle01
May 31 2016 06:05
@asma8867 You don't need push in this case. You just need to set the value of the title, not push it onto an array of values.
Asma
@asma8867
May 31 2016 06:05
@rabibsust the one you used is for first instruction command that I have already used too.
@tdoyle01 it is still not corret :(

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

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


var test=collection[id];

  if (value!=="" && prop!=="tracks"){
    test[prop]=value;
  }

    if (prop==="tracks" && value!=="") {
    test[prop]=value;
  }

  if (value===""){
    delete test[prop];
  }


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Jamesdinnes
@Jamesdinnes
May 31 2016 06:09
whats up homies
Péter Kovács
@petecz
May 31 2016 06:10
hey, anyone experienced weirdness about the es6 for of loop?
Ahmad Jamaly Rabib
@rabibsust
May 31 2016 06:11
@asma8867 for the second condition I used
else if(prop === "tracks" && value !=="")
{
var length = collection[id][prop].length +1;
collection[id][prop][length] = value;
}
first get the array length then put in the position
Yes you can push an element there
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:11
@asma8867 or do this
 if (prop==="tracks" && value!=="") {
    test[prop].push(value);
Naguib Bouchibi ⚡️
@naguib101
May 31 2016 06:12
@Masd925 omg thank you very much man, I wasn't really familiar of this ! thanks !
CamperBot
@camperbot
May 31 2016 06:12
skyrunner176 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1670 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
May 31 2016 06:15
@peteczz What kind of weirdness?
Ahmad Jamaly Rabib
@rabibsust
May 31 2016 06:15

@Masd925 Can you please tell me what I am missing?
"Bob", "number" should return "No such contact" this condition is not solving.
function lookUpProfile(firstName, prop){
for(i=0; i <= contacts.length; i++) {
if(firstName == contacts[i].firstName)
{

    if(contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else
      {
        return "No such property";
      }

  }

}
return "No such contact";
}

Thomas Gerot
@tjgerot
May 31 2016 06:16
What challenge is this?
Péter Kovács
@petecz
May 31 2016 06:16
@Masd925 im trying to do the twitch thingy with angular, i have an array of the channel list and using for of loop to make the http requests. it should work but the second loop weirldy concate the first and the second item in the array
Coy Sanders
@coymeetsworld
May 31 2016 06:17
@rabibsust you want to go through all contacts before determining no such contact exists
Asma
@asma8867
May 31 2016 06:17
@UtkarshShukla7 I did that but did not work for me :(
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:18
@asma8867 paste your updated code
Coy Sanders
@coymeetsworld
May 31 2016 06:18
or maybe you are hard to see when only part of the code was formatted
Asma
@asma8867
May 31 2016 06:18

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

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


var test=collection[id];

  if (value!=="" && prop!=="tracks"){
    test[prop]=value;
  }

    if (prop==="tracks" && value!=="") {
    test[prop].push(value);
  }

  if (value===""){
    delete test[prop];
  }


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Coy Sanders
@coymeetsworld
May 31 2016 06:19
try refreshing browser @rabibsust
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:20
@asma8867 are you sure you have to delete property not object whe value===""
Asma
@asma8867
May 31 2016 06:21
@UtkarshShukla7 yup. and my error is for the push command.
Markus Kiili
@Masd925
May 31 2016 06:21
@rabibsust i <= contacts.length <- use < here instead of <=
Ahmad Jamaly Rabib
@rabibsust
May 31 2016 06:22
@Masd925 Thanks a lot
CamperBot
@camperbot
May 31 2016 06:22
rabibsust sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1671 | @masd925 |http://www.freecodecamp.com/masd925
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:23
@asma8867 it is working for me
function updateRecords(id, prop, value) {
var test=collection[id];
  if (value!=="" && prop!=="tracks"){
    test[prop]=value;
  }
    if (prop==="tracks" && value!=="") {
    test[prop].push(value);
  }
    if (value===""){
    delete test[prop];
  }
  return collection;
}
@asma8867 try to reset and try
Joshua Trimm
@jtrimm007
May 31 2016 06:24
I'm stumped on what they want for #164. Any help, please?
Asma
@asma8867
May 31 2016 06:24
@rabibsust Thanks. i have just used your tricky way and it worked for me too.
CamperBot
@camperbot
May 31 2016 06:24
asma8867 sends brownie points to @rabibsust :sparkles: :thumbsup: :sparkles:
:cookie: 230 | @rabibsust |http://www.freecodecamp.com/rabibsust
Asma
@asma8867
May 31 2016 06:26
@UtkarshShukla7 yope :) it works. thanks :)
CamperBot
@camperbot
May 31 2016 06:26
asma8867 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 547 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:26
@asma8867 :+1:
@jtrimm007 if you will provide name of the challenge and code only then anyone will be able to help you because numbers won't help to find the challenge to others
Phil Nguyen
@philiphnguyen
May 31 2016 06:29
Can anyone help with "Seek and Destroy"? I'm not sure how to filter out the extra arguments...

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

  var filtArr = theArr[0].filter(function(value){
    for (var j = 1; j < theArr.length;j++){
      if(value != theArr[j]){
        value = value;
      }
      return value;
    }
  });

  return filtArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Péter Kovács
@petecz
May 31 2016 06:29
@Masd925 oh found the bug.. sorry :)
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:39
@philiphnguyen return outside for loop (in filter) value=value will not work.So for every element in array, no element is filtered
Phil Nguyen
@philiphnguyen
May 31 2016 06:47
@UtkarshShukla7 Yeah perhaps I don't fully understand the filter method :worried: my understanding of it is that in the array being filtered, each array element is run through the callback function?
Joshua Trimm
@jtrimm007
May 31 2016 06:47
@UtkarshShukla7 Wordblanks
thank you
Can't sleep so I code! lol
**Learn coding.... lol
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:48
@jtrimm007 please paste your code
Joshua Trimm
@jtrimm007
May 31 2016 06:49

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

// Your code above this line
return result;
}

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

UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:49
@philiphnguyen yes but check about the return type
Joshua Trimm
@jtrimm007
May 31 2016 06:49
I have no clue what they are trying to get me to do.....
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:50
@jtrimm007 @jtrimm007 they want you to output
big dog ran quickly
Joshua Trimm
@jtrimm007
May 31 2016 06:51
myNoun = "dog" ?
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:51
@jtrimm007 so you have to concat string parameters in the proper order and spaces
@jtrimm007 yes
Joshua Trimm
@jtrimm007
May 31 2016 06:51
k that helps
Thank you so much!
Followed you on github!
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:51
@jtrimm007 np try and if you are unable to solve ask me
Joshua Trimm
@jtrimm007
May 31 2016 06:52
thx
UtkarshShukla7
@UtkarshShukla7
May 31 2016 06:52
@jtrimm007 :+1:
Reggie
@ReggieSibley
May 31 2016 07:01
hi guys
Thompson Ike
@hubhubace
May 31 2016 07:03
hi guys
the empty string between string exist for what reasom?
txt3 = txt1 + " " + txt2;
swhy not txt3 = txt1 + txt2;
the txt are all strings
anyone?
this is a concatenated statement
kirbyedy
@kirbyedy
May 31 2016 07:06
@hubhubace yes that is basically a space to separate the txt
if you dont have it it will be like... browndog
but with space... brown dog
Thompson Ike
@hubhubace
May 31 2016 07:07
ok
thanks
@kirbyedy thanks
CamperBot
@camperbot
May 31 2016 07:07
hubhubace sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1043 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Danny Rubio
@drbe4t
May 31 2016 07:13
yooooo.. I'm struggling with this cocatenating string thing.
'''
var myStr = "This is the start." + "This is the end.";
'''
CamperBot
@camperbot
May 31 2016 07:14
:bulb: to format code use backticks! ``` more info
Danny Rubio
@drbe4t
May 31 2016 07:14
var myStr = "This is the start." + "This is the end.";
it says that i should have the value of This is the start. this is the end. what am I missing here?
Gregory Garzon
@chibieee
May 31 2016 07:15
try adding a space between start. and the last "
Danny Rubio
@drbe4t
May 31 2016 07:16
ok
NAILED IT!! haha this javacript is something else. This is the first time i've REALLY gotten into it. So thanks
Gregory Garzon
@chibieee
May 31 2016 07:18
no problem
Reggie
@ReggieSibley
May 31 2016 07:29
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence " += "This is the second sentence.";
im trying to concatenate these two strings with the += operator. whats wrong here?
Markus Kiili
@Masd925
May 31 2016 07:32
@ReggieSibley You use += operator with a variable, not on string literal.
@ReggieSibley myStr += "some string"; would add the string literal to the string contained in myStr.
Reggie
@ReggieSibley
May 31 2016 07:33
ok i will give it a shot
got it thanks buddy!
@Masd925
Loïc Touzard
@LoicTouzard
May 31 2016 07:37

I just finished the where are thou challenge, could you give a comment on my solution ? Is there a smaller code for this ?
Condensed :

const whereAreYou = (c,s) => c.filter(v => Object.keys(s).every(p => v.hasOwnProperty(p) && v[p] === s[p]));

More readable :

function whereAreYou(collection, source) {
    return collection.filter(function(item){
        return Object.keys(source).every(function(property){
            return item.hasOwnProperty(property) && item[property] === source[property];
        });
    });
}
Markus Kiili
@Masd925
May 31 2016 07:44
@LoicTouzard That way is the best that I know of. Your code does some extra work because you make Object.keys(source) on every filter callback call. The code would pass the tests without the hasOwnProperty check, but you can claim that it should be there.
Loïc Touzard
@LoicTouzard
May 31 2016 07:47
@Masd925 Thanks for the comment. You're right keys is calculated every step and that's unnecessary.
And indeed I just understood why is the hasOwnProperty facultative ! item.[property] would be undefined and still different from source[property]
CamperBot
@camperbot
May 31 2016 07:47
loictouzard sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1672 | @masd925 |http://www.freecodecamp.com/masd925
Jacob
@Jeicobu
May 31 2016 07:47
Hey guys, can someone help me please? Im stucked in challenge Find the Longest Word in a String. Here is my code http://prntscr.com/bahzcu . When i list array, i can see only numbers, when i try type of, it return number and still when i use Math.max(array), it return null and console.log lists NaN...
Loïc Touzard
@LoicTouzard
May 31 2016 07:48
Math.max doesnt take array in argument @Jeicobu
Markus Kiili
@Masd925
May 31 2016 07:48
@Jeicobu Math.max doesn't work on arrays just like that.
Loïc Touzard
@LoicTouzard
May 31 2016 07:48
it takes a list of number, such as Math.max(1,5,9,13)
Markus Kiili
@Masd925
May 31 2016 07:48
@Jeicobu Math.max.apply(null,arr) would work.
Jacob
@Jeicobu
May 31 2016 07:48
Aha...
Loïc Touzard
@LoicTouzard
May 31 2016 07:49
or you can expand your array like that Math.max(...arr)
@Masd925 What is this null trick ? :o
Jacob
@Jeicobu
May 31 2016 07:49
@Masd925 @LoicTouzard Thanks alot :+1:
CamperBot
@camperbot
May 31 2016 07:49
jeicobu sends brownie points to @masd925 and @loictouzard :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @loictouzard |http://www.freecodecamp.com/loictouzard
:star2: 1673 | @masd925 |http://www.freecodecamp.com/masd925
Jacob
@Jeicobu
May 31 2016 07:50
Worked like magic :clap:
Loïc Touzard
@LoicTouzard
May 31 2016 07:50
:thumbsup:
Markus Kiili
@Masd925
May 31 2016 07:51
@LoicTouzard It sets value on this, but here there is no use for setting it. Just syntax of .apply().
Loïc Touzard
@LoicTouzard
May 31 2016 07:51
found that in the doc
function getMaxArray(array) {
    return Math.max.apply(null, array);
}
Blauelf
@Blauelf
May 31 2016 08:03
That first argument (here: null) is used for this when calling the function, with a value of null being replaced by the global object (for example window in browsers). Math.max does not use this, so it could be anything I guess, just like @Masd925 said :)
Loïc Touzard
@LoicTouzard
May 31 2016 08:07
@Blauelf Hello :P
Blauelf
@Blauelf
May 31 2016 08:07
Hello :)
CP
@lubere0102
May 31 2016 08:08

// Setup
function phoneticLookup(val) {
  // Only change code below this line
  var val = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot":"Frank"
  };

  // Only change code above this line

}

// Change this value to test
phoneticLookup("alpha");
how do i change to lookup table
?
Loïc Touzard
@LoicTouzard
May 31 2016 08:08
Your function shall return a value
CP
@lubere0102
May 31 2016 08:08

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

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

  }

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

// Change this value to test
phoneticLookup("charlie");
Loïc Touzard
@LoicTouzard
May 31 2016 08:09
You can use the parameter val to access a specific element of the lookup table
Blauelf
@Blauelf
May 31 2016 08:09
@lubere0102 Don't call your variable val, as this is already the name of a parameter. Use lookup instead. And then use val (which holds a property name to lookup) to return the corresponding value.
Loïc Touzard
@LoicTouzard
May 31 2016 08:09
oopsy didn't see that x)
Thompson Ike
@hubhubace
May 31 2016 08:09
pls what is the difference bw null and undefined?
Blauelf
@Blauelf
May 31 2016 08:10
@lubere0102 Oh, and you have an extra }
Srinivasan
@kksrini89
May 31 2016 08:10
How we can execute js function parallelly? Sample code would be more helpful to understand.. ???
Thompson Ike
@hubhubace
May 31 2016 08:10
in simplest form
Blauelf
@Blauelf
May 31 2016 08:10
@hubhubace null is usually used for "a reference to no object"
Loïc Touzard
@LoicTouzard
May 31 2016 08:10
null == undefined is true
null === undefined is false
null means your variable exists but has no value
undefined tell that your variable may not even be decclared
This message was deleted
CP
@lubere0102
May 31 2016 08:11
And then use val (which holds a property name to lookup) to return the corresponding value.
// Setup
function phoneticLookup(val) {
  var result = "";

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


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

// Change this value to test
phoneticLookup("charlie");
what do you mean by Use lookup instead. And then use val (which holds a property name to lookup) to return the corresponding value.
using val
Loïc Touzard
@LoicTouzard
May 31 2016 08:13
@lubere0102 lookup is kinda like an array.
To access an index in an array you do array[index]
With objects (as lookup here) it's the same mechanism to access property object[property]
Blauelf
@Blauelf
May 31 2016 08:13
@hubhubace So null is a value you deliberately assign to a property to note it's empty (and especially not pointing to an object, that's where it's derived from, the null-pointer), while undefined often means "not specified" or "not initialized".
Thompson Ike
@hubhubace
May 31 2016 08:14
cool
thanks
James Riall
@JamesRiall
May 31 2016 08:14
CP - val will be the key
CP - val will be the key within the lookup table you want to access. So you need to return the value of val within lookup.
You can push to var result if you like or just push lookup.val
Loïc Touzard
@LoicTouzard
May 31 2016 08:15

I'm having some problems with the search and replace challenge

function myReplace(str, before, after) {
  return str.replace(new RegExp(before, 'gi'), after);
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting")

Can't find a good way to conserve case while replacing

Blauelf
@Blauelf
May 31 2016 08:16
lookup.val would be wrong (same as lookup["val"], would access a property literally of name "val"), would have to be lookup[val]. And don't push, there is no array.
fobindianman
@fobindianman
May 31 2016 08:16
Hey guys, does anyone see anything wrong with this? var myStr = "This is the first sentence. ";
myStr += "This is the second sentence. ";
Loïc Touzard
@LoicTouzard
May 31 2016 08:16
I tried this but it didn't worked.. case is not conserved ..
function myReplace(str, before, after) {
  return str.replace(new RegExp(before, 'gi'), after, function(match){
    return match[0].toUpperCase() === match[0]?after[0].toUpperCase()+after.slice(1,after.length):after;
  });
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting")
fobindianman
@fobindianman
May 31 2016 08:17
It's popping up as var myStr = "This is the first sentence. ";
myStr += "This is the second sentence. ";
Blauelf
@Blauelf
May 31 2016 08:17
@fobindianman Maybe there is not meant to be a trailing space for the second string?
Ojabo John Heart
@MrHeart
May 31 2016 08:17
pls can somebody help with this Where do I belong challenge?
fobindianman
@fobindianman
May 31 2016 08:17
Wow thanks @Blauelf ! Weird
CamperBot
@camperbot
May 31 2016 08:17
fobindianman sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1911 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
May 31 2016 08:18
@MrHeart The position in a sorted array is determined by how many elements come in front, so just count the ones that are <num ;)
Loïc Touzard
@LoicTouzard
May 31 2016 08:22
nvm I discoverd that if the before is UpperCase, the after just have to be UpperCase too. The problem wassn't as complicated as I though.
function myReplace(str, before, after) {
  if(before[0].toUpperCase() === before[0]){
    after = after[0].toUpperCase()+after.slice(1,after.length);
  }
  return str.replace(new RegExp(before, 'g'), after);
}
Stephen James
@sjames1958gm
May 31 2016 08:24
@LoicTouzard The problem with the one before is you had an extra parameter before the function
return str.replace(new RegExp(before, 'gi'), after, function(match){ << after is not needed here
Loïc Touzard
@LoicTouzard
May 31 2016 08:25
@sjames1958gm Really ?
it is str.replace not after.replace
Haaa I understand, the second parameter is the replacer no matter what, could be a string or a func right ?
Stephen James
@sjames1958gm
May 31 2016 08:26
@LoicTouzard Remove the after, before the function
@sjames1958gm yes the function was not getting called
Loïc Touzard
@LoicTouzard
May 31 2016 08:27
@sjames1958gm Yeah, thanks for pointing that out !
CamperBot
@camperbot
May 31 2016 08:27
loictouzard sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1388 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
CP
@lubere0102
May 31 2016 08:27


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

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


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

// Change this value to test
phoneticLookup("charlie");
Stephen James
@sjames1958gm
May 31 2016 08:27
@LoicTouzard :+1:
CP
@lubere0102
May 31 2016 08:27
what is wrong wit this?
sorry im horrible..
Stephen James
@sjames1958gm
May 31 2016 08:27
@lubere0102 You need to set the result variable to the value in lookup of the property in the variable val.
Nishkarsh Shakya
@nishkarsh08
May 31 2016 08:29

NEED HELP !!!!

function repeatStringNumTimes(str, num) {
// repeat after me
var a = str;
for(var i=0 ; i< num-1; i++){
if(num > 0){
a = str.repeat(num);

}else {
  a = "";
}

}
return a;
}

repeatStringNumTimes("abc", -2);

problem faced:
repeatStringNumTimes("abc", -2) should return "".

Stephen James
@sjames1958gm
May 31 2016 08:31
@nishkarsh08 If you are using repeat there is no need for the loop.
@nishkarsh08 If num is -2 how many times do you go through the loop?
CP
@lubere0102
May 31 2016 08:33

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

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[16];   // Change this Line
it didn't pass because i didn't use braket notation
Stephen James
@sjames1958gm
May 31 2016 08:34
@lubere0102 That is supposed to be player = testObj[playerNumber]
Loïc Touzard
@LoicTouzard
May 31 2016 08:34
:D
CP
@lubere0102
May 31 2016 08:34
ah..
Loïc Touzard
@LoicTouzard
May 31 2016 08:34
To show you that you can use variable as index
Blauelf
@Blauelf
May 31 2016 08:36
In that case, testObj is an object, but not an array, so I would not call it "index" but "key" or "property name".
Loïc Touzard
@LoicTouzard
May 31 2016 08:37
You're right, Listen to him @lubere0102 !
Stephen James
@sjames1958gm
May 31 2016 08:37
@lubere0102 You need to use that same concept to the other challenge
CP
@lubere0102
May 31 2016 08:38

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

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

  result = val[lookup];

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

// Change this value to test
phoneticLookup("charlie");
Nishkarsh Shakya
@nishkarsh08
May 31 2016 08:38

Oh boy........such a blunder
let's make better mistake tomorrow..!!!

thanx a lot @sjames1958gm

CamperBot
@camperbot
May 31 2016 08:38
nishkarsh08 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1389 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Blauelf
@Blauelf
May 31 2016 08:38
@lubere0102 The other way around :P
val contains a string, while lookup is an object.
CP
@lubere0102
May 31 2016 08:38
damn it
why am i so dumb
my head is not working
Blauelf
@Blauelf
May 31 2016 08:39
It's just practice. Read/write more code and you'll spot these patterns immediately.
Francis Baguma
@modernwiz
May 31 2016 08:40
Hey guys i got a problem here
Instructions
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
CP
@lubere0102
May 31 2016 08:40
@Blauelf thank you... fianlly i passed..
CamperBot
@camperbot
May 31 2016 08:40
lubere0102 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1912 | @blauelf |http://www.freecodecamp.com/blauelf
CP
@lubere0102
May 31 2016 08:40
how do i do that
oh it was a bot
Francis Baguma
@modernwiz
May 31 2016 08:40
var myStr = "\ \t \t \r \n "; // Change this line this is my solution
but still it does not work
Srinivasan
@kksrini89
May 31 2016 08:41
Anyone
CP
@lubere0102
May 31 2016 08:41

var count = 0;

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