These are chat archives for FreeCodeCamp/HelpJavaScript

11th
Nov 2016
Walid Ashri
@walidashri
Nov 11 2016 00:00
:O
how to make unfriend here @sjames1958gm :broken_heart:
Stephen James
@sjames1958gm
Nov 11 2016 00:03
@walidashri Please accept my apology
:worried:
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:06
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
Can someone please help with Chunky Monkey
not sure where to start
Stephen James
@sjames1958gm
Nov 11 2016 00:08
@djangoearnhardt The variable has to contain a string
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:09
do I need to use something to turn it into a string? @sjames1958gm
Lucas Tormin
@tormink
Nov 11 2016 00:11
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
@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
@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
@tormink I don't believe concat modifies the array you have to save the returned value
veeteeran
@veeteeran
Nov 11 2016 00:16
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
You can use a var in your string @djangoearnhardt instead of hardcoding in the zip code
Lucas Tormin
@tormink
Nov 11 2016 00:16
@sjames1958gm ohh...I believe that's it, I'll try it out then...thanks
Gabriel
@xGabey
Nov 11 2016 00:17
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
@tormink :+1:
Ryan Talbot
@rgtalbot
Nov 11 2016 00:17
Can you be more specific @xGabey?
Lucas Tormin
@tormink
Nov 11 2016 00:17
@sjames1958gm yeeeeeah you deserve all the cookie points man thank you
CamperBot
@camperbot
Nov 11 2016 00:17
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
oh..brownie points I guess
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:18
could you explain that a little more @rgtalbot
veeteeran
@veeteeran
Nov 11 2016 00:18
blob
Gabriel
@xGabey
Nov 11 2016 00:19
@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
@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
$.getJSON('http://api.openweathermap.org/data/2.5/weather?zip=' + zipCode + ',us&appid=43570f3ce225106d3f5ffafe9e44cc60' ...
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:20
ok, i’ll give it a try, thanks @rgtalbot
CamperBot
@camperbot
Nov 11 2016 00:20
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
Does anyone get the Seek and Destroy?
Jan
@burning-monk
Nov 11 2016 00:21
yes sir
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:21
How?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:21
That is a little vague @valdor14 is there something specific you are getting caught on?
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:21
The function destroyer takes 1 argument and they assign it more than 1
Jan
@burning-monk
Nov 11 2016 00:21
@valdor14 did you read the article about arguments?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:22
you have to learn how to manipulate arguments @valdor14
Vlad-Alexandru Cristian
@valdor14
Nov 11 2016 00:22
Where can I read it?
Walid Ashri
@walidashri
Nov 11 2016 00:22
@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
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
Thank you so much
Jan
@burning-monk
Nov 11 2016 00:23
I solved with indexOf instead of filter()
and Array.from()
Ryan Talbot
@rgtalbot
Nov 11 2016 00:25
looks like you took the two examples I gave you and used half of each @awb715
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:25
@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
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
Thank you @walidashri
CamperBot
@camperbot
Nov 11 2016 00:26
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
@rgtalbot ugh
djangoearnhardt
@djangoearnhardt
Nov 11 2016 00:28
@rgtalbot what behavior would I want var y to follow?
Ryan Talbot
@rgtalbot
Nov 11 2016 00:28
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
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
<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
ok i’ll give it some time, thanks @rgtalbot
CamperBot
@camperbot
Nov 11 2016 00:31
djangoearnhardt sends brownie points to @rgtalbot :sparkles: :thumbsup: :sparkles:
:warning: djangoearnhardt already gave rgtalbot points
Aaron Bell
@awb715
Nov 11 2016 00:34
@rgtalbot not working
Ryan Talbot
@rgtalbot
Nov 11 2016 00:35
worked fine on my end @awb715. did you change it by looking or copy and paste?
jump020305
@jump020305
Nov 11 2016 00:41
  • 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
@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
@awb715 @Chrono79 can you guys help me
Ken Haduch
@khaduch
Nov 11 2016 00:47
@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
@khaduch thanks for your reply...I tried but its not working :(
CamperBot
@camperbot
Nov 11 2016 00:48
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
@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
Hello.
Ken Haduch
@khaduch
Nov 11 2016 00:50
@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
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
@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
What is your issue @tragetraje ?
Justin Vernon
@Jvernz
Nov 11 2016 00:54
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
move no such contact outside the loop
Ken Haduch
@khaduch
Nov 11 2016 00:54
@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
great explanation @rgtalbot !
jump020305
@jump020305
Nov 11 2016 00:55
@khaduch i need to replace p tags when i switch tabs....any idea
Ryan Talbot
@rgtalbot
Nov 11 2016 00:55
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
@jump020305 - I'm not React savvy at all... sorry!
Justin Vernon
@Jvernz
Nov 11 2016 00:57
@rgtalbot @khaduch Thanks for the help. Still getting the same issue though.
CamperBot
@camperbot
Nov 11 2016 00:57
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
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
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
@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
@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
@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
@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
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
@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
jvernz sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: jvernz already gave khaduch points
Ken Haduch
@khaduch
Nov 11 2016 01:06
@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
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
: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
He needs to call the function somewhere
Zina Astafyeva
@tragetraje
Nov 11 2016 01:07
Screen Shot 2016-11-11 at 12.04.24 PM.png
Ryan Talbot
@rgtalbot
Nov 11 2016 01:07
I don’t think I understand your issue then @tragetraje
Zina Astafyeva
@tragetraje
Nov 11 2016 01:08
hm, ok :( @rgtalbot
Emilie
@Snipercatz
Nov 11 2016 01:08
@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
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
@rgtalbot can you help me
Ryan Talbot
@rgtalbot
Nov 11 2016 01:09
I’m working on it @jump020305
jump020305
@jump020305
Nov 11 2016 01:09
@rgtalbot thanks
CamperBot
@camperbot
Nov 11 2016 01:09
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
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
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
nevermind, i see what i did wrong
Ryan Talbot
@rgtalbot
Nov 11 2016 01:11
Its what you were returning @Jvernz
Walid Ashri
@walidashri
Nov 11 2016 01:11
@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
@rgtalbot Correct. Finally noticed it. Misread the instructions. Finally completed the challenge. Thanks to everyone who helped!
CamperBot
@camperbot
Nov 11 2016 01:11
jvernz sends brownie points to @rgtalbot :sparkles: :thumbsup: :sparkles:
:warning: jvernz already gave rgtalbot points
Ryan Talbot
@rgtalbot
Nov 11 2016 01:12
what are you trying to accomplish @jump020305? you aren’t calling your newContentAdded function anywhere
Christian
@xChristianZx
Nov 11 2016 01:16
Hello all. Can anyone offer some help on the "Stand in Line"?
Ken Haduch
@khaduch
Nov 11 2016 01:17
@cazenaty - yes - what's your code at this point? Or your questions?
Christian
@xChristianZx
Nov 11 2016 01:18

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
why are you using unshift instead of shift @cazenaty?
Ken Haduch
@khaduch
Nov 11 2016 01:19
@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
@rgtalbot , i thought unshift would remove the first element out of the array, no?
Ken Haduch
@khaduch
Nov 11 2016 01:20
@cazenaty - look up Array.shift() vs. Array.unshift()...
Conor Murphy
@cmurphy580
Nov 11 2016 01:20
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
@khaduch , ok, will do. thank you
CamperBot
@camperbot
Nov 11 2016 01:21
cazenaty sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1913 | @khaduch |http://www.freecodecamp.com/khaduch
skratchbreaker
@skratchbreaker
Nov 11 2016 01:23
Anybody did the counting card problem?
Ken Haduch
@khaduch
Nov 11 2016 01:27
@skratchbreaker - ask questions, post code, you'll get some help here...
sally
@susally
Nov 11 2016 01:29

// 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
@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
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
@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
@khaduch , how can I post code like @Jvernz up above?
Ken Haduch
@khaduch
Nov 11 2016 01:33
@cazenaty - read the next link
'''
CamperBot
@camperbot
Nov 11 2016 01:33
:bulb: to format code use backticks! ``` more info
sally
@susally
Nov 11 2016 01:33
that is right thank you
Christian
@xChristianZx
Nov 11 2016 01:34
excellent, thank you again
Daniel Melchior
@danny-boy
Nov 11 2016 01:38
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
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
Would anyone mind checking my work?
Christian
@xChristianZx
Nov 11 2016 01:41
@danny-boy , post your code, i just finished that one with @khaduch 's help.
Daniel Melchior
@danny-boy
Nov 11 2016 01:42

```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
so, you have the right idea with arr1.push(item)
Daniel Melchior
@danny-boy
Nov 11 2016 01:45
yeah the code seems to work
Christian
@xChristianZx
Nov 11 2016 01:45
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
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
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
that is what I ended up with which worked out
Aaron Bell
@awb715
Nov 11 2016 01:47
check out the cool jquery
Christian
@xChristianZx
Nov 11 2016 01:48
np @danny-boy
Daniel Melchior
@danny-boy
Nov 11 2016 01:48
very simple solution christian, nice job
looks like the real thing aaron :+1:
Aaron Bell
@awb715
Nov 11 2016 01:49
i have an issue tho but trying to figure it out
Christian
@xChristianZx
Nov 11 2016 01:50
thank you Dan
yeah, that looks great @awb715
Aaron Bell
@awb715
Nov 11 2016 01:50
dont give it away for me
but the toggle continously happens
Justin Vernon
@Jvernz
Nov 11 2016 01:54
```

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
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
@somiajagadish what code do you have so far?
Stephen James
@sjames1958gm
Nov 11 2016 01:56
@somiajagadish There are 4 keywords that need to be replaced
@Jvernz array.join returns a new string
Somia ♡
@somiajagadish
Nov 11 2016 01:57
@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
ah, gotcha
Somia ♡
@somiajagadish
Nov 11 2016 01:57
@sjames1958gm Haha you helped me yesterday
Justin Vernon
@Jvernz
Nov 11 2016 01:57
@sjames1958gm I want it to return a new string, but its returning as an array
Somia ♡
@somiajagadish
Nov 11 2016 01:58
@cazenaty yeah :smile:
Stephen James
@sjames1958gm
Nov 11 2016 01:58
@somiajagadish Just insert the two characters in place of the keywords
Justin Vernon
@Jvernz
Nov 11 2016 01:58
is it because i defined array as an array? maybe i need a string variable
Somia ♡
@somiajagadish
Nov 11 2016 01:58
@sjames1958gm What keywords?
Christian
@xChristianZx
Nov 11 2016 01:58
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
@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
Hold on. I will show you what I think
Stephen James
@sjames1958gm
Nov 11 2016 01:59
newline backslash backslash carriage-return
Somia ♡
@somiajagadish
Nov 11 2016 01:59
Is right
Justin Vernon
@Jvernz
Nov 11 2016 01:59
@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
@somiajagadish you've got the right idea, now just need to substitute those with code so....
Stephen James
@sjames1958gm
Nov 11 2016 02:00
@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
newline = \n
Gabi
@JJcreated
Nov 11 2016 02:01
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
@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
@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
whats wrong with that code please?
Justin Vernon
@Jvernz
Nov 11 2016 02:01
@sjames1958gm I see. Thanks very much for the help!
CamperBot
@camperbot
Nov 11 2016 02:01
:star2: 4305 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Somia ♡
@somiajagadish
Nov 11 2016 02:01
@cazenaty But Do i put the slashes in the quotes?
CamperBot
@camperbot
Nov 11 2016 02:02
jvernz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Nov 11 2016 02:02
@Jvernz :+1:
Somia ♡
@somiajagadish
Nov 11 2016 02:02
:sparkles: :cactus:
Christian
@xChristianZx
Nov 11 2016 02:02
@somiajagadish no quotes for the slashes
so the "Firstline" should look like this - FirstLine\n
Somia ♡
@somiajagadish
Nov 11 2016 02:04
Okay so like this?
var myStr = "FirstLine"/n"SecondLine"/r"ThirdLine";
Christian
@xChristianZx
Nov 11 2016 02:04
you're getting there
Somia ♡
@somiajagadish
Nov 11 2016 02:04
?
Christian
@xChristianZx
Nov 11 2016 02:04
no "" requred
Somia ♡
@somiajagadish
Nov 11 2016 02:05
"FirstLine/nSeondLine/rThirdLine"
Like this?
Christian
@xChristianZx
Nov 11 2016 02:05
also use \
not /
Somia ♡
@somiajagadish
Nov 11 2016 02:05
Okay hold on i'll be back
var myStr = "FirstLine\nSecondline\rThirdLine"; // Change this line
like this?
Christian
@xChristianZx
Nov 11 2016 02:08
yes
Somia ♡
@somiajagadish
Nov 11 2016 02:08
It said it's wrong..
Christian
@xChristianZx
Nov 11 2016 02:08
so now you just need the Backslashes to show up around "SecondLine"
Gabi
@JJcreated
Nov 11 2016 02:09
guys?
Somia ♡
@somiajagadish
Nov 11 2016 02:09
what do you mean?
Johnny
@JohnnyBizzel
Nov 11 2016 02:09
@somiajagadish Did you read the instructions?
Somia ♡
@somiajagadish
Nov 11 2016 02:10
yes
Christian
@xChristianZx
Nov 11 2016 02:10
@JJcreated you're way ahead of me, sorry, wish I could help
Juliana G P S Ferreira
@julianaferry
Nov 11 2016 02:11
Hello! just joined in..
Johnny
@JohnnyBizzel
Nov 11 2016 02:11
@JJcreated You do a return inside a for loop
Walid Ashri
@walidashri
Nov 11 2016 02:13
@JJcreated [3,10,5].sort() returns // [10,3,5]
Ike Orji
@ikeuzo57
Nov 11 2016 02:13
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
@walidashri @JohnnyBizzel the .sort link said it'd sort itself in order with the command
Johnny
@JohnnyBizzel
Nov 11 2016 02:14
@ikeuzo57 is there an .endsWith() function in JS?
Ike Orji
@ikeuzo57
Nov 11 2016 02:14
@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
@JohnnyBizzel not allowed in this excercise
Justin Vernon
@Jvernz
Nov 11 2016 02:16

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
@ikeuzo57 Maybe use indexOf() to find where to do the split() ?
NULL made me stuck
Johnny
@JohnnyBizzel
Nov 11 2016 02:16
@Jvernz You are not creating an array of numbers
Marc M
@Marc-Moeller
Nov 11 2016 02:17

// 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
@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
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
yes
Marc M
@Marc-Moeller
Nov 11 2016 02:17
-> playerNumber should be a number
-> You should be using the variable playerNumber in your bracket notation
Johnny
@JohnnyBizzel
Nov 11 2016 02:18
@flyyyperth var player = testObj[changeME];
Walid Ashri
@walidashri
Nov 11 2016 02:18
@flyyyperth playerNumber = a number
Conor Murphy
@cmurphy580
Nov 11 2016 02:18
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
@Shiv-Shakti I can't really follow it. Can you explain it?
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 02:19
@cmurphy580 check the value of input asfter keystroke
Aaron Bell
@awb715
Nov 11 2016 02:20
@cmurphy580 working on the exact same thing
chunnali
@chunnali
Nov 11 2016 02:21
can anyone click on my codepen and let me know if it display the correct location?
Aaron Bell
@awb715
Nov 11 2016 02:21
you mean search box @cmurphy580
Johnny
@JohnnyBizzel
Nov 11 2016 02:21
@chunnali Correct :+1: for me (Leeds)
chunnali
@chunnali
Nov 11 2016 02:21
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
@chunnali wrong location ha
chunnali
@chunnali
Nov 11 2016 02:22
@JohnnyBizzel @Jeff-Shapiro thank you!! can’t figure out what’s wrong
CamperBot
@camperbot
Nov 11 2016 02:22
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
@Jeff-Shapiro check it out @awb715 yeah let me know if you figure anything out
CamperBot
@camperbot
Nov 11 2016 02:22
:cookie: 787 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
look at mine
its almost working properly
Johnny
@JohnnyBizzel
Nov 11 2016 02:23
@chunnali Maybe the IP address lookup is not working for her
Marc M
@Marc-Moeller
Nov 11 2016 02:23
@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
@flyyyperth What's the challenge called?
Walid Ashri
@walidashri
Nov 11 2016 02:23
@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
@walidashri @JohnnyBizzel even if I’m using latitude and longitude api to locate them?
Johnny
@JohnnyBizzel
Nov 11 2016 02:24
@chunnali Don't know. Try a different API
Walid Ashri
@walidashri
Nov 11 2016 02:25
@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
@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
@walidashri alright, will try that instead then
Walid Ashri
@walidashri
Nov 11 2016 02:26
@chunnali what for the CORS :D
Joseph
@revisualize
Nov 11 2016 02:26
Hello.
Walid Ashri
@walidashri
Nov 11 2016 02:27
@revisualize Hi
Marc M
@Marc-Moeller
Nov 11 2016 02:27
@JohnnyBizzel thanks mate :) <3
CamperBot
@camperbot
Nov 11 2016 02:27
flyyyperth sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 788 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 11 2016 02:27
@flyyyperth ;) :+1:
Gabi
@JJcreated
Nov 11 2016 02:27
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

@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
@awb715 Dang! thats really good! I like the shift up of the content
Joseph
@revisualize
Nov 11 2016 02:29
@JJcreated What are you working on?
Gabi
@JJcreated
Nov 11 2016 02:30
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
@JJcreated That tells me very little.
What are you working on?
Johnny
@JohnnyBizzel
Nov 11 2016 02:31
@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
@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
@JohnnyBizzel I'd be able to talk on that if I know what they were working on.
Gabi
@JJcreated
Nov 11 2016 02:32
@revisualize im working on the where do i belong challenge
Mitch
@MitchWilkins
Nov 11 2016 02:32

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
@JJcreated There we go.
Mitch
@MitchWilkins
Nov 11 2016 02:32
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
@JJcreated Store it in a variable - don't return
Joseph
@revisualize
Nov 11 2016 02:34
I just returned it.
Justin Vernon
@Jvernz
Nov 11 2016 02:34

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
@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
@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
Should i just make an if(num===0) statement?
Mitch
@MitchWilkins
Nov 11 2016 02:37
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
@revisualize Makes sense :+1:
Joseph
@revisualize
Nov 11 2016 02:37
@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
@revisualize Also makes sense :smile:
Justin Vernon
@Jvernz
Nov 11 2016 02:38
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
@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
@Jvernz What is wrong with the code?
Patrick Lippert
@mayhawstudios
Nov 11 2016 02:40

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
@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
@Jvernz Just add if num === 0 return 1; somewhere near the top
Justin Vernon
@Jvernz
Nov 11 2016 02:41
@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
@Jvernz Works for me
Gabi
@JJcreated
Nov 11 2016 02:42
@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
@JohnnyBizzel Thanks!
CamperBot
@camperbot
Nov 11 2016 02:42
jvernz sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 789 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 11 2016 02:42
@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
wow look atthis!
so proud of myself for making this functionality
Johnny
@JohnnyBizzel
Nov 11 2016 02:47
@awb715 Well done mate ;)
Walid Ashri
@walidashri
Nov 11 2016 02:50
@awb715 well done but make the link open in new tab better :)
Aaron Bell
@awb715
Nov 11 2016 02:51
what do you mean
Gabi
@JJcreated
Nov 11 2016 02:54
still not working, ill try again tomorrow
thanks anyways guys
Zaurbek Zhakupov
@zzhakupov
Nov 11 2016 02:56
Guys can I have some feedback on my Wiki viewer? https://codepen.io/Zooll/pen/ObMRbM
Johnny
@JohnnyBizzel
Nov 11 2016 02:58
@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
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
@JohnnyBizzel THx! I missed that fact
CamperBot
@camperbot
Nov 11 2016 02:59
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
@jasonfirestein a=b or if a is not created yet: var a =b
Joseph
@revisualize
Nov 11 2016 03:15
Hey hey.
Patrick Lippert
@mayhawstudios
Nov 11 2016 03:21
@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
@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
I am pretty lost with this stand in line challenge
João Mhurilo Godoi da Silva
@ebak123
Nov 11 2016 03:30

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
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
@ebak123 if c>-1 return true
Walid Ashri
@walidashri
Nov 11 2016 03:46
@MitchWilkins myFunction should return true or false to get the right filtering
Jenky W. Nolasco
@jenkynolasco11
Nov 11 2016 03:53
Hola mundo o/
Adolfo Saenz
@AdoSae1
Nov 11 2016 03:53
@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
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
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
not really sure how to solve it
Walid Ashri
@walidashri
Nov 11 2016 04:00
@AdoSae1 now set result to get the value of the property val of the object
Emerson
@DikoFaji
Nov 11 2016 04:02
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
@walidashri yea im not getting that part
Emerson
@DikoFaji
Nov 11 2016 04:03

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
@walidashri
result=lookup[""];
Walid Ashri
@walidashri
Nov 11 2016 04:10
@AdoSae1 so close lookup[somthinghere]
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:11
do i keep result=
Walid Ashri
@walidashri
Nov 11 2016 04:11
@AdoSae1 yes
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:11
ok let me try some things
Walid Ashri
@walidashri
Nov 11 2016 04:11
@DikoFaji no
collection[id].hasOwnProperty(prop)
Abhaya Basnet
@abhayaa
Nov 11 2016 04:12
hi, i have a question unrelated to fcc challenges
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:20
@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
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
@AdoSae1 :+1:
Adolfo Saenz
@AdoSae1
Nov 11 2016 04:20
:+1:
João Mhurilo Godoi da Silva
@ebak123
Nov 11 2016 04:22
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
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
always auto save here :worried:
Walid Ashri
@walidashri
Nov 11 2016 04:25
@Jvernz try open the old one in new tab
Justin Vernon
@Jvernz
Nov 11 2016 04:25
Could it be if I work on a different computer?
Jeff Shapiro
@Jeff-Shapiro
Nov 11 2016 04:30
@Jvernz try clicking on your picture instead of map
Justin Vernon
@Jvernz
Nov 11 2016 04:31
@Jeff-Shapiro You're my hero thanks
CamperBot
@camperbot
Nov 11 2016 04:31
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
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
@walidashri thank you!
CamperBot
@camperbot
Nov 11 2016 04:35
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
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
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
Does anyone know a way to tell if the caesar cipher is encrypted or decrypted?
Justin Vernon
@Jvernz
Nov 11 2016 04:52
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

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
@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
@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
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

Could someone tell me how to return undefined when using

return

in a function?

Justin Vernon
@Jvernz
Nov 11 2016 04:58
@LGWinkelmann Actually, I think you need to create a parameter inside your setGear function.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 04:58
  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
I've got mine answered, but I can't figure out why.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:01
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
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
cause u call a function of num and it works when i look at it
Justin Vernon
@Jvernz
Nov 11 2016 05:02
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
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
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
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
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
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
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
@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
besides you and me i think only 2 other people are active in this chat.
Justin Vernon
@Jvernz
Nov 11 2016 05:11
Seems so now, but I was getting help left and right earlier in the day.
NoobsNoob
@NoobsNoob
Nov 11 2016 05:11
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
guess people have off tomorrow and they are all out having a party now lol
Justin Vernon
@Jvernz
Nov 11 2016 05:18

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
@Jvernz what did you need to replace?
the underscore?
Justin Vernon
@Jvernz
Nov 11 2016 05:23
@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
space ok or not ok?
Justin Vernon
@Jvernz
Nov 11 2016 05:23
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
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
You can go to your profile and "view solution"
awesome source, thanks @NoobsNoob
CamperBot
@camperbot
Nov 11 2016 05:25
jvernz sends brownie points to @noobsnoob :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for noobsnoob
NoobsNoob
@NoobsNoob
Nov 11 2016 05:27
@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
@NoobsNoob Awesome! Check for Palindromes was the name
NoobsNoob
@NoobsNoob
Nov 11 2016 05:28
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
Do I need to find those symbols?
pycraft
@pycraft
Nov 11 2016 05:32
excuse me guys can somebody help me with javascript?
anybody? ;(
hello~~
Justin Vernon
@Jvernz
Nov 11 2016 05:34
@pycraft Hey what'sup? I'm no expert but if I can help I will
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 05:35
need to put up your code
DC
@vuvu10
Nov 11 2016 05:35

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
@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
oops sorry for the long links
but im kinda stuck at here
Justin Vernon
@Jvernz
Nov 11 2016 05:36
@pycraft paste you're code by typing ``` shift+enter
like this
NoobsNoob
@NoobsNoob
Nov 11 2016 05:37
@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
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

// 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
@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
@NoobsNoob \d is supposed to be "matches a digit (equal to [0-9])"
NoobsNoob
@NoobsNoob
Nov 11 2016 05:40
[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
@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
@NoobsNoob icant go to next level :(
NoobsNoob
@NoobsNoob
Nov 11 2016 05:41
what is your output
pycraft
@pycraft
Nov 11 2016 05:42
@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
@pycraft your operators are incorrect in your else if statements. = is assignment, === is comparison
NoobsNoob
@NoobsNoob
Nov 11 2016 05:43
@Jvernz How did you go now?
Justin Vernon
@Jvernz
Nov 11 2016 05:44
@NoobsNoob still in the same spot
NoobsNoob
@NoobsNoob
Nov 11 2016 05:44
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
I'm going to try to rearrange my code and see if it changes anything
Ken Haduch
@khaduch
Nov 11 2016 05:44
@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
can you paste it here again and I'll check it
Justin Vernon
@Jvernz
Nov 11 2016 05:45

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
@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
@revisualize I don't know what that means :/
NoobsNoob
@NoobsNoob
Nov 11 2016 05:46
ooooh ok biggest difference I see is the same mistake I tore my hurt out over
Justin Vernon
@Jvernz
Nov 11 2016 05:47
wait do i need to run my regex on the str?
NoobsNoob
@NoobsNoob
Nov 11 2016 05:47
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
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

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
@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
@NoobsNoob @revisualize Nice! that solved a lot of my issues but not all of them. Thanks
CamperBot
@camperbot
Nov 11 2016 05:48
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
@Jvernz Yes.
Walid Ashri
@walidashri
Nov 11 2016 05:48
@Tyriffik did u add the class to the img?
Ken Haduch
@khaduch
Nov 11 2016 05:48

@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
@Jvernz try putting your replace directly after your lowercase
Tyrell
@Tyriffik
Nov 11 2016 05:49
@walidashri ohhh i don't think so, I'm goign to try again, thanks!
CamperBot
@camperbot
Nov 11 2016 05:49
tyriffik sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 615 | @walidashri |http://www.freecodecamp.com/walidashri
Tom
@moT01
Nov 11 2016 05:49
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
@NoobsNoob my last issue is that any input with punctuation in it is returning as false
Emerson
@DikoFaji
Nov 11 2016 05:50

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
@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
I take that back, it could be capitalization. @NoobsNoob
NoobsNoob
@NoobsNoob
Nov 11 2016 05:51
make sure tolowercase is on both sides of the if
Justin Vernon
@Jvernz
Nov 11 2016 05:51
@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
@Jvernz All's well that ends well. Onto the next challenge :)
Tyrell
@Tyriffik
Nov 11 2016 05:52
@walidashri Thank you So Much @walidashri !! I'm so bad at this! It worked.
CamperBot
@camperbot
Nov 11 2016 05:52
tyriffik sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:warning: tyriffik already gave walidashri points
Emerson
@DikoFaji
Nov 11 2016 05:55
@revisualize can u help me Joseph?
Adolfo Saenz
@AdoSae1
Nov 11 2016 05:57
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
That feel when you knock out an algorithm in 10 minutes
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:12
@Jvernz can you help with my problem?
Dany
@Danylrs
Nov 11 2016 06:13
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

welcome to FreeCodeCamp @Danylrs!

Donatas
@Donaatas
Nov 11 2016 06:13
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
Hello I need help on these:
Donatas
@Donaatas
Nov 11 2016 06:14
@Danylrs post your code and say what you need :)
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:14

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
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
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

`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
@AdoSae1 What's your problem?
Donatas
@Donaatas
Nov 11 2016 06:16
@dgana remind the problem?
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:16
how lol im still newb
Philipp Scholz
@philipp32
Nov 11 2016 06:17

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
@Danylrs Link your code. What's your issue?
Ida Bagus Chahya Dhegana
@dgana
Nov 11 2016 06:17
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
@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
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
@Jvernz already changed that. :)
Donatas
@Donaatas
Nov 11 2016 06:19
@philipp32 use recursion.
if (num == 1) {
return 1;
}
else {
return num * factorialize(num - 1);
}
Emerson
@DikoFaji
Nov 11 2016 06:20
this basic JS RECORD COLLECTION challenge is a pain! need to take a break
Justin Vernon
@Jvernz
Nov 11 2016 06:20
@Danylrs Don't feel bad, this challenge got me pretty good too
Philipp Scholz
@philipp32
Nov 11 2016 06:20
@Donaatas that doesn't work at all. :/ I'm sorry.
Donatas
@Donaatas
Nov 11 2016 06:21
wait
Dany
@Danylrs
Nov 11 2016 06:21
lol @Jvernz its frustrating
Justin Vernon
@Jvernz
Nov 11 2016 06:21
@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

@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
@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
I hear ya! No worries take your time. I agree with you 100%.
Philipp Scholz
@philipp32
Nov 11 2016 06:22
@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
philipp32 sends brownie points to @donaatas :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @donaatas |http://www.freecodecamp.com/donaatas
Donatas
@Donaatas
Nov 11 2016 06:23
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
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
@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

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
no wiki entry for: guys am i doing this push function rightcollectionidpushprop collectionidproppushvalue
Justin Vernon
@Jvernz
Nov 11 2016 06:24
@DikoFaji I will check in a second
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:25
what is the short hand for spaces i thought it was /S
Justin Vernon
@Jvernz
Nov 11 2016 06:25
@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
@Jvernz yes pls.. RECORD COLLECTION challenge is giving me a headache now :(
Justin Vernon
@Jvernz
Nov 11 2016 06:25
@DikoFaji I was there earlier today lol
Thomas Swatland
@swatbone85
Nov 11 2016 06:25
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
@Jvernz really thats nice! :D
Justin Vernon
@Jvernz
Nov 11 2016 06:26
@swatbone85 I will check yours in a second too, just finished it. remind me if I forget
Dany
@Danylrs
Nov 11 2016 06:26
ok let me try this out @Jvernz brb
Thomas Swatland
@swatbone85
Nov 11 2016 06:26
@Jvernz Awesome, thanks mate :)
CamperBot
@camperbot
Nov 11 2016 06:26
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
@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
@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
here is my code:
Emerson
@DikoFaji
Nov 11 2016 06:26
@Jvernz its my 8th straight days now :D
Philipp Scholz
@philipp32
Nov 11 2016 06:27
@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

@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
@Donaatas That works now. :)
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:27
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
@AdoSae1 they told u to return that property
Justin Vernon
@Jvernz
Nov 11 2016 06:27
@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
```js
hello
Justin Vernon
@Jvernz
Nov 11 2016 06:28
@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
@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
@DikoFaji where are u trying to push ur values ??
Justin Vernon
@Jvernz
Nov 11 2016 06:29
@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
about @Dorcy-ndg3
CamperBot
@camperbot
Nov 11 2016 06:30
:cookie: 343 | @dorcy-ndg3 |http://www.freecodecamp.com/dorcy-ndg3
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:31
@Dorcy-ndg3 ok but when i return a value for one i cant do the other
Justin Vernon
@Jvernz
Nov 11 2016 06:31
@AdoSae1 what challenge is this?
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:31
..
"testing objects for properties"
Thomas Swatland
@swatbone85
Nov 11 2016 06:31
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
been stuck for like 45 min -___-
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:31
// 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

@Jvernz im trying to achieve this one:

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

Thomas Swatland
@swatbone85
Nov 11 2016 06:32
var strArr = str.match(/\w/g)
this is what I have been trying
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:32
i think is what @DikoFaji code looks like
Justin Vernon
@Jvernz
Nov 11 2016 06:32
@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
yeah we r doing the same
i dont know if that push is correct
Justin Vernon
@Jvernz
Nov 11 2016 06:33
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
@Jvernz I see! I will give it a go, what do the square brackets do?
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:33
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
@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
what in the hell am i doing wrong ???
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:34
whats the nmae of ur challenge ??
Justin Vernon
@Jvernz
Nov 11 2016 06:34
@swatbone85 no idea!
Ryan Copeland
@ryan6627
Nov 11 2016 06:34
return early pattern for functions
Justin Vernon
@Jvernz
Nov 11 2016 06:34
I think it's just part of the regexp for the digits/letters
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:34
@Dorcy-ndg3 let me try brb
Thomas Swatland
@swatbone85
Nov 11 2016 06:34
@Jvernz Lol, thank you so much for your help :)
CamperBot
@camperbot
Nov 11 2016 06:34
swatbone85 sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:warning: swatbone85 already gave jvernz points
Justin Vernon
@Jvernz
Nov 11 2016 06:35
@swatbone85 good luck!
Emerson
@DikoFaji
Nov 11 2016 06:35
@LGWinkelmann we r having the same problem, have u figure it out?
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:36
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
@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
@Jvernz @Dorcy-ndg3
Ryan Copeland
@ryan6627
Nov 11 2016 06:36
built.
in.
answers.
2 hours
Justin Vernon
@Jvernz
Nov 11 2016 06:37
@AdoSae1 your code is way too in depth
Ryan Copeland
@ryan6627
Nov 11 2016 06:37
on one problem
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:37
@Jvernz i think so too
Justin Vernon
@Jvernz
Nov 11 2016 06:37
@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
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
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
@Danylrs Awesome!!
@Danylrs good job, keep it up man!
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:38
@ryan6627 u dint put a return statement
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:38
@AdoSae1 where it says ```js
return "Chang me"
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:38
ur supposed to return undefined
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:38
they literally want u to change it
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:39
@ryan6627 also ur if should look like this
if(a<0 || b < 0)
Justin Vernon
@Jvernz
Nov 11 2016 06:39
@AdoSae1 You're actually really close
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:39
@Jvernz thats the worst part :worried: lol
Justin Vernon
@Jvernz
Nov 11 2016 06:40
@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
ok
Justin Vernon
@Jvernz
Nov 11 2016 06:40
your else statement is correct as well
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:40
@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
that doesn't work
Justin Vernon
@Jvernz
Nov 11 2016 06:41
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
sure will thanks! @Jvernz
CamperBot
@camperbot
Nov 11 2016 06:41
danylrs sends brownie points to @jvernz :sparkles: :thumbsup: :sparkles:
:warning: danylrs already gave jvernz points
Ryan Copeland
@ryan6627
Nov 11 2016 06:41
two returns causes error
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:41
@ryan6627 what are u returningg
Ryan Copeland
@ryan6627
Nov 11 2016 06:41
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
@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
im listening
...
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:42
@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
im done
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:43
@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
@AdoSae1 check out the Accessing Objects w/ Bracket Notation challenge.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 06:44
return "Not Found". <-!!!!!!!!!
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:45
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
@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
ok i removed the kitten part
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:45
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
@swatbone85 Did you solve the challenge?
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:47
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
i dont know how to return the property for the first if
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:51
well the property is called checkProp right??
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:51
yep
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:51
and checkProp is located in myObject
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:51
correct
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:51
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
RECORD COLLECTION Challenge
Justin Vernon
@Jvernz
Nov 11 2016 06:53
@DikoFaji figure it out?
Emerson
@DikoFaji
Nov 11 2016 06:53
not yet
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 06:53
@DikoFaji try it out
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:53
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
@AdoSae1 did u pass the challenge
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:55
yea
Emerson
@DikoFaji
Nov 11 2016 06:55
// 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
i think the most answered challenge in this chatroom is record collection
Justin Vernon
@Jvernz
Nov 11 2016 06:55
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

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
@DikoFaji u've barely written any code yet
AKASH GUNJAL
@AKASH888
Nov 11 2016 06:57
how to pass these test conditions?
Joseph
@revisualize
Nov 11 2016 06:57
@DikoFaji You're missing a bunch of if statements:
https://gist.github.com/revisualize/123deb77d85079f079020ac3cd6ea5ba
Adolfo Saenz
@AdoSae1
Nov 11 2016 06:57
@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
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
@AKASH888 u wrote many if statements and nothing like a return one!
Joseph
@revisualize
Nov 11 2016 06:58

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
@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

@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
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
@DikoFaji No.
Justin Vernon
@Jvernz
Nov 11 2016 06:59
@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
@DikoFaji check out what @revisualize is sending it will help
Joseph
@revisualize
Nov 11 2016 07:00
On that note though. It is 11pm in Seattle.
Adolfo Saenz
@AdoSae1
Nov 11 2016 07:00
@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
@AdoSae1 type ``` then shift+enter
like this
Joseph
@revisualize
Nov 11 2016 07:01

@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
@Dorcy-ndg3 i think i miss his post
NITIN RAGHAV
@nitinraghav
Nov 11 2016 07:01
does anybody know a good jQuery and AJAx tutorial. I am currently at random quote machine challenge.
Joseph
@revisualize
Nov 11 2016 07:02
@DikoFaji Good thing you can SCROLL up.
Adolfo Saenz
@AdoSae1
Nov 11 2016 07:03
thanks!
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:03
@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
:zzz:
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:05
@revisualize :+1:
Norshowerr
@Mandelo
Nov 11 2016 07:06
Profile Lookup Anybody knows?
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:07
so i just got to the Basic Algorithm Scripting : Reverse a String..... and i am already stumped
Emerson
@DikoFaji
Nov 11 2016 07:07
@revisualize thanks currently reading the link now
CamperBot
@camperbot
Nov 11 2016 07:07
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
@LGWinkelmann welcome to algorithms!
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:08
ugh :(
lol
sravanth baratam
@sravanthbaratam
Nov 11 2016 07:08

// 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
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
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
@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
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
.reverse() applies to an array
not a string
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:11
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
bingo
Woolwit
@Woolwit
Nov 11 2016 07:12
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
Gonna play some Rocket League b4 I fry my brain. These algorithms are killer
Woolwit
@Woolwit
Nov 11 2016 07:18
@nitinraghav Codecademy has a JQuery track. https://www.codecademy.com/learn/jquery
Markus Kiili
@Masd925
Nov 11 2016 07:20
@Woolwit Such global variables mess up FCC tests.
Woolwit
@Woolwit
Nov 11 2016 07:20
@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
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
@Woolwit thanks for the tip, so id still have to type em quotes you mean !
CamperBot
@camperbot
Nov 11 2016 07:22
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
@Jvernz i know u may have left but its easier said than coded
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:22
@LGWinkelmann obviously
but if u have already split
please only join after reversing the array
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:23
trying to get it to split now
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:23
and look out for mutability issues
u cant get it to split ???
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:23
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
can i look at ur code??
NITIN RAGHAV
@nitinraghav
Nov 11 2016 07:24
@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

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
@nitinraghav wic do u think is easier and a smarter way of coding ??
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:25
yea obviously it doesnt work
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:25
@LGWinkelmann look out for mutability
u cant just change it like that
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:26
saddly i know the word but i dont understand mytability
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:26
atleast equalize it to itself or create a new variable to put ur new array
Emerson
@DikoFaji
Nov 11 2016 07:26

@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
Dont u think google could be of help here
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:27
yea should do that lol
D O R C ¥
@Dorcy-ndg3
Nov 11 2016 07:27
@LGWinkelmann what i mean here u cant just cant decide to change a string
葛思圆
@siooooo
Nov 11 2016 07:27
blob
why it didn't work?T_T
Emerson
@DikoFaji
Nov 11 2016 07:28
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
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

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
@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
@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
@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
ok
Justin Vernon
@Jvernz
Nov 11 2016 07:36
@DikoFaji your hasOwnProperty lines aren't written correctly
collection[id].hasOwnProperty(prop)
Markus Kiili
@Masd925
Nov 11 2016 07:37
@DikoFaji You need to use bracket notation when the property key is stored in a variable.
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:37
@Dorcy-ndg3 i got it thanks for your help
CamperBot
@camperbot
Nov 11 2016 07:37
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
cool, u see these things are not very hard :smile:
Woolwit
@Woolwit
Nov 11 2016 07:38
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
@Jvernz yes your correct i just missed it
Justin Vernon
@Jvernz
Nov 11 2016 07:38
@Dorcy-ndg3 sweet maybe you can help me soon lol, stuck on returning largest number
Luke Winkelmann
@LGWinkelmann
Nov 11 2016 07:39
yea just needed a var for each line more or less