These are chat archives for FreeCodeCamp/HelpJavaScript

11th
Nov 2016
Walid Ashri
@walidashri
Nov 11 2016 00:00 UTC
:O
how to make unfriend here @sjames1958gm :broken_heart:
Stephen James
@sjames1958gm
Nov 11 2016 00:03 UTC
@walidashri Please accept my apology
:worried:
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:06 UTC
Can you use a variable in place of ‘https….’ to access an API? Does it need to be a string?
$(document).ready(function(){
var y = document.getElementsByClassName("city")[0].innerText;
var api = 'http://api.openweathermap.org/data/2.5/weather?q='+ y + '&appid=b1b15e88fa797225412429c1c50c122a1';
$.getJSON(api, function(jd) {
Gabriel
@xGabey
Nov 11 2016 00:07 UTC
Can someone please help with Chunky Monkey
not sure where to start
Stephen James
@sjames1958gm
Nov 11 2016 00:08 UTC
@djangoearnhardt The variable has to contain a string
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:09 UTC
do I need to use something to turn it into a string? @sjames1958gm
Lucas Tormin
@tormink
Nov 11 2016 00:11 UTC
function steamrollArray(arr) {
  // I'm a steamroller, baby
  var steamrolled = [];
  for(var i=0;i<arr.length;i++){
    if(Array.isArray(arr[i])){
      steamrolled.concat(steamrollArray(arr[i]));
    } else {
      steamrolled.push(arr[i]);
    }
  }
  return steamrolled;
}

steamrollArray([1, [2], [3, [[4]]]]);
So this test case returns 1 . I can't seem to understand why. The objective of this is flattening an array of arrays into a single array.
Stephen James
@sjames1958gm
Nov 11 2016 00:12 UTC
@djangoearnhardt getJSON expects the first parameter to be a string if you put a variable with a string it will be passed to the getJSON from the variable
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:15 UTC
@sjames1958gm I’m stumped on how to get my api to return a city value, then access a link w/ the city’s weather info. How could I get an updated API address to be recognized by getJSON
http://codepen.io/djangoearnhardt/pen/qqbXzW?editors=1111
Stephen James
@sjames1958gm
Nov 11 2016 00:16 UTC
@tormink I don't believe concat modifies the array you have to save the returned value
veeteeran
@veeteeran
Nov 11 2016 00:16 UTC
Hi. Can anyone give me a hint about this?
Screen Shot 2016-11-10 at 4.15.09 PM
Ryan Talbot
@rgtalbot
Nov 11 2016 00:16 UTC
You can use a var in your string @djangoearnhardt instead of hardcoding in the zip code
Lucas Tormin
@tormink
Nov 11 2016 00:16 UTC
@sjames1958gm ohh...I believe that's it, I'll try it out then...thanks
Gabriel
@xGabey
Nov 11 2016 00:17 UTC
Could someone plz help me to get started with the Chucky Monkey challenge?
totally lost in algorithm... :(
Stephen James
@sjames1958gm
Nov 11 2016 00:17 UTC
@tormink :+1:
Ryan Talbot
@rgtalbot
Nov 11 2016 00:17 UTC
Can you be more specific @xGabey?
Lucas Tormin
@tormink
Nov 11 2016 00:17 UTC
@sjames1958gm yeeeeeah you deserve all the cookie points man thank you
CamperBot
@camperbot
Nov 11 2016 00:17 UTC
tormink sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4304 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Lucas Tormin
@tormink
Nov 11 2016 00:17 UTC
oh..brownie points I guess
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:18 UTC
could you explain that a little more @rgtalbot
veeteeran
@veeteeran
Nov 11 2016 00:18 UTC
blob
Gabriel
@xGabey
Nov 11 2016 00:19 UTC
@rgtalbot I'm not totally sure how to begin assigning variables. Basically, what are the procedures I need to take to begin?
Stephen James
@sjames1958gm
Nov 11 2016 00:19 UTC
@djangoearnhardt If you are using an API to get the city - make sure you put the weather request inside the API callback
Ryan Talbot
@rgtalbot
Nov 11 2016 00:19 UTC
$.getJSON('http://api.openweathermap.org/data/2.5/weather?zip=' + zipCode + ',us&appid=43570f3ce225106d3f5ffafe9e44cc60' ...
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:20 UTC
ok, i’ll give it a try, thanks @rgtalbot
CamperBot
@camperbot
Nov 11 2016 00:20 UTC
djangoearnhardt sends brownie points to @rgtalbot :sparkles: :thumbsup: :sparkles:
:cookie: 185 | @rgtalbot |http://www.freecodecamp.com/rgtalbot
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:20 UTC
Does anyone get the Seek and Destroy?
Jan
@burning-monk
Nov 11 2016 00:21 UTC
yes sir
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:21 UTC
How?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:21 UTC
That is a little vague @valdor14 is there something specific you are getting caught on?
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:21 UTC
The function destroyer takes 1 argument and they assign it more than 1
Jan
@burning-monk
Nov 11 2016 00:21 UTC
@valdor14 did you read the article about arguments?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:22 UTC
you have to learn how to manipulate arguments @valdor14
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:22 UTC
Where can I read it?
Walid Ashri
@walidashri
Nov 11 2016 00:22 UTC
@veeteeran you don't need to set arr.push() to new var
push() modify the array and returns it's length
Aaron Bell
@awb715
Nov 11 2016 00:22 UTC
https://codepen.io/Aaron-w-Bell/pen/qqbXJz?editors=1010 @rgtalbot i switched up my buttons using bootstrap and now none of its working =/
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:23 UTC
Thank you so much
Jan
@burning-monk
Nov 11 2016 00:23 UTC
I solved with indexOf instead of filter()
and Array.from()
Ryan Talbot
@rgtalbot
Nov 11 2016 00:25 UTC
looks like you took the two examples I gave you and used half of each @awb715
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:25 UTC
@rgtalbot Am I getting closer?
$(document).ready(function(){
var y = document.getElementsByClassName("city")[0].innerText;
/*var api = 'http://api.openweathermap.org/data/2.5/weather?q='+ y + '&appid=b1b15e88fa797225412429c1c50c122a1';*/
$.getJSON('http://api.openweathermap.org/data/2.5/weather?q='+y+'&appid=b1b15e88fa797225412429c1c50c122a1', function(jd)
Ryan Talbot
@rgtalbot
Nov 11 2016 00:26 UTC
You are on the right track @djangoearnhardt, but your var y is only going to run when you load the page. so that needs some work
veeteeran
@veeteeran
Nov 11 2016 00:26 UTC
Thank you @walidashri
CamperBot
@camperbot
Nov 11 2016 00:26 UTC
veeteeran sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 607 | @walidashri |http://www.freecodecamp.com/walidashri
Aaron Bell
@awb715
Nov 11 2016 00:28 UTC
@rgtalbot ugh
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:28 UTC
@rgtalbot what behavior would I want var y to follow?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:28 UTC
You would want to have an event trigger it @djangoearnhardt, by submitting a form or clicking a button or something
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:30 UTC
my goal is to have a browser recognize the city a person is in, then run the API and get data from that @rgtalbot
Ryan Talbot
@rgtalbot
Nov 11 2016 00:30 UTC
<form onsubmit="onSearch()">
            <div class="input-group ">

              <input id="form" type="text" class="form-control" placeholder="Search for...">
              <span class="input-group-btn" >
                 <button  class="btn btn-default" type="submit" ><span class="glyphicon glyphicon-search"></span></button>
              </span>

      </form>
//this function gets activate onclick

function onSearch() {
  event.preventDefault();
  var input = document.getElementById("form").value;

  $("#form").val(""); //removes previous search values
@awb715
You need to look into how to get a current location from your browswer @djangoearnhardt, and how to handle that response in case a user doesn’t share thier location information. Its a lot more complicated than one line of code.
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:31 UTC
ok i’ll give it some time, thanks @rgtalbot
CamperBot
@camperbot
Nov 11 2016 00:31 UTC
djangoearnhardt sends brownie points to @rgtalbot :sparkles: :thumbsup: :sparkles:
:warning: djangoearnhardt already gave rgtalbot points
Aaron Bell
@awb715
Nov 11 2016 00:34 UTC
@rgtalbot not working
Ryan Talbot
@rgtalbot
Nov 11 2016 00:35 UTC
worked fine on my end @awb715. did you change it by looking or copy and paste?
jump020305
@jump020305
Nov 11 2016 00:41 UTC
  • I am new to Reactjs.
  • If the staus is active. I need to update the p tag and need to update in my liClass as .sports-last-second
  • .sports-changed-status should be changed to .sports-last-second
  • I have created a if condition but not sure how to insert.
  • Can you guys tell how to do it.
  • Providng my code below.
    newContentAdded: function () {

      var first-tab = 'got-the-value';

    if (first-tab == 'got-the-value')
    {
     <p> got-the-value got-the-value got-the-value got-the-value </p>
    }
    }

working fiddle
https://jsfiddle.net/9e767txs/33/

not working fiddle
https://jsfiddle.net/9e767txs/37/

Diego Mayer
@Chrono79
Nov 11 2016 00:42 UTC
@temiadesina follow @sjames1958gm advice and note that if you apply the lowercase first you don't need to use i modifier when using replace (not that your regex needed it in the first place)
why are the widths off?
jump020305
@jump020305
Nov 11 2016 00:46 UTC
@awb715 @Chrono79 can you guys help me
Ken Haduch
@khaduch
Nov 11 2016 00:47 UTC
@jump020305 - I'm not a React expert, but I think that this is a simple javascript problem - your variable first-tab is not legal. Change it to first_tab and try again. I think you cannot have a - in a variable name.
jump020305
@jump020305
Nov 11 2016 00:48 UTC
@khaduch thanks for your reply...I tried but its not working :(
CamperBot
@camperbot
Nov 11 2016 00:48 UTC
jump020305 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1911 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Nov 11 2016 00:49 UTC
@jump020305 - make sure you change both instances of that name, and click the "Run" button? It worked for me?
Joseph
@revisualize
Nov 11 2016 00:49 UTC
Hello.
Ken Haduch
@khaduch
Nov 11 2016 00:50 UTC
@jump020305 - I just loaded your fiddle and it worked?
@jump020305 - oh, maybe not. It is complaining about a different syntax error... checking it out.
Zina Astafyeva
@tragetraje
Nov 11 2016 00:51 UTC
Hi guys! Can anybody help me to debug my ajax request from wikipedia viewer challenge? Thanks in advance!
Ken Haduch
@khaduch
Nov 11 2016 00:52 UTC
@jump020305 it just doesn't like the string <p> got-the-value got-the-value got-the-value got-the-value </p> - is that supposed to be output with some other command?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:53 UTC
What is your issue @tragetraje ?
Justin Vernon
@Jvernz
Nov 11 2016 00:54 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
  console.log(contacts[firstName]);
for (var i = 0; i < contacts.length;i++){
  if (firstName===contacts[firstName]){
    if (prop===contacts[prop]){
      return contacts[firstName] + " " + contacts[prop[i]];
    }
    else if (prop!==contacts[prop]){
      return "No such property";
    }
  }
  else {
    return "No such contact";
  }
}
Why is my code only outputting "No such contact"?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:54 UTC
move no such contact outside the loop
Ken Haduch
@khaduch
Nov 11 2016 00:54 UTC
@Jvernz - a few problems - you need to be using contacts[i] to access the contacts, and @rgtalbot said the other thing... And firstName can be used as .firstName when access the property in an object, or else using bracket notation ["firstName"].
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 00:54 UTC
great explanation @rgtalbot !
jump020305
@jump020305
Nov 11 2016 00:55 UTC
@khaduch i need to replace p tags when i switch tabs....any idea
Ryan Talbot
@rgtalbot
Nov 11 2016 00:55 UTC
Lol. I’m not sure if that is sarcasm @Jeff-Shapiro. I’m tired and everyone is getting stuck on that today and I’ve typed out how for loops work and why like 100 times today
I know I should explain it, that’s my bad
Ken Haduch
@khaduch
Nov 11 2016 00:57 UTC
@jump020305 - I'm not React savvy at all... sorry!
Justin Vernon
@Jvernz
Nov 11 2016 00:57 UTC
@rgtalbot @khaduch Thanks for the help. Still getting the same issue though.
CamperBot
@camperbot
Nov 11 2016 00:57 UTC
jvernz sends brownie points to @rgtalbot and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 186 | @rgtalbot |http://www.freecodecamp.com/rgtalbot
:star2: 1912 | @khaduch |http://www.freecodecamp.com/khaduch
Justin Vernon
@Jvernz
Nov 11 2016 00:57 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length;i++){
  if (firstName===contacts[i]){
    if (prop===contacts[prop[i]]){
      return contacts[i] + " " + contacts[prop[i]];
    }
    else if (prop!==contacts[i]){
      return "No such property";
    }
  }

}
 if (firstName!==contacts[i]) {
    return "No such contact";
  }
Ryan Talbot
@rgtalbot
Nov 11 2016 00:58 UTC
YOu don’t need the if outside the loop. but yea, there are still issues in your loop
Zina Astafyeva
@tragetraje
Nov 11 2016 01:01 UTC
@rgtalbot i guess something is wrong with the url, it works in a browser but only works sometimes as part of the request http://codepen.io/tragetraje/pen/qqOQbV?editors=0010
Ken Haduch
@khaduch
Nov 11 2016 01:02 UTC
@Jvernz - you got the contacts[i] in the wrong place... it has to be contacts[i] and contacts[i][prop] or contacts[i].firstName to access the firstName of a contact. and prop !== contacts[i] is not going to work - it would have to be contacts[i].hasOwnProperty(prop), for example...
Ryan Talbot
@rgtalbot
Nov 11 2016 01:03 UTC
@tragetraje look into the enter key refreshing the page and how to prevent it. I think that’s your issue.
Ken Haduch
@khaduch
Nov 11 2016 01:03 UTC
@jump020305 - even though I don't know React - I see you have this Pane object - do you have to use that somehow to render the output?
Ryan Talbot
@rgtalbot
Nov 11 2016 01:03 UTC
If you don’t know react @khaduch I wouldn’t try to help. Its component base architecture and very different from vanilla js
Justin Vernon
@Jvernz
Nov 11 2016 01:03 UTC
@khaduch Thanks for the tip. I'm not very good with the syntax. I'll give it a shot!
CamperBot
@camperbot
Nov 11 2016 01:03 UTC
jvernz sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: jvernz already gave khaduch points
Ken Haduch
@khaduch
Nov 11 2016 01:06 UTC
@rgtalbot - well, no one else seems to be jumping on it... I have had a little bit of exposure to it, but the challenge is there. :)
Zina Astafyeva
@tragetraje
Nov 11 2016 01:06 UTC
thanks for your reply @rgtalbot but could you please point to my error? i've refreshed the page and the query actually worked, it returns an array
CamperBot
@camperbot
Nov 11 2016 01:06 UTC
:cookie: 187 | @rgtalbot |http://www.freecodecamp.com/rgtalbot
tragetraje sends brownie points to @rgtalbot :sparkles: :thumbsup: :sparkles:
Ryan Talbot
@rgtalbot
Nov 11 2016 01:06 UTC
He needs to call the function somewhere
Zina Astafyeva
@tragetraje
Nov 11 2016 01:07 UTC
Screen Shot 2016-11-11 at 12.04.24 PM.png
Ryan Talbot
@rgtalbot
Nov 11 2016 01:07 UTC
I don’t think I understand your issue then @tragetraje
Zina Astafyeva
@tragetraje
Nov 11 2016 01:08 UTC
hm, ok :( @rgtalbot
Emilie
@Snipercatz
Nov 11 2016 01:08 UTC
@amrojjeh doesn't it seem like questions like these come out of nowhere? Like suddenly it goes from being super easy to wtf?
Ryan Talbot
@rgtalbot
Nov 11 2016 01:08 UTC
I was looking at the code for @jump020305 but it is written in es5 and not really structured the way a react app would be in the real world, so its taking me time to read through it
Its also not commented
what is your issue @tragetraje ?
jump020305
@jump020305
Nov 11 2016 01:09 UTC
@rgtalbot can you help me
Ryan Talbot
@rgtalbot
Nov 11 2016 01:09 UTC
I’m working on it @jump020305
jump020305
@jump020305
Nov 11 2016 01:09 UTC
@rgtalbot thanks
CamperBot
@camperbot
Nov 11 2016 01:09 UTC
jump020305 sends brownie points to @rgtalbot :sparkles: :thumbsup: :sparkles:
:cookie: 188 | @rgtalbot |http://www.freecodecamp.com/rgtalbot
Justin Vernon
@Jvernz
Nov 11 2016 01:10 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length;i++){
  if (firstName===contacts[i].firstName){
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i].firstName + " " + contacts[i][prop];
    }
    else if (contacts[i].hasOwnProperty(prop)===false){
      return "No such property";
    }
  }

}

    return "No such contact";


// Only change code above this line
}

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

It's saying lookUpProfile("Harry", "likes");
should return an array, and my output is

Harry Hogwarts,Magic,Hagrid

Ryan Talbot
@rgtalbot
Nov 11 2016 01:10 UTC
I’m not sure what you are trying to accomplish because you aren’t calling the newContentAdded() function anywhere
Justin Vernon
@Jvernz
Nov 11 2016 01:10 UTC
nevermind, i see what i did wrong
Ryan Talbot
@rgtalbot
Nov 11 2016 01:11 UTC
Its what you were returning @Jvernz
Walid Ashri
@walidashri
Nov 11 2016 01:11 UTC
@tragetraje this is ur api response 1st is the search term every array contain def peace of info like text link and so
Justin Vernon
@Jvernz
Nov 11 2016 01:11 UTC
@rgtalbot Correct. Finally noticed it. Misread the instructions. Finally completed the challenge. Thanks to everyone who helped!
CamperBot
@camperbot
Nov 11 2016 01:11 UTC
jvernz sends brownie points to @rgtalbot :sparkles: :thumbsup: :sparkles:
:warning: jvernz already gave rgtalbot points
Ryan Talbot
@rgtalbot
Nov 11 2016 01:12 UTC
what are you trying to accomplish @jump020305? you aren’t calling your newContentAdded function anywhere
Christian
@xChristianZx
Nov 11 2016 01:16 UTC
Hello all. Can anyone offer some help on the "Stand in Line"?
Ken Haduch
@khaduch
Nov 11 2016 01:17 UTC
@cazenaty - yes - what's your code at this point? Or your questions?
Christian
@xChristianZx
Nov 11 2016 01:18 UTC

function nextInLine(arr, item) {
// Your code here
arr.push(item), arr.unshift[0];
return arr[0]; // Change this line
}

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

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

shoot, can't upload an actual picture. one moment sorry
Ryan Talbot
@rgtalbot
Nov 11 2016 01:19 UTC
why are you using unshift instead of shift @cazenaty?
Ken Haduch
@khaduch
Nov 11 2016 01:19 UTC
@cazenaty - okay... the arr.push(item); is correct - you have to add the item to the end of the array, and that's going to do that. The next step is to take the first element out of the array and return the first element -
Christian
@xChristianZx
Nov 11 2016 01:20 UTC
@rgtalbot , i thought unshift would remove the first element out of the array, no?
Ken Haduch
@khaduch
Nov 11 2016 01:20 UTC
@cazenaty - look up Array.shift() vs. Array.unshift()...
Conor Murphy
@cmurphy580
Nov 11 2016 01:20 UTC
I'm trying to get the start page to cover the screen. The only way i can do this is by making the position fixed, but when i do a search that prohibits me from scrolling down. Any ideas? https://codepen.io/cmurphy580/full/gLaamJ/
Christian
@xChristianZx
Nov 11 2016 01:21 UTC
@khaduch , ok, will do. thank you
CamperBot
@camperbot
Nov 11 2016 01:21 UTC
cazenaty sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1913 | @khaduch |http://www.freecodecamp.com/khaduch
skratchbreaker
@skratchbreaker
Nov 11 2016 01:23 UTC
Anybody did the counting card problem?
Ken Haduch
@khaduch
Nov 11 2016 01:27 UTC
@skratchbreaker - ask questions, post code, you'll get some help here...
sally
@susally
Nov 11 2016 01:29 UTC

// Setup
var myStr = "Jello World";

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

Why this codes are not right
Ken Haduch
@khaduch
Nov 11 2016 01:31 UTC
@susally - string in javascript are not mutable - you cannot do myStr[0] to change a single character. What's the objective of this? Or which lesson is it? I think that you just want to change the value of the variable as you are doing in your line 5?
sally
@susally
Nov 11 2016 01:32 UTC
Understand String Immutability in this lesson
yes I want to change the value of the variable in line 5?
Ken Haduch
@khaduch
Nov 11 2016 01:32 UTC
@susally - the description of that problem says that you cannot do myStr[0] = "J"; So that also applies to this problem. You just want to enter the new value for that variable as you have done. Remove that myStr[0] = "H"; line, and it should work...
Christian
@xChristianZx
Nov 11 2016 01:33 UTC
@khaduch , how can I post code like @Jvernz up above?
Ken Haduch
@khaduch
Nov 11 2016 01:33 UTC
@cazenaty - read the next link
'''
CamperBot
@camperbot
Nov 11 2016 01:33 UTC
:bulb: to format code use backticks! ``` more info
sally
@susally
Nov 11 2016 01:33 UTC
that is right thank you
Christian
@xChristianZx
Nov 11 2016 01:34 UTC
excellent, thank you again
Daniel Melchior
@danny-boy
Nov 11 2016 01:38 UTC
So I just wrote my code for "stand in line", my tests validate on the console but are not being green lit (?)
Justin Vernon
@Jvernz
Nov 11 2016 01:38 UTC
The object oriented programming course goes by so fast. There's no way I'm retaining all this info lol
Daniel Melchior
@danny-boy
Nov 11 2016 01:39 UTC
Would anyone mind checking my work?
Christian
@xChristianZx
Nov 11 2016 01:41 UTC
@danny-boy , post your code, i just finished that one with @khaduch 's help.
Daniel Melchior
@danny-boy
Nov 11 2016 01:42 UTC

```function nextInLine(arr, item) {
var arr1 = arr;
arr1.push(item);
var removed = arr1.splice(0,1);

return removed; // Change this line
}

// Test Setup
var testArr = [2];

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

sorry, not sure how the formatting works
Christian
@xChristianZx
Nov 11 2016 01:44 UTC
so, you have the right idea with arr1.push(item)
Daniel Melchior
@danny-boy
Nov 11 2016 01:45 UTC
yeah the code seems to work
Christian
@xChristianZx
Nov 11 2016 01:45 UTC
for the second part, instead of splice, I used arr.shift(item)
but no greens at all?
Daniel Melchior
@danny-boy
Nov 11 2016 01:45 UTC
oh ok, ill go that route then
only on the last test
not sure why, when i log results to the console they come up correctly
oh well..
thank you for the help christian :)
Christian
@xChristianZx
Nov 11 2016 01:47 UTC
yeah, this one was on the confusing side for me as well
function nextInLine(arr, item) {
  // Your code here

  return  arr.push(item), arr.shift(item);  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Christian
@xChristianZx
Nov 11 2016 01:47 UTC
that is what I ended up with which worked out
Aaron Bell
@awb715
Nov 11 2016 01:47 UTC
check out the cool jquery
Christian
@xChristianZx
Nov 11 2016 01:48 UTC
np @danny-boy
Daniel Melchior
@danny-boy
Nov 11 2016 01:48 UTC
very simple solution christian, nice job
looks like the real thing aaron :+1:
Aaron Bell
@awb715
Nov 11 2016 01:49 UTC
i have an issue tho but trying to figure it out
Christian
@xChristianZx
Nov 11 2016 01:50 UTC
thank you Dan
yeah, that looks great @awb715
Aaron Bell
@awb715
Nov 11 2016 01:50 UTC
dont give it away for me
but the toggle continously happens
Justin Vernon
@Jvernz
Nov 11 2016 01:54 UTC
```

function reverseString(str) {
  var array = [];
  array = str.split('');
  array.reverse();
  array.join('');
  return array;
}
reverseString("hello");
Why is my array not rejoining as a string?
Somia ♡
@somiajagadish
Nov 11 2016 01:55 UTC
Hi, I need help!

Quotes are not the only characters that can be escaped inside a string. Here is a table of common escape sequences:
Code Output
\' single quote
\" double quote
\ backslash
\n newline
\r carriage return
\t tab
\b backspace
\f form feed

Note that the backslash itself must be escaped in order to display as a backslash.
Instructions

Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine

You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

"FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"

Anyone?
Christian
@xChristianZx
Nov 11 2016 01:56 UTC
@somiajagadish what code do you have so far?
Stephen James
@sjames1958gm
Nov 11 2016 01:56 UTC
@somiajagadish There are 4 keywords that need to be replaced
@Jvernz array.join returns a new string
Somia ♡
@somiajagadish
Nov 11 2016 01:57 UTC
@cazenaty I don't have any yet because I don't understand how to put the slashes in
Christian
@xChristianZx
Nov 11 2016 01:57 UTC
ah, gotcha
Somia ♡
@somiajagadish
Nov 11 2016 01:57 UTC
@sjames1958gm Haha you helped me yesterday
Justin Vernon
@Jvernz
Nov 11 2016 01:57 UTC
@sjames1958gm I want it to return a new string, but its returning as an array
Somia ♡
@somiajagadish
Nov 11 2016 01:58 UTC
@cazenaty yeah :smile:
Stephen James
@sjames1958gm
Nov 11 2016 01:58 UTC
@somiajagadish Just insert the two characters in place of the keywords
Justin Vernon
@Jvernz
Nov 11 2016 01:58 UTC
is it because i defined array as an array? maybe i need a string variable
Somia ♡
@somiajagadish
Nov 11 2016 01:58 UTC
@sjames1958gm What keywords?
Christian
@xChristianZx
Nov 11 2016 01:58 UTC
so, using the text with escape sequences written out, you want to substitute the keywords with the corresponding escape sequences listed above
Stephen James
@sjames1958gm
Nov 11 2016 01:58 UTC
@Jvernz The name of the variable is not relavant - array.join("") doesn't change the variable it returns a new string. Similar to split returning an array
Somia ♡
@somiajagadish
Nov 11 2016 01:59 UTC
Hold on. I will show you what I think
Stephen James
@sjames1958gm
Nov 11 2016 01:59 UTC
newline backslash backslash carriage-return
Somia ♡
@somiajagadish
Nov 11 2016 01:59 UTC
Is right
Justin Vernon
@Jvernz
Nov 11 2016 01:59 UTC
@sjames1958gm I just defined a new variable as a split and it ended up working. I tried array.join('') and it returned as an array again
Christian
@xChristianZx
Nov 11 2016 02:00 UTC
@somiajagadish you've got the right idea, now just need to substitute those with code so....
Stephen James
@sjames1958gm
Nov 11 2016 02:00 UTC
@Jvernz You could do this return array.join("") because the return from join (a string) is then returned from the function
Christian
@xChristianZx
Nov 11 2016 02:00 UTC
newline = \n
Gabi
@JJcreated
Nov 11 2016 02:01 UTC
hey guys, im doing the where do i belong challenge and ive run into some problems
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  for(var a = 0; a < arr.length; a++){
    if(arr[a] === num){
      return arr.indexOf(num);     
    }
  arr.push(num);
  var sorted = arr.sort();
 var index = sorted.indexOf(num);
  for(var i = 0; i < sorted.length; i++){
    if(sorted[i] === num){
      return arr.indexOf(sorted[i]);
    }
  }


  return index;
  }

}

getIndexToIns([3, 10, 5], 3);
Stephen James
@sjames1958gm
Nov 11 2016 02:01 UTC
@Jvernz array.join("") creates a string but if you don't assign to a variable or as above return it directly you will lose the string.
Justin Vernon
@Jvernz
Nov 11 2016 02:01 UTC
@sjames1958gm It appears you are correct. I need to learn a lot of the syntax that comes with coding. I tried to do array.join('') instead of return array.join('');
Gabi
@JJcreated
Nov 11 2016 02:01 UTC
whats wrong with that code please?
Justin Vernon
@Jvernz
Nov 11 2016 02:01 UTC
@sjames1958gm I see. Thanks very much for the help!
CamperBot
@camperbot
Nov 11 2016 02:01 UTC
:star2: 4305 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Somia ♡
@somiajagadish
Nov 11 2016 02:01 UTC
@cazenaty But Do i put the slashes in the quotes?
CamperBot
@camperbot
Nov 11 2016 02:02 UTC
jvernz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Nov 11 2016 02:02 UTC
@Jvernz :+1:
Somia ♡
@somiajagadish
Nov 11 2016 02:02 UTC
:sparkles: :cactus:
Christian
@xChristianZx
Nov 11 2016 02:02 UTC
@somiajagadish no quotes for the slashes
so the "Firstline" should look like this - FirstLine\n
Somia ♡
@somiajagadish
Nov 11 2016 02:04 UTC
Okay so like this?
var myStr = "FirstLine"/n"SecondLine"/r"ThirdLine";
Christian
@xChristianZx
Nov 11 2016 02:04 UTC
you're getting there
Somia ♡
@somiajagadish
Nov 11 2016 02:04 UTC
?
Christian
@xChristianZx
Nov 11 2016 02:04 UTC
no "" requred
Somia ♡
@somiajagadish
Nov 11 2016 02:05 UTC
"FirstLine/nSeondLine/rThirdLine"
Like this?
Christian
@xChristianZx
Nov 11 2016 02:05 UTC
also use \
not /
Somia ♡
@somiajagadish
Nov 11 2016 02:05 UTC
Okay hold on i'll be back
var myStr = "FirstLine\nSecondline\rThirdLine"; // Change this line
like this?
Christian
@xChristianZx
Nov 11 2016 02:08 UTC
yes
Somia ♡
@somiajagadish
Nov 11 2016 02:08 UTC
It said it's wrong..
Christian
@xChristianZx
Nov 11 2016 02:08 UTC
so now you just need the Backslashes to show up around "SecondLine"
Gabi
@JJcreated
Nov 11 2016 02:09 UTC
guys?
Somia ♡
@somiajagadish
Nov 11 2016 02:09 UTC
what do you mean?
Johnny
@JohnnyBizzel
Nov 11 2016 02:09 UTC
@somiajagadish Did you read the instructions?
Somia ♡
@somiajagadish
Nov 11 2016 02:10 UTC
yes
Christian
@xChristianZx
Nov 11 2016 02:10 UTC
@JJcreated you're way ahead of me, sorry, wish I could help
Juliana G P S Ferreira
@julianaferry
Nov 11 2016 02:11 UTC
Hello! just joined in..
Johnny
@JohnnyBizzel
Nov 11 2016 02:11 UTC
@JJcreated You do a return inside a for loop
Walid Ashri
@walidashri
Nov 11 2016 02:13 UTC
@JJcreated [3,10,5].sort() returns // [10,3,5]
Ike Orji
@ikeuzo57
Nov 11 2016 02:13 UTC
Hi guys Can some one please advise me on how to adjust this code for the output right
```
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  if(str.substr(-1) == target){
    return true;
  }else{
    return false;
  }

}

confirmEnding("He has to give me a new name", "name");//should return true.
//confirmEnding("Bastian", "n");
Gabi
@JJcreated
Nov 11 2016 02:14 UTC
@walidashri @JohnnyBizzel the .sort link said it'd sort itself in order with the command
Johnny
@JohnnyBizzel
Nov 11 2016 02:14 UTC
@ikeuzo57 is there an .endsWith() function in JS?
Ike Orji
@ikeuzo57
Nov 11 2016 02:14 UTC
@julianaferry Welcome to Code Camp
soclose to getting the transitions right
dont get it away! just showing everyone
Ike Orji
@ikeuzo57
Nov 11 2016 02:15 UTC
@JohnnyBizzel not allowed in this excercise
Justin Vernon
@Jvernz
Nov 11 2016 02:16 UTC

function factorialize(num) {
  var x = 0;
  for(var i = 0;i < num; i++) {
    x = num * (num-1);
  }
  return x;
}

factorialize(5);
Why is my loop only running once?
Johnny
@JohnnyBizzel
Nov 11 2016 02:16 UTC
@ikeuzo57 Maybe use indexOf() to find where to do the split() ?
NULL made me stuck
Johnny
@JohnnyBizzel
Nov 11 2016 02:16 UTC
@Jvernz You are not creating an array of numbers
Marc M
@Marc-Moeller
Nov 11 2016 02:17 UTC

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

// Only change code below this line;

var playerNumber=16;       // Change this Line
var player = testObj[16];   // Change this Line
hello people
Johnny
@JohnnyBizzel
Nov 11 2016 02:17 UTC
@Shiv-Shakti IS this your code by any chance?
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var k=0;
  var R=[];
  var G=[];
  var i=0;
if (arr[1] != null)
  return 1;
  return 0;
  for (i;i<arr.length;i++)
    if (!((arr[i] === false) ||(arr[i] === "") ||(arr[i] === 0) ||(arr[i] === undefined) ||(arr[i] === null)||(arr[i] === NaN)))
      { R[k]=arr[i];
        k++;}
  k=0;
  for(i=0;i<R.length;i++)
    if (!(R[i] === null)){
        G[k]=R[i];
        k++;}

    return  G;}

bouncer([1,false, null, 0, NaN, undefined,4, ""]);
Marc M
@Marc-Moeller
Nov 11 2016 02:17 UTC
can I get a little help with this please, how do I make player number a number and access it via bracket notation ?
PARESH
@Shiv-Shakti
Nov 11 2016 02:17 UTC
yes
Marc M
@Marc-Moeller
Nov 11 2016 02:17 UTC
-> playerNumber should be a number
-> You should be using the variable playerNumber in your bracket notation
Johnny
@JohnnyBizzel
Nov 11 2016 02:18 UTC
@flyyyperth var player = testObj[changeME];
Walid Ashri
@walidashri
Nov 11 2016 02:18 UTC
@flyyyperth playerNumber = a number
Conor Murphy
@cmurphy580
Nov 11 2016 02:18 UTC
does anyone have any idea on how to get rid of the content box after erasing the search?
https://codepen.io/cmurphy580/pen/gLaamJ?editors=0010
Johnny
@JohnnyBizzel
Nov 11 2016 02:19 UTC
@Shiv-Shakti I can't really follow it. Can you explain it?
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 02:19 UTC
@cmurphy580 check the value of input asfter keystroke
Aaron Bell
@awb715
Nov 11 2016 02:20 UTC
@cmurphy580 working on the exact same thing
chunnali
@chunnali
Nov 11 2016 02:21 UTC
can anyone click on my codepen and let me know if it display the correct location?
Aaron Bell
@awb715
Nov 11 2016 02:21 UTC
you mean search box @cmurphy580
Johnny
@JohnnyBizzel
Nov 11 2016 02:21 UTC
@chunnali Correct :+1: for me (Leeds)
chunnali
@chunnali
Nov 11 2016 02:21 UTC
it display my location but when I asked one of my friend, she got a location that was miles away form her...
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 02:21 UTC
@chunnali wrong location ha
chunnali
@chunnali
Nov 11 2016 02:22 UTC
@JohnnyBizzel @Jeff-Shapiro thank you!! can’t figure out what’s wrong
CamperBot
@camperbot
Nov 11 2016 02:22 UTC
chunnali sends brownie points to @johnnybizzel and @jeff-shapiro :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @jeff-shapiro |http://www.freecodecamp.com/jeff-shapiro
Conor Murphy
@cmurphy580
Nov 11 2016 02:22 UTC
@Jeff-Shapiro check it out @awb715 yeah let me know if you figure anything out
CamperBot
@camperbot
Nov 11 2016 02:22 UTC
:cookie: 787 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
look at mine
its almost working properly
Johnny
@JohnnyBizzel
Nov 11 2016 02:23 UTC
@chunnali Maybe the IP address lookup is not working for her
Marc M
@Marc-Moeller
Nov 11 2016 02:23 UTC
@JohnnyBizzel @walidashri I still get error: playerNumber should be a number
I changed the code to: var playerNumber=testObj[playerNumber]; // Change this Line
Johnny
@JohnnyBizzel
Nov 11 2016 02:23 UTC
@flyyyperth What's the challenge called?
Walid Ashri
@walidashri
Nov 11 2016 02:23 UTC
@chunnali for me also ok it's ip location some times give the main internet provider server location
chunnali
@chunnali
Nov 11 2016 02:24 UTC
@walidashri @JohnnyBizzel even if I’m using latitude and longitude api to locate them?
Johnny
@JohnnyBizzel
Nov 11 2016 02:24 UTC
@chunnali Don't know. Try a different API
Walid Ashri
@walidashri
Nov 11 2016 02:25 UTC
@flyyyperth playerNumber = number then
the next line the vlaue = testObj[playerNumber];
@chunnali if use geo location never miss
Johnny
@JohnnyBizzel
Nov 11 2016 02:25 UTC
@flyyyperth I put this in and it passes

var playerNumber = 16;       // Change this Line
var player = testObj[playerNumber];
chunnali
@chunnali
Nov 11 2016 02:26 UTC
@walidashri alright, will try that instead then
Walid Ashri
@walidashri
Nov 11 2016 02:26 UTC
@chunnali what for the CORS :D
Joseph
@revisualize
Nov 11 2016 02:26 UTC
Hello.
Walid Ashri
@walidashri
Nov 11 2016 02:27 UTC
@revisualize Hi
Marc M
@Marc-Moeller
Nov 11 2016 02:27 UTC
@JohnnyBizzel thanks mate :) <3
CamperBot
@camperbot
Nov 11 2016 02:27 UTC
flyyyperth sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 788 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 11 2016 02:27 UTC
@flyyyperth ;) :+1:
Gabi
@JJcreated
Nov 11 2016 02:27 UTC
been trying, still cant get it, im not seeing the problem, the logic of the code seems to be right
Johnny
@JohnnyBizzel
Nov 11 2016 02:29 UTC

@JJcreated You do a return inside a for loop.

Do not do this unless it is the solution.

Conor Murphy
@cmurphy580
Nov 11 2016 02:29 UTC
@awb715 Dang! thats really good! I like the shift up of the content
Joseph
@revisualize
Nov 11 2016 02:29 UTC
@JJcreated What are you working on?
Gabi
@JJcreated
Nov 11 2016 02:30 UTC
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  for(var a = 0; a < arr.length; a++){
    if(arr[a] === num){
      return arr.indexOf(num);     
    }
  arr.push(num);
  var sorted = arr.sort();
 var index = sorted.indexOf(num);
  for(var i = 0; i < sorted.length; i++){
    if(sorted[i] === num){
      return arr.indexOf(sorted[i]);
    }
  }


  return index;
  }

}

getIndexToIns([3, 10, 5], 3);
Joseph
@revisualize
Nov 11 2016 02:30 UTC
@JJcreated That tells me very little.
What are you working on?
Johnny
@JohnnyBizzel
Nov 11 2016 02:31 UTC
@revisualize I think the 2nd item has to be placed in the right order of the sorted first argument (array)???
Gabi
@JJcreated
Nov 11 2016 02:31 UTC
@JohnnyBizzel the return is inside the first if statement though, if i dont return then how do i resolve the first part of the code
Joseph
@revisualize
Nov 11 2016 02:31 UTC
@JohnnyBizzel I'd be able to talk on that if I know what they were working on.
Gabi
@JJcreated
Nov 11 2016 02:32 UTC
@revisualize im working on the where do i belong challenge
Mitch
@MitchWilkins
Nov 11 2016 02:32 UTC

Can some one help me with the logic for this? I'm not sure where to start? ```
function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
```

Joseph
@revisualize
Nov 11 2016 02:32 UTC
@JJcreated There we go.
Mitch
@MitchWilkins
Nov 11 2016 02:32 UTC
function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
return newArr;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Johnny
@JohnnyBizzel
Nov 11 2016 02:32 UTC
@JJcreated Store it in a variable - don't return
Joseph
@revisualize
Nov 11 2016 02:34 UTC
I just returned it.
Justin Vernon
@Jvernz
Nov 11 2016 02:34 UTC

function factorialize(num) {
  var factArray = [num];
  var z = num;
  for(var i = 0;i < num; i++) {
    factArray[i] = z;
    z--;
  }
   return factArray.reduce(function(previousVal, currentVal) {
                                  return previousVal * currentVal;
                                  }, 1);


}
factorialize(5);
Why is factorialize(0); returning 0? How can I make it return 1?
Johnny
@JohnnyBizzel
Nov 11 2016 02:36 UTC
@MitchWilkins One strategy is to concatenate the 2 arrays together then filter that against the 2 original arrays
Joseph
@revisualize
Nov 11 2016 02:36 UTC
@JJcreated @JohnnyBizzel How I did that lesson was.. I sorted the array.. Then I looked for the index of the element that was greater than the number .
Justin Vernon
@Jvernz
Nov 11 2016 02:37 UTC
Should i just make an if(num===0) statement?
Mitch
@MitchWilkins
Nov 11 2016 02:37 UTC
So run a function that would filter out the numbers individually? Or can .filter() filter an entire array from another array?
Johnny
@JohnnyBizzel
Nov 11 2016 02:37 UTC
@revisualize Makes sense :+1:
Joseph
@revisualize
Nov 11 2016 02:37 UTC
@JohnnyBizzel I also did it by concatenating the number to the array then sorted it and looking for the index of the number.
Johnny
@JohnnyBizzel
Nov 11 2016 02:38 UTC
@revisualize Also makes sense :smile:
Justin Vernon
@Jvernz
Nov 11 2016 02:38 UTC
function factorialize(num) {
  var factArray = [num];
  var z = num;
  if(num===0){
    return 1;
  }
  for(var i = 0;i < num; i++) {
    factArray[i] = z;
    z--;
  }
   return factArray.reduce(function(previousVal, currentVal) {
                                  return previousVal * currentVal;
                                  }, 1);


}
factorialize(1);
is the if statement "cheating?"
Aaron Bell
@awb715
Nov 11 2016 02:39 UTC
@cmurphy580 https://codepen.io/Aaron-w-Bell/pen/qqbXJz?editors=0010 almost there. try searching and clicking the up arrow and going thorugh the process
Johnny
@JohnnyBizzel
Nov 11 2016 02:39 UTC
@Jvernz What is wrong with the code?
Patrick Lippert
@mayhawstudios
Nov 11 2016 02:40 UTC

function permAlone(str) {
  var array = str.split("");
  var permutations = [];

  function swap(arr, a, b){
    var temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp;
  }

  function permute(element, arr){
    if (element == 1){
      permutations.push(arr);
    }

    for (var i = 0; i < element; i++){
      permute(element - 1, arr);

      if (element % 2 === 0){
        swap(arr, i, element - 1);
      }
      else {
        swap(arr, 0, element - 1);
      }
    }
  }

  permute(array.length, array);

  return permutations;

}

permAlone('aab');
Stuck on the "No Repeats Please" assignment. Trying to implement Heap's Permutation Algorithm to find the possible permutations, but the script breaks FCC's console and codepen just outputs the input array
Justin Vernon
@Jvernz
Nov 11 2016 02:41 UTC
@JohnnyBizzel Nothing now. but factiorialize(0) was outputting 0 instead of 1, so i made an if statement to target the 0.
Johnny
@JohnnyBizzel
Nov 11 2016 02:41 UTC
@Jvernz Just add if num === 0 return 1; somewhere near the top
Justin Vernon
@Jvernz
Nov 11 2016 02:41 UTC
@JohnnyBizzel that's exactly what i did, I just didn't know if that's what I was "supposed" to do
Johnny
@JohnnyBizzel
Nov 11 2016 02:42 UTC
@Jvernz Works for me
Gabi
@JJcreated
Nov 11 2016 02:42 UTC
@revisualize i did this, and also said that if the number is already in the array, then dont concat and just return the index of the number, most were resolving but others werent for some reason
Justin Vernon
@Jvernz
Nov 11 2016 02:42 UTC
@JohnnyBizzel Thanks!
CamperBot
@camperbot
Nov 11 2016 02:42 UTC
jvernz sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 789 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 11 2016 02:42 UTC
@Jvernz :smile: :+1:
@mayhawstudios Try your code in here: http://pythontutor.com/javascript.html
It runs but seems to have the same permutation 6 times
Aaron Bell
@awb715
Nov 11 2016 02:45 UTC
wow look atthis!
so proud of myself for making this functionality
Johnny
@JohnnyBizzel
Nov 11 2016 02:47 UTC
@awb715 Well done mate ;)
Walid Ashri
@walidashri
Nov 11 2016 02:50 UTC
@awb715 well done but make the link open in new tab better :)
Aaron Bell
@awb715
Nov 11 2016 02:51 UTC
what do you mean
Gabi
@JJcreated
Nov 11 2016 02:54 UTC
still not working, ill try again tomorrow
thanks anyways guys
Zaurbek Zhakupov
@zzhakupov
Nov 11 2016 02:56 UTC
Guys can I have some feedback on my Wiki viewer? https://codepen.io/Zooll/pen/ObMRbM
Johnny
@JohnnyBizzel
Nov 11 2016 02:58 UTC
@Zooll8 If you don't put a search term it says Top 15 Wiki Search Results for ""
Jason Firestein
@jasonfirestein
Nov 11 2016 02:58 UTC
can someone help me with this "a should be assigned to b with =" (New coder please help)
Zaurbek Zhakupov
@zzhakupov
Nov 11 2016 02:59 UTC
@JohnnyBizzel THx! I missed that fact
CamperBot
@camperbot
Nov 11 2016 02:59 UTC
zooll8 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 790 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Zaurbek Zhakupov
@zzhakupov
Nov 11 2016 03:01 UTC
@jasonfirestein a=b or if a is not created yet: var a =b
Joseph
@revisualize
Nov 11 2016 03:15 UTC
Hey hey.
Patrick Lippert
@mayhawstudios
Nov 11 2016 03:21 UTC
@JohnnyBizzel I'm stepping through it and don't understand why it won't swap the array items. Testing the swap() formula works, but it won't with the permutation function.
Johnny
@JohnnyBizzel
Nov 11 2016 03:24 UTC
@mayhawstudios I'll be honest. I didn't understand how to do that even with the official solution. I will PM you that.
Rembrandt Reyes
@rembrandtreyes
Nov 11 2016 03:29 UTC
I am pretty lost with this stand in line challenge
João Mhurilo Godoi da Silva
@ebak123
Nov 11 2016 03:30 UTC

Guys, i'm stuck at lesson 250 (Mutations). I dont understando what the function indexOf do... Thats my code:
function mutation(arr) {
var a,b,c,f;
var d=[],e=[];

a=arr.join(' ');
b=a.toLowerCase();
f=arr1;
c=b.indexOf(f);
return c;
}

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

its returning the index of the match, but i need to return true if i match the letters on the string, or false if doesnt
Mitch
@MitchWilkins
Nov 11 2016 03:40 UTC
can some one help me with my filter function? I'm trying to get it to filter out the 4
function diffArray(arr1, arr2) {
  var filterArr = [];
  function myFunction(value){
    for (var i = 0; i < arr2.length; i++) {
      filterArr =  arr2.indexOf(arr1[i]);
    }return filterArr;
  }
  var newArr = [];
  // Same, same; but different.
  newArr = arr1.concat(arr2);
  return newArr.filter(myFunction);
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Walid Ashri
@walidashri
Nov 11 2016 03:41 UTC
@ebak123 if c>-1 return true
Walid Ashri
@walidashri
Nov 11 2016 03:46 UTC
@MitchWilkins myFunction should return true or false to get the right filtering
Jenky W. Nolasco
@jenkynolasco11
Nov 11 2016 03:53 UTC
Hola mundo o/
Adolfo Saenz
@AdoSae1
Nov 11 2016 03:53 UTC
@walidashri i am confused with "using objects for Lookups" can you help?
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Zach
@ziggity
Nov 11 2016 03:56 UTC
Manipulate Arrays with Shift: I'm stuck! Anyone can you help? Heres my code:

// Example
var ourArray = ["Stimpson", "J", ["cat"]];
removedFromOurArray = ourArray.shift();
// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].

// Setup
var myArray = [["John", 23], ["dog", 3]];

// Only change code below this line.
var removedFromMyArray = myArray.shift();

(function)(y, z){return 'myArray = ' + JSON.stringify(y) + ' & removedFromMyarray = ' + JSON.stringify(z);})(myArray, removedFromMyArray);

Adolfo Saenz
@AdoSae1
Nov 11 2016 03:56 UTC
this is my code:

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

// Only change code below this line

var lookup= {

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

};

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

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

@ziggity any idea?
Zach
@ziggity
Nov 11 2016 03:59 UTC
not really sure how to solve it
Walid Ashri
@walidashri
Nov 11 2016 04:00 UTC
@AdoSae1 now set result to get the value of the property val of the object
Emerson
@DikoFaji
Nov 11 2016 04:02 UTC
pls help im stuck in basic javascript (Record Collection), im checking if object property insist. i dont know if my syntax is correct
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:03 UTC
@walidashri yea im not getting that part
Emerson
@DikoFaji
Nov 11 2016 04:03 UTC

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 (prop == "tracks" && value !== ""){
if (collection.hasOwnProperty(id[prop])){

is this correct
(collection.hasOwnProperty(id[prop]))
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:07 UTC
@walidashri
result=lookup[""];
Walid Ashri
@walidashri
Nov 11 2016 04:10 UTC
@AdoSae1 so close lookup[somthinghere]
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:11 UTC
do i keep result=
Walid Ashri
@walidashri
Nov 11 2016 04:11 UTC
@AdoSae1 yes
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:11 UTC
ok let me try some things
Walid Ashri
@walidashri
Nov 11 2016 04:11 UTC
@DikoFaji no
collection[id].hasOwnProperty(prop)
Abhaya Basnet
@abhayaa
Nov 11 2016 04:12 UTC
hi, i have a question unrelated to fcc challenges
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:20 UTC
@walidashri :clap: I got it thank you so much. the wording on some of these really puts me all over the place.
CamperBot
@camperbot
Nov 11 2016 04:20 UTC
adosae1 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 612 | @walidashri |http://www.freecodecamp.com/walidashri
Walid Ashri
@walidashri
Nov 11 2016 04:20 UTC
@AdoSae1 :+1:
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:20 UTC
:+1:
João Mhurilo Godoi da Silva
@ebak123
Nov 11 2016 04:22 UTC
Guys, i'm stuck at lesson 250 (Mutations). I'm having problem with backwards words.. This is my code:
function mutation(arr) {
var a,b,c,f,g,verify;
var d=[],e=[];
a=arr[0];//Receiving the string
b=a.toLowerCase();//lowercase the string
d=b.split('');//Array with the string letters
c=arr1;//Receiving the string test
f=c.toLowerCase();//lowercase the string test
e=f.split('');//Array with the string test letters
g=b.indexOf(f); //Testing the string with the string test
if(g>-1){
return true;
}else{
return false;
}
}
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
Justin Vernon
@Jvernz
Nov 11 2016 04:23 UTC
Is there a way to keep my previous challenges saved? Sometimes I go back to earlier algorithm's for advice and my code is gone :/
João Mhurilo Godoi da Silva
@ebak123
Nov 11 2016 04:25 UTC
always auto save here :worried:
Walid Ashri
@walidashri
Nov 11 2016 04:25 UTC
@Jvernz try open the old one in new tab
Justin Vernon
@Jvernz
Nov 11 2016 04:25 UTC
Could it be if I work on a different computer?
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 04:30 UTC
@Jvernz try clicking on your picture instead of map
Justin Vernon
@Jvernz
Nov 11 2016 04:31 UTC
@Jeff-Shapiro You're my hero thanks
CamperBot
@camperbot
Nov 11 2016 04:31 UTC
jvernz sends brownie points to @jeff-shapiro :sparkles: :thumbsup: :sparkles:
:cookie: 333 | @jeff-shapiro |http://www.freecodecamp.com/jeff-shapiro
Justin Vernon
@Jvernz
Nov 11 2016 04:33 UTC
In other coding sites I would use console.log() to check the value of my variables. It doesn't seem to work at will in this editor
Emerson
@DikoFaji
Nov 11 2016 04:35 UTC
@walidashri thank you!
CamperBot
@camperbot
Nov 11 2016 04:35 UTC
dikofaji sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 613 | @walidashri |http://www.freecodecamp.com/walidashri
Vu Phung
@VDPhung
Nov 11 2016 04:39 UTC
I need a hint or example on how to use on click event to call API multiple times
$(document).ready(function(){
//click event
$("#getQuote").on("click", function(){
//quote message
//$(".quoteMessage").html("This should be a quote");
//call random quote API from quote on design website using jQuery
$.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(json) {
//$(".quoteMessage").append(a[0].content + "<p>— " + a[0].title + "</p>")
//$(".quoteMessage").html(JSON.stringify(a));
var html= "";
// loop each object and assign it to div and p tag
json.forEach(function(val) {
html += "<div class = 'quote'>";
html += "<p>" + val.content + val.title + "</p>";
html += "</div>";
});
$(".quoteMessage").html(html);
});
});
});
my issue is, it only executes once when I click on my get qutoe
then the webpage is dead, and I have to refresh
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 04:43 UTC
so i could use some help with Make Object Properties Private
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;

  this.getGear = function(){

  }; 
  this.setGear = function(){

  };
  return gear;
};

var myCar = new Car();

var myBike = new Bike();
myBike.getGear(4);
myBike.setGear(3);
this is what it should do and its not 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).
i need to put some thing in the getGear and setGear methods
but idk what
Ian Arsenault
@ianarsenault
Nov 11 2016 04:47 UTC
Does anyone know a way to tell if the caesar cipher is encrypted or decrypted?
Justin Vernon
@Jvernz
Nov 11 2016 04:52 UTC
Am I supposed to credit sights like mozilla if I use their example code for learning new methods?
Emerson
@DikoFaji
Nov 11 2016 04:53 UTC

pls help im having trouble in creating new object property this is what i am doing:

collection[id].push(prop);

Luke Winkelmann
@LGWinkelmann
Nov 11 2016 04:54 UTC
@Jvernz if its in a project i think so if its just in one of these challenges i think your good
Justin Vernon
@Jvernz
Nov 11 2016 04:55 UTC
@LGWinkelmann I think you need to return the variable inside each function
```
this.getGear = function(){
   return gear;
 };
for example
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 04:56 UTC
i tried but no change the one i have currently i for got to remove but i will try again. @Jvernz
Logan Sinclair
@LoganS1
Nov 11 2016 04:58 UTC

Could someone tell me how to return undefined when using

return

in a function?

Justin Vernon
@Jvernz
Nov 11 2016 04:58 UTC
@LGWinkelmann Actually, I think you need to create a parameter inside your setGear function.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 04:58 UTC
  this.getGear = function(gear){
return gear;
  }; 
  this.setGear = function(gear){
return gear;
  };
even when i do this it doesn't work. and this seem simple
Justin Vernon
@Jvernz
Nov 11 2016 05:00 UTC
I've got mine answered, but I can't figure out why.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:01 UTC
so a parameter kind works lol when i just tell it to set to 4 one of the boxes checks but i need it to work for any answer
mind linking the code? @Jvernz
Justin Vernon
@Jvernz
Nov 11 2016 05:01 UTC
var Bike = function() {
var gear = 5;
  // Only change code below this line.
 this.getGear = function(){
   return gear;
 };
  this.setGear = function(num) {
    gear = num;
    return num;
  };
};

var myCar = new Car();

var myBike = new Bike();
I know var gear = 5; is just meant to make gear a number variable
when i take out gear = num; in the setGear function, it makes my code wrong, but i can't figure out why
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:02 UTC
cause u call a function of num and it works when i look at it
Justin Vernon
@Jvernz
Nov 11 2016 05:02 UTC
when I did it earlier this afternoon, I didn't hesitate to put it in there
well the thing is, function(num) gives me my value for return num;
I don't see how gear = num; has any impact
I actually think it's just the specific wording used for the problem
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:05 UTC
i dont understand why the wording is the way it is but i will just put a not in and remember to ask some one later.
but thanks you very much @Jvernz
CamperBot
@camperbot
Nov 11 2016 05:05 UTC
lgwinkelmann sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @jvernz |http://www.freecodecamp.com/jvernz
Justin Vernon
@Jvernz
Nov 11 2016 05:06 UTC
Alright good thinking. I just did all kinds of stuff and couldn't figure it out. The way I wrote it, seemingly by chance, is the only way it works for me.
No problem! @LGWinkelmann
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:07 UTC
most of the stuff i get help on i either over think or something simple and then i see it and its like well duh of course i should have thought of that my self lol
Justin Vernon
@Jvernz
Nov 11 2016 05:07 UTC
array = array.replace(/[^\w\s]/);
I pulled this code from stackoverflow to enable me to rid my string of special characters, but it doesn't seem to work. Any advice?
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:09 UTC
i assume that (/[^\w\s]/) may be too advanced. also when i look at that code it says replace not anything like remove but this is me stabbing in the dark
Justin Vernon
@Jvernz
Nov 11 2016 05:10 UTC
@LGWinkelmann No problem, just seeing if anyone knows this stuff. This is for the 4th algorithmic problem. You'll be there soon enough :D
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:11 UTC
besides you and me i think only 2 other people are active in this chat.
Justin Vernon
@Jvernz
Nov 11 2016 05:11 UTC
Seems so now, but I was getting help left and right earlier in the day.
NoobsNoob
@NoobsNoob
Nov 11 2016 05:11 UTC
Caesar's Cipher - Can't work out where I'm breaking this as getting the wrong returned values.
function rot13(str) { // LBH QVQ VG!
  charArray = str.split("");
  result = [];
  tempChar = "";
  for(i = 0; i < charArray.length; i++) {
    if(charArray[i].match(/^[A-Z]/)) {
      result.push(String.fromCharCode(charArray[i].charCodeAt(0) + 13));
      return result;
    }
    else {
      result.push(charArray[i]);
    }
  }
  return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:12 UTC
guess people have off tomorrow and they are all out having a party now lol
Justin Vernon
@Jvernz
Nov 11 2016 05:18 UTC

function palindrome(str) {
  // Good luck!
 var x = str.toLowerCase();
  var array = x.split('');
  array = array.reverse();
  array = array.join('');
  array = array.replace(/[^\w\s]/gi, '');

 if(array===str) {
    return true;
  }
  else {
    return false;
  }



}



palindrome("_eye");
I can't get anything to return true except for 1 word inputs like "eye" or "did". Can anyone throw me some advice?
NoobsNoob
@NoobsNoob
Nov 11 2016 05:22 UTC
@Jvernz what did you need to replace?
the underscore?
Justin Vernon
@Jvernz
Nov 11 2016 05:23 UTC
@NoobsNoob I need to replace all special characters in order to just have letters existing in my strings
NoobsNoob
@NoobsNoob
Nov 11 2016 05:23 UTC
space ok or not ok?
Justin Vernon
@Jvernz
Nov 11 2016 05:23 UTC
I changed the line to array = array.replace(/[^a-z]/gi, '');
space not okay either
feels like I'm doing this completely wrong lol
NoobsNoob
@NoobsNoob
Nov 11 2016 05:24 UTC
What you just gave is basically what I was thinking.
I've done that exercise nut on another PC so can't see my code
but I recall I used https://regex101.com/ to help build the regex
Justin Vernon
@Jvernz
Nov 11 2016 05:24 UTC
You can go to your profile and "view solution"
awesome source, thanks @NoobsNoob
CamperBot
@camperbot
Nov 11 2016 05:25 UTC
jvernz sends brownie points to @noobsnoob :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for noobsnoob
NoobsNoob
@NoobsNoob
Nov 11 2016 05:27 UTC
@Jvernz what was the exercise name? I'll find my solution. WOn't just dump but will see how can help you find the answer.
Justin Vernon
@Jvernz
Nov 11 2016 05:28 UTC
@NoobsNoob Awesome! Check for Palindromes was the name
NoobsNoob
@NoobsNoob
Nov 11 2016 05:28 UTC
Found it.
Ok I chained a few methods together on mine so it looks a biut different though effect is the same.
regex is NOT NUMRANGE CHARRANGE with global applied
Does that make sense?
Justin Vernon
@Jvernz
Nov 11 2016 05:30 UTC
Do I need to find those symbols?
pycraft
@pycraft
Nov 11 2016 05:32 UTC
excuse me guys can somebody help me with javascript?
anybody? ;(
hello~~
Justin Vernon
@Jvernz
Nov 11 2016 05:34 UTC
@pycraft Hey what'sup? I'm no expert but if I can help I will
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:35 UTC
need to put up your code

I need help with this part code: function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = "Vuvu'" + myNoun + "is very" + myAdjective + ".\n";
result += "One day, the" + myNoun + "" + myVerb + "" + myAdverb;
result += ", when nobody was watching.";

// Your code above this line
return result;
}

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

pycraft
@pycraft
Nov 11 2016 05:36 UTC
@Jvernz https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%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%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%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%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%20%20if%20(prop%20!%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22)%7B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D%20%3D%20value%20%3B%0A%20%20%7Delse%20if%20(prop%20%3D%20%22tracks%22%20%26%26%20value%20!%3D%20%22%22)%20%7B%0A%20%20%20%20collection%5Bid%5D%5B%22tracks%22%5D.push(value)%3B%0A%20%20%7Delse%20if%20(value%20%3D%22%22)%20%7B%0A%20%20%20%20delete%20collection%5Bid%5D.prop%3B%0A%20%20%20%20%0A%20%20%7Delse%7B%20%20%0A%20%20%20%20%0A%20%20%0A%20%20return%20collection%3B%0A%20%20%7D%0A%20%20%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
pycraft
@pycraft
Nov 11 2016 05:36 UTC
oops sorry for the long links
but im kinda stuck at here
Justin Vernon
@Jvernz
Nov 11 2016 05:36 UTC
@pycraft paste you're code by typing ``` shift+enter
like this
NoobsNoob
@NoobsNoob
Nov 11 2016 05:37 UTC
@Jvernz Back again. If you use the number and letter identifier but reversed with the ^ it will remove everything that is not a number or leter
Justin Vernon
@Jvernz
Nov 11 2016 05:37 UTC
array.replace(/[^a-z]\d+/gi, '');
I feel like that should work but it's not, unless I've messed up somewhere else @NoobsNoob
pycraft
@pycraft
Nov 11 2016 05:38 UTC

// 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 (prop !== "tracks" && value !== ""){
    collection[id][prop] = value ;
  }else if (prop = "tracks" && value != "") {
    collection[id]["tracks"].push(value);
  }else if (value ="") {
    delete collection[id].prop;

  }else{  


  return collection;
  }
  }

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
NoobsNoob
@NoobsNoob
Nov 11 2016 05:38 UTC
@Jvernz Close
replace(/[^0-9a-z]/g, '')
@Jvernz wht is d+? I'm still new to regex myself
@pycraft What's the result as is?
Justin Vernon
@Jvernz
Nov 11 2016 05:39 UTC
@NoobsNoob \d is supposed to be "matches a digit (equal to [0-9])"
NoobsNoob
@NoobsNoob
Nov 11 2016 05:40 UTC
[0-9a-z] apparently achieves the same. Still a noob at it myself so can't explain why sorry.
Justin Vernon
@Jvernz
Nov 11 2016 05:40 UTC
@NoobsNoob I'm awful at it so don't feel bad lol
apparently that wasn't my issue though, because nothing is returning true except for single words
pycraft
@pycraft
Nov 11 2016 05:41 UTC
@NoobsNoob icant go to next level :(
NoobsNoob
@NoobsNoob
Nov 11 2016 05:41 UTC
what is your output
pycraft
@pycraft
Nov 11 2016 05:42 UTC
@NoobsNoob updateRecords(5439,"artist","ABBA") does make "aritst" property in property "5439" but cant go to next level tho
Justin Vernon
@Jvernz
Nov 11 2016 05:43 UTC
@pycraft your operators are incorrect in your else if statements. = is assignment, === is comparison
NoobsNoob
@NoobsNoob
Nov 11 2016 05:43 UTC
@Jvernz How did you go now?
Justin Vernon
@Jvernz
Nov 11 2016 05:44 UTC
@NoobsNoob still in the same spot
NoobsNoob
@NoobsNoob
Nov 11 2016 05:44 UTC
Can't see myself progressing until tomorrow with some help so may as help where I can
Justin Vernon
@Jvernz
Nov 11 2016 05:44 UTC
I'm going to try to rearrange my code and see if it changes anything
Ken Haduch
@khaduch
Nov 11 2016 05:44 UTC
@pycraft - the line }else if (prop = "tracks" && value != "") { should be }else if (prop === "tracks" && value != "") {. And you are not taking into consideration the case where the object does not have the tracks property already in place - but if you make that change, also in the last line }else if (value ="") { should be changed to }else if (value === "") {, I think that you'll pass all but one test.
NoobsNoob
@NoobsNoob
Nov 11 2016 05:44 UTC
can you paste it here again and I'll check it
Justin Vernon
@Jvernz
Nov 11 2016 05:45 UTC

function palindrome(str) {
  // Good luck!
 var x = str.toLowerCase();
  var array = x.split('');
  array = array.reverse();
  array = array.join('');
  array = array.replace(/[^0-9a-z]/g, '');

 if(array===str) {
    return true;
  }
  else {
    return false;
  }

}

palindrome("_eye");
Joseph
@revisualize
Nov 11 2016 05:45 UTC
@pycraft You should ALWAYS return the collection.
@Jvernz You need to do your regex on BOTH sides.
Justin Vernon
@Jvernz
Nov 11 2016 05:46 UTC
@revisualize I don't know what that means :/
NoobsNoob
@NoobsNoob
Nov 11 2016 05:46 UTC
ooooh ok biggest difference I see is the same mistake I tore my hurt out over
Justin Vernon
@Jvernz
Nov 11 2016 05:47 UTC
wait do i need to run my regex on the str?
NoobsNoob
@NoobsNoob
Nov 11 2016 05:47 UTC
when you compare array against string, you need to also apply the regex replace on str in the if
Bingo
Aamnah Akram
@aamnah
Nov 11 2016 05:47 UTC
I'm at 'Truncate a string' basic algo and i don't think i understand the objective. It says '
Note that inserting the three dots to the end will add to the string length.' does that mean i should truncate it again using str.length > num ?
Tyrell
@Tyriffik
Nov 11 2016 05:47 UTC

Can someone help me with this simple cat code? I can't seem to figure out why my picture isn't changing sizes. The colour and font is working, but the size class isn't working...help!<style>
.smaller-image {
width: 100px;
}

.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}

</style>

NoobsNoob
@NoobsNoob
Nov 11 2016 05:48 UTC
@revisualize Can you help with Caesar's Cipher exercise?

function rot13(str) { // LBH QVQ VG!
  charArray = str.split("");
  result = [];
  tempChar = "";
  for(i = 0; i < charArray.length; i++) {
    if(charArray[i].match(/[A-Z]/)) {
      result.push(String.fromCharCode(charArray[i].charCodeAt(0) + 13));
    }
    else {
      result.push(charArray[i]);
    }
  }
  return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Justin Vernon
@Jvernz
Nov 11 2016 05:48 UTC
@NoobsNoob @revisualize Nice! that solved a lot of my issues but not all of them. Thanks
CamperBot
@camperbot
Nov 11 2016 05:48 UTC
jvernz sends brownie points to @noobsnoob and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for noobsnoob
:star2: 2284 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Nov 11 2016 05:48 UTC
@Jvernz Yes.
Walid Ashri
@walidashri
Nov 11 2016 05:48 UTC
@Tyriffik did u add the class to the img?
Ken Haduch
@khaduch
Nov 11 2016 05:48 UTC

@vuvu10 - make sure that you put a space between any of the words that you are joining to make the output - for example in this line:

result = "Vuvu'"  +  myNoun  +  "is very" +  myAdjective  +  ".\n";

Change it to put spaces before and after each variable that you are inserting:

result = "Vuvu' "  +  myNoun  +  " is very " +  myAdjective  +  ".\n";

Or any place that you are putting a "filler" between variables:

result += "One day, the"    +  myNoun  +  ""  +  myVerb  +  ""  +  myAdverb

It should be

result += "One day, the "    +  myNoun  +  " "  +  myVerb  +  " "  +  myAdverb

The spaces are important!

NoobsNoob
@NoobsNoob
Nov 11 2016 05:49 UTC
@Jvernz try putting your replace directly after your lowercase
Tyrell
@Tyriffik
Nov 11 2016 05:49 UTC
@walidashri ohhh i don't think so, I'm goign to try again, thanks!
CamperBot
@camperbot
Nov 11 2016 05:49 UTC
tyriffik sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 615 | @walidashri |http://www.freecodecamp.com/walidashri
im working on my calculator, ...using parsefloat() to change my strings to #'s, then when i use them in a calculation it like adds or subtracts a millionth of a decimal some times, any thoughts?
Justin Vernon
@Jvernz
Nov 11 2016 05:50 UTC
@NoobsNoob my last issue is that any input with punctuation in it is returning as false
Emerson
@DikoFaji
Nov 11 2016 05:50 UTC

pls help im having trouble creating object properties kindly look. thank you!

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

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

return collection;
}

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

NoobsNoob
@NoobsNoob
Nov 11 2016 05:50 UTC
@revisualize I've got what I think is a working process but I'm not getting the right values back from the charCodes
Justin Vernon
@Jvernz
Nov 11 2016 05:50 UTC
I take that back, it could be capitalization. @NoobsNoob
NoobsNoob
@NoobsNoob
Nov 11 2016 05:51 UTC
make sure tolowercase is on both sides of the if
Justin Vernon
@Jvernz
Nov 11 2016 05:51 UTC
@NoobsNoob I figured it out, I'd accidentally made another variable and assigned the lowercase function to it
Thanks for all the help though!
NoobsNoob
@NoobsNoob
Nov 11 2016 05:52 UTC
@Jvernz All's well that ends well. Onto the next challenge :)
Tyrell
@Tyriffik
Nov 11 2016 05:52 UTC
@walidashri Thank you So Much @walidashri !! I'm so bad at this! It worked.
CamperBot
@camperbot
Nov 11 2016 05:52 UTC
tyriffik sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:warning: tyriffik already gave walidashri points
Emerson
@DikoFaji
Nov 11 2016 05:55 UTC
@revisualize can u help me Joseph?
Adolfo Saenz
@AdoSae1
Nov 11 2016 05:57 UTC
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
my code:

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

function checkObj(checkProp) {
if (myObj.hasOwnProperty("")) {
return"";
}

return "Change Me!";
}

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

Justin Vernon
@Jvernz
Nov 11 2016 06:03 UTC
That feel when you knock out an algorithm in 10 minutes
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:12 UTC
@Jvernz can you help with my problem?
Dany
@Danylrs
Nov 11 2016 06:13 UTC
Hello Code World! anyone up to "Selecting from many options with Switch statements" in JS. I Need serious help! lol After a few hours of being on a roll with this Im in total dissaray
CamperBot
@camperbot
Nov 11 2016 06:13 UTC

welcome to FreeCodeCamp @Danylrs!

Donatas
@Donaatas
Nov 11 2016 06:13 UTC
arr[i] !== null
so am I missing something or this code line should evaluate null to false, as I want it to?
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:14 UTC
Hello I need help on these:
Donatas
@Donaatas
Nov 11 2016 06:14 UTC
@Danylrs post your code and say what you need :)
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:14 UTC

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

return item; // Change this line
}

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

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

Thomas Swatland
@swatbone85
Nov 11 2016 06:15 UTC
Hi, I'm struggling with the Check for Palindromes challenge. The regexp \w includes underscore "_" but I need to get rid of it. I feel as if the answer is right there, and much simpler than I'm thinking...
Donatas
@Donaatas
Nov 11 2016 06:15 UTC
pasting code use ` sign to change format please left side of your keyboard same button as ~
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:16 UTC

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

return item; // Change this line
}

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

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

Justin Vernon
@Jvernz
Nov 11 2016 06:16 UTC
@AdoSae1 What's your problem?
Donatas
@Donaatas
Nov 11 2016 06:16 UTC
@dgana remind the problem?
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:16 UTC
how lol im still newb
Philipp Scholz
@philipp32
Nov 11 2016 06:17 UTC

Goord Morning, I am working on the factoralize a number challenge.

function factorialize(num) {
  var h = 1;
  if (num == 1) {
    h = 1;
  } else {
    for (i=0; i<num; i++)
      h = h*i;
  }
  return h;
}      

factorialize(5);

It does return the number 0 and in case h is 0 it returns 1. But it won't factorize the rest. What is wrong?

Justin Vernon
@Jvernz
Nov 11 2016 06:17 UTC
@Danylrs Link your code. What's your issue?
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:17 UTC
This is the stand in line
nextInLine([2], 1) should return 2 // I dont know how to do this
Justin Vernon
@Jvernz
Nov 11 2016 06:18 UTC
@philipp32 just off the bat, I think your if statement is supposed to be if num === 0 then return 1
Dany
@Danylrs
Nov 11 2016 06:19 UTC
Example

switch (num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
...
  case valueN:
    statementN;
    break;
}

Code Editor

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line



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

// Change this value to test
caseInSwitch(1);
Im not sure where to start to be honest. Is this the case ---> caseInSwitch and the value "alpha", what about the statement? what statement do I write?
@Jvernz
Philipp Scholz
@philipp32
Nov 11 2016 06:19 UTC
@Jvernz already changed that. :)
Donatas
@Donaatas
Nov 11 2016 06:19 UTC
@philipp32 use recursion.
if (num == 1) {
return 1;
}
else {
return num * factorialize(num - 1);
}
Emerson
@DikoFaji
Nov 11 2016 06:20 UTC
this basic JS RECORD COLLECTION challenge is a pain! need to take a break
Justin Vernon
@Jvernz
Nov 11 2016 06:20 UTC
@Danylrs Don't feel bad, this challenge got me pretty good too
Philipp Scholz
@philipp32
Nov 11 2016 06:20 UTC
@Donaatas that doesn't work at all. :/ I'm sorry.
Donatas
@Donaatas
Nov 11 2016 06:21 UTC
wait
Dany
@Danylrs
Nov 11 2016 06:21 UTC
lol @Jvernz its frustrating
Justin Vernon
@Jvernz
Nov 11 2016 06:21 UTC
@Danylrs I'm not very good at coding. I got the answer, but I'm trying to remember how I got it. I don't want to just give you the answer without knowing what it means
Donatas
@Donaatas
Nov 11 2016 06:21 UTC

@philipp32

function factorialize(num) {
  if (num <= 1) {
    return 1;
  }
  else {
  return num * factorialize(num - 1);
  }
}

factorialize(5);

my code. ant it works :)

Justin Vernon
@Jvernz
Nov 11 2016 06:22 UTC
@Danylrs Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
These are the rules
Dany
@Danylrs
Nov 11 2016 06:22 UTC
I hear ya! No worries take your time. I agree with you 100%.
Philipp Scholz
@philipp32
Nov 11 2016 06:22 UTC
@Donaatas Thank you for the working code. Before I use it to complete my challenge, I'd like to know what is wrong with my code.
CamperBot
@camperbot
Nov 11 2016 06:22 UTC
philipp32 sends brownie points to @donaatas :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @donaatas |http://www.freecodecamp.com/donaatas
Donatas
@Donaatas
Nov 11 2016 06:23 UTC
there is nothing wrong, you can do programming in different ways, and i don't know if freecodecamp even showed how to do recursion, it's something more comonly used in c++ or other languages, and it happens it's awesome for factorials :D
Dany
@Danylrs
Nov 11 2016 06:23 UTC
right, so I would assume that I am writing the following :
caseInSwitch === "alpha":
@Jvernz
but what is there a statement that needs to be typed out
Justin Vernon
@Jvernz
Nov 11 2016 06:23 UTC
@Danylrs So basically what you want to do is have the value next to case be a possible input from the function.
and your 4 possible values are 1 2 3 and 4
so you will have case 1, case 2, case 3, and case 4
Emerson
@DikoFaji
Nov 11 2016 06:24 UTC

help guys am i doing this push function right?

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

CamperBot
@camperbot
Nov 11 2016 06:24 UTC
no wiki entry for: guys am i doing this push function rightcollectionidpushprop collectionidproppushvalue
Justin Vernon
@Jvernz
Nov 11 2016 06:24 UTC
@DikoFaji I will check in a second
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:25 UTC
what is the short hand for spaces i thought it was /S
Justin Vernon
@Jvernz
Nov 11 2016 06:25 UTC
@Danylrs what you want it for when your input for the function caseInSwitch is 1, you want the output to be "alpha"
Emerson
@DikoFaji
Nov 11 2016 06:25 UTC
@Jvernz yes pls.. RECORD COLLECTION challenge is giving me a headache now :(
Justin Vernon
@Jvernz
Nov 11 2016 06:25 UTC
@DikoFaji I was there earlier today lol
Thomas Swatland
@swatbone85
Nov 11 2016 06:25 UTC
Hi, I'm struggling with the Check for Palindromes challenge. The regexp \w includes underscore "_" but I need to get rid of it. I feel as if the answer is right there, and much simpler than I'm thinking...
Emerson
@DikoFaji
Nov 11 2016 06:25 UTC
@Jvernz really thats nice! :D
Justin Vernon
@Jvernz
Nov 11 2016 06:26 UTC
@swatbone85 I will check yours in a second too, just finished it. remind me if I forget
Dany
@Danylrs
Nov 11 2016 06:26 UTC
ok let me try this out @Jvernz brb
Thomas Swatland
@swatbone85
Nov 11 2016 06:26 UTC
@Jvernz Awesome, thanks mate :)
CamperBot
@camperbot
Nov 11 2016 06:26 UTC
swatbone85 sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @jvernz |http://www.freecodecamp.com/jvernz
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:26 UTC
@Jvernz Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
Donatas
@Donaatas
Nov 11 2016 06:26 UTC
@philipp32 just see some youtube tutorials on recursion, if you didn't quite catch one on this code snipet, it will be very useful in the future :)
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:26 UTC
here is my code:
Emerson
@DikoFaji
Nov 11 2016 06:26 UTC
@Jvernz its my 8th straight days now :D
Philipp Scholz
@philipp32
Nov 11 2016 06:27 UTC
@Donaatas
function factorialize(num) {
  var result = 1;
  if (num === 0) {
    result = 1;
  } else {
      for (i=1; i<=num; i++)
      result *= i;
  }  
  return result;
}      

factorialize(5);
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:27 UTC

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

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp)) {
return;
} else {
return"Not Found";
}

return "Change Me!";
}

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

Philipp Scholz
@philipp32
Nov 11 2016 06:27 UTC
@Donaatas That works now. :)
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:27 UTC
copy your code then in chat start with ```js then hit shift enter copy your code
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:27 UTC
@AdoSae1 they told u to return that property
Justin Vernon
@Jvernz
Nov 11 2016 06:27 UTC
@DikoFaji so I don't know how to explain it very well, but there is a difference between dot notation and bracket notation. from what I remember, I think dot notation is related to strings only and bracket notation can be used for variables. Don't take my word for it, probably better to just look it up
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:27 UTC
```js
hello
Justin Vernon
@Jvernz
Nov 11 2016 06:28 UTC
@DikoFaji If you can post your code, I will tell you what push functions you need to work on. However, your second function you posted looks good. collection[id][prop].push(value);
Emerson
@DikoFaji
Nov 11 2016 06:29 UTC
@Jvernz collection[id].push(prop);
collection[id][prop].push(value);
@Jvernz im trying that one
@Jvernz ive been in different variation, believe me :D
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:29 UTC
@DikoFaji where are u trying to push ur values ??
Justin Vernon
@Jvernz
Nov 11 2016 06:29 UTC
@swatbone85 So your regexp isn't correct. There's different ways you can do it. I'm a complete regexp rookie, but the way I did mine was by only accepting letters a-z and digits 0-9
@DikoFaji post your code by typing ``` and then shift+enter
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:30 UTC
about @Dorcy-ndg3
CamperBot
@camperbot
Nov 11 2016 06:30 UTC
:cookie: 343 | @dorcy-ndg3 |http://www.freecodecamp.com/dorcy-ndg3
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:31 UTC
@Dorcy-ndg3 ok but when i return a value for one i cant do the other
Justin Vernon
@Jvernz
Nov 11 2016 06:31 UTC
@AdoSae1 what challenge is this?
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:31 UTC
..
"testing objects for properties"
Thomas Swatland
@swatbone85
Nov 11 2016 06:31 UTC
I see, I have been looking for ways to exclude the underscore from \w, but with no luck.
```
var strArr = str.match(/\w/g);
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:31 UTC
been stuck for like 45 min -___-
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:31 UTC
// 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) {


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

  return collection;

}
Emerson
@DikoFaji
Nov 11 2016 06:32 UTC

@Jvernz im trying to achieve this one:

After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"

Thomas Swatland
@swatbone85
Nov 11 2016 06:32 UTC
var strArr = str.match(/\w/g)
this is what I have been trying
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:32 UTC
i think is what @DikoFaji code looks like
Justin Vernon
@Jvernz
Nov 11 2016 06:32 UTC
@swatbone85 I'll go ahead and give you the regexp I used, it took me a while to find it, but I did. replace(/[^0-9a-z]/g, '')
Emerson
@DikoFaji
Nov 11 2016 06:32 UTC
yeah we r doing the same
i dont know if that push is correct
Justin Vernon
@Jvernz
Nov 11 2016 06:33 UTC
It means basically what I just told you, only accepting digits and letters. It eliminates all spaces and symbols and punctuation. @swatbone85 I wouldn't have given it to you if I didn't think there would be more of a challenge ahead for that algorithm =)
Thomas Swatland
@swatbone85
Nov 11 2016 06:33 UTC
@Jvernz I see! I will give it a go, what do the square brackets do?
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:33 UTC
i just copied your code and put it in to the challenge so that u could see how they were asking you to put it in chat.
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:33 UTC
@swatbone85 this covers everything for that palindrome challenge
 str.toLowerCase().replace(/[.,\/#!$%\^&\*;:{}=\-_`~()\s]/g,"");
@AdoSae1 maybe u need an else if statement
Ryan Copeland
@ryan6627
Nov 11 2016 06:34 UTC
what in the hell am i doing wrong ???
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:34 UTC
whats the nmae of ur challenge ??
Justin Vernon
@Jvernz
Nov 11 2016 06:34 UTC
@swatbone85 no idea!
Ryan Copeland
@ryan6627
Nov 11 2016 06:34 UTC
return early pattern for functions
Justin Vernon
@Jvernz
Nov 11 2016 06:34 UTC
I think it's just part of the regexp for the digits/letters
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:34 UTC
@Dorcy-ndg3 let me try brb
Thomas Swatland
@swatbone85
Nov 11 2016 06:34 UTC
@Jvernz Lol, thank you so much for your help :)
CamperBot
@camperbot
Nov 11 2016 06:34 UTC
swatbone85 sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:warning: swatbone85 already gave jvernz points
Justin Vernon
@Jvernz
Nov 11 2016 06:35 UTC
@swatbone85 good luck!
Emerson
@DikoFaji
Nov 11 2016 06:35 UTC
@LGWinkelmann we r having the same problem, have u figure it out?
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:36 UTC
this is my code: still no luck

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

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp)) {
return("kitten");
}else if (myObj.hasOwnProperty(checkProp)) {
return("pony");
}else {
return"Not Found";
}

return "Change Me!";
}

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

Justin Vernon
@Jvernz
Nov 11 2016 06:36 UTC
@DikoFaji He was just posting what he assumed your code looked like. If you will post all of your code in compose mode it will be easier to assist you!
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:36 UTC
@Jvernz @Dorcy-ndg3
Ryan Copeland
@ryan6627
Nov 11 2016 06:36 UTC
built.
in.
answers.
2 hours
Justin Vernon
@Jvernz
Nov 11 2016 06:37 UTC
@AdoSae1 your code is way too in depth
Ryan Copeland
@ryan6627
Nov 11 2016 06:37 UTC
on one problem
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:37 UTC
@Jvernz i think so too
Justin Vernon
@Jvernz
Nov 11 2016 06:37 UTC
@AdoSae1 you need to create code that accepts all inputs and gives a response based on those inputs
Dany
@Danylrs
Nov 11 2016 06:37 UTC
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      answer = "alpha";
      break;
    case 2:
      answer = "beta";
      break;
    case 3:
      answer = "gamma";
      break;
    case 4:
      answer = "delta";
      break;
  }



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

// Change this value to test
caseInSwitch(1);
@jvernz got it!
thanks @Jvernz
CamperBot
@camperbot
Nov 11 2016 06:38 UTC
danylrs sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:cookie: 247 | @jvernz |http://www.freecodecamp.com/jvernz
Justin Vernon
@Jvernz
Nov 11 2016 06:38 UTC
@Danylrs Awesome!!
@Danylrs good job, keep it up man!
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:38 UTC
@ryan6627 u dint put a return statement
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:38 UTC
@AdoSae1 where it says ```js
return "Chang me"
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:38 UTC
ur supposed to return undefined
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:38 UTC
they literally want u to change it
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:39 UTC
@ryan6627 also ur if should look like this
if(a<0 || b < 0)
Justin Vernon
@Jvernz
Nov 11 2016 06:39 UTC
@AdoSae1 You're actually really close
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:39 UTC
@Jvernz thats the worst part :worried: lol
Justin Vernon
@Jvernz
Nov 11 2016 06:40 UTC
@AdoSae1 I'll help
You essentially need 2 parts, you need your initial if statement and an else statement
your if statement is correct btw
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:40 UTC
ok
Justin Vernon
@Jvernz
Nov 11 2016 06:40 UTC
your else statement is correct as well
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:40 UTC
@AdoSae1 dont u think these are the same instructions u want to return different answers??
if (myObj.hasOwnProperty(checkProp)) {
return("kitten");
}else if (myObj.hasOwnProperty(checkProp)) {
return("pony");
Ryan Copeland
@ryan6627
Nov 11 2016 06:41 UTC
that doesn't work
Justin Vernon
@Jvernz
Nov 11 2016 06:41 UTC
so it's what's in the body of your if statement that needs to be changed @AdoSae1
Dany
@Danylrs
Nov 11 2016 06:41 UTC
sure will thanks! @Jvernz
CamperBot
@camperbot
Nov 11 2016 06:41 UTC
danylrs sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:warning: danylrs already gave jvernz points
Ryan Copeland
@ryan6627
Nov 11 2016 06:41 UTC
two returns causes error
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:41 UTC
@ryan6627 what are u returningg
Ryan Copeland
@ryan6627
Nov 11 2016 06:41 UTC
I just did the return underneath the if function because it's less than 0
causes error
Justin Vernon
@Jvernz
Nov 11 2016 06:42 UTC
@AdoSae1 instead of returning specific answers like return "kitten"; there is a way you can return everything in that object
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:42 UTC
im listening
...
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:42 UTC
@ryan6627 doest it look like this
if(a<0 || b < 0){
  return undefined;
}
@AdoSae1 what are the instructions
Ryan Copeland
@ryan6627
Nov 11 2016 06:43 UTC
im done
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:43 UTC
@Dorcy-ndg3 Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
Justin Vernon
@Jvernz
Nov 11 2016 06:43 UTC
@AdoSae1 check out the Accessing Objects w/ Bracket Notation challenge.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:44 UTC
return "Not Found". <-!!!!!!!!!
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:45 UTC
now @AdoSae1 ur first if statement is supposed to return the property value yet ur returning kitten then ur supposed to create an else statement to return not found
all the others are not useful in this case
Justin Vernon
@Jvernz
Nov 11 2016 06:45 UTC
@AdoSae1 Think about the parameter you're using for your function and how you can incorporate that into returning your object property
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:45 UTC
ok i removed the kitten part
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:45 UTC
did u return the property value??
@AdoSae1 make sure u use bracket notation while returning that property
Justin Vernon
@Jvernz
Nov 11 2016 06:47 UTC
@swatbone85 Did you solve the challenge?
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:47 UTC
then after that if statement just create an else sttement to return not found
@AdoSae1 how far??
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:50 UTC
i dont know how to return the property for the first if
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:51 UTC
well the property is called checkProp right??
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:51 UTC
yep
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:51 UTC
and checkProp is located in myObject
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:51 UTC
correct
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:51 UTC
so u have to do smn like this
return myObject[checkProp];
thats using bracket notation
am sure u did it in the previous challenges
ohhh @AdoSae1 its myObj
not myObject
correct that please
but u get the logic i guess
Emerson
@DikoFaji
Nov 11 2016 06:53 UTC
RECORD COLLECTION Challenge
Justin Vernon
@Jvernz
Nov 11 2016 06:53 UTC
@DikoFaji figure it out?
Emerson
@DikoFaji
Nov 11 2016 06:53 UTC
not yet
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:53 UTC
@DikoFaji try it out
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:53 UTC
i get it once i look at it but am still frustrated at myself for not remembering something i did earlier
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:54 UTC
@AdoSae1 did u pass the challenge
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:55 UTC
yea
Emerson
@DikoFaji
Nov 11 2016 06:55 UTC
// 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) {

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

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:55 UTC
i think the most answered challenge in this chatroom is record collection
Justin Vernon
@Jvernz
Nov 11 2016 06:55 UTC
probably lol
@AdoSae1 don't be frustrated. It's a learning experience. Everytime I run into an actual challenge, I tend to have to look back at previous lessons several times
sometimes lessons from like 100 lessons ago
Emerson
@DikoFaji
Nov 11 2016 06:56 UTC

im trying to achieve this:

After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"

D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:57 UTC
@DikoFaji u've barely written any code yet
AKASH GUNJAL
@AKASH888
Nov 11 2016 06:57 UTC
how to pass these test conditions?
Joseph
@revisualize
Nov 11 2016 06:57 UTC
@DikoFaji You're missing a bunch of if statements:
https://gist.github.com/revisualize/123deb77d85079f079020ac3cd6ea5ba
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:57 UTC
@Jvernz thanks for that, i was starting to feel like I'm the only one not getting this and falling behind.
CamperBot
@camperbot
Nov 11 2016 06:57 UTC
adosae1 sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @jvernz |http://www.freecodecamp.com/jvernz
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:58 UTC
@AKASH888 u wrote many if statements and nothing like a return one!
Joseph
@revisualize
Nov 11 2016 06:58 UTC

Parameters are values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another example of this:

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

You can use the fName and uName parameters just like a variable inside of your function.

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

Justin Vernon
@Jvernz
Nov 11 2016 06:59 UTC
@AdoSae1 Man, not even close. It's taken me 2 hours or something to do Record Collection because i couldn't figure out how to do bracket notation
Emerson
@DikoFaji
Nov 11 2016 06:59 UTC

@Jvernz @Dorcy-ndg3 im trying to achieve this:

After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"

Dennis Orsini
@dlbears
Nov 11 2016 06:59 UTC
Can someone help me I cant seem to filter through this array of objects, any sort of test i use either return undefined or an empty array. this is for the twitch api project and im using this data for the api request that im filtering https://gist.github.com/QuincyLarson/2ff6892f948d0b7118a99264fd9c1ce8
Joseph
@revisualize
Nov 11 2016 06:59 UTC
@DikoFaji No.
Justin Vernon
@Jvernz
Nov 11 2016 06:59 UTC
@DikoFaji Pay attention to what @revisualize is posting, he basically giving you the answers
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:00 UTC
@DikoFaji check out what @revisualize is sending it will help
Joseph
@revisualize
Nov 11 2016 07:00 UTC
On that note though. It is 11pm in Seattle.
Adolfo Saenz
@AdoSae1
Nov 11 2016 07:00 UTC
@Jvernz one last thing how would i post a picture of my code like im seeing above instead of just copying and pasting it on here like i was doing?
Justin Vernon
@Jvernz
Nov 11 2016 07:01 UTC
@AdoSae1 type ``` then shift+enter
like this
Joseph
@revisualize
Nov 11 2016 07:01 UTC

@AdoSae1
How to do code block format:
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

Emerson
@DikoFaji
Nov 11 2016 07:01 UTC
@Dorcy-ndg3 i think i miss his post
NITIN RAGHAV
@nitinraghav
Nov 11 2016 07:01 UTC
does anybody know a good jQuery and AJAx tutorial. I am currently at random quote machine challenge.
Joseph
@revisualize
Nov 11 2016 07:02 UTC
@DikoFaji Good thing you can SCROLL up.
Adolfo Saenz
@AdoSae1
Nov 11 2016 07:03 UTC
thanks!
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:03 UTC
@nitinraghav am also at that challenge, i dont know if i have to type the quotes manually or if i need a source that keeps generating a random quote
revisualize @revisualize leaves. :v:
Joseph
@revisualize
Nov 11 2016 07:04 UTC
:zzz:
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:05 UTC
@revisualize :+1:
Norshowerr
@Mandelo
Nov 11 2016 07:06 UTC
Profile Lookup Anybody knows?
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:07 UTC
so i just got to the Basic Algorithm Scripting : Reverse a String..... and i am already stumped
Emerson
@DikoFaji
Nov 11 2016 07:07 UTC
@revisualize thanks currently reading the link now
CamperBot
@camperbot
Nov 11 2016 07:07 UTC
dikofaji sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2285 | @revisualize |http://www.freecodecamp.com/revisualize
Justin Vernon
@Jvernz
Nov 11 2016 07:08 UTC
@LGWinkelmann welcome to algorithms!
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:08 UTC
ugh :(
lol
sravanth baratam
@sravanthbaratam
Nov 11 2016 07:08 UTC

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

// Only change code below this line;
var playerNumber = "Montana" ; // Change this Line
var player =testObj[playerNumber]; // Change this Line

Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:08 UTC
need to get all the way to Repeat a string repeat a string Incomplete by the 15th
Justin Vernon
@Jvernz
Nov 11 2016 07:09 UTC
for the most part, you use things you've learned already. You may have to go back and figure it out, but you'll get it. They also provide you with helpful links
Emerson
@DikoFaji
Nov 11 2016 07:09 UTC
@revisualize ok read it, i already know the algorithm, my problem is that i dont know if im using the push function correctly
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:10 UTC
yea i guessed the reverse link that they gave me. but idk why i need split or join.
Justin Vernon
@Jvernz
Nov 11 2016 07:10 UTC
.reverse() applies to an array
not a string
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:11 UTC
yeaaa so i need to split the string into and array then reverse it then join it?
Justin Vernon
@Jvernz
Nov 11 2016 07:12 UTC
bingo
Woolwit
@Woolwit
Nov 11 2016 07:12 UTC
I'm working on No repeats please. I know my code is laborious and wonky, but whenever I run it with a test question it seems to be returning the correct answer. Yet none of the tests except 'should return a number' pass (so it's not something silly like not turning it into a string). If anyone has any ideas I'd be very grateful.
// noprotect
var permArr = [], usedChars = [];
function permAlone(input) {
permute(input); 
removeDoubles(permArr);
function permute(input) {
  var i, ch, chars = input.split("");
  for (i = 0; i < chars.length; i++) {
    ch = chars.splice(i, 1);
    usedChars.push(ch);
    if (chars.length === 0) permArr[permArr.length] = usedChars.join("");
    permute(chars.join(""));
    chars.splice(i, 0, ch);
    usedChars.pop();
  }
console.log(permArr);
return permArr;
}
function removeDoubles(permArr) {
  for (var i = permArr.length - 1; i >= 0; i--) {
  for (var j = 0; j < permArr[i].length; j++) {
    if (permArr[i][j] === permArr[i][j +1]) {
      permArr.splice(i, 1);
      if (i >= 1) {
      i = permArr.length - 1;
      j = -1;
      console.log(permArr);
        } else {
          return true;
          }
        }
      }
    }
  }
return permArr.length;
}
permAlone("aaabb");
Justin Vernon
@Jvernz
Nov 11 2016 07:13 UTC
Gonna play some Rocket League b4 I fry my brain. These algorithms are killer
Woolwit
@Woolwit
Nov 11 2016 07:18 UTC
@nitinraghav Codecademy has a JQuery track. https://www.codecademy.com/learn/jquery
Markus Kiili
@Masd925
Nov 11 2016 07:20 UTC
@Woolwit Such global variables mess up FCC tests.
Woolwit
@Woolwit
Nov 11 2016 07:20 UTC
@Dorcy-ndg3 Probably you'd have an array of quotes you've collected that get displayed randomly.
@Masd925 Thanks for the tip. I'll try putting them inside the function.
CamperBot
@camperbot
Nov 11 2016 07:21 UTC
woolwit sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2880 | @masd925 |http://www.freecodecamp.com/masd925
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:22 UTC
@Woolwit thanks for the tip, so id still have to type em quotes you mean !
CamperBot
@camperbot
Nov 11 2016 07:22 UTC
dorcy-ndg3 sends brownie points to @woolwit :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @woolwit |http://www.freecodecamp.com/woolwit
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:22 UTC
@Jvernz i know u may have left but its easier said than coded
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:22 UTC
@LGWinkelmann obviously
but if u have already split
please only join after reversing the array
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:23 UTC
trying to get it to split now
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:23 UTC
and look out for mutability issues
u cant get it to split ???
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:23 UTC
yea exactly but when i thought i had all the code it didnt work
no it wont split yet
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:24 UTC
can i look at ur code??
NITIN RAGHAV
@nitinraghav
Nov 11 2016 07:24 UTC
@Dorcy-ndg3 well i guess u can do it bot ways: u can have a n array with quotes sitting in it or u can access a web server to GET quotes for your quote machine
i am looking at the latter method to practice AJAX
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:24 UTC

function reverseString(str) {
  var array = [];

  array = str;

  str.split('');

  array.reverse('');

  array.join('');

  return str;
}

reverseString("hello");
this seemed to simple
and well
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:25 UTC
@nitinraghav wic do u think is easier and a smarter way of coding ??
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:25 UTC
yea obviously it doesnt work
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:25 UTC
@LGWinkelmann look out for mutability
u cant just change it like that
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:26 UTC
saddly i know the word but i dont understand mytability
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:26 UTC
atleast equalize it to itself or create a new variable to put ur new array
Emerson
@DikoFaji
Nov 11 2016 07:26 UTC

@revisualize here am i in the right track?
```
// 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 (prop == "track" && value !== ""){
if (collection.id.hasOwnProperty(prop)){
//push value
}else{
//push property and value
}

}else if(value === ""){
//delete property
}else{
if(collection.id.hasOwnProperty(prop)){
//replace the prop value
}else{
//push prop and value
}
}
return collection;
}

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

D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:26 UTC
Dont u think google could be of help here
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:27 UTC
yea should do that lol
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:27 UTC
@LGWinkelmann what i mean here u cant just cant decide to change a string
葛思圆
@siooooo
Nov 11 2016 07:27 UTC
blob
why it didn't work?T_T
Emerson
@DikoFaji
Nov 11 2016 07:28 UTC
RECORD COLLECTION Challege
// 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 (prop == "track" && value !== ""){
    if (collection.id.hasOwnProperty(prop)){
      //push value
    }else{
      //push property and value
    }

  }else if(value === ""){
    //delete property
  }else{
    if(collection.id.hasOwnProperty(prop)){
      //replace the prop value
    }else{
      //push prop and value
    }
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Woolwit
@Woolwit
Nov 11 2016 07:28 UTC
Wow, that was it @Masd925! @Dorcy-ndg3 Yes, you'd Google some quotes, or make them up, and type them into an array. At least, that's how I did it. The random part was which one gets pulled from the array.
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:29 UTC

instead u could create a new variable say

var things="";
things = str.split(' ');

so i have not changed it directly @LGWinkelmann

Emerson
@DikoFaji
Nov 11 2016 07:29 UTC
@Jvernz pls check, ive already done this, but i think im having trouble with the push function
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:30 UTC
@DikoFaji ur supposed to specify that
```
if(this condition is true){
return something
and @DikoFaji else can never before followed by else if, ur else statement should be the last
Markus Kiili
@Masd925
Nov 11 2016 07:33 UTC
@Dorcy-ndg3 That initialization to an empty string is just redundant. var things; would work as well.
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:34 UTC
ok
Justin Vernon
@Jvernz
Nov 11 2016 07:36 UTC
@DikoFaji your hasOwnProperty lines aren't written correctly
collection[id].hasOwnProperty(prop)
Markus Kiili
@Masd925
Nov 11 2016 07:37 UTC
@DikoFaji You need to use bracket notation when the property key is stored in a variable.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:37 UTC
@Dorcy-ndg3 i got it thanks for your help
CamperBot
@camperbot
Nov 11 2016 07:37 UTC
lgwinkelmann sends brownie points to @dorcy-ndg3 :sparkles: :thumbsup: :sparkles:
:cookie: 344 | @dorcy-ndg3 |http://www.freecodecamp.com/dorcy-ndg3
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:38 UTC
cool, u see these things are not very hard :smile:
Woolwit
@Woolwit
Nov 11 2016 07:38 UTC
While I'm in here, I want to recommend a JS resource I'd be lost without. You (drop down menu) select JS, paste in your code, and then hit Visualize Execution. You can then step through your code one step at a time and see what happens. http://pythontutor.com/visualize.html#mode=edit
Emerson
@DikoFaji
Nov 11 2016 07:38 UTC
@Jvernz yes your correct i just missed it
Justin Vernon
@Jvernz
Nov 11 2016 07:38 UTC
@Dorcy-ndg3 sweet maybe you can help me soon lol, stuck on returning largest number
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:39 UTC
yea just needed a var for each line more or less
Justin Vernon
@Jvernz
Nov 11 2016 07:39 UTC
if (collection.id.hasOwnProperty(prop)){
      //push value
    }else{
      //push property and value
    }
Here you don't need an else statement.
@DikoFaji
Joseph
@revisualize
Nov 11 2016 07:42 UTC
Dot Notation is a String Literal. Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation.
Aamnah Akram
@aamnah
Nov 11 2016 07:42 UTC
in Mutations (basic algo), this is my code, and it doesn't pass all the conditions, could anyone please point out why?
function mutation(arr) {
  var arg1 = arr[0].toLowerCase();
  var arg2 = arr[1].toLowerCase();

  if (arg1.indexOf(arg2) === -1) {
    console.log(arr + "false");
    return false;
  } else {
    console.log(arr + "true");
    return true;
  }
}
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:43 UTC
thanks @Masd925
CamperBot
@camperbot
Nov 11 2016 07:43 UTC
dorcy-ndg3 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2881 | @masd925 |http://www.freecodecamp.com/masd925
Emerson
@DikoFaji
Nov 11 2016 07:44 UTC
@Jvernz here is it! thats why i came to my first question:
if (prop == "track" && value !== ""){
    if (collection[id].hasOwnProperty(prop)){
      //push value
      collection[id][prop].push(value);
    }else{
      //push property and value
      collection[id].push(prop);
      collection[id][prop].push(value);
    }

  }
Markus Kiili
@Masd925
Nov 11 2016 07:45 UTC
@DikoFaji tracks, not track
Emerson
@DikoFaji
Nov 11 2016 07:45 UTC
oh
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:45 UTC
@aamnah dont u think u need to use indexOf and probably a loop to got through that specific word
Markus Kiili
@Masd925
Nov 11 2016 07:46 UTC
@DikoFaji When the tracks array is absent, assign [value] to the property.
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:46 UTC
@aamnah i think @Masd925 can help more
Markus Kiili
@Masd925
Nov 11 2016 07:46 UTC
@aamnah You need to loop or iterate the second string characters.
Aamnah Akram
@aamnah
Nov 11 2016 07:47 UTC
@Dorcy-ndg3 i am using indexOf() and i don't think i need a loop since the aray only has two value, i'm calling them by index..
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:47 UTC
u need a form of iteration in simple words
i dont know a method u will use
Markus Kiili
@Masd925
Nov 11 2016 07:49 UTC
@aamnah You need to check each character of the second string and check with indexOf whether it is found on the first.
Checking the whole string is not correct.
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:50 UTC
@aamnah iterate through the second word and if it is not equal to -1 then it should return true and vice versa
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:51 UTC
so i went back cause i actually skipped Record Collection challenge and i think i got it but i dont understand why collection[id][prop] is undefined
Aamnah Akram
@aamnah
Nov 11 2016 07:51 UTC
@Masd925 okay. i was reading the docs and the example was checking the whole word.. but i see that was the doc for String.indexOf and not Array.indexOf. these two are different?
i think i confused the two
thank you @Dorcy-ndg3 and @Masd925 , going back to the code now
CamperBot
@camperbot
Nov 11 2016 07:52 UTC
aamnah sends brownie points to @dorcy-ndg3 and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @dorcy-ndg3 |http://www.freecodecamp.com/dorcy-ndg3
:star2: 2882 | @masd925 |http://www.freecodecamp.com/masd925
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:53 UTC
:+1: :smile:
Emerson
@DikoFaji
Nov 11 2016 07:53 UTC
@Masd925 mark, how about this one? im having trouble to this one:
if(collection[id].hasOwnProperty(prop)){
      //replace the prop value
      collection[id][prop].pop(value);
      collection[id][prop].push(value);
    }else{
      //push prop and value
      collection[id].push(prop);
      collection[id][prop].push(value);
    }
  }
`
Justin Vernon
@Jvernz
Nov 11 2016 07:54 UTC
Enough coding for one day. I'll pick back up here tomorrow. Happy coding! :+1:
Markus Kiili
@Masd925
Nov 11 2016 07:54 UTC
@DikoFaji Post the whole function please.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:55 UTC
later @Jvernz
Emerson
@DikoFaji
Nov 11 2016 07:55 UTC
@Masd925

// 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 (prop == "tracks" && value !== ""){
    if (collection[id].hasOwnProperty(prop)){
      //push value
      collection[id][prop].push(value);
    }else{
      //push property and value
      collection[id].push(prop);
      collection[id][prop].push(value);
    }

  }else if(value === ""){
    //delete property
    delete collection[id][prop];
  }else{
    if(collection[id].hasOwnProperty(prop)){
      //replace the prop value
      collection[id][prop].pop(value);
      collection[id][prop].push(value);
    }else{
      //push prop and value
      collection[id].push(prop);
      collection[id][prop].push(value);
    }
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Markus Kiili
@Masd925
Nov 11 2016 07:55 UTC
@aamnah The string method looks for a substring and the array method for an element.
You don't need to use arrays in that challenge. You can of course use them if you wish.
Emerson
@DikoFaji
Nov 11 2016 07:59 UTC
@Masd925 i cant achieve this two:
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Aamnah Akram
@aamnah
Nov 11 2016 07:59 UTC
@Masd925 gotcha
Markus Kiili
@Masd925
Nov 11 2016 07:59 UTC
@DikoFaji If you start with the test if(value==="") you avoid repeating the test later.
No need to .pop() anything here.
Emmanuel
@chriemma
Nov 11 2016 08:05 UTC
what wrong with code var myStr = "This the first sentence. ";
myStr += "This is the second sentence.";
@kazzacarrot yes but another challenge here on this var myStr = "This the first sentence. ";
myStr += "This is the second sentence.";
Emerson
@DikoFaji
Nov 11 2016 08:10 UTC
@Masd925 if im not using pop what function shoud i use to replace the value? delete and push?
Markus Kiili
@Masd925
Nov 11 2016 08:11 UTC
@DikoFaji Why do you need to replace something?
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 08:11 UTC
@DikoFaji delete is enough
c0d0er
@c0d0er
Nov 11 2016 08:12 UTC
any idea to fix? any idea to fix: after i click any button, then it leaves the blue border and the border is not same width? http://codepen.io/c0d0er/pen/LRKVmE?editors=0010
Markus Kiili
@Masd925
Nov 11 2016 08:13 UTC
@DikoFaji If value is an empty string, you delete the property. If prop is not tracks, you assign value to the property. If prop is tracks, you check tracks property existence and either push value or assign [value].
Emerson
@DikoFaji
Nov 11 2016 08:13 UTC
@Masd925 if the artist or the album has already have a value
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 08:14 UTC
@DikoFaji return that value
Markus Kiili
@Masd925
Nov 11 2016 08:14 UTC
@DikoFaji If prop is not tracks, you just assign value to the property.
It overwrites the old value, if the property exists.
Emerson
@DikoFaji
Nov 11 2016 08:15 UTC
@Masd925 yes and push the prop if it does not exist?
Markus Kiili
@Masd925
Nov 11 2016 08:16 UTC
No, the same assignment creates the property if it doesn't exist.
If value is not "" and prop is not "tracks", just assign value to the property collection[id][prop] using the assignment operator =.
Emerson
@DikoFaji
Nov 11 2016 08:18 UTC
i seee
i think i saw the problem now
collection[id][prop] = "something";
@Masd925 is this how to fill in value?
collection[id][prop] = "something";
Markus Kiili
@Masd925
Nov 11 2016 08:20 UTC
Just use collection[id][prop]=value;
Emerson
@DikoFaji
Nov 11 2016 08:21 UTC
yes just pointing an example
ok ill try now
Nikhil Singh
@nikhilmufc7
Nov 11 2016 08:36 UTC
function myLocalScope() {
  'use strict';
  var loc = "myVar";



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

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


// Now remove the console log line to pass the test
can someone tell what I am doing wrong here, in the challenge Local scope and variables
Markus Kiili
@Masd925
Nov 11 2016 08:38 UTC
@nikhilmufc7 Variable name should be myVar, not loc.
ugncry
@EugeneCryshtal
Nov 11 2016 08:38 UTC

Greetings travellers! I'd like to be helped :(
I'm struggling with very start jQuery code
http://codepen.io/kyauhen/pen/LbGRYX?editors=0011

So in short - I want to click on RU|EN and to change actual locale + change the colors (black to gray)

Problem is - after page is loaded the function runs immediately and DON'T run after I click on RU|EN bar.

I've searched this problem but the only thing i get is to try something like:

("div").on("click", "#rulocale", function(){
});

but I don't really want to use such construction. help me please :3

Nikhil Singh
@nikhilmufc7
Nov 11 2016 08:39 UTC
got it thanks @Masd925
CamperBot
@camperbot
Nov 11 2016 08:39 UTC
nikhilmufc7 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2883 | @masd925 |http://www.freecodecamp.com/masd925
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 08:40 UTC
@EugeneCryshtal how much you going to pay me?
ugncry
@EugeneCryshtal
Nov 11 2016 08:41 UTC
@Jeff-Shapiro excuse me?
This is my first message in the FCC room, probably don't know some rules..
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 08:42 UTC
@EugeneCryshtal you need to make a function and run that function on click.
Markus Kiili
@Masd925
Nov 11 2016 08:48 UTC
@EugeneCryshtal You need to put the jquery code inside the document ready callback function.
You have some after it.
var rulocale = $('#rulocale');
var enlocale = $('#enlocale');
Temi
@temiadesina
Nov 11 2016 08:49 UTC
Hi guys so I just finished the Longest word in a string exercise, and I am just curious if using array methods over a traditional and easier for loop would have been more efficient:
function findLongestWord(str) {
  var splittedArray = [];

  splittedArray = str.split(' ');

  var maxlength = splittedArray[0].length;

  for (var i=0; i<splittedArray.length; i++){
    if(splittedArray[i].length > maxlength)  
      maxlength = splittedArray[i].length;
  }
  return maxlength;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Markus Kiili
@Masd925
Nov 11 2016 08:51 UTC
@temiadesina Using loops and basic operations is usually more efficient. Using methods usually produces more compact and elegant code but it is less efficient. It is a question of different programming paradigms too.
I real projects shorter code has value too. More code fits into one screen etc.
function findLongestWord(str) {
  return str.split(' ').reduce(function(prev, curr) {
    return Math.max(prev, curr.length);
  }, 0);
}
Temi
@temiadesina
Nov 11 2016 08:57 UTC
@Masd925 I see, I knew there was going to be a function to that but I couldn't place how reduce() was going to work, I guess a rule of thumb is if speed trade off isn't so significant then by all means write what can be understood,hmmm but as size of array increases does the for loop process it faster than the function ?
Ghulam Shabir
@ghulamshabir
Nov 11 2016 08:58 UTC
@temiadesina
function findLongestWord(str) {

  var words = str.split(" ");
  return Math.max(...words.map(function(val){
    return val.length;})

    );
}
chaoz4ngel
@chaoz4ngel
Nov 11 2016 08:58 UTC
@DikoFaji collection[id].prop
Temi
@temiadesina
Nov 11 2016 09:00 UTC
@ghulamshabir the trailing dots in front of words as in ...words do they mean anything ?
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:00 UTC
@temiadesina its spread operator
gabi
@gikwu1
Nov 11 2016 09:02 UTC
hi all
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:02 UTC
@gikwu1 hi
Temi
@temiadesina
Nov 11 2016 09:02 UTC
@ghulamshabir hmmm never heard of it what does it do ?
gabi
@gikwu1
Nov 11 2016 09:02 UTC
can some one tell me how to get over this challenge

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

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
@ghulamshabir ?
hi
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:04 UTC
@temiadesina it flattens array, you can use Math.max.apply instead of spread operator
@gikwu1 you need to create a new string from those parameters by combining them using + concatenating operator, make sure you put spaces between words
Stanley Su
@cuddlycuddles
Nov 11 2016 09:06 UTC

<style>
body {
background-color: black;
font-family: Monospace;
color: green;
}
pink-text {
color: pink;
}
</style>

<h1 class="pink-text">Hello World!</h1>

What do I do to make it pink?

ugncry
@EugeneCryshtal
Nov 11 2016 09:07 UTC
@cuddlycuddles you missed a dot before pink-text class
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:07 UTC
@cuddlycuddles you are missing dot . in front of pink-text css selector
ugncry
@EugeneCryshtal
Nov 11 2016 09:08 UTC
should be
```
.pink-text{
Stanley Su
@cuddlycuddles
Nov 11 2016 09:08 UTC
OMG thanks I completely forgot that classes needed a dot before them, tyyy
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:09 UTC
@cuddlycuddles mention @name and say thanks to send a brownie
CamperBot
@camperbot
Nov 11 2016 09:09 UTC
ghulamshabir sends brownie points to @cuddlycuddles and @name :sparkles: :thumbsup: :sparkles:
:cookie: 57 | @cuddlycuddles |http://www.freecodecamp.com/cuddlycuddles
:warning: could not find receiver for name
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:10 UTC

record-collection

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

i tried this to push "prop, value" in collection, but didn't work :/

Stanley Su
@cuddlycuddles
Nov 11 2016 09:10 UTC
@EugeneCryshtal @ghulamshabir thanks
CamperBot
@camperbot
Nov 11 2016 09:10 UTC
cuddlycuddles sends brownie points to @eugenecryshtal and @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for eugenecryshtal
:cookie: 954 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:10 UTC
@chaoz4ngel collection[id][prop].push(value)
Stanley Su
@cuddlycuddles
Nov 11 2016 09:10 UTC
@ugncry thanks
CamperBot
@camperbot
Nov 11 2016 09:10 UTC
cuddlycuddles sends brownie points to @ugncry :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ugncry
ugncry
@EugeneCryshtal
Nov 11 2016 09:10 UTC
@cuddlycuddles you are welcome. I'm here from another account, too lazy to relog lol
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:11 UTC
@cuddlycuddles :smile:
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:13 UTC
@ghulamshabir "TypeError: Cannot read property push of undefined
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:13 UTC
@chaoz4ngel its because you are not testing for non existent tracks array before pushing
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:14 UTC
@ghulamshabir and if tracks non exist in that id, how can i add that?
ugncry
@EugeneCryshtal
Nov 11 2016 09:15 UTC
@Masd925 Well I put these vars into .ready() callback, but it still doesn't work properly.
I can't get why .on() function runs right after page loaded and then it's dont run after clicks.
http://codepen.io/kyauhen/pen/LbGRYX?editors=0011
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:21 UTC
@chaoz4ngel do you know the method for testing the existence of a property in an object ?
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 09:21 UTC
@EugeneCryshtal srry i had to go out. Do you still require assisstance?
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:22 UTC
@ghulamshabir cause i have created (if hasOwnProperty is false) an array with [prop, value]...then i do
collection[id].push(collection,array)
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:22 UTC
@chaoz4ngel do not push collection into object
@chaoz4ngel assign an empty array to collection[id][prop] then push
kyauhen
@kyauhen
Nov 11 2016 09:23 UTC
@Jeff-Shapiro yeah. As you see I have the function localeChange() and .on('click', localeChange())
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:23 UTC
@ghulamshabir
  if(prop ==="tracks" && collection[id].hasOwnProperty(prop)===false){
    var array = [prop, value];
    collection[id].push(array);
kyauhen
@kyauhen
Nov 11 2016 09:23 UTC
logged on FCC account
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 09:23 UTC
@kyauhen huh?
kyauhen
@kyauhen
Nov 11 2016 09:24 UTC
@Jeff-Shapiro I'm EugeneCryshtal o:
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 09:24 UTC
ohh ok would you like to go to a google hangout?
then we can share screens :)
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:24 UTC
@chaoz4ngel var array = [value]
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:25 UTC
@ghulamshabir but if the property isn't in the data (example: no tracks in id 5439.
i don't need to add prop too?
kyauhen
@kyauhen
Nov 11 2016 09:26 UTC
@Jeff-Shapiro ohh that's would be great, but atm I'm on the main job :D
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:26 UTC
@chaoz4ngel you have to add prop because it will create new tracks property in that objecrt
kyauhen
@kyauhen
Nov 11 2016 09:26 UTC
so i cant screen share lol
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:26 UTC
@chaoz4ngel collection[id][prop].push(array)
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:29 UTC
@ghulamshabir same
Ghulam Shabir
@ghulamshabir
Nov 11 2016 09:29 UTC
@chaoz4ngel you don't need to push prop into array its not creating a new property
@chaoz4ngel post code starting from updateRecords
chaoz4ngel
@chaoz4ngel
Nov 11 2016 09:31 UTC
function updateRecords(id, prop, value) {
  // Se non ha la proprietà "prop"
  if(prop ==="tracks" && collection[id].hasOwnProperty(prop)===false){
   var array = [value];
  collection[id][prop].push(array);
  }
    return collection;
}