These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Jun 2016
Arjun
@arjunsingh81989
Jun 10 2016 00:00
Hi, can anyone tell me how to print formatted code in chat
Justin Dado
@rene-justin-dado
Jun 10 2016 00:00
@tertiaryidentifier Thank you! I'll give it a whirl.
@mayunited12 Put spaces between the characters
CamperBot
@camperbot
Jun 10 2016 00:00
rene-justin-dado sends brownie points to @tertiaryidentifier and @mayunited12 :sparkles: :thumbsup: :sparkles:
:cookie: 247 | @tertiaryidentifier |http://www.freecodecamp.com/tertiaryidentifier
:cookie: 165 | @mayunited12 |http://www.freecodecamp.com/mayunited12
Tommy567295
@Tommy567295
Jun 10 2016 00:00
Can anyone help with the "Golf code" course?
John
@tertiaryidentifier
Jun 10 2016 00:01
@arjunsingh81989 use
code
use ```
and then ``` to close
@Tommy567295 whats your problem currently?
Coy Sanders
@coymeetsworld
Jun 10 2016 00:02
@mayunited12 the first code you have there is backslash, you want backspace. Check the table again for the appropriate character
@arjunsingh81989
help format
CamperBot
@camperbot
Jun 10 2016 00: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

Arjun
@arjunsingh81989
Jun 10 2016 00:03
var message ="@John Thanks ";
console.log(message);
var message ="@Coy Sanders Thanks";
console.log ( message );
This message was deleted
Luke
@lukenetti3
Jun 10 2016 00:05
Can someone help me with the Seek and Destroy challenge. Can you use filter filter out more than 1 val? I mean to check for more than one value.

function destroyer(arr) {
// Remove all the values
var newArr = [];
var newerArr = [];
var notIncluded = [];

for (var i = 0; i < arguments.length; i++) {
notIncluded[i] = arguments[i + 1];

}
notIncluded.pop();

newArr = arr.filter(function(val){
return val !== notIncluded[0];
});

newerArr = newArr.filter(function(val) {
return val !== notIncluded[1];
});

return newerArr;
}

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

The problem with this is I can only take 2 arguments. I tried a for loop but it won't let me make a new function inside a for loop.
mayunited12
@mayunited12
Jun 10 2016 00:10
@rene-justin-dado I did put a single space actually, its not just visible enough here.
Coy Sanders
@coymeetsworld
Jun 10 2016 00:12
@lukenetti3 you can define your callback filter function outside of the for loop, and reference inside filter function
function someFilterFunction() {

}

for (var i = 0; .....) {
  arr = arr.filter(someFilterFunction);
}
your filter callback function doesn't have to be an anonymous function
Luke
@lukenetti3
Jun 10 2016 00:14
@coymeetsworld Okay, but even when I do attempt that, I still need to filter both those values. I tried something like this and it didn't work either.
newArr = arr.filter(function(val){
for (var j = 0; j < 2; j++) {
return (val !== notIncluded[j]);
}
});
Coy Sanders
@coymeetsworld
Jun 10 2016 00:14
you don't want the for loop inside the filter function
you also don't want to hardcode 2 anywhere, or assume you only get 2 values to destroy
mayunited12
@mayunited12
Jun 10 2016 00:16

@coymeetsworld @tertiaryidentifier Thanks y'all. I've realised my mistake. I simply just removed the spaces after my first single column and before my last single column.

Before
var myStr = ' \ \t \t \r \n ';

After

var myStr = '\ \t \t \r \n';

never knew spaces mattered this much.

CamperBot
@camperbot
Jun 10 2016 00:16
mayunited12 sends brownie points to @coymeetsworld and @tertiaryidentifier :sparkles: :thumbsup: :sparkles:
:cookie: 248 | @tertiaryidentifier |http://www.freecodecamp.com/tertiaryidentifier
:star2: 1111 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Luke
@lukenetti3
Jun 10 2016 00:16
@coymeetsworld Okay. Yeah I could change that to the length of the arguments. So your saying to make a function that is a filter function then close the function and call it when I run the filter calling that function?
Coy Sanders
@coymeetsworld
Jun 10 2016 00:16
@mayunited12 don't think that's right still
does that work?
flindip
@flindip
Jun 10 2016 00:17
This message was deleted
that wasn't it
Coy Sanders
@coymeetsworld
Jun 10 2016 00:18
yes, @lukenetti3, but to make the code simpler I would also move the for loop outside of the filter function.
mayunited12
@mayunited12
Jun 10 2016 00:18
Untitled.png Here's the table @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2016 00:19
yep
Tommy567295
@Tommy567295
Jun 10 2016 00:19
@tertiaryidentifier, I'm not sure what I'm doing wrong to not get the right return values.
Coy Sanders
@coymeetsworld
Jun 10 2016 00:19
oh hmm, i guess it is backslash
that's weird, I thought the first escape sequence was backspace...
nvm i guess your code passes right @mayunited12 ?
Luke
@lukenetti3
Jun 10 2016 00:20
@coymeetsworld How would I move the for loop outside of the filter function? I need the for loop to loop through my arguments to filter the values.
Coy Sanders
@coymeetsworld
Jun 10 2016 00:20
like i showed above @lukenetti3
skipperhi
@skipperhi
Jun 10 2016 00:20
This message was deleted
Tommy567295
@Tommy567295
Jun 10 2016 00:21

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

// Change these values to test
golfScore(4, 1);
skipperhi
@skipperhi
Jun 10 2016 00:21
This message was deleted
John
@tertiaryidentifier
Jun 10 2016 00:21
@Tommy567295 could you print your code and remind which challenge this is again?
Tommy567295
@Tommy567295
Jun 10 2016 00:21
golf code!
John
@tertiaryidentifier
Jun 10 2016 00:21
@Tommy567295 whoops! there it is. nevermind. one second
Tommy567295
@Tommy567295
Jun 10 2016 00:22
Thank you! @tertiaryidentifier
CamperBot
@camperbot
Jun 10 2016 00:22
tommy567295 sends brownie points to @tertiaryidentifier :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @tertiaryidentifier |http://www.freecodecamp.com/tertiaryidentifier
Coy Sanders
@coymeetsworld
Jun 10 2016 00:22
else if (strokes > par) {
   return "Par";
"Par" is when strokes is equal to par
Luke
@lukenetti3
Jun 10 2016 00:22
@coymeetsworld Okay, I see what your saying. Sorry I didn't see that other post. So then how could I write the filter function to be used in the loop. Something like this?
Coy Sanders
@coymeetsworld
Jun 10 2016 00:22
also strokes can never be less than 1 @Tommy567295 :)
Luke
@lukenetti3
Jun 10 2016 00:23

function filterFunction(value) {

}

for (var j = 0; j < arguments.length; j++) {
newArr = arr.filter(filterFunction);
}

John
@tertiaryidentifier
Jun 10 2016 00:23
shoutout to @coymeetsworld for being one step ahead of me. agreed
Coy Sanders
@coymeetsworld
Jun 10 2016 00:23
don't use newArr, just reassign arr @lukenetti3
Tommy567295
@Tommy567295
Jun 10 2016 00:23
how do I make the strokes = 1 then?
John
@tertiaryidentifier
Jun 10 2016 00:24
if (strokes === 1)
Luke
@lukenetti3
Jun 10 2016 00:24
@coymeetsworld So would my filter function then be deleting elements in the array? Not sure what my filter function would be doing now.
Coy Sanders
@coymeetsworld
Jun 10 2016 00:24
double equals will suffice too
Tommy567295
@Tommy567295
Jun 10 2016 00:24
still doesn't work @tertiaryidentifier
John
@tertiaryidentifier
Jun 10 2016 00:24
@coymeetsworld any chance you could help with the "Make Object Properties Private" challenge?
Coy Sanders
@coymeetsworld
Jun 10 2016 00:24
did you correct the other thing I said @Tommy567295 ?
John
@tertiaryidentifier
Jun 10 2016 00:24
@Tommy567295 show your revised code
Tommy567295
@Tommy567295
Jun 10 2016 00:24
yes.
one sec
Coy Sanders
@coymeetsworld
Jun 10 2016 00:25
@lukenetti3 filter function goes through the array and removes things based on conditions you use in your callback
flindip
@flindip
Jun 10 2016 00:25

ok, now I got the code. Working on Caesar's Cipher. Trying to figure out the right returns.

Here is the code:


function rot13(str) { // LBH QVQ VG!
  for(var i=0;i<str.length;i++){
      var code=str.charCodeAt(0);
      if(code<78){
          return String.fromCharCode(str[i].charCodeAt(0)+13);
      }
      else{
          return String.fromCharCode(str[i].charCodeAt(0)-13);
      }

  }
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
i'm only getting a single letter string return
Coy Sanders
@coymeetsworld
Jun 10 2016 00:26
John
@tertiaryidentifier
Jun 10 2016 00:26

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

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

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

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

var Bike = function() {

  // Only change code below this line.

  var gear = 1;

  this.setGear = function(gearChange) {
    gear += gearChange;
  };

  this.getGear = function() {
    return gear;
  };



};

var myCar = new Car();

var myBike = new Bike();
Tommy567295
@Tommy567295
Jun 10 2016 00:26

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

// Change these values to test
golfScore(4, 1);
Coy Sanders
@coymeetsworld
Jun 10 2016 00:26

function isBigEnough(value) {
  return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
// filtered is [12, 130, 44]
Tommy567295
@Tommy567295
Jun 10 2016 00:26
I get everything but the return "Hole-in-one!"
Coy Sanders
@coymeetsworld
Jun 10 2016 00:26
one is lower case
Tommy567295
@Tommy567295
Jun 10 2016 00:27
oh my goodness
I've been stuck for 20 mins on a lower case
John
@tertiaryidentifier
Jun 10 2016 00:27
congrats @Tommy567295 :D
Tommy567295
@Tommy567295
Jun 10 2016 00:27
THANK YOU @coymeetsworld and @tertiaryidentifier
CamperBot
@camperbot
Jun 10 2016 00:27
tommy567295 sends brownie points to @coymeetsworld and @tertiaryidentifier :sparkles: :thumbsup: :sparkles:
:warning: tommy567295 already gave tertiaryidentifier points
:star2: 1112 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2016 00:27
np @Tommy567295
@tertiaryidentifier what do you have problems with?
Luke
@lukenetti3
Jun 10 2016 00:28

@coymeetsworld function filterFunction(value) {
return value !== notIncluded;
}

for (var j = 0; j < arguments.length; j++) {
arr.filter(filterFunction);
}

my notIncluded is an array so I can't get it working. Not sure how I can incorporate my for loop into that.
John
@tertiaryidentifier
Jun 10 2016 00:28
@coymeetsworld so many things ;) ... but in this challenge, myBike.getgear() doesn't return 4 after calling myBike.getGear(4), etc. with other test numbers
I think it's some error with how I set up the .setGear
Stephen James
@sjames1958gm
Jun 10 2016 00:29
@tvelev92 All my projects look for crap - others will have to advise on format :)
Tzvetlin Velev
@tvelev92
Jun 10 2016 00:29
can i see ur wiki search project?
@sjames1958gm
Coy Sanders
@coymeetsworld
Jun 10 2016 00:30
that's because getGear doesn't take in a parameter @tertiaryidentifier
Stephen James
@sjames1958gm
Jun 10 2016 00:30
John
@tertiaryidentifier
Jun 10 2016 00:30
@coymeetsworld in weirder news, the first of these test statements is now true, but the last two are false:
```
```
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
Coy Sanders
@coymeetsworld
Jun 10 2016 00:30
gear should be set to 0 I think too for Bike
thats probably your issue
Stephen James
@sjames1958gm
Jun 10 2016 00:30
@lukenetti3 Is this destroyer?
Coy Sanders
@coymeetsworld
Jun 10 2016 00:30
setGear(4) would set the gear to 5
wait nvm
Luke
@lukenetti3
Jun 10 2016 00:30
@sjames1958gm Yes. Did you get it?
John
@tertiaryidentifier
Jun 10 2016 00:31
I changed it to 0, and now the second two statements don't work
Coy Sanders
@coymeetsworld
Jun 10 2016 00:31
oh ok
well I guess the 0 doesn't matter
the problem is when you're setting gear, you're not adding to it
John
@tertiaryidentifier
Jun 10 2016 00:31
the 0 made the first test work
Coy Sanders
@coymeetsworld
Jun 10 2016 00:31
you're setting it
John
@tertiaryidentifier
Jun 10 2016 00:31
right, so do I reset the variable?
Coy Sanders
@coymeetsworld
Jun 10 2016 00:31
setGear(4); gear should be 4
if you ran setGear(3), gear should be 3, not 7
Stephen James
@sjames1958gm
Jun 10 2016 00:31
@lukenetti3 Is notIncluded the array of not to be included elements? That is arguments[1..n]?
Coy Sanders
@coymeetsworld
Jun 10 2016 00:31
more like reassign
Tzvetlin Velev
@tvelev92
Jun 10 2016 00:31
@sjames1958gm <div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-8 col-md-offset-2">n
what is the second line doing xactly
Coy Sanders
@coymeetsworld
Jun 10 2016 00:31
set gear to the parameter you're passing in
don't add to it
Tzvetlin Velev
@tvelev92
Jun 10 2016 00:31
exacylu
John
@tertiaryidentifier
Jun 10 2016 00:32
???
Coy Sanders
@coymeetsworld
Jun 10 2016 00:32
gear = gearChange;
John
@tertiaryidentifier
Jun 10 2016 00:32
okay I get not adding to it. but I don't know the code for reassign ...
ohhhh right
Coy Sanders
@coymeetsworld
Jun 10 2016 00:32
:)
don't think too hard
Stephen James
@sjames1958gm
Jun 10 2016 00:32
@tvelev92 Its using bootstrap column arrangement - so the offset of 2 is 2/12 of the screen and the md-8 is centered 8/12 of the screen
John
@tertiaryidentifier
Jun 10 2016 00:32
thanks @coymeetsworld , that's always my problem
CamperBot
@camperbot
Jun 10 2016 00:32
tertiaryidentifier sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1113 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2016 00:32
yeah, guess its better than the opposite
:thumbsup:
Luke
@lukenetti3
Jun 10 2016 00:32
@sjames1958gm Yes. notIncluded was an array that contained the arguments to not be included.
Stephen James
@sjames1958gm
Jun 10 2016 00:33
@lukenetti3 So you want the filter function to return true when value is not in the array of the rest of the arguments.
Tzvetlin Velev
@tvelev92
Jun 10 2016 00:34
@sjames1958gm how is it different from col-lg-8 col-lg-2 col-md-8 col-md-2
Stephen James
@sjames1958gm
Jun 10 2016 00:34
@lukenetti3 There is a function onarrays that will return -1 if value is not in notIncluded so if you test for -1 and return true if equal - done
@tvelev92 It is supposed to be md for medium size screens and lg for large, I am not sure I am using that correctly.
John
@tertiaryidentifier
Jun 10 2016 00:35
having a lot of difficult conceptualizing condensing arrays with reduse ...
*reduce
Luke
@lukenetti3
Jun 10 2016 00:38
@sjames1958gm So your saying my filter function that I create will test if the value in the array is in the notIncluded array? I am just not sure how to use that for loop in the filter call.
Stephen James
@sjames1958gm
Jun 10 2016 00:38
@tertiaryidentifier Similar to map and filter, reduce will call the provided function once for each value in the array. The function will be provided with two values.
previous and current - current is just the current entry. Previous is either the initial value (provided after the function (when current is arr[0]) or the return value from the previous call. When the function is called for the last value in the array the returned value is the return value from reduce.
Luke
@lukenetti3
Jun 10 2016 00:38
@sjames1958gm Sorry, I am pretty confused by this.
Stephen James
@sjames1958gm
Jun 10 2016 00:39
@lukenetti3 So you want if (value is not in notIncluded) return true else return false.
notIncluded.indexOf(value) === -1 will test if value is in that array
Luke
@lukenetti3
Jun 10 2016 00:40
@sjames1958gm Okay, then just remove that index of the original array?
John
@tertiaryidentifier
Jun 10 2016 00:40
why do you end the expression with , 0); ...? @sjames1958gm
is that the optional second argument?
Stephen James
@sjames1958gm
Jun 10 2016 00:41
@tertiaryidentifier yes that is the intial value for previous.
flindip
@flindip
Jun 10 2016 00:41
On "Caesar's Cipher" It seems its only returning the first letter value. Not the rest of the string:


function rot13(str) { // LBH QVQ VG!
  for(var i=0;i<str.length;i++){

  var code=str.charCodeAt(0);
    if(code<78){
          return String.fromCharCode(str[i].charCodeAt(0)+13);
      }
      else{
          return String.fromCharCode(str[i].charCodeAt(0)-13);
      }

  }



  return str;    



}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Stephen James
@sjames1958gm
Jun 10 2016 00:41
@lukenetti3 no. Just return true to keep value and false drop value that is how the filter function and filter work together.
John
@tertiaryidentifier
Jun 10 2016 00:42
thanks @sjames1958gm , figured it out ... barely
CamperBot
@camperbot
Jun 10 2016 00:42
tertiaryidentifier sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1499 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 10 2016 00:42
@flindip Look at your code. It returns from both branches of the if else
@flindip Also you need to use [i] when looking at the code as well.
@tertiaryidentifier If you want go back to the sum all the entries in an array challenge and do that with reduce.
Luke
@lukenetti3
Jun 10 2016 00:43

@sjames1958gm function filterFunc(value) {
if (notIncluded.indexOf(value) === -1) {
return true;
} else {
return false;
}

}

for (var j = 0; j < arguments.length; j++) {
arr.filter(filterFunc);
}

Stephen James
@sjames1958gm
Jun 10 2016 00:43
@sjames1958gm You could even do the nested arrays where you multiply with double reduce.
Luke
@lukenetti3
Jun 10 2016 00:44
@sjames1958gm Except how does that for loop play a role?
Stephen James
@sjames1958gm
Jun 10 2016 00:44
@lukenetti3 That is not needed - filter provide the looping
JPar9
@JPar9
Jun 10 2016 00:44
Hi, can anyone help with the celsius to fahrenheit question on intro javascript?
Stephen James
@sjames1958gm
Jun 10 2016 00:45
Also you can just do return (notIncluded.indexOf(value) === -1) ;
@JPar9 What do you have so far?
flindip
@flindip
Jun 10 2016 00:45
@sjames1958gm should I just remove the conditional returns and just a return for the function?
Stephen James
@sjames1958gm
Jun 10 2016 00:45
@lukenetti3 You do need to build notIncluded somewhere.
@flindip Remember the challenge where it talked about the anti pattern of if (condition) return true else return false just replace with return condition; that is what is at work here.
JPar9
@JPar9
Jun 10 2016 00:46
@sjames1958gm Not sure how to copy it, but I put var celsius = celsius * 9/5 + 32; inside the function. It says celsius is already defined. I also tried just the math without the var celsius = and that didn't work either. Is there a way I can easily copy the code to make it make more sense in context?
Luke
@lukenetti3
Jun 10 2016 00:47
@sjames1958gm Heres my whole code. Still not sure what I am doing wrong.

function destroyer(arr) {
// Remove all the values
var newArr = [];
var newerArr = [];
var notIncluded = [];
var store;

for (var i = 0; i < arguments.length; i++) {
notIncluded[i] = arguments[i + 1];

}
notIncluded.pop();

function filterFunc(value) {
if (notIncluded.indexOf(value) === -1) {
return true;
} else {
return false;
}

}

arr.filter(filterFunc);

return arr;
}

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

JPar9
@JPar9
Jun 10 2016 00:47
''' var celsius = celsius * 9/5 + 32;
CamperBot
@camperbot
Jun 10 2016 00:47
:bulb: to format code use backticks! ``` more info
JPar9
@JPar9
Jun 10 2016 00:47
''' var celsius = celsius * 9/5 + 32;
''' test
CamperBot
@camperbot
Jun 10 2016 00:47
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Jun 10 2016 00:47
@JPar9 Isnt' there a variable farhenheit there?
Luke
@lukenetti3
Jun 10 2016 00:47
@sjames1958gm Sorry for all the questions!
JPar9
@JPar9
Jun 10 2016 00:47
There is, but it's aboe the "only change code below this line"
Stephen James
@sjames1958gm
Jun 10 2016 00:47
@JPar9 backticks are next to the one key - press shift-enter after the three then paster
@lukenetti3 np
JPar9
@JPar9
Jun 10 2016 00:48
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line

 var celsius = celsius * 9/5 + 32;

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

// Change the inputs below to test your code
convertToF(30);
Stephen James
@sjames1958gm
Jun 10 2016 00:48
@lukenetti3 1) you are going to bust through then end of arguments. (i < arguments.length - 1)
@JPar9 celsius is the input to your function already provided set the value to be returned.
@lukenetti3 Here is a freebee from the the MDN page on arguments.
var notIncluded = Array.from(arguments).slice(1);
flindip
@flindip
Jun 10 2016 00:50
@sjames1958gm I think I understand. So just 2 if conditionals?
JPar9
@JPar9
Jun 10 2016 00:50
@sjames1958gm Yeah, I know, but how would I set it to do the *9/5+32 operation? Would it have to be a new variable or something?
Stephen James
@sjames1958gm
Jun 10 2016 00:50
@JPar9 Look at the top of the function they have given you the variable
Luke
@lukenetti3
Jun 10 2016 00:51
@sjames1958gm So that needs to go inside my filterFunc? why am I using slice?
flindip
@flindip
Jun 10 2016 00:51
@flindip I just removed the else and its just a return now
Stephen James
@sjames1958gm
Jun 10 2016 00:51
@lukenetti3 That is before your filter function gets rid of your loop to build notIncluded (slice is to remove arguments[0])
JPar9
@JPar9
Jun 10 2016 00:51
@sjames1958gm Would I just do var fahrenheit = and then what I need done with celsius to convert it?
Stephen James
@sjames1958gm
Jun 10 2016 00:51
@JPar9 The code you had to the right of the = sign before was correct
Luke
@lukenetti3
Jun 10 2016 00:52
@sjames1958gm Don't I already have notIncluded built as an array?
Stephen James
@sjames1958gm
Jun 10 2016 00:52
@flindip You will need to check if the char code is between A - Z before adding or subtracting 13.
JPar9
@JPar9
Jun 10 2016 00:52
@sjames1958gm Ok, yeah, it works now. Not sure why I thought celsius had to be the variable being defined as well but I couldn't wrap my head around it any other way for some reason... thanks!!
CamperBot
@camperbot
Jun 10 2016 00:52
jpar9 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1500 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 10 2016 00:52
@lukenetti3 yes, but this is for the future.
@JPar9 The variables in the function definition are variables in the funcition.
@lukenetti3 I am concerned you notIncluded is not entirely correct.
flindip
@flindip
Jun 10 2016 00:53
@sjames1958gm I believe thats what I did with the code(operator)78)
Luke
@lukenetti3
Jun 10 2016 00:54
@sjames1958gm When I tried all of the different arguments it gives me the correct values I want in an array.
Stephen James
@sjames1958gm
Jun 10 2016 00:54
@flindip If you put the following at the top of your function then you can do code >= A && code <= M etc.
  var A = "A".charCodeAt(0);
  var Z = "Z".charCodeAt(0);
  var M = "M".charCodeAt(0);
@lukenetti3 ok. Cool.
Luke
@lukenetti3
Jun 10 2016 00:54
@sjames1958gm I am just not sure why, I can't get it to filter correctly now.
Stephen James
@sjames1958gm
Jun 10 2016 00:55
@lukenetti3 Can you post again.
Luke
@lukenetti3
Jun 10 2016 00:55

function filterFunc(value) {

if (notIncluded.indexOf(value) === -1) {
return true;
} else {
return false;
}

}

arr.filter(filterFunc);

This is my filter function.
@sjames1958gm I realize I could simplify it, but just trying to get it to work for now.
Stephen James
@sjames1958gm
Jun 10 2016 00:56
@lukenetti3 That looks good. Ah, key point filter does not modify arr - you have to return the value returned from filter.
Luke
@lhovee
Jun 10 2016 00:56
why can't my code return false when the true statements aren't met?

function truthCheck(collection, pre) {
  // Is everyone being true?
  var newStr = [];
for (var i=0; i<collection.length; i++) {
  if (collection[i].sex==="male" || "female") {return true;} if (collection[i].onBoat===true) {return true;} if (collection[i].single==="yes") {return true;} 
  else {return false;}}
}
truthCheck([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age");
Luke
@lukenetti3
Jun 10 2016 00:57
@sjames1958gm Got it! Thank you so much! Had been working on that for a long time. Didn't realize that the true or false statements would work like that when I called the filter function.
CamperBot
@camperbot
Jun 10 2016 00:57
lukenetti3 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1501 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
flindip
@flindip
Jun 10 2016 00:58
@sjames1958gm I'm curious would this be easier if I just pushed this into an array?
@sjames1958gm thanks
CamperBot
@camperbot
Jun 10 2016 00:58
flindip sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1502 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 10 2016 00:58
@lhovee Firstly you are hard coding the test values, not a good idea. The reason is that
if (collection[i].sex==="male" || "female") {return true;} is if collection[i].sex === "male" or "female" is not what you think. the === only goes with the stuff before the || the second part of the or (||) is "female" which true so this always returns true.
@flindip Yes, or you can add or subtract 13, convert back to string and += your result string.
Luke
@lhovee
Jun 10 2016 01:00
@sjames1958gm in order to avoid hard coding what could I do? collection[i].pre is what I was thinking originally but that doesn't seem to work
flindip
@flindip
Jun 10 2016 01:00
@sjames1958gm yeah, I think my method path is working. I'm just not getting the full values. If I put it into an array and then join it. I think I may get the whole thing...
Stephen James
@sjames1958gm
Jun 10 2016 01:00
@lukenetti3 the filter function is basically asking the filter function for each value. You want me to keep this? yes(true) or no (false)
@flindip Check - returning is not good as it ends the function on the first value.
Luke
@lukenetti3
Jun 10 2016 01:02
@sjames1958gm That makes sense. Thanks again!
CamperBot
@camperbot
Jun 10 2016 01:02
lukenetti3 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: lukenetti3 already gave sjames1958gm points
Stephen James
@sjames1958gm
Jun 10 2016 01:02
@lhovee Which challenge is this.
Woo HOo 1500 stars :)
Luke
@lhovee
Jun 10 2016 01:03
Everything Be True @sjames1958gm
@sjames1958gm haha congrats! I always wonder if people like you and several others work for FCC or something? Or maybe later challenges require helping other people?
Stephen James
@sjames1958gm
Jun 10 2016 01:05
@lhovee I have run through the challenges and am going through the projects, slowly, I like to help and I keep getting distracted
anthroacoustic
@anthroacoustic
Jun 10 2016 01:05
Hi, I'm having some troube with the "No Repeats Please" Challenge it's my last bonfire :)*
Stephen James
@sjames1958gm
Jun 10 2016 01:06
So in your loop if collection[i][pre] is ever false then you want to return false if none are then return true?
@anthroacoustic That was my last, and most challenging.
Luke
@lhovee
Jun 10 2016 01:07
@sjames1958gm good on ya man. You and a lot of people like you are helping others better themselves. Maybe one day after I get the job FCC will hopefully bring I'll do what you do
anthroacoustic
@anthroacoustic
Jun 10 2016 01:07
I can find the characters that repeat, and I think I've figured out how to permutate through the characters, but somehow it is adding an extra one onto the number
Cacious Siamunyanga
@cacious7
Jun 10 2016 01:07
hey guys am having trouble with the using objects for lookups challenge
anthroacoustic
@anthroacoustic
Jun 10 2016 01:07
@cacious7 what's the name of the challenge?
Stephen James
@sjames1958gm
Jun 10 2016 01:07
@anthroacoustic I used regexp - match(/(.)\1/)
anthroacoustic
@anthroacoustic
Jun 10 2016 01:08
@sjames1958gm hmmm... I haven't used any regexp - yet on this one .. I will look into it. Thank you!
CamperBot
@camperbot
Jun 10 2016 01:08
anthroacoustic sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1503 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 10 2016 01:08
Cacious Siamunyanga
@cacious7
Jun 10 2016 01:10
the chalenge name is "using objects for lookups" under basic javascript
Stephen James
@sjames1958gm
Jun 10 2016 01:11
@cacious7 What do you have so far?
when i print out val, it return the necesary property name entered. but i dont know why i simply cant use that value to in val to look up the properties
Stephen James
@sjames1958gm
Jun 10 2016 01:14
@cacious7 There is no reason to add in a new variable. You need to review this challenge.
https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables
Cacious Siamunyanga
@cacious7
Jun 10 2016 01:15
okay, let me check it out
Luke
@lhovee
Jun 10 2016 01:20
@sjames1958gm I originally didn't see the '?' in your last post to me. Yes, I want to return true for collection[i][pre] if it is and false if it isn't
Stephen James
@sjames1958gm
Jun 10 2016 01:22
@lhovee Earlier you had collection[i].pre which wouldn't work if pre is variable
Luke
@lhovee
Jun 10 2016 01:22
@sjames1958gm right so I started putting an 'if' statement for each possible 'pre' .... good call or no?
Darren Jansen
@DarrenJansen
Jun 10 2016 01:33

I'm having trouble with Factorialize a Number challenge. My code returns the right answers, but the little red Xs done turn to checks. There is one criterion that my code does not meet, which is that factorialize(0) doesn't return the answer 1.

var array=[];
function factorialize(num) {

  var factor=1;
  for(i=num;i>0;i--){
    array.push(num);
    num-=1;
  }

factor = array.reduce(function(a,b){return a*b;});

       return factor;
}
factorialize(5);

Anybody know why it isn't working?

sorry, not "done" I mean "don't"
iammikesingh
@iammikesingh
Jun 10 2016 01:37
hey guys struggling with the record collection challenge. Anyone tell me whats wrong with my code?

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

return collection;
}

Stephen James
@sjames1958gm
Jun 10 2016 01:41
@lhovee Just if (!collection[i][pre]) return false;
@iammikesingh In one case tracks does not exist on the record, you have to check and create if it doesn't
@DarrenJansen First you cannot have global variables. Move array inside your function.
@DarrenJansen Your array should be empty if num is zero, provide 1 as the second argument to reduce and if the array is empty then 1 is result.
Darren Jansen
@DarrenJansen
Jun 10 2016 01:45
@sjames1958gm thanks. I'll try that.
CamperBot
@camperbot
Jun 10 2016 01:45
darrenjansen sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1504 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 10 2016 01:45
@DarrenJansen :+1:
Greg Duncan
@GregatGit
Jun 10 2016 01:50
how can you use the result of function when you checking a condition so you don't have to call the function again
if (myArr.indexOf(2) > -1){
   // can I use the result of myArr.indexOf(2) 
  // with out calling it again?
}
Stephen James
@sjames1958gm
Jun 10 2016 01:51
@GregatGit In other languages you can do the assignment in the conditional, but I don't think so in javascript. WIll have to assign it before the if
Greg Duncan
@GregatGit
Jun 10 2016 01:52
@sjames1958gm thanks for that -
CamperBot
@camperbot
Jun 10 2016 01:52
gregatgit sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1505 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 10 2016 01:54
@GregatGit :+1:
Angelo Ryndon
@AIRyndon
Jun 10 2016 02:09
Halo Everyone! Is there a nicer way of doing the Search and Replace? Here is how I did it..I feel like its pretty crude
function myReplace(str, before, after) {

  var regExp = new RegExp(before,'gi');
  var newString = str.replace(regExp,function(match,p1){

    if(/[A-Z]/.test(match[0])){
      var str1 = after.slice(0,1).toUpperCase();
      var str2 = after.slice(1);

      return str1 + str2;
    }
    return after;
  }); 
  return newString;
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting");
Matt Reynolds
@mareynolds
Jun 10 2016 02:13
In the Search and Replace algorithm, I'm getting "{ [native code] }" instead of the desired uppercase letter. I want to replace the 'before' string with a 'newWord' that has the same capitalization as the original. Not sure why its saying 'native code' instead of a capitalized letter though.
function myReplace(str, before, after)
{
  var fullArr = str.split(" ");
  var newWord = after;
  for (var i = 0; i < fullArr.length; i++)
  {
    if (fullArr[i] === before)
    {
      if (before[0] == before[0].toUpperCase())
      {
        console.log("first char is " + before[0]);
        console.log("full word is " + before);
        newWord = newWord.charAt(0).toUpperCase + newWord.slice(1); 
      }
      fullArr[i] = newWord;
    }
  }
  str = fullArr.join(" ");
  return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Angelo Ryndon
@AIRyndon
Jun 10 2016 02:19
@mareynolds what i posted just above your post does that using regexp, I think toUpperCase() is missing..on the third statement on that if block
Manuel Micu
@manu-4216
Jun 10 2016 02:21
hi there. can someone have a look over my JS twitch project pls (looks, JS code). Here is the link: http://codepen.io/manu4216/full/QEbqxK/
Matt Reynolds
@mareynolds
Jun 10 2016 02:22
wow, its amazing what adding a simple parentheses () will do (it wasn't included on the end of toUpperCase). Now it works! Thanks @AIRyndon
CamperBot
@camperbot
Jun 10 2016 02:22
mareynolds sends brownie points to @airyndon :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @airyndon |http://www.freecodecamp.com/airyndon
Stephen Mansfield
@StephenMansfield
Jun 10 2016 02:22
@manu-4216 is their something wrong with it or just looking for a review?
Angelo Ryndon
@AIRyndon
Jun 10 2016 02:22
@mareynolds :)
Matt Reynolds
@mareynolds
Jun 10 2016 02:25
it's always interesting to see how different other people's code is. Even though they get to the same result, the way the problem is addressed through code can vary significantly from person to person.
Manuel Micu
@manu-4216
Jun 10 2016 02:25
@StephenMansfield Not sure about the code design decisions in general. For instance putting HTML in the JS when displaying the list - not sure about that.
1- Oh, and I couldn't change the state of my <a> buttons (all, online, offline) after visited. Didn't find an answer
2- And not sure if it's ok to load the data one by one, or should have waited for all the list to be ready, then display it
3- And I tried tu use some Sass, but honestly I didn't even use it too much. I feel it was an overkill to use it
4- And not sure about flexbox vs Bootstrap
Clinkzc
@clinkzc
Jun 10 2016 02:37

Can I get help with Multiple Identical Options in Switch Statement please


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

    default: answer= "else";
}

What might be the problem?

Alain
@ALAINF971
Jun 10 2016 02:49
can I get help with the Stand in line chanlenge
Norvin Burrus
@ndburrus
Jun 10 2016 02:50
@clinkzc carefully review the format/ting of the switch statement example and compare to the code... :)
Alain
@ALAINF971
Jun 10 2016 02:50
Capture.PNG
tried to get the last part, wont work
After nextInLine(testArr, 10), testArr[4] should be 10
Rémi Fortier
@mizujin
Jun 10 2016 02:52
@ALAINF971 is that the full code ?
Alain
@ALAINF971
Jun 10 2016 02:53
yes
Norvin Burrus
@ndburrus
Jun 10 2016 02:53
@ALAINF971 ...are you certain you've chosen the appropriate array method? :sparkles: here: return arr.unshift();
Alain
@ALAINF971
Jun 10 2016 02:54
if i use unshift it those not work for this part. nextInLine([5,6,7,8,9], 1) should return 5
i mean if i dont use unshift
Norvin Burrus
@ndburrus
Jun 10 2016 02:55
@ALAINF971 ..compared to using what? it sounds as though you tried another method... this may be useful: "Javascript Array Methods: Unshift(), Shift(), Push(), And Pop()" {ref.: http://www.bennadel.com/blog/1796-javascript-array-methods-unshift-shift-push-and-pop.htm }
Alain
@ALAINF971
Jun 10 2016 02:57
i tried arr[0], but it does not remove the first element. so i have to use unshift()
Capture2.PNG
Rémi Fortier
@mizujin
Jun 10 2016 02:59
@ALAINF971 have you tried shift() instead ?
Norvin Burrus
@ndburrus
Jun 10 2016 02:59
@ALAINF971 The unshift() method can prepend one or more elements to the beginning of an array. prepend: add (something) to the beginning of something else. does this sound like what we're trying to do? ...text from exercise: ...then remove the first element of array. :)
Alain
@ALAINF971
Jun 10 2016 02:59
arr.shift(); let me try
Rémi Fortier
@mizujin
Jun 10 2016 03:00
This is the correct method to remove the first index of an array
Alain
@ALAINF971
Jun 10 2016 03:02
@mizujin thanks shift() worked
CamperBot
@camperbot
Jun 10 2016 03:02
alainf971 sends brownie points to @mizujin :sparkles: :thumbsup: :sparkles:
:cookie: 365 | @mizujin |http://www.freecodecamp.com/mizujin
Rémi Fortier
@mizujin
Jun 10 2016 03:02
@ALAINF971 No problem :-)
Alain
@ALAINF971
Jun 10 2016 03:03
shift()places data at the begining of the array right?
SHAILESH KRISHNA
@krishns18
Jun 10 2016 03:03
removes it from the begining
Norvin Burrus
@ndburrus
Jun 10 2016 03:04
@clinkzc ...how are you doing?
Alain
@ALAINF971
Jun 10 2016 03:04
ok, what does unshift() do then
Rémi Fortier
@mizujin
Jun 10 2016 03:04
@ALAINF971 unshift() puts stuff in the beginning
SHAILESH KRISHNA
@krishns18
Jun 10 2016 03:04
adds it to the beginning
Alain
@ALAINF971
Jun 10 2016 03:05
ok, thanks i got them mixed up. haha
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:05
hey guys, where hv i gone wrong? https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20{%0A%20%20%20%202548%3A%20{%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%202468%3A%20{%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%201245%3A%20{%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20]%0A%20%20%20%20}%2C%0A%20%20%20%205439%3A%20{%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20}%0A}%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse%28JSON.stringify%28collection%29%29%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords%28id%2C%20prop%2C%20value%29%20{%0A%0Aif%20%28value!%3D%3D%20%22%22%20%26%26%20prop!%3D%3D%20%22tracks%22%29{%0A%20%20collection[id][prop].push%28value%29%20%3B%0A}%0A%20%20%0A%20else%20if%20%28prop%20%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22%29{%0A%20%20%20collection[id].tracks.push%28value%29%3B%0A%20}%0A%20%20else%20if%28value%20%3D%3D%3D%22%22%29{%0A%20%20%20%20delete%20collection[id][prop]%3B%0A%20%20}%0A%20%20return%20collection%3B%0A}%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords%285439%2C%20%22artist%22%2C%20%22ABBA%22%29%3B%0A%0A
Rémi Fortier
@mizujin
Jun 10 2016 03:08
@cacious7 wait a second
This message was deleted
This message was deleted
This message was deleted
@cacious7 Are you sure you can use push() on something else than arrays ? ;-)
William Cabell
@wbac88
Jun 10 2016 03:18
Can anyone tell me how to add an element to an array on: https://www.freecodecamp.com/challenges/introducing-javascript-object-notation-json
I have no idea why it's not working.

var myMusic = [
  {
    "artist": "The Pixies",
    "title":"Doolittle",
    "release_year": 1989,
    "formats": [
      "CD",
      "Cassette",
      "LP"
    ],
    "gold": true

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



];
Diego Mayer
@Chrono79
Jun 10 2016 03:20
@wbac88 you need a comma between the 2 objects, each element of an array is separated by commas, you also forgot one }
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:20
@wbac88 {
"artist": "cacious",
"title": "kuyimba",
"release_year" : 2016,
"formats" : ["CD", "DVD", "Blur Ray"]
}
smthing like that
William Cabell
@wbac88
Jun 10 2016 03:20
@Chrono79 Hi again. After the "gold:true" line?
Diego Mayer
@Chrono79
Jun 10 2016 03:21
yes, write }, to close your first object too
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:22
hey guys, is there anything wrong with this statement? delete collection[id][prop];
William Cabell
@wbac88
Jun 10 2016 03:22
OK, fixed both of those, and at line 14, it shows the error: missing semicolon and expected ] to match the one from line 2

var myMusic = [
  {
    "artist": "The Pixies",
    "title":"Doolittle",
    "release_year": 1989,
    "formats": [
      "CD",
      "Cassette",
      "LP"
    ],
    "gold": true,
  }
    {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }

];
Diego Mayer
@Chrono79
Jun 10 2016 03:23
@wbac88 the comma goes between this } {
William Cabell
@wbac88
Jun 10 2016 03:24
@Chrono79 Ah, thanks again for the help! Of course, must be getting tired...
CamperBot
@camperbot
Jun 10 2016 03:24
wbac88 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1107 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 10 2016 03:24
no problem
Norvin Burrus
@ndburrus
Jun 10 2016 03:36
@cacious7 that statement looks ok... :)
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:36
guys, am stuck with challenge "Record Collection"
the error am getting is "collection[id][prop] is undefined
Norvin Burrus
@ndburrus
Jun 10 2016 03:38
@cacious7 can you post your code please? :sparkles:
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:39
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20{%0A%20%20%20%202548%3A%20{%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%202468%3A%20{%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%201245%3A%20{%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20]%0A%20%20%20%20}%2C%0A%20%20%20%205439%3A%20{%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20}%0A}%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse%28JSON.stringify%28collection%29%29%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords%28id%2C%20prop%2C%20value%29%20{%0A%0Aif%20%28value!%3D%3D%20%22%22%20%26%26%20prop!%3D%3D%20%22tracks%22%29{%0A%20%20collection[id][prop].push%28value%29%20%3B%0A}%0A%20%20%0A%20else%20if%20%28prop%20%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22%29{%0A%20%20%20collection[id].tracks.push%28value%29%3B%0A%20}%0A%20%20else%20if%28value%20%3D%3D%3D%22%22%29{%0A%20%20%20%20delete%20collection[id][prop]%3B%0A%20%20}%0A%20%20return%20collection%3B%0A}%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords%285439%2C%20%22artist%22%2C%20%22ABBA%22%29%3B%0A%0A
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:51
does anyone know the soution?
IndiraShrestha
@IndiraShrestha
Jun 10 2016 03:53
help hasownproperty
CamperBot
@camperbot
Jun 10 2016 03:53
no wiki entry for: hasownproperty
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 03:54
@cacious7 yes ,you have to think about the case where tracks is not present in the array and you are performing push operation (which will be invalid because it is still undefined and push can only be performed on arrays)
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:56
@UtkarshShukla7 thanks. so do you have a suggestion on how i can tackle it?
CamperBot
@camperbot
Jun 10 2016 03:56
cacious7 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 601 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Cacious Siamunyanga
@cacious7
Jun 10 2016 03:57
@UtkarshShukla7 and whats wrong with the code, "delete collection[id][prop]" ?
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 03:58
@cacious7 yes ,so first check if the object has tracks property .If yes then push else define tracks as an array and then push in it
@cacious7 seems correct ,why any issues with it
Ian Arsenault
@ianarsenault
Jun 10 2016 04:00
anyone know if I'm supposed to be doing a switch statement for the counting cards problem?
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:01
@GorgonsMaze yes you can use switch statement for it
Malcolm Walters
@MalWalters
Jun 10 2016 04:03

Hi, Anyone able to help me with the Seek and Destroy Bonfire? ```function destroyer(arr) {
var temp = arguments[0];
var filtered = [];
var criteria;

for (var i = 1; i < arguments.length; i++){
criteria = arguments[i];
filtered = temp.filter(function(i,criteria){
return (i != criteria);
});
}
return filtered;
}

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

Cacious Siamunyanga
@cacious7
Jun 10 2016 04:03
@UtkarshShukla7 "TypeError: collection[id][prop] is undefined" is the error am getting from the console
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:05
@cacious7 ok let me check ,have you done what I told you to do?
@cacious7 Also ,I didn't noticed this earlier but you are also pushing when prop!==tracks.So change it to this
if (value!== "" && prop!== "tracks"){
  collection[id][prop]=value ;
}
Cacious Siamunyanga
@cacious7
Jun 10 2016 04:08
thanks
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:08
@cacious7 and I can't seem to reproduce that error .Can you tell me for which case you got this error
Shusil Banjade
@shusil123
Jun 10 2016 04:08
@MalWalters , don't make functions ( filters ) inside a loop . You can push the i to a new array if it's not equal to criteria and return the array
Use val instead of 'i' in the filter . That looks confusing ( two i's )
Malcolm Walters
@MalWalters
Jun 10 2016 04:13
@shusil123 Not quite sure I follow, sorry. I thought that using .filter I wouldn't have to loop through the elements of the array (arguments[0])
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:14
@MalWalters read this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
Also,change your filter will always get the same result if you'll use filter on temp instead of filtered
KESHAV KUNDAL
@keshav929
Jun 10 2016 04:16
hi guys i need some serious urgent help , i am working on a project and i have to submit it tomorrow , i am trying to implement a scroll effect. but i dont how to start , the thing is there will be a wide search bar in the middle of the homepage and on scrolling , after the search bar goes out of the page it appears in the navigation bar . if anyone can help me out , i 'll be thankful.. :)
bitgrower
@bitgrower
Jun 10 2016 04:16

@MalWalters first of all ... you should copy the contents of the arguments object to a new array ...

when you set arguments[0] to temp, I'm not sure what kind of variable js now sees temp to be ... but it's probably NOT an array ... which would make attempting to use array.filter not work ...

Cacious Siamunyanga
@cacious7
Jun 10 2016 04:16
@UtkarshShukla7 maybe i just ned to reload
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:17
@cacious7 or better reset and start with fresh code
Malcolm Walters
@MalWalters
Jun 10 2016 04:17
@UtkarshShukla7 Thanks, I've read through the documentation but still not getting it working. There's something I'm not understanding, I'll go through a few more suggestions from the chat and see where I get to.
CamperBot
@camperbot
Jun 10 2016 04:17
malwalters sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 602 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
bitgrower
@bitgrower
Jun 10 2016 04:18
@keshav929 sorry - can't help you very much except to tell you there is js code out there which implements smooth scrolling -- if you are using ajax, the problem is in the propagation of the scroll event up the dom, and there are ways to prevent that ... other than that, can't help you ...
Jack C
@JackCameo
Jun 10 2016 04:18
Can someone please help me, I'm stuck on the javascript profile lookup
Am I suppose to be using a for loop
KESHAV KUNDAL
@keshav929
Jun 10 2016 04:18
i have seen that @bitgrower thanks anyways
CamperBot
@camperbot
Jun 10 2016 04:18
keshav929 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1091 | @bitgrower |http://www.freecodecamp.com/bitgrower
Deepak Manjunath
@Deepak2322
Jun 10 2016 04:18
$(document).ready(function(){
    function noScrollEvent(){
    window.addEventListener("keydown", function(e) {
        // space and arrow keys
        if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
            e.preventDefault();
        }
    }, false);
}

    $('#register_gender,#register_date').keydown(function(){
        var isVisible = $(':input').is(':visible');
        if(isVisible){
            noScrollEvent();
        }
        else{
            return true;
        }
    });

});
i am calling the noscrollevent function when dropdown is visible,however this event stays even if it is not visible. it means i will not be able to scroll the page using arrows and spacebar
bitgrower
@bitgrower
Jun 10 2016 04:19
@JackCameo yes
help profile lookup
CamperBot
@camperbot
Jun 10 2016 04:19

:point_right: challenge profile lookup [wiki]

Challenge Profile Lookup

Instructions

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

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

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

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

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

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

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about challenge profile lookup on the FCC Wiki

Dan Crews
@DannyCrews
Jun 10 2016 04:19
@cacious7 value!== "" should be value !== ""
Joseph
@revisualize
Jun 10 2016 04:20
Hey hey.
bitgrower
@bitgrower
Jun 10 2016 04:20
We have an array of objects representing different people in our contacts lists. <<< -- notice it says ARRAY of objects ... the way you find stuff in an array is usually by using a for loop :)
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:21
@MalWalters man when you pass criteria in the filter function it will be treated as index of temp .So just remove it from arguments and let it be inside the function and you should see some changes
bitgrower
@bitgrower
Jun 10 2016 04:21
actually, I should say, iterate thru an array ... you can also use indexOf in an array -- (useful in Seek & Destroy @MalWalters )
Jack C
@JackCameo
Jun 10 2016 04:22
@bitgrower can you please tell me what I'm doing wrong here
for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else if (contacts[i].firstName == firstName && !(contacts[i].hasOwnProperty(prop))){
      return "No such property";
    } else if (contacts[i].firstName !== firstName) {
      return "No such contact";
    }
  }
bitgrower
@bitgrower
Jun 10 2016 04:23
not with code looking like that !
Jack C
@JackCameo
Jun 10 2016 04:23
lol I forgot how to paste code
bitgrower
@bitgrower
Jun 10 2016 04:23
help format code
CamperBot
@camperbot
Jun 10 2016 04:23
no wiki entry for: format code
bitgrower
@bitgrower
Jun 10 2016 04:23
help paste code
CamperBot
@camperbot
Jun 10 2016 04:23
no wiki entry for: paste code
bitgrower
@bitgrower
Jun 10 2016 04:24
argh ... my terminology finder is failing ...
Samuel Cupidon
@Zerazera
Jun 10 2016 04:24
help code like a pro
CamperBot
@camperbot
Jun 10 2016 04:24
no wiki entry for: code like a pro
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:24
@MalWalters actually you just have to change filtered =temp initially .Then apply filter function on it (instead of temp) and remove the criteria from arguments of filter function and your challenge should pass
help format
CamperBot
@camperbot
Jun 10 2016 04:24

: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

Dan Crews
@DannyCrews
Jun 10 2016 04:24
@bitgrower Post your code between two sets of three backticks ```
bitgrower
@bitgrower
Jun 10 2016 04:24
thank you @UtkarshShukla7
CamperBot
@camperbot
Jun 10 2016 04:24
bitgrower sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 603 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:24
@bitgrower np :wink:
Austin Melendez
@LCapitan
Jun 10 2016 04:24

could someone tell me why this is incorrect?
// 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];

bitgrower
@bitgrower
Jun 10 2016 04:25
LOL -- I know how to paste code, I was trying to find the instructions for someone else ... @DannyCrews
Noel
@knowellG
Jun 10 2016 04:25
'''
CamperBot
@camperbot
Jun 10 2016 04:25
:bulb: to format code use backticks! ``` more info
Jack C
@JackCameo
Jun 10 2016 04:25
@bitgrower
for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else if (contacts[i].firstName == firstName && !(contacts[i].hasOwnProperty(prop))){
      return "No such property";
    } else if (contacts[i].firstName !== firstName) {
      return "No such contact";
    }
  }
i revised it moving the final if and making that last return outside of the for loop
oh that fixed it
Dan Crews
@DannyCrews
Jun 10 2016 04:26
@bitgrower I was actually trying to respond to him! LOL fumble finger :(
Jack C
@JackCameo
Jun 10 2016 04:27
@bitgrower @DannyCrews thank you
CamperBot
@camperbot
Jun 10 2016 04:27
jackcameo sends brownie points to @bitgrower and @dannycrews :sparkles: :thumbsup: :sparkles:
:cookie: 346 | @dannycrews |http://www.freecodecamp.com/dannycrews
:star2: 1092 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 10 2016 04:27
@MalWalters -- you are also using arguments.length as your loop terminator, it's quite possible that value is going to be re-evaluated ... you are doing some things I've never seen anyone try to do before ... so the results are not very clear to me ... like, if you shorten what arguments[0] is in length, whether that affects the length of temp (probably so, would be my guess ... )
Jack C
@JackCameo
Jun 10 2016 04:27
brownie points!
Austin Melendez
@LCapitan
Jun 10 2016 04:27

'''
// 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];''' anyone? lol

CamperBot
@camperbot
Jun 10 2016 04:27
:bulb: to format code use backticks! ``` more info
Austin Melendez
@LCapitan
Jun 10 2016 04:27
That didn't work as I thought it would..
bitgrower
@bitgrower
Jun 10 2016 04:28
@DannyCrews nah, not fumble fingers ... tricky gitter auto-complete ... has to be the worst auto-complete i've ever seen ...
Jack C
@JackCameo
Jun 10 2016 04:28
@LCapitan use back ticks - button to left of 1 on keyboard
Austin Melendez
@LCapitan
Jun 10 2016 04:28
// 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];
bitgrower
@bitgrower
Jun 10 2016 04:28
@LCapitan try putting the variable playerNumber where you currently have 16 ... in the var player
Austin Melendez
@LCapitan
Jun 10 2016 04:28
Niceee
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:29
@bitgrower @MalWalters you can use arguments.length
Austin Melendez
@LCapitan
Jun 10 2016 04:29
Bueno. Thanks @bitgrower !
CamperBot
@camperbot
Jun 10 2016 04:29
lcapitan sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1093 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 10 2016 04:30
arguments.length is valid ... but if you are changing the lenght of the underlying data structure, then the lenght will be re-evaluated at each instance of the loop iteration ... and, if you are shortening it ... which happens frequentlly with array.filter, then the length will be different (shorter)
Malcolm Walters
@MalWalters
Jun 10 2016 04:30
@UtkarshShukla7 Thanks, those suggestions worked!
CamperBot
@camperbot
Jun 10 2016 04:30
malwalters sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:warning: malwalters already gave utkarshshukla7 points
Dan Crews
@DannyCrews
Jun 10 2016 04:30
@LCapitan And get rid of the space in testObj []
bitgrower
@bitgrower
Jun 10 2016 04:30
it's not that arguments.length isn't valid ...
it's that it most likely changes length due to activity within the loop ...
Khawaja Asim
@tmAsim
Jun 10 2016 04:31
Hi
i just struck in one challange
any body here who can help me ?
Malcolm Walters
@MalWalters
Jun 10 2016 04:32
@UtkarshShukla7 With this set up though I do still have a warning about making functions within loops so I'm guessing this is far from best practice
Norvin Burrus
@ndburrus
Jun 10 2016 04:33
@tmAsim what are you working on?
Khawaja Asim
@tmAsim
Jun 10 2016 04:33
@ndburrus javascript code challenge
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:33
@bitgrower But because he is not performing any changes to the arguments array,he can use it although your point is valid too
Norvin Burrus
@ndburrus
Jun 10 2016 04:33
@tmAsim exercise/challenge name?
Noel
@knowellG
Jun 10 2016 04:34
Can anyone explain array.sort() to me? I'm not understanding what the compare (callback) function is supposed to do.
bitgrower
@bitgrower
Jun 10 2016 04:34
yeah ... I think the coding here is sufficiently non-standard ... which means there's enough vaguery to lead to confusion ...
Khawaja Asim
@tmAsim
Jun 10 2016 04:35
@ndburrus Golf Code
Malcolm Walters
@MalWalters
Jun 10 2016 04:35
@bitgrower The code passes but with a warning about making functions within loops, so this is far from a great solution. I'll keep working on it and see if I can get around it somehow.
Norvin Burrus
@ndburrus
Jun 10 2016 04:35
@tmAsim can you post your code?
Khawaja Asim
@tmAsim
Jun 10 2016 04:36
@ndburrus function golfScore(par, strokes) {
if(strokes==1){return "Hole-in-one!";}
else if(strokes >= par+3){return "Go Home!";}
else if(strokes == par+2){return "Double Bongey";}
else if(strokes == par+1){return "Bogey";}
else if(strokes == par){return "Par";}
else if(strokes == par-1){return "Birdie";}
else {return "Eagle";}
}
golfScore(4, 6);
@ndburrus Error says : golfScore(4, 6) should return "Double Bogey"
Khawaja Asim
@tmAsim
Jun 10 2016 04:37
@ndburrus oh sorry thank you so much
CamperBot
@camperbot
Jun 10 2016 04:37
tmasim sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 491 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 10 2016 04:37
@tmAsim why are you starting at the top of the chart (with hole in one), then jumping to the end of the chart (go home)? you resolved it?
Dan Crews
@DannyCrews
Jun 10 2016 04:38
@knowellG That callback is actually called compareFunction and you can define your sort order to be something other than the default.
Khawaja Asim
@tmAsim
Jun 10 2016 04:38
@ndburrus yup
Norvin Burrus
@ndburrus
Jun 10 2016 04:38
@tmAsim what was it?
Khawaja Asim
@tmAsim
Jun 10 2016 04:38
@ndburrus thank you for your support
would you like to suggest me better solution ?
CamperBot
@camperbot
Jun 10 2016 04:38
tmasim sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: tmasim already gave ndburrus points
Matt Reynolds
@mareynolds
Jun 10 2016 04:39
This message was deleted
Khawaja Asim
@tmAsim
Jun 10 2016 04:39
@ndburrus miss spelled
Gautham Chander
@Gauthamchander
Jun 10 2016 04:39

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var timesFour = oldArray.map(function(val){
return val + 3;
});
var newArray = oldArray;

You should add three to each value in the array.
im struggling in this pls help
Noel
@knowellG
Jun 10 2016 04:39
@DannyCrews I get that, but the arguments passed in (a,b) pointing to the first 2 in the array?
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:40
@Gauthamchander maybe apply map on newArray instead of oldArray
Norvin Burrus
@ndburrus
Jun 10 2016 04:40
@tmAsim ok... i think the solution is as good as it can get. i would be consistent with the chart order, though. (just a personal preference) the code starts at the top with hole in one, then jumps to the end of the chart (go home) - and proceeds through the chart in reverse chronological order.. :) you're welcome.. :)
Khawaja Asim
@tmAsim
Jun 10 2016 04:40
This message was deleted
@ndburrus thankyou
CamperBot
@camperbot
Jun 10 2016 04:41
tmasim sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: tmasim already gave ndburrus points
Matt Reynolds
@mareynolds
Jun 10 2016 04:41
I'm struggling with JS object lookups in the Profile Lookup challenge. How can I look check to see if the 'firstName' is found in this object and if so, then return another property (i.e. return the corresponding last name)? Every time I run this code it fails the IF statement, but I know the name is in the list so it should find a match. Any help?
//Setup
var contacts = [
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];
function lookUpProfile(firstName, prop)
{
// Only change code below this line
  for (var i = 0; i < 4; i++)
  {
    if (firstName == contacts[i].hasOwnProperty(firstName)) {
      console.log("first name matches");
    } else {
      console.log("not found in iteration " + i);
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
bitgrower
@bitgrower
Jun 10 2016 04:44

@MalWalters -- one of the lessons of seek and destroy is supposed to be how to handle the arguments object ... and come in contact with specific idiosyncrasies of the arguments object, specifically, that the arguments object is "array like", but not an array ... as well as the fact that the variable named arguments object refers to something different in each new scope (eg, in a function call) ... and , yeah, making a function within a call (the anonymous function passed to array filter) is probably not a good idea, either ...

one of the things which will empower your coding is to know how to take all the values in the arguments object and put them into a local variable (copying them) so they can be easily used in other scopes (eg, called functions) ...

And yes, it can be as simple as just iterating thru the arguments object and pushing the arguments into a new array ... (actually, apparently the preferred way, because of the V8 version(?) of js -- which is what chrome is based on ... ) ... there's also a (not recommended by some because of the v8 js) line of code which will do the same thing found on the MDN arguments object page ...

Norvin Burrus
@ndburrus
Jun 10 2016 04:44
@mareynolds check the format/syntax of this statement/piece of code i < 4. also, this line console.log("first name matches"); is good for viewing the output, but does not meet the requirement... :) the next step after this statement need to check if the input prop is in the firstName record.... :)
bitgrower
@bitgrower
Jun 10 2016 04:45
anyway -- GREAT job getting it to work ... even though your solution is a bit non-standard ... I like the ingenuity of it ... I'm sure that took some hair pulling ... S&D is not an easy challenge ... :)
bitgrower
@bitgrower
Jun 10 2016 04:47
and my apologies ... and thanks to @UtkarshShukla7 ... :)
CamperBot
@camperbot
Jun 10 2016 04:47
bitgrower sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave utkarshshukla7 points
Malcolm Walters
@MalWalters
Jun 10 2016 04:48
@bitgrower Thanks, that explanation and background really helps. With that in mind I'll see if I can re-write and still get it to work. After 2 days on this one I'd really like to move forward but I can see the benefits of getting this cleared up here and now. Thanks again for all the help and guidance.
CamperBot
@camperbot
Jun 10 2016 04:48
malwalters sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1094 | @bitgrower |http://www.freecodecamp.com/bitgrower
Dan Crews
@DannyCrews
Jun 10 2016 04:48
This message was deleted
This message was deleted
Noel
@knowellG
Jun 10 2016 04:50
oohhh OK. That makes it clearer. Thanks @DannyCrews !
CamperBot
@camperbot
Jun 10 2016 04:50
knowellg sends brownie points to @dannycrews :sparkles: :thumbsup: :sparkles:
:cookie: 347 | @dannycrews |http://www.freecodecamp.com/dannycrews
Dan Crews
@DannyCrews
Jun 10 2016 04:50

@knowellG It steps through pairs:
```var numbers = [1,5,3.14];
When you call numbers.sort(compare), internally it will actually execute:

compare(1,5); // Returns -4, a is less than b
compare(1,3.14); // Return -2.14, a is less than b
compare(5,3.14); // returns 1.86, a is greater than b
```

ack, it's late - lol
Noel
@knowellG
Jun 10 2016 04:52
cool. thanks a lot.
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:52
@bitgrower Still new at this .I think I should be more considerate about the best practises .You are correct my method is sort of amiguous and promotes bad practise .Thanks to you ,now I will check out those too :smile: .And please sir no need to apologise .If anything you are helping me
Matt Reynolds
@mareynolds
Jun 10 2016 04:53

@ndburrus what's wrong with i < 4 in the For loop? I changed the "first name matches" to return true instead, but at this point my loop never gets to that point so something else is amiss. Isn't the line

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

going to show it is a true statement because in the example, it can find the prop 'firstName' in one of the properties in the contacts array?

David Halls
@DavidHalls
Jun 10 2016 04:54
@mareynolds hasOwnProperty will already return t or f
Malcolm Walters
@MalWalters
Jun 10 2016 04:54
@UtkarshShukla7 Every set of eyes helps :)
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 04:55
@MalWalters Really .Many a times I have pasted my code to help others and i got suggestions for improvement .
which helps to learn new things
Norvin Burrus
@ndburrus
Jun 10 2016 04:56
@mareynolds i guess you could use 4 for the number of iterations (because the object length is known). was code added to check for prop within a firstName match/ed record?
Noel
@knowellG
Jun 10 2016 04:56
@mareynolds, Looks like your 'if' condition is comparing firstName to a boolean
Chris Cullen
@123xylem
Jun 10 2016 04:57
help Smallest Common Multiple
CamperBot
@camperbot
Jun 10 2016 04:57

:point_right: algorithm smallest common multiple [wiki]

Algorithm Smallest Common Multiple

Explanation:

The smallest common multiple between two numbers is the smallest number that both numbers can divide into. This concept can be extended to more than two numbers as well.

We can first start with just finding the smallest common multiple between two numbers. Naively, you can start writing out multiple of each number until you write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The first smallest number we run into in both lists is 12 so this is the smallest common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common multiple of just the two numbers but forget the keyword range. However, this means that if you are given [1,5], then you have to check for the smallest common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by all of them.

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

Matt Reynolds
@mareynolds
Jun 10 2016 04:58
@knowellG ah ok. so if I loop through 'i' times to look through each element in the contacts array, one of them will find a first name value that matches the input, so it should return a true. But I just ran it and it never finds it, so something is still missing.
if (contacts[i].hasOwnProperty(firstName)) {
Norvin Burrus
@ndburrus
Jun 10 2016 04:59
This message was deleted
David Halls
@DavidHalls
Jun 10 2016 04:59
@mareynolds no, it is looking to see if it has the PROPERTY, not the value of firstname
Gautham Chander
@Gauthamchander
Jun 10 2016 05:00
no its not coming @UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 05:00
@Gauthamchander name of challenge?
Gautham Chander
@Gauthamchander
Jun 10 2016 05:01
Iterate over Arrays with map @UtkarshShukla7
Matt Reynolds
@mareynolds
Jun 10 2016 05:02
I'm confused. This is the provided array, and since each element in the array has a 'firstName' property, how do I check if one of them matches a given input (e.g. 'firstName' == 'Kristian')?
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 05:02
@Gauthamchander your code seems correct nut it is not modifying newArray
var newArray = oldArray.map(function(val){
  return val + 3;
});
Gautham Chander
@Gauthamchander
Jun 10 2016 05:03
it worked thanks a lot @UtkarshShukla7
CamperBot
@camperbot
Jun 10 2016 05:03
gauthamchander sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 604 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 05:03
@Gauthamchander np
David Halls
@DavidHalls
Jun 10 2016 05:04
@mareynolds what is the challenge asking you to do?
UtkarshShukla7
@UtkarshShukla7
Jun 10 2016 05:04
Profile lookup
Danielle Duncan
@danielleduncan
Jun 10 2016 05:04
my code is confirming the ending of one word strings but not the last word of sentences.function confirmEnding(str, target) { var arr = [str]; if (arr.length == 1) { if (str.slice(str.length - 1) == target) { return true; } else { return false; } } else if (arr.length > 1) { if (arr.splice(arr.length - 1) == target) { return true; } else { return false; } } }theses are the error messages i'm getting confirmEnding("He has to give me a new name", "name") should return true.
confirmEnding("He has to give me a new name", "me") should return true.
Noel
@knowellG
Jun 10 2016 05:04
@mareynolds, contacts[i].firstName == 'Kristian' or contacts[i]["firstName"] == 'Kristian'
Danielle Duncan
@danielleduncan
Jun 10 2016 05:04
the first error msg makes sense, but the second one seems as though it should be false
I'm going to repost the code with indentation
function confirmEnding(str, target) {
var arr = [str];
if (arr.length == 1) {
if (str.slice(str.length - 1) == target) {
return true;
}
else {
return false;
}
}
else if (arr.length > 1) {
if (arr.splice(arr.length - 1) == target) {
return true;
}
else {
return false;
}
}
}
*guess not, lol
Matt Reynolds
@mareynolds
Jun 10 2016 05:06

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

If both are true, then return the "value" of that property.
If firstName does not correspond to any contacts then return "No such contact"
If prop does not correspond to any valid properties then return "No such property"

Mahesh-sathavalli
@Mahesh-sathavalli
Jun 10 2016 05:06

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

// Only change code below this line;

var playerNumber = "16"; // Change this Line
var player = testObj[playerNumber]; // Change this Line

David Halls
@DavidHalls
Jun 10 2016 05:06
@mareynolds ok, so the way you had it first was close, but you dont need hasOwnProperty in that if statement. You will probably need multiple if statements
Mahesh-sathavalli
@Mahesh-sathavalli
Jun 10 2016 05:07

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

// Only change code below this line;

var playerNumber = "16"; // Change this Line
var player = testObj[playerNumber]; This code is not working in challenge 219

Norvin Burrus
@ndburrus
Jun 10 2016 05:08
@Mahesh-sathavalli challenge name?
Mahesh-sathavalli
@Mahesh-sathavalli
Jun 10 2016 05:08
Accessing Objects Properties with Variables
David Halls
@DavidHalls
Jun 10 2016 05:10
@Mahesh-sathavalli is "16" a string or a number?
Mahesh-sathavalli
@Mahesh-sathavalli
Jun 10 2016 05:11
@Byzgig I have assigned string now but it is the number in testObj
David Halls
@DavidHalls
Jun 10 2016 05:11
@Mahesh-sathavalli so, with you having it assigned as a string, will it ever match a number?
Mahesh-sathavalli
@Mahesh-sathavalli
Jun 10 2016 05:12
@Byzgig It worked I removed the string made it number
@Byzgig thankyou
CamperBot
@camperbot
Jun 10 2016 05:12
mahesh-sathavalli sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @byzgig |http://www.freecodecamp.com/byzgig
David Halls
@DavidHalls
Jun 10 2016 05:12
@Mahesh-sathavalli cheers
pentaxpic
@pentaxpic
Jun 10 2016 05:15
hi all, i have issue with the challenge "record collection" - i keep getting the error [cannot read property 'push' of undefined]. any advice or help will be greatly appreciated.
David Halls
@DavidHalls
Jun 10 2016 05:15
@pentaxpic sounds like you are trying to access a variable that you have not declared
Dan Crews
@DannyCrews
Jun 10 2016 05:19
@pentaxpic This TypeError means that the variable to the left of the push method is undefined - sounds like it might be a scope issue
Markus Kiili
@Masd925
Jun 10 2016 05:20
@pentaxpic If the tracks array is absent, you need to create it.
pentaxpic
@pentaxpic
Jun 10 2016 05:22
@Byzgig @DannyCrews @Masd925 phew, ok, i finally got it, thank you all for all your help! you guys are amazing!
CamperBot
@camperbot
Jun 10 2016 05:22
pentaxpic sends brownie points to @byzgig and @dannycrews and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @byzgig |http://www.freecodecamp.com/byzgig
:star2: 1797 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 348 | @dannycrews |http://www.freecodecamp.com/dannycrews
chantasaur
@chantasaur
Jun 10 2016 05:24
i have a question i want to have a function that syncs across all users, that runs by itself
Dan Crews
@DannyCrews
Jun 10 2016 05:26
@danielleduncan You're kind of off on the wrong track. Look at the documentation for substr() and think about using Str.length. There shouldn't be any numbers in the code since you need to address the general case that target can be any length.
Markus Kiili
@Masd925
Jun 10 2016 05:28
@chantasaur You are talking about backend coding?
chantasaur
@chantasaur
Jun 10 2016 05:29
@Masd925 yes but that chat is dead rn
AmanuelTilahun
@AmanuelTilahun
Jun 10 2016 05:54
var code = "formatted";
didnt mean to send that
Can someone help me with Chaining if else statements? Medium is not working.
Coy Sanders
@coymeetsworld
Jun 10 2016 05:58
what do you have @AmanuelTilahun and what are your errors?
AmanuelTilahun
@AmanuelTilahun
Jun 10 2016 05:59

this is the whole code:
function testSize(num) {
// Only change code below this line
if (num < 5) {
return "Tiny";
}
else if (num < 10) {
return "Small";
}
else if (num < 15) {
return "Meduim";
}
else if (num < 20) {
return "Large";
}
else if (num >= 20) {
return "Huge";
}
else {
return "Change Me";
}
// Only change code above this line
}

// Change this value to test
testSize(10);

Coy Sanders
@coymeetsworld
Jun 10 2016 05:59
spelled medium wrong
you can also remove the else statement too, its not necessary
AmanuelTilahun
@AmanuelTilahun
Jun 10 2016 06:00
oh man, thanks @coymeetsworld
CamperBot
@camperbot
Jun 10 2016 06:00
amanueltilahun sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1115 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2016 06:00
since your if statements cover all ranges of numbers and you won't get anything but a number in the tests, the else statement will never execute
or even better is remove else if (num >= 20) with just else
since if the chain gets that far you know for a fact number has to be greater than or equal to 20
so you don't need to check for it
AmanuelTilahun
@AmanuelTilahun
Jun 10 2016 06:02
I see, thanks again for the help
Coy Sanders
@coymeetsworld
Jun 10 2016 06:02
no problem
Shraddha Parab
@Shraddha99
Jun 10 2016 06:22

Testing Objects for Properties challenege . I type this code var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

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

this runs fine . but it won't work if I use the . opertaor
operator*
like return myObj.checkProp;
Coy Sanders
@coymeetsworld
Jun 10 2016 06:23
thats because the dot operator doesn't work when the property is a variable
Brendan Kinahan
@BKinahan
Jun 10 2016 06:23
@Shraddha99 dot operator works differently. there is no property named "checkProp", checkProp is a variable, not a property name.
Coy Sanders
@coymeetsworld
Jun 10 2016 06:24
you can only use dot operator if you know what the literal name of the property is, or else it will check for a property literally named checkProp
Shraddha Parab
@Shraddha99
Jun 10 2016 06:24
okay I got it Thank You @BKinahan @coymeetsworld :)
CamperBot
@camperbot
Jun 10 2016 06:24
shraddha99 sends brownie points to @bkinahan and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1609 | @bkinahan |http://www.freecodecamp.com/bkinahan
:star2: 1116 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2016 06:24
no problem @Shraddha99
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:26
hay there
kirbyedy
@kirbyedy
Jun 10 2016 06:26
@BKinahan hey you are a bit early today ? :D
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:26
i got stuck on javascript exercise
153
You should use two double quotes (") and four escaped double quotes (\").
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
please help me out
Coy Sanders
@coymeetsworld
Jun 10 2016 06:27
what do you have for it?
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:27
anyone ?
Coy Sanders
@coymeetsworld
Jun 10 2016 06:28
what do you have for myStr @MuhammadTahaBhatti ?
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:28
var myStr= "\"I am a \"double quoted\" string \""
Coy Sanders
@coymeetsworld
Jun 10 2016 06:29
thats not the whole string
Achillesthewarrior
@Achillesthewarrior
Jun 10 2016 06:29
if(arr[0]==="a"||"e"||"i"||"o"||"u"){
      arr.push("way");
      var newArr = arr.join("");
      return newArr;
    }
Above if statement is not performing correctly as it is executing even for consonants. Plz help.
Coy Sanders
@coymeetsworld
Jun 10 2016 06:29
also there's no quote before I
the string should be I am a "double quoted" string inside "double quotes".
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:29
i tried this too but not working :(
Coy Sanders
@coymeetsworld
Jun 10 2016 06:30
You need to put double quotes between that string, and every double quote inside of that String you need to put a backslash before it
eeflores
@eeflores
Jun 10 2016 06:30
@Achillesthewarrior there should be tests between each || eg arr[0] === 'a' || arr[0] === 'e'
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:30
got it :)
Achillesthewarrior
@Achillesthewarrior
Jun 10 2016 06:31
@eeflores any other way to shorten the process?
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:31
i missed the dot sign :D
Julian Müller
@Julian24816
Jun 10 2016 06:31
your code should look like that: var myStr="I am a \"double quoted\" string inside \"double quotes\"."
Coy Sanders
@coymeetsworld
Jun 10 2016 06:31
you could use regex @Achillesthewarrior
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:31
:sparkles:
Coy Sanders
@coymeetsworld
Jun 10 2016 06:31
although i don't think you're that far
Muhammad Taha Bhatti
@MuhammadTahaBhatti
Jun 10 2016 06:31
Thank you @coymeetsworld and @Julian24816 :)
CamperBot
@camperbot
Jun 10 2016 06:31
muhammadtahabhatti sends brownie points to @coymeetsworld and @julian24816 :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @julian24816 |http://www.freecodecamp.com/julian24816
:star2: 1117 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2016 06:31
@Julian24816 next time can you let him try to figure it out? He'll learn it better when he doesn't have to copy and paste
Achillesthewarrior
@Achillesthewarrior
Jun 10 2016 06:32
i can use regex. but even in the above case it should not execute for the consonants. Why it is doing so?
Coy Sanders
@coymeetsworld
Jun 10 2016 06:32
did you see what @eeflores wrote? your original way of comparing arr[0] to those vowels won't work
eeflores
@eeflores
Jun 10 2016 06:32
@Achillesthewarrior the single char expressions between each ||are evaluating to true
@Achillesthewarrior if('e') { console.log("is true"); }
Achillesthewarrior
@Achillesthewarrior
Jun 10 2016 06:33
but my arr[0] is "c"
or i am missing something?
eeflores
@eeflores
Jun 10 2016 06:34
your if combines multiple tests - the second to fifth test evaluates to true
@Achillesthewarrior this is regardless of what arr[0] is
Jaren Escueta
@jarenescueta731
Jun 10 2016 06:36
anyone available to help me out with the wikipedia viewer project?
eeflores
@eeflores
Jun 10 2016 06:36
@Achillesthewarrior look at the falsy bouncer exercise
Achillesthewarrior
@Achillesthewarrior
Jun 10 2016 06:37
@eeflores I still don't get it. let me check falsy bouncer exercise. thanx @eeflores
CamperBot
@camperbot
Jun 10 2016 06:37
achillesthewarrior sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 748 | @eeflores |http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jun 10 2016 06:37
good luck @Achillesthewarrior
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 06:37
Help me find the error in my program for
Search and replace
function replace(str, before, after) {
  // Find index where before is on string
  if(before.charAt(0)===before.charAt(0).toUpperCase()){
      str = str.replace(before, after.toCharAt(0).toUpperCase()+after.slice(1));

  }
  else{
      str = str.replace(before, after);

  }

  return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
CamperBot
@camperbot
Jun 10 2016 06:37
no wiki entry for: me find the error in my program for search and replacefunction replacestr before after find index where before is on string ifbeforecharat0beforecharat0touppercase str strreplacebefore aftertocharat0touppercaseafterslice1 else str strreplacebefore after return strmyreplacea quick brown fox jumped over the lazy dog jumped leaped
Alex T.
@lx-t
Jun 10 2016 06:38
@Achillesthewarrior You expression is always true, because it works this way: first, it compares arr[0] with "a", in case it is not true, it moves to the next expression after logical or operator ||, "e" is always true because it is not an empty string. There you go, your if expression is always true.
Mason Posch
@masonposch
Jun 10 2016 06:38

On "Profile Lookup." I'm know I took a wrong turn somewhere when it came to loops. This might be dumb, but the only thing I can think of is to you if statements within a while loop... Any suggestions or pointers in the right direction?

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

}

contacts.push[i];

i++;
// Only change code above this line
}

Thomas Nguyen
@thomasnguyen
Jun 10 2016 06:38
hey guys so in my code do i put functions or global varibles at the top of my code
Achillesthewarrior
@Achillesthewarrior
Jun 10 2016 06:39
@lx-t thank you alex. you just saved my life. i was bugged for last 1 hour.
CamperBot
@camperbot
Jun 10 2016 06:39
achillesthewarrior sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 311 | @lx-t |http://www.freecodecamp.com/lx-t
simuliax
@simuliax
Jun 10 2016 06:40
Hello,
i have a problem in this challenge :Return the length of the longest word in the provided sentence. findLongestWord("May the force be with you") should return 5. my code does all other tasks and also returns 5 on this but still shows red X. can someone help?
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 06:41

Help me find the error in my program for
Search and replace
function replace(str, before, after) {
// Find index where before is on string
if(before.charAt(0)===before.charAt(0).toUpperCase()){
str = str.replace(before, after.toCharAt(0).toUpperCase()+after.slice(1));

}
else{
str = str.replace(before, after);

}

return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
```

CamperBot
@camperbot
Jun 10 2016 06:41
no wiki entry for: me find the error in my program forsearch and replacefunction replacestr before after find index where before is on string ifbeforecharat0beforecharat0touppercase str strreplacebefore aftertocharat0touppercaseafterslice1 else str strreplacebefore after return strmyreplacea quick brown fox jumped over the lazy dog jumped leaped
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 06:41
Help me find the error in my program for
Search and replace
function replace(str, before, after) {
  // Find index where before is on string
  if(before.charAt(0)===before.charAt(0).toUpperCase()){
      str = str.replace(before, after.toCharAt(0).toUpperCase()+after.slice(1));

  }
  else{
      str = str.replace(before, after);

  }

  return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
CamperBot
@camperbot
Jun 10 2016 06:41
no wiki entry for: me find the error in my program forsearch and replacefunction replacestr before after find index where before is on string ifbeforecharat0beforecharat0touppercase str strreplacebefore aftertocharat0touppercaseafterslice1 else str strreplacebefore after return strmyreplacea quick brown fox jumped over the lazy dog jumped leaped
shawn
@shawnk723
Jun 10 2016 06:43
can somebody tell me what's wrong with this code?

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort();
var arr1=[];
for (i=0;i<arr[0].length;i++)
{
if(arr[0][i]<arr[1])
{
arr1.push(arr[0][i]);
}

}

num=arr1.length;
return num;
}

getIndexToIns([40, 60], 50);

this is for "Where do I belong" from basic algo..
Jack Anderson
@JackAndersonLee
Jun 10 2016 06:45
@shawnk723 try to remove the [0] in the for loop
says arr[0].length, unless that's what you're looking for
David Halls
@DavidHalls
Jun 10 2016 06:46
@glnarayana93 so, nothing is working on it?
shawn
@shawnk723
Jun 10 2016 06:46
why is that?
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 06:47
@Byzgig no its not changing to uppercase
Jack Anderson
@JackAndersonLee
Jun 10 2016 06:47
Ignore that lol
shawn
@shawnk723
Jun 10 2016 06:47
arr[0].length what i intended to iterate bc target array is in arr[0]. isn't it?
David Halls
@DavidHalls
Jun 10 2016 06:47
@gl is it changing the words?
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 06:47
@Byzgig yes
David Halls
@DavidHalls
Jun 10 2016 06:48
@glnarayana93 try taking the to off of toCharAt
Guys need help
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 06:49
@Byzgig ok silly msistake
@Byzgig thanks
CamperBot
@camperbot
Jun 10 2016 06:49
glnarayana93 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @byzgig |http://www.freecodecamp.com/byzgig
Richard Andrews
@Whiplash5057
Jun 10 2016 06:49
I want to append the numbers in the screen
in Pure JavaScript
append function()
shawn
@shawnk723
Jun 10 2016 06:50
so Jack any other suggestion? :(
I have no clue...
Jack Anderson
@JackAndersonLee
Jun 10 2016 06:51
Well it seems like you're returning the length
Seems like it wants you to return the index instead
shawn
@shawnk723
Jun 10 2016 06:51
I think that's what this problem is asking
i think we are supposed to return how many smaller numbers there are in the array.
my bad Jack.
i think you are right!
i totally misunderstood this problem
i'll try it again. Thanks! :)
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 07:06

function translatePigLatin(str) {
  if(str.charAt(0)==="a"||str.charAt(0)==="e"||str.charAt(0)==="i"||str.charAt(0)==="o"||str.charAt(0)==="u"||str.charAt(0)==="A"||str.charAt(0)==="E"||str.charAt(0)==="O"||str.charAt(0)==="U"){
    str=str+"way";
  }
  else{
    var i;
    for(i=0;i<str.length;i++){
      if(str.charAt(i)==="a"||str.charAt(i)==="e"||str.charAt(i)==="i"||str.charAt(i)==="o"||str.charAt(i)==="u"||str.charAt(i)==="A"||str.charAt(i)==="E"||str.charAt(i)==="O"||str.charAt(i)==="U")
        break;
    }
    var str2=str.substr(0,i);

    str=str.slice(i)+str2+"ay";
  }

  return str;
}

translatePigLatin("consonant");
any better way to solve this?
Jack Anderson
@JackAndersonLee
Jun 10 2016 07:06
@shawnk723 Hey sorry, worked called
You get the solution yet?
Yildirim
@yildirimmurat
Jun 10 2016 07:07
hello
David Halls
@DavidHalls
Jun 10 2016 07:07
@glnarayana93 regex could improve it, shorten your code a bit
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 07:08
@Byzgig for the if condition??
Jack Anderson
@JackAndersonLee
Jun 10 2016 07:09
@shawnk723 I took another look at the problem. You could make another array and include "num" inside of it
sort it
then use indexOf to find where it is
David Halls
@DavidHalls
Jun 10 2016 07:11
@glnarayana93 yea, something like /aeiou/
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 07:12
@Byzgig how to use regex expressions in js?
David Halls
@DavidHalls
Jun 10 2016 07:13
@glnarayana93 you could do var regex = /your regex/; then use replace or regex.test(character to test)
Deepak Yadav
@ydeepk
Jun 10 2016 07:14

please help me with Twitch tv APi

my codepen url http://codepen.io/ydeepk/pen/gMOVbj

see the if else inside getData() function,

on successfull deployemnt online users will display green background and offline users will be diplayed using red background.. please help ASAP guy's.. :worried:

Yildirim
@yildirimmurat
Jun 10 2016 07:16
how can I access an object's property name instead of its value? I am trying to check whether there is a property named, say prop?
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 07:16
@Byzgig thanks will try now
CamperBot
@camperbot
Jun 10 2016 07:16
glnarayana93 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:warning: glnarayana93 already gave byzgig points
David Halls
@DavidHalls
Jun 10 2016 07:16
@yildirimmurat use hasOwnProperty
Yildirim
@yildirimmurat
Jun 10 2016 07:17
@Byzgig Thanks man.
CamperBot
@camperbot
Jun 10 2016 07:17
yildirimmurat sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @byzgig |http://www.freecodecamp.com/byzgig
Yildirim
@yildirimmurat
Jun 10 2016 07:38

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

function lookUpProfile(firstName, prop){
// Only change code below this line
var hasName=false;
var hasProp=false;

for(var i=0;i<contacts.length;i++){
if(firstName===contacts[i].firstName){
hasName=true;
if(contacts[i].hasOwnProperty(prop)){
hasProp=true;
return contacts[i].prop;
}
}
}

if(!hasName){
return "No such contact";
}
if(!hasProp){
return "No such property";
}

// Only change code above this line
}

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

I think I have problem inside for loop. Anyone can help pls?
David Halls
@DavidHalls
Jun 10 2016 07:44
@yildirimmurat you have an issue with your first return statement
Yildirim
@yildirimmurat
Jun 10 2016 07:47
@Byzgig Yeah I should have used brackets. but why?
David Halls
@DavidHalls
Jun 10 2016 07:48
@yildirimmurat its something about getting the values with brackets, but i cant think of it now, kinda fried
Guys check out my calculator
Expiratio
@Expiratio
Jun 10 2016 07:53
@Whiplash5057 good stuff
Richard Andrews
@Whiplash5057
Jun 10 2016 07:58
@Expiratio thanks :smile:
CamperBot
@camperbot
Jun 10 2016 07:58
whiplash5057 sends brownie points to @expiratio :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @expiratio |http://www.freecodecamp.com/expiratio
Shusil Banjade
@shusil123
Jun 10 2016 07:58
@yildirimmurat , because prop is a varaible. And we use bracket notations to access object properties with variables...
@Whiplash5057 , cool and the buttons act like pressed when pressing them. Super cool...
eyeseau
@eyea
Jun 10 2016 08:00
i want to know step 140 ...how to finish
help ~~~
CamperBot
@camperbot
Jun 10 2016 08:00

CamperBot

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

Basic Commands:

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

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

Shusil Banjade
@shusil123
Jun 10 2016 08:03
@eyeA , what's the name of the challenge ??
eyeseau
@eyea
Jun 10 2016 08:07
here
@shusil123 Escape Sequences in Strings
Omar
@omabra
Jun 10 2016 08:07
hello
find check for Palindromes
CamperBot
@camperbot
Jun 10 2016 08:08

find check for palindromes

:zero: algorithm check for palindromes

Shusil Banjade
@shusil123
Jun 10 2016 08:12
var myStr ="\\ \t \t \r \n"; // Change this line
@eyeA
Just write symbols for escape sequences
\ for backslash, \t for tab, \r for carriage-return, \n for new line, separated by spaces
G Lakshmi Narayana
@glnarayana93
Jun 10 2016 08:25
help me find the error

function pairElement(str) {
var arr=[];
  var i;
  for(i=0;i<str.length-1;i++){
    arr[i]=[str.charAt[i],str.charAt[i+1]];
  }
  arr[i++]=[str.charAt[i],str.charAt[i+1]];
  arr[i]=[str.charAt[i],str.charAt[0]];

  return arr;
}

pairElement("GCG");
CamperBot
@camperbot
Jun 10 2016 08:25
no wiki entry for: me find the errorfunction pairelementstr var arr var i fori0istrlength-1i arristrcharatistrcharati1 arristrcharatistrcharati1 arristrcharatistrcharat0 return arrpairelementgcg
Luv Yadav
@insidiousluv11
Jun 10 2016 08:25
Where I am going wrong in this:
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20{%0A%20%20%20%202548%3A%20{%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%202468%3A%20{%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20]%0A%20%20%20%20}%2C%0A%20%20%20%201245%3A%20{%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20[%20]%0A%20%20%20%20}%2C%0A%20%20%20%205439%3A%20{%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20}%0A}%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse%28JSON.stringify%28collection%29%29%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords%28id%2C%20prop%2C%20value%29%20{%0A%20%20%20if%28value%20!%3D%3D%20%22%22%29{%0A%20%20%20%20%20if%28prop%20!%3D%3D%20%22tracks%22%29{%0A%20%20%20%20%20%20%20collection[id][prop]%20%3D%20value%3B%0A%20%20%20%20%20}%0A%20%20%20}%20%0A%20%20%20%20if%28prop%20%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22%29%20{%0A%20%20%20%20%20%20%20collection[id][prop].push%28value%29%3B%0A%20%20%20%20}%0A%20%20%0A%20%20if%28value%20%3D%3D%3D%20%22%22%29{%0A%20%20%20%20delete%20collection[id][prop]%3B%0A%20%20}%0A%20%20return%20collection%3B%0A}%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords%285439%2C%20%22artist%22%2C%20%22ABBA%22%29%3B%0A%0A
Richard Andrews
@Whiplash5057
Jun 10 2016 08:26
@shusil123 thanks :smile:
CamperBot
@camperbot
Jun 10 2016 08:26
whiplash5057 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @shusil123 |http://www.freecodecamp.com/shusil123
Shusil Banjade
@shusil123
Jun 10 2016 08:26
@Whiplash5057 :+1:
chetanmahore
@chetanmahore
Jun 10 2016 08:28
why the first letter of var is always in small?
Shusil Banjade
@shusil123
Jun 10 2016 08:29
@insidiousluv11 , since last element on the object #5439, doesn't have tracks property, you have to create the tracks property first before inserting the value to it.
eyeseau
@eyea
Jun 10 2016 08:29
@shusil123 thanks very much ~~~
CamperBot
@camperbot
Jun 10 2016 08:29
eyea sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 376 | @shusil123 |http://www.freecodecamp.com/shusil123
Shusil Banjade
@shusil123
Jun 10 2016 08:29
@eyeA , Anytime
@insidiousluv11 , you got that ??
chetanmahore
@chetanmahore
Jun 10 2016 08:35
I am stuck here
Patrick Metzdorf
@batjko
Jun 10 2016 08:35
@chetanmahore It's called "camelCase". Just a convention for variable names.
chetanmahore
@chetanmahore
Jun 10 2016 08:35
i don't know how to do this "Assign the contents of a to variable b"
Shusil Banjade
@shusil123
Jun 10 2016 08:35
@chetanmahore , var b = a;
Will do the work
var a = 7;
var b = a;
chetanmahore
@chetanmahore
Jun 10 2016 08:37
"Do not change code above the line"
anima17
@anima17
Jun 10 2016 08:38
hi everyone!i am working on "profile lookup"
here is my code
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){
  if(contacts[i].firstName === firstName){
    if(contacts[i].hasOwnProperty(prop)){
    return contacts[i].prop;
    }


  }else if (contacts[i].firstName !== firstName){
    return "No such contact";
  }else{
}
  return "No such property";
}
// Only change code above this line
}
can anyone tell me whats wrong with my code?
Shusil Banjade
@shusil123
Jun 10 2016 08:39
@chetanmahore , below the line , you have to do that. var a = 7; var b = a; . Don't touch the already given code..
chetanmahore
@chetanmahore
Jun 10 2016 08:40
@shusil123 ok. thank you
CamperBot
@camperbot
Jun 10 2016 08:40
chetanmahore sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 377 | @shusil123 |http://www.freecodecamp.com/shusil123
Shusil Banjade
@shusil123
Jun 10 2016 08:40
@chetanmahore , My pleasure
eyeseau
@eyea
Jun 10 2016 08:40
you are so kind~~~
Shusil Banjade
@shusil123
Jun 10 2016 08:42
@anima17 , since prop is a variable, you have to return it with bracket notation. Iike return contacts[i][prop];
:smile: , @eyeA
chetanmahore
@chetanmahore
Jun 10 2016 08:49
Initialize the three variables a, b, and c with 5, 10, and "I am a" respectively so that they will not be undefined.
eyeseau
@eyea
Jun 10 2016 08:50
yes it'is undefined
chetanmahore
@chetanmahore
Jun 10 2016 08:50
@eyeA I understand what it means, but don't know how to do this.
var a = 5;
var b = 10;
var c ="i am a"
this is not working
Shusil Banjade
@shusil123
Jun 10 2016 08:52
@chetanmahore , Semicolon is missing in var c...
It should be like var c = "i am a";
Tim
@t1flanagan
Jun 10 2016 08:54
Can someone help me with this Record Collection nonsense before I break my computer in half?
Shusil Banjade
@shusil123
Jun 10 2016 08:55
@t1flanagan , What's the problem ?? Paste the code here. And please, Don't break the computer already, It's only the start.
Tim
@t1flanagan
Jun 10 2016 08:56

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

return collection;
}

I don't know how to paste code with in that black box, ha
That's what I have for the function, but it fails one of the tests because "tracks" isn't a listed property and I can't figure out how to make it work.
kirbyedy
@kirbyedy
Jun 10 2016 08:57
wiki format
CamperBot
@camperbot
Jun 10 2016 08:57

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Shusil Banjade
@shusil123
Jun 10 2016 08:58
Yes, the last object element in the array, doesn't have tracks property , so you have to create it, before adding value to the tracks array
Yildirim
@yildirimmurat
Jun 10 2016 08:58
@shusil123 thanks
CamperBot
@camperbot
Jun 10 2016 08:58
yildirimmurat sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 379 | @shusil123 |http://www.freecodecamp.com/shusil123
Shusil Banjade
@shusil123
Jun 10 2016 08:59
So, if the prop is tracks, first check if the prop exists in the id or not. If it does, push the value, if not , create an empty array, tracks,and then push the value
@t1flanagan
@yildirimmurat , Anytime
eyeseau
@eyea
Jun 10 2016 08:59
wow~~~
Tim
@t1flanagan
Jun 10 2016 09:00
Uhhh okay, I'll try to figure it out.
Shusil Banjade
@shusil123
Jun 10 2016 09:02
@eyeA :smile:
Ojabo John Heart
@MrHeart
Jun 10 2016 09:02

@t1flanagan , this should keep you going:
function updateRecords(id, prop, value) {
if(value !=="" && prop != "tracks"){
collection[id][prop] = value;
}
if(prop =="tracks" && value !== ""){
collection[id][prop] = [value];
}
else if (value === "") {
delete collection[id][prop];
}
else { }

return collection;
}

Coy Sanders
@coymeetsworld
Jun 10 2016 09:04
what @t1flanagan has is fine @MrHeart
Shusil Banjade
@shusil123
Jun 10 2016 09:05
@coymeetsworld , I was just missing you , when @MrHeart posted the solution. You, Sir
:smile:
Blauelf
@Blauelf
Jun 10 2016 09:05
@MrHeart That second assignment in your code discards the old tracks array if it exists (in that case you should push instead). Also, your third if is not required (there's no way the condition is not true at that point)
Tim
@t1flanagan
Jun 10 2016 09:05
Thanks for the help guys. I think my brain needs a break.
Coy Sanders
@coymeetsworld
Jun 10 2016 09:05
well he didn't really add anything @shusil123 :)
and what Tim had is a little better anyways
Shusil Banjade
@shusil123
Jun 10 2016 09:06
:smile: True that..
Tim
@t1flanagan
Jun 10 2016 09:06
Except that it doesn't work :( haha
eyeseau
@eyea
Jun 10 2016 09:06
@t1flanagan you are so humorous
Robert
@castillozavala
Jun 10 2016 09:06
Hey Guys, need help with the " Using Objects for LookUps"
switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}
Coy Sanders
@coymeetsworld
Jun 10 2016 09:06
neither do @t1flanagan, but @shusil123 pointed you in right direction
if you look at the ABBA contact you can see that it has no tracks property, so you have to account for that situation
Shusil Banjade
@shusil123
Jun 10 2016 09:09
@castillozavala , What's the problem with your code.? Seems fine to me, The switch statement...
What are the errors??
Coy Sanders
@coymeetsworld
Jun 10 2016 09:09
he isn't supposed to use a switch statement @castillozavala @shusil123
Shusil Banjade
@shusil123
Jun 10 2016 09:09
Oops , @coymeetsworld
Coy Sanders
@coymeetsworld
Jun 10 2016 09:09
He needs to make an object called lookup, and then reference that object to get the code name
the case would be the property, the result would be the value
Ashutosh Narang
@Survivor75
Jun 10 2016 09:13

What is wrong with this code :

// 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 === ""){

delete collection.id.prop;

}

else if(prop !== "tracks"){

collection[id].prop = value;

}

else if(prop == "tracks"){

collection[id].prop.push(value);

}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Coy Sanders
@coymeetsworld
Jun 10 2016 09:14
@Survivor75 you can't use dot notation on a variable like prop
dot notation only works if you know the name of the property you're accessing, you'll need to use bracket notation
Shusil Banjade
@shusil123
Jun 10 2016 09:15
@Survivor75 , access prop with bracket notation with id, like collection[id][prop] and see the conversation above. It's all about this problem
Blauelf
@Blauelf
Jun 10 2016 09:15
@Survivor75 Several problems. For example, you cannot use dot notation with id and prop, as collection.id.prop is same as collection["id"]["prop"] and does not refer to either variable but to static strings as property names. Then, you don't need to test for "tracks" after you can reach that code only if the condition before excluded any case that prop is not "tracks" (so no need for that if(prop == "tracks")).
And then there's the special case that the tracks property does not exist and you cannot use push.
Vladimir Oscolcov
@dmduelist
Jun 10 2016 09:16
Hey everyone!
eyeseau
@eyea
Jun 10 2016 09:16
afternoon ...
Vladimir Oscolcov
@dmduelist
Jun 10 2016 09:17
how's it going ?
eyeseau
@eyea
Jun 10 2016 09:24
what is the time ? here is 05:24 pm
Quoc Anh Nguyen
@quocanh261997
Jun 10 2016 09:24
anyone can suggest me how to do the Seek and Destroy challenge?
eyeseau
@eyea
Jun 10 2016 09:25
@quocanh261997 what's your mean in detail?
Shusil Banjade
@shusil123
Jun 10 2016 09:25
@quocanh261997 , Paste the code here. Or if you haven't started yet, First read about Global arguments object in MDN..
Tim
@t1flanagan
Jun 10 2016 09:25
function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
    if (collection[id][prop] === undefined) {
      collection[id].push(prop);
    }
    else collection[id][prop].push(value);
  } else if (value !== "") {
      collection[id][prop] = value;
  } else if (value === "") {
    delete collection[id][prop];
  }

  return collection;
}
okay, why can't I push the prop to collection[id]?
or is this overthinking?
eyeseau
@eyea
Jun 10 2016 09:26
MDN ...
Shusil Banjade
@shusil123
Jun 10 2016 09:26
@t1flanagan , You are ovethinking with all that undefined and all. Your previous code was almost correct..
Tim
@t1flanagan
Jun 10 2016 09:26
damn okay
Shusil Banjade
@shusil123
Jun 10 2016 09:27
@eyeA Mozilla Developers Network...
Quoc Anh Nguyen
@quocanh261997
Jun 10 2016 09:27

@shusil123
```function destroyer(arr) {
var args = arr.slice.call(arguments);
var newArray = arr.filter(function(val){
for (var a = 0; a<args.length; a++){
var index = arr.indexOf(args[a]);
arr = arr.splice(index,1);
}
return arr;
});
}

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

```
here are my code, but I don't know how to remove multiple explica elements

function destroyer(arr) {
  var args = arr.slice.call(arguments);
  var newArray  = arr.filter(function(val){
    for (var a = 0; a<args.length; a++){
      var index = arr.indexOf(args[a]);
      arr = arr.splice(index,1);
    }
    return arr;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Coy Sanders
@coymeetsworld
Jun 10 2016 09:28
you should read up on the filter function as it was suggested @quocanh261997, you don't want to return an array in the filter function
Shusil Banjade
@shusil123
Jun 10 2016 09:28
  if(prop == "tracks" && value !== "") {
      if (collection[id].hasOwnProperty(prop)) { //to check if prop exists
       collection[id][prop].push(value);
      }

      else {                          //If not create it first and push
        collection[id].tracks = [];
        collection[id][prop].push(value);
      }
    }
@t1flanagan , The second condition in your previous code. I modified it. Read the comments aside
Coy Sanders
@coymeetsworld
Jun 10 2016 09:28
you want to return true or false statements
Tim
@t1flanagan
Jun 10 2016 09:29
Okay, I'll break it down. Thanks so much.
Manuel Micu
@manu-4216
Jun 10 2016 09:29
http://codepen.io/manu4216/full/QEbqxK/ Feedback pls for twitch app
Shusil Banjade
@shusil123
Jun 10 2016 09:29
@t1flanagan , Pleasure is all mine ...
Coy Sanders
@coymeetsworld
Jun 10 2016 09:30
looks good @manu-4216 :thumbsup:
Markus Kiili
@Masd925
Jun 10 2016 09:30
@quocanh261997 Don't mutate arr inside filter callback. Filter will do the iterating arr elements and returns the new filtered array. Return true from the callback for those elements val that you choose to keep.
Coy Sanders
@coymeetsworld
Jun 10 2016 09:30
why do you call it 6-Twitch btw?
Manuel Micu
@manu-4216
Jun 10 2016 09:31
6th project
Coy Sanders
@coymeetsworld
Jun 10 2016 09:31
ah ok :)
Shraddha Parab
@Shraddha99
Jun 10 2016 09:31
@shusil123 thanks
CamperBot
@camperbot
Jun 10 2016 09:31
shraddha99 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 381 | @shusil123 |http://www.freecodecamp.com/shusil123
eyeseau
@eyea
Jun 10 2016 09:31
@shusil123 yes i know
Shusil Banjade
@shusil123
Jun 10 2016 09:33
@eyeA , What do you know ?? Did I miss something ?? :smile:
Markus Kiili
@Masd925
Jun 10 2016 09:35
@quocanh261997 Your code structure for solving destroyer with filter should be like this:
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments,1);
  return arr.filter(function(val) {
    ....
    return ....
  });
}
eyeseau
@eyea
Jun 10 2016 09:36
@shusil123 i don't know what i konwn....haha
Shusil Banjade
@shusil123
Jun 10 2016 09:38
Man, I finished two Algorithms in the advanced Bonfires section (Symmtric difference and Inventory update), finally . I am feeling like the king of the world. Took me a day , though . :worried:
vichus1995
@vichus1995
Jun 10 2016 09:39
Can someone suggest a good approach for the Exact Change algorithm challenge.i'm drawing a blank.
Coy Sanders
@coymeetsworld
Jun 10 2016 09:39
nice @shusil123
eyeseau
@eyea
Jun 10 2016 09:39
aiyawoqu ....
Coy Sanders
@coymeetsworld
Jun 10 2016 09:39
don't worry about how long it takes more important that you're working on it
Shraddha Parab
@Shraddha99
Jun 10 2016 09:40

Idk what's Wrong here function updateRecords(id, prop, value)
{
if (value !== "" && prop == tracks)
{
if(collection[id].hasOwnProperty(prop))
{
collection[id][prop].push(value);
}
else
{
collection[id].tracks = [];
collection[id][prop].push(value);
}

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

return collection;
}

Shusil Banjade
@shusil123
Jun 10 2016 09:40
Thanks @coymeetsworld , You motivates me and that feeling when the code works, finally... Out of this world...
CamperBot
@camperbot
Jun 10 2016 09:40
shusil123 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1119 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Blauelf
@Blauelf
Jun 10 2016 09:41
@vichus1995 I converted anything to cents (multiplying by 100 and rounding), processing integers only in my main code, then divided by 100 for the output only.
Coy Sanders
@coymeetsworld
Jun 10 2016 09:41
yeah especially the adv algorithms which can be tough, took me a while on quite a few of them
Shusil Banjade
@shusil123
Jun 10 2016 09:42
yes :smile: . Some are very very tough.
vichus1995
@vichus1995
Jun 10 2016 09:42
thanks @Blauelf
CamperBot
@camperbot
Jun 10 2016 09:42
vichus1995 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1970 | @blauelf |http://www.freecodecamp.com/blauelf
Shraddha Parab
@Shraddha99
Jun 10 2016 09:46
its giving an reference error tracks is not defined
Blauelf