These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Jul 2016
Joel Santos
@St3ps
Jul 09 2016 00:01 UTC
anyone?
amran16
@amran16
Jul 09 2016 00:01 UTC
@revisualize still not working
Joseph
@revisualize
Jul 09 2016 00:02 UTC
@St3ps Scope.
bitgrower
@bitgrower
Jul 09 2016 00:03 UTC
@St3ps -- meaning ... arguments[0] would be referring to the y of your returned function ... so you would just be doubling the value of y
Joseph
@revisualize
Jul 09 2016 00:03 UTC
@St3ps The anonymous y function has it's own scope for arguments as well.
Joel Santos
@St3ps
Jul 09 2016 00:03 UTC
@bitgrower @revisualize oh **!
Joseph
@revisualize
Jul 09 2016 00:03 UTC
function addTogether() {
console.log(arguments[0]);
  return function(y) {
      console.log(y);
   console.log(arguments);
    return arguments[0] + y;
  };
};

addTogether(4)(6);
Joel Santos
@St3ps
Jul 09 2016 00:04 UTC
Yeap, makes sense.
@revisualize @bitgrower thanks guys
CamperBot
@camperbot
Jul 09 2016 00:04 UTC
st3ps sends brownie points to @revisualize and @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1391 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1133 | @bitgrower |http://www.freecodecamp.com/bitgrower
Joseph
@revisualize
Jul 09 2016 00:05 UTC
@St3ps :+1:
bitgrower
@bitgrower
Jul 09 2016 00:05 UTC
the arguments variable, that reference, refers to something different with each new scope opened ...
yw... happy coding @St3ps
Joel Santos
@St3ps
Jul 09 2016 00:06 UTC
:D
eniloc
@eniloc
Jul 09 2016 00:10 UTC

Janina Pohorecki
@janepohorecka
Jul 09 2016 00:13 UTC
Guys, I have spent hours on a simple problem. I really need some help :(
Instructions
Call the processArg function with an argument of 7 and assign its return value to the variable processed.
silver537
@silver537
Jul 09 2016 00:15 UTC
i finally destroyed search and replace challenge. come at me bro!
eniloc
@eniloc
Jul 09 2016 00:16 UTC

var myStr= "I am a \"double quoted\" string inside \"double quotes\""; * I'm really beginning and I wanted to know what was wrong with this. I might not have understood well because english is not my main language. Thanks
David Di Feo
@ddifeo
Jul 09 2016 00:17 UTC
@janepohorecka its asking you to assign the return value from processArg into the variable processed. So it would look something like this...
@janepohorecka processed = processArg(7);
silver537
@silver537
Jul 09 2016 00:18 UTC
@eniloc you gotta write exactly what it's asking you. any misspelling or missing punctuation will come out as wrong
David Di Feo
@ddifeo
Jul 09 2016 00:18 UTC
@eniloc whats the name of the challenge?
Janina Pohorecki
@janepohorecka
Jul 09 2016 00:19 UTC
@realxtensive OMG. I realized I have forgotten the semicolon at the end.. I had this completely correct except for the semicolon.. Your comment made me see that. Thank you!!!
CamperBot
@camperbot
Jul 09 2016 00:19 UTC
janepohorecka sends brownie points to @realxtensive :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @realxtensive |http://www.freecodecamp.com/realxtensive
eniloc
@eniloc
Jul 09 2016 00:19 UTC
@realxtensive it's Escaping Literal Quotes in Strings
Moisés Man
@moigithub
Jul 09 2016 00:20 UTC
@eniloc missing dot at the end
double quotes\"."; :point_left: :point_left: :point_left: :point_left: :point_left: :point_left:
David Di Feo
@ddifeo
Jul 09 2016 00:20 UTC
@janepohorecka haha no problem. I would be lying if I said that hasn't happened to me before lol
eniloc
@eniloc
Jul 09 2016 00:20 UTC
could anyone tell me how post code in gitter chat. That would help a lot
David Di Feo
@ddifeo
Jul 09 2016 00:21 UTC
@eniloc yup missing the period
eniloc
@eniloc
Jul 09 2016 00:22 UTC
@realxtensive yeah i saw it. Thanks anyway
CamperBot
@camperbot
Jul 09 2016 00:22 UTC
eniloc sends brownie points to @realxtensive :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @realxtensive |http://www.freecodecamp.com/realxtensive
David Di Feo
@ddifeo
Jul 09 2016 00:22 UTC
help format
CamperBot
@camperbot
Jul 09 2016 00:22 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

eniloc
@eniloc
Jul 09 2016 00:24 UTC
cool thanks
Joel Santos
@St3ps
Jul 09 2016 00:24 UTC
I hope this won't be a silly question but:
function addTogether() { 

 var thisArr = [...arguments].every(el => (typeof el === 'number'));

  console.log(arguments[1] + " : " + thisArr);
//returns undefined : true
//how can this be? how can arguments[1] be undefined and yet considered true?

/*ommited code*/

addTogether(2)([3]);
//function call. the 2nd argument is an array
matthew3454
@matthew3454
Jul 09 2016 00:28 UTC
Please help me with the following. Thank you.
var convert = function(num) {
  var decimalValue = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000];
  var romanNumeral = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M'];
  var romanized = '';
  for (var index = decimalValue.length; index >= 0; index--) {
     while (num >= decimalValue[index]) {
        romanized += romanNumeral[index];
        num -= decimalValue[index];
     }
   }

  return romanized;
};
I love you and I want to have your baby!
Whenever I cry, I do it on time, I'll be there right there waiting for you!
music
CamperBot
@camperbot
Jul 09 2016 00:30 UTC
matthew3454
@matthew3454
Jul 09 2016 00:30 UTC
Please help me with the following. Thank you.
Joel Santos
@St3ps
Jul 09 2016 00:30 UTC
Dude, give it a minute.
Relax.
matthew3454
@matthew3454
Jul 09 2016 00:30 UTC
```
var convert = function(num) {
  var decimalValue = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000];
  var romanNumeral = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M'];
  var romanized = '';
  for (var index = decimalValue.length; index >= 0; index--) {
     while (num >= decimalValue[index]) {
        romanized += romanNumeral[index];
        num -= decimalValue[index];
     }
   }

  return romanized;
};
```
Joel Santos
@St3ps
Jul 09 2016 00:31 UTC
No homo needed. Just breathe.
matthew3454
@matthew3454
Jul 09 2016 00:32 UTC
@St3ps Oh I'm heavy baby! ;)
Joel Santos
@St3ps
Jul 09 2016 00:33 UTC
@matthew3454 lol, yeah i almost forgot it's friday night
matthew3454
@matthew3454
Jul 09 2016 00:33 UTC
@St3ps How are things in Portugal?
What is your go to drink to soothe the mood?
And where do you enjoy it? At home or ir de vinos?
@St3ps Friday is my fried day.:)
Joel Santos
@St3ps
Jul 09 2016 00:36 UTC
@matthew3454 Yeah, 'fried' sounds like everyday this summer. I have sunburn on my face from walking half an hour.
Oh and yeah, drinking. there's that. summer and all.
matthew3454
@matthew3454
Jul 09 2016 00:37 UTC
@St3ps Oh really? You should shave your head and you'll have sun burns....he he he he . Get it?
Joel Santos
@St3ps
Jul 09 2016 00:39 UTC
@matthew3454 lol no need to delete it, i'm actually trying to figure out your code man
matthew3454
@matthew3454
Jul 09 2016 00:39 UTC
@St3ps Oh really? You should shave your head and you'll have sun burns...he he he he. Get it?
@St3ps accident
Moyosore Sosan
@Mohyour
Jul 09 2016 00:39 UTC
hi

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

else if (contacts[i].firstName!==firstName){
    return "No such contact";
    }

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

}
// Only change code above this line
}

This is my code, the first if statement id the issue i guess, but can't lay hands on it. please help
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i=0; i<contacts.length; i++){
    if ((contacts[i].firstName===firstName) && (contacts[i].hasOwnProperty(prop)===true)){
        return contacts[i][prop];
        }

    else if (contacts[i].firstName!==firstName){
        return "No such contact";
        }

    else if (contacts[i].hasOwnProperty(prop)===false){
      return "No such property";
    }
    else{
      return "oops"
    }
  }
// Only change code above this line
}
Joel Santos
@St3ps
Jul 09 2016 00:42 UTC
@matthew3454 uh, i dont understand, your code works
in what instance does it not work?
eniloc
@eniloc
Jul 09 2016 00:43 UTC
could anyone help me here?
matthew3454
@matthew3454
Jul 09 2016 00:43 UTC
@St3ps idk brother. All I know is CTRL + ETR no funciona.
var chanels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp",  "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas", "comster404"];
var status = ["a"];

function makeCallback(){
  return function(data){
    if (data.hasOwnProperty('error')){
      status.push("Account closed");
    } else {
      if (data.stream != null){
        status.push("Online");
      } else {
        status.push("Offline");
      }
    }
    console.log(status);
  }
 }

function updateStatus(){
  for (var i=0; i<chanels.length; i++){
    var name = chanels[i];
    $.getJSON('https://api.twitch.tv/kraken/streams/' + name +'?callback=?', makeCallback());
  }
}

$(document).ready(function(){ 
    updateStatus();
});
I get error message "Uncaught TypeError: status.push is not a function". Where did i wrong?
eniloc
@eniloc
Jul 09 2016 00:44 UTC
ar myStr = '<a href="http://www.example.com"target="_blank">Link</a>'; // i dont understand...
Joel Santos
@St3ps
Jul 09 2016 00:45 UTC
@matthew3454 see for yourself
https://repl.it/CaJ2
matthew3454
@matthew3454
Jul 09 2016 00:46 UTC
@St3ps Whoa dude! idk y mine don work then
Joel Santos
@St3ps
Jul 09 2016 00:47 UTC
@matthew3454 you do have the convert() call at the end, right?
@eniloc what dont you understand?
matthew3454
@matthew3454
Jul 09 2016 00:48 UTC
@St3ps I do
Joel Santos
@St3ps
Jul 09 2016 00:48 UTC
@matthew3454 and no results work? like all of the calls listed at the left, they're all in the red?
eniloc
@eniloc
Jul 09 2016 00:49 UTC
@St3ps Not that i don't understand but it should be working no? If not just tell me what my mistake is
matthew3454
@matthew3454
Jul 09 2016 00:49 UTC
@St3ps This what pops up in the syntax bar thingy magig :DLXV
@St3ps Yes red
@St3ps all
Joel Santos
@St3ps
Jul 09 2016 00:51 UTC
@matthew3454 and it returns nothing? try changing the convert call
matthew3454
@matthew3454
Jul 09 2016 00:51 UTC
@St3ps to condemn call?;)
Joel Santos
@St3ps
Jul 09 2016 00:51 UTC
@eniloc well, can you explain what you're trying to do with it? you're creating a string variable, but you're applying this in html?
@matthew3454 lol, noo don't condemn it poor thing, it doesn't know better.
:p
matthew3454
@matthew3454
Jul 09 2016 00:52 UTC
@St3ps it will when I'm done with it. muhuhahahahaha!!
Joel Santos
@St3ps
Jul 09 2016 00:53 UTC
rip function call
matthew3454
@matthew3454
Jul 09 2016 00:53 UTC
@St3ps ?
Moisés Man
@moigithub
Jul 09 2016 00:53 UTC
This message was deleted
Joel Santos
@St3ps
Jul 09 2016 00:53 UTC
rip, cause, it's condemned. i dunno, i'm tired man
eniloc
@eniloc
Jul 09 2016 00:54 UTC
@St3ps I'm in the challenge: Quoting Strings with Single Quotes
uniforlyff
@uniforlyff
Jul 09 2016 00:56 UTC
' single quote
Moisés Man
@moigithub
Jul 09 2016 00:57 UTC
@eniloc missing a space ??
/www.example.com"target
eniloc
@eniloc
Jul 09 2016 00:57 UTC
No it's good
Joel Santos
@St3ps
Jul 09 2016 00:57 UTC
@eniloc yeap it's a space
eniloc
@eniloc
Jul 09 2016 00:57 UTC
it worked
Joel Santos
@St3ps
Jul 09 2016 00:57 UTC
lol
Moisés Man
@moigithub
Jul 09 2016 00:57 UTC
but test not passing.. soo...
eniloc
@eniloc
Jul 09 2016 00:58 UTC
I think i'm tired
Joel Santos
@St3ps
Jul 09 2016 00:58 UTC
haha....
Moyosore Sosan
@Mohyour
Jul 09 2016 00:58 UTC
please help
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i=0; i<contacts.length; i++){
    if ((contacts[i].firstName===firstName) && (contacts[i].hasOwnProperty(prop)===true)){
        return contacts[i][prop];
        }

    if (contacts[i].firstName!==firstName){
        return "No such contact";
        }

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

  }
// Only chang
Moisés Man
@moigithub
Jul 09 2016 00:58 UTC
test check for EXACT matches...
uniforlyff
@uniforlyff
Jul 09 2016 00:58 UTC
@matthew3454 ur code shud work
Moisés Man
@moigithub
Jul 09 2016 00:58 UTC
1 character more or less. will make it fail
Moyosore Sosan
@Mohyour
Jul 09 2016 00:58 UTC
test not passng
96street
@96street
Jul 09 2016 00:58 UTC

How do I iterate through the object names here? E.g. access

first, last

{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }

uniforlyff
@uniforlyff
Jul 09 2016 00:58 UTC
thats the code i agev u ystrday lel
so it shud
Joel Santos
@St3ps
Jul 09 2016 00:58 UTC
@uniforlyff i tested it on repl.it and it did
uniforlyff
@uniforlyff
Jul 09 2016 00:59 UTC
no not u
matt
Joel Santos
@St3ps
Jul 09 2016 00:59 UTC
@uniforlyff yeah, i picked up your code and tested it
Moisés Man
@moigithub
Jul 09 2016 00:59 UTC
@Mohyour u returning no contact too soon
uniforlyff
@uniforlyff
Jul 09 2016 00:59 UTC
@St3ps hehe okay
matthew3454
@matthew3454
Jul 09 2016 01:00 UTC
@uniforlyff oh baby I waiting for you all night
Reginald Johnson
@reggie3
Jul 09 2016 01:00 UTC
@96street , are the objects all in an array?
uniforlyff
@uniforlyff
Jul 09 2016 01:00 UTC
about @matthew3454
CamperBot
@camperbot
Jul 09 2016 01:00 UTC
:cookie: 325 | @matthew3454 |http://www.freecodecamp.com/matthew3454
Joel Santos
@St3ps
Jul 09 2016 01:00 UTC
lol
Moisés Man
@moigithub
Jul 09 2016 01:00 UTC
@96street check this mdn.io/Object.keys
matthew3454
@matthew3454
Jul 09 2016 01:00 UTC
to rescue me from my evil code
uniforlyff
@uniforlyff
Jul 09 2016 01:01 UTC
@matthew3454 @matthew3454 ur code works
96street
@96street
Jul 09 2016 01:01 UTC
yes @reggie3
function whatIsInAName(collection, source) {

  var arr = [];
  for(var objs in collection)  {
    for(var items in objs) {
     for(var srcKey in source) {    
      if(source==collection[objs][items]) {
        arr.push(source);
      }
    }
   }
  } 


  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
@moigithub Can you help me?
96street
@96street
Jul 09 2016 01:01 UTC
i'm stuck on 'Wherefore art thou'
matthew3454
@matthew3454
Jul 09 2016 01:01 UTC
@uniforlyff it seems to be asymptomatic then. ;)
uniforlyff
@uniforlyff
Jul 09 2016 01:01 UTC
@matthew3454 hwo do u not know how to make the orman numerals work when you already finish all them projects :joy:
matthew3454
@matthew3454
Jul 09 2016 01:01 UTC
@uniforlyff just like me. ;)
Jo Cook
@ScreamJosifer
Jul 09 2016 01:02 UTC
Could someone please tell me how to post my code in the chat in order to ask for help?
matthew3454
@matthew3454
Jul 09 2016 01:02 UTC
@uniforlyff because I'm a hustler baby
Joel Santos
@St3ps
Jul 09 2016 01:02 UTC
type ``` on top and on bottom
Jo Cook
@ScreamJosifer
Jul 09 2016 01:02 UTC
Thank you, @St3ps
CamperBot
@camperbot
Jul 09 2016 01:02 UTC
screamjosifer sends brownie points to @st3ps :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @st3ps |http://www.freecodecamp.com/st3ps
Joel Santos
@St3ps
Jul 09 2016 01:02 UTC
sandwich your code with ```
np
matthew3454
@matthew3454
Jul 09 2016 01:03 UTC
@uniforlyff Are you really going to be my wonder man? Please say yes!
uniforlyff
@uniforlyff
Jul 09 2016 01:04 UTC
haha
u look lyk my friend
and act like em
matthew3454
@matthew3454
Jul 09 2016 01:04 UTC
@uniforlyff Great! Well now you have a spare one. ;)
Jo Cook
@ScreamJosifer
Jul 09 2016 01:04 UTC
Okay, then could someone help me figure out what is wrong with my code (I am in the Selecting from many options with Switch Statements)? I have Googled it, asked friends and bought a book on JavaScript with no avail. Any help would be dearly appreciated.
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  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);
Moisés Man
@moigithub
Jul 09 2016 01:05 UTC
@96street whats objs.. whats items.. whats srcKey
add console.log( ... ) n check...
for..in.. iterate on properties... collection is an array...
for(var objs in collection) { <-- so objs is not what u think it is
Moyosore Sosan
@Mohyour
Jul 09 2016 01:06 UTC
@ScreamJosifer maybe you should remove your strings frm d brackets
Jo Cook
@ScreamJosifer
Jul 09 2016 01:07 UTC
@Mohyour I am so sorry, I just started coding like a week ago and am still getting used to the vocabulary. Are you suggesting I remove the {}?
Joel Santos
@St3ps
Jul 09 2016 01:07 UTC
There's no need to put parenthesis around string literals. Like, you have ("alpha")
perhaps "alpha" will work
Jo Cook
@ScreamJosifer
Jul 09 2016 01:07 UTC
@St3ps Oh! Thank you! Let me try that!
CamperBot
@camperbot
Jul 09 2016 01:07 UTC
screamjosifer sends brownie points to @st3ps :sparkles: :thumbsup: :sparkles:
:warning: screamjosifer already gave st3ps points
Alex N.
@N0bl3
Jul 09 2016 01:07 UTC
@ScreamJosifer the problem is not the parenthesis at all even if unecessary
Moyosore Sosan
@Mohyour
Jul 09 2016 01:08 UTC
oh @ScreamJosifer you have to tell it what to switch. put
switch (var); {}
Jo Cook
@ScreamJosifer
Jul 09 2016 01:08 UTC
It says "unexpected token case".
Alex N.
@N0bl3
Jul 09 2016 01:08 UTC
you just forgot the so called switch statement you are supposed to study in this exercise :)
Joel Santos
@St3ps
Jul 09 2016 01:09 UTC
yeap, there's also that, lol
Jo Cook
@ScreamJosifer
Jul 09 2016 01:09 UTC
@N0bl3 I would be embarrassed but I am so far beyond such with my programming ignorance. ;_; Alright, let me shamefully try to fix that.
Alex N.
@N0bl3
Jul 09 2016 01:09 UTC
@ScreamJosifer the syntax is
switch (var) {
case "aeeazar":
return "blabla";
default:
return "blabla";
}
matthew3454
@matthew3454
Jul 09 2016 01:09 UTC
@uniforlyff Do you have anymore troubleshooting suggestions?
Jo Cook
@ScreamJosifer
Jul 09 2016 01:09 UTC
Oh man. This is just terribly awkward.
Alex N.
@N0bl3
Jul 09 2016 01:09 UTC
@Mohyour dont push a ; between switch and the {} @ScreamJosifer
@ScreamJosifer it s not , we all do this ^^
Jo Cook
@ScreamJosifer
Jul 09 2016 01:10 UTC
IT WORKED.
Joel Santos
@St3ps
Jul 09 2016 01:10 UTC
@ScreamJosifer it's not. you're going to make a lot of these as you go.
Alex N.
@N0bl3
Jul 09 2016 01:10 UTC
well it is in a certain way but you can't be ashamed of it
Jo Cook
@ScreamJosifer
Jul 09 2016 01:10 UTC
OKAY, WHO DO I OWE FOR THIS MIRACLE?!
Alex N.
@N0bl3
Jul 09 2016 01:11 UTC
@ScreamJosifer i want a cookie!!
Jo Cook
@ScreamJosifer
Jul 09 2016 01:11 UTC
You are all getting Channukah gifts this year. Free beer on me. Whatever you want. Thank you so much.
A cookie from the Cook it is.
Alex N.
@N0bl3
Jul 09 2016 01:12 UTC
@ScreamJosifer next for the if else challenge don't forget the if ;) but you know what i did next time, i was looking for a bug, my function was never running , i searched for 1 hour but actually...; this function wasn't existing at all haha
Joel Santos
@St3ps
Jul 09 2016 01:12 UTC
@ScreamJosifer hold on to your gifts, the fun is just beginning...
Moyosore Sosan
@Mohyour
Jul 09 2016 01:12 UTC
Any help on this please
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i=0; i<contacts.length; i++){
    if ((contacts[i].firstName===firstName) && (contacts[i].hasOwnProperty(prop)===true)){
        return contacts[i][prop];
        }

    if (contacts[i].firstName!==firstName){
        return "No such contact";
        }

    if (contacts[i].hasOwnProperty(prop)===false){
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
It won't pass all the test cases
96street
@96street
Jul 09 2016 01:13 UTC

@moigithub so would:

var objKey = Object.keys(collection[objs]);

get me first, last etc?

Jo Cook
@ScreamJosifer
Jul 09 2016 01:13 UTC
Well...hopefully you guys won't see me around again for a while. (See you all in twelve seconds when I make another dumb mistake.)
Joseph
@revisualize
Jul 09 2016 01:19 UTC
@Mohyour Question.. What happens if you always return something in a loop?
@Mohyour How many times do you think your loop runs?
matthew3454
@matthew3454
Jul 09 2016 01:20 UTC
@ScreamJosifer you're perfect the way you are baby
Joel Santos
@St3ps
Jul 09 2016 01:22 UTC
function addTogether() {

  var thisArr = [...arguments].every(el => (typeof el === 'number'));

  console.log(arguments[1] + " : " + thisArr);
 //this returns undefined : true 
//how can that be, considering the .every above?

/*ommited code*/ 

addTogether(2)([3]);
**
Alex N.
@N0bl3
Jul 09 2016 01:23 UTC
lool
@St3ps what s this, :D
Moyosore Sosan
@Mohyour
Jul 09 2016 01:24 UTC
@revisualize it goes over the loop again i think
Joel Santos
@St3ps
Jul 09 2016 01:24 UTC
@N0bl3 crap lol
i sorted it out now
Joseph
@revisualize
Jul 09 2016 01:25 UTC
@Mohyour Nope.
@Mohyour If your loop always returns something.. It halts and halts the function.
Alex N.
@N0bl3
Jul 09 2016 01:25 UTC
@St3ps crapscript is the pas present and future implementation of JS! :D
Joel Santos
@St3ps
Jul 09 2016 01:25 UTC
@N0bl3 does it make sense? like the array is being passed into the function, and even though it's being tested in the .every function, it returns as true
@N0bl3 i excel at it a bit too much.
(i mean, in the .every function, it tests if the element in the arguments is a number, and the last argument, returns true, but it's an array, so shouldn't it be false?
Moyosore Sosan
@Mohyour
Jul 09 2016 01:28 UTC
@revisualize by that you mean it stops the function
Joel Santos
@St3ps
Jul 09 2016 01:28 UTC
wait, it's the way i'm testing it. i thought the 2nd argument would be as arguments1 but it's not.
Alex N.
@N0bl3
Jul 09 2016 01:29 UTC
@St3ps i have a possible , just POSSIBLE explanation. that as you didnt describe the arguments in the definition of the function they are either writeen like (2,4,5) and added to arguments array OR written like ([5,6,3,2]) which becomes the arguments array
Joseph
@revisualize
Jul 09 2016 01:29 UTC
@Mohyour Correct.
Joel Santos
@St3ps
Jul 09 2016 01:30 UTC
@N0bl3 the arguments are passed down through the function on the bottom -- the arguments being passed are (2)([3])
but clearly this cannot work, there isnt a arguments1
Alex N.
@N0bl3
Jul 09 2016 01:31 UTC
@St3ps ok i think i get it
@N0bl3 it s not what i said.
@N0bl3 actually you call the function once with 2 and once again with [3] that you already knew
Edvin Castillo
@3dv1n
Jul 09 2016 01:32 UTC
hi friends I am solving the record collection task. And I'm not sure if this:
Alex N.
@N0bl3
Jul 09 2016 01:32 UTC
@St3ps but arguments isnt an Array
Edvin Castillo
@3dv1n
Jul 09 2016 01:33 UTC
collection[prop]=value assign the value
Alex N.
@N0bl3
Jul 09 2016 01:33 UTC
@St3ps maybe it renders a value which is true? can you log arguments.every?
Joel Santos
@St3ps
Jul 09 2016 01:34 UTC
@N0bl3 alright hold on
Andy
@nolaandy
Jul 09 2016 01:34 UTC
Is there a better way to write this code?
function palindrome(str) {
  // Good luck!
  str = str.toLowerCase();
  str = str.replace(/\s+/g, '');
  str = str.replace(/[_,.:()/\-]/g, '');
  var arr = str.split("");
  arr.reverse();
  var newArr= arr.join("");

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

palindrome("ufotofu");
Alex N.
@N0bl3
Jul 09 2016 01:35 UTC
@St3ps arguments.every doesnt exist
Moyosore Sosan
@Mohyour
Jul 09 2016 01:37 UTC
@revisualize how do i then ammend the code
Joel Santos
@St3ps
Jul 09 2016 01:37 UTC
@N0bl3
  var thisArr = [...arguments].every(el => {

      console.log(el);
      return (typeof el === 'number')
      });
it only reaches the first argument. the 2nd argument is never placed here
it returns on the log: 2
Alex N.
@N0bl3
Jul 09 2016 01:38 UTC
@St3ps the method arguments.every doesnt exists as it is not an Array
Joel Santos
@St3ps
Jul 09 2016 01:41 UTC
@N0bl3 you're right, which is why i made //thisArr = [...arguments]
Using the spread operator "..." preceding arguments and, both being closed in bracket notation, you are basically saying: thisArr will become an array, spread evenly with the arguments in, uh, arguments!
patrickcshan
@patrickcshan
Jul 09 2016 01:42 UTC
Hi guys, can you take a look at my uniteUnique method? I am returning the correct results, but there might be a format problem?
Alex N.
@N0bl3
Jul 09 2016 01:42 UTC
ah i see! well then you are passing ONE array like and assigning it to the first index of thisArr
@St3ps so you have [arguments] , not [arg1,arg2,arg3,...]
Joel Santos
@St3ps
Jul 09 2016 01:44 UTC
Like, in a normal scenario, (ex: func(1,2,3) you'd have thisArr = [1, 2, 3]
Alex N.
@N0bl3
Jul 09 2016 01:44 UTC
@N0bl3 nop you would have thisArr = [[1,2,3]]
96street
@96street
Jul 09 2016 01:44 UTC
how would i access the 2nd object in this object? { first: "Romeo", last: "Montague" }
JJMin
@JJMin
Jul 09 2016 01:44 UTC
any reason why this isn't working?
Joel Santos
@St3ps
Jul 09 2016 01:44 UTC
@N0bl3 :o ok, i'll test it 1 sec
JJMin
@JJMin
Jul 09 2016 01:44 UTC

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

// Only change code below this line

var gloveBoxContents = myStorage.car.inside.["glove box"];

Alex N.
@N0bl3
Jul 09 2016 01:44 UTC
@St3ps i am testing too ^^
llamatarianism
@llamatarianism
Jul 09 2016 01:45 UTC
pretty sure @St3ps is right
JJMin
@JJMin
Jul 09 2016 01:45 UTC
blob
This message was deleted
This message was deleted
llamatarianism
@llamatarianism
Jul 09 2016 01:45 UTC
[...x] is the same as Array.from(x)
patrickcshan
@patrickcshan
Jul 09 2016 01:45 UTC
@JJMin I don't think you need to have quotes around glove box.
llamatarianism
@llamatarianism
Jul 09 2016 01:45 UTC
it doesn't make it nested
JJMin
@JJMin
Jul 09 2016 01:46 UTC
@patrickcshan no you need quotes
Alex N.
@N0bl3
Jul 09 2016 01:46 UTC
@St3ps no you are right
llamatarianism
@llamatarianism
Jul 09 2016 01:46 UTC
TechPointYT
@TechPointYT
Jul 09 2016 01:46 UTC
i am lost with the record collection challenge
llamatarianism
@llamatarianism
Jul 09 2016 01:47 UTC
@JJMin your problem is the .[
Alex N.
@N0bl3
Jul 09 2016 01:47 UTC
@St3ps i have to do some research, if i find why ill tell you
TechPointYT
@TechPointYT
Jul 09 2016 01:47 UTC
what are you suppose to do
Joel Santos
@St3ps
Jul 09 2016 01:47 UTC
@N0bl3 hehe, happens from time to time
llamatarianism
@llamatarianism
Jul 09 2016 01:47 UTC
it should be myStorage.car.inside["glove box"]
you've got myStorage.car.inside.["glove box"]
the . is causing problems
JJMin
@JJMin
Jul 09 2016 01:47 UTC
@llamatarianism thanks, I see it :+1:
CamperBot
@camperbot
Jul 09 2016 01:47 UTC
jjmin sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 928 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
TechPointYT
@TechPointYT
Jul 09 2016 01:48 UTC
has anyone passed the record collection challenge
llamatarianism
@llamatarianism
Jul 09 2016 01:48 UTC
@St3ps well of course it's only logging 1 thing
TechPointYT
@TechPointYT
Jul 09 2016 01:48 UTC
???
Joel Santos
@St3ps
Jul 09 2016 01:48 UTC
@N0bl3 you mean, about the problem? don't worry about it man, it has to do with the 2nd argument not being passed, it just does not see the array
llamatarianism
@llamatarianism
Jul 09 2016 01:48 UTC
your function only takes 1 argument
addTogether(2)([3]);
Alex N.
@N0bl3
Jul 09 2016 01:48 UTC
@St3ps maybe it is lazy evaluation by v8 then?
llamatarianism
@llamatarianism
Jul 09 2016 01:48 UTC
addTogether is only taking 1 argument: 2
it should then return a function
Alex N.
@N0bl3
Jul 09 2016 01:48 UTC
@St3ps what browser are you using?
llamatarianism
@llamatarianism
Jul 09 2016 01:48 UTC
which will take in another argument: [3]
@N0bl3 it's nothing to do with any of that
Alex N.
@N0bl3
Jul 09 2016 01:49 UTC
@llamatarianism ooooooo that was interesting
llamatarianism
@llamatarianism
Jul 09 2016 01:49 UTC
@St3ps it might help you understand if I break it up:
Alex N.
@N0bl3
Jul 09 2016 01:49 UTC
@llamatarianism thanks for the light!!
CamperBot
@camperbot
Jul 09 2016 01:49 UTC
n0bl3 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 929 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Jul 09 2016 01:49 UTC
var addTwo = addTogether(2);
addTwo([3]);
TechPointYT
@TechPointYT
Jul 09 2016 01:50 UTC
have yall done the record collection challenge ?
Alex N.
@N0bl3
Jul 09 2016 01:50 UTC
@llamatarianism ohhhh amazing
llamatarianism
@llamatarianism
Jul 09 2016 01:50 UTC
@N0bl3 an example of another function that returns a function:
Joel Santos
@St3ps
Jul 09 2016 01:51 UTC
@llamatarianism :p i get it, i'm wondering then if i'm reacing this problem correctly
reaching*
llamatarianism
@llamatarianism
Jul 09 2016 01:51 UTC
function multiply(x) {
  return function(y) {
    return x * y;
  }
}

console.log(multiply(2)(3));
// => 6
var timesTwo = multiply(2);
console.log(timesTwo(3));
// => 6
each of those functions just takes 1 argument - x and y
TechPointYT
@TechPointYT
Jul 09 2016 01:52 UTC
@St3ps @llamatarianism yall mind helping me out a little ?
Alex N.
@N0bl3
Jul 09 2016 01:52 UTC
@llamatarianism niceeeeeee makes 2D function!
llamatarianism
@llamatarianism
Jul 09 2016 01:52 UTC
once I'm done helping @St3ps
@St3ps post your code again?
Joel Santos
@St3ps
Jul 09 2016 01:53 UTC
@llamatarianism sure man 1 sec
function addTogether() {

  var thisArr = [...arguments].every(el => {

      console.log(el);
      return (typeof el === 'number')
      });

  console.log(arguments[1] + " : " + thisArr);

  if(!thisArr) {
    return undefined;
  }

  if (arguments.length === 1) {

    var x = arguments[0];
    return function(y) {

        return x + y;
    };

  } else {

    var arr = [...arguments];
    return arr.reduce((prev, curr) => prev + curr);

  }

}

addTogether(2)([3]);
Moyosore Sosan
@Mohyour
Jul 09 2016 01:54 UTC
@moigithub when should i return it
Joel Santos
@St3ps
Jul 09 2016 01:54 UTC
it's a bit messy sorry about that
llamatarianism
@llamatarianism
Jul 09 2016 01:54 UTC
looks alright to me
there are ways you could simplify it
but the general idea seems alright
you just need to add a typecheck to the function you return
return function(y) {
  if (typeof y !== "number") return;
  return x + y;
}
sidenote: return; is the same as return undefined;
Joel Santos
@St3ps
Jul 09 2016 01:56 UTC
awesome! let me check it out
Moyosore Sosan
@Mohyour
Jul 09 2016 01:56 UTC
can someone please help ammend
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i=0; i<contacts.length; i++){
    if ((contacts[i].firstName===firstName) && (contacts[i].hasOwnProperty(prop)===true)){
        return contacts[i][prop];
        }

    if (contacts[i].firstName!==firstName){
        return "No such contact";
        }

    if (contacts[i].hasOwnProperty(prop)===false){
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
llamatarianism
@llamatarianism
Jul 09 2016 01:57 UTC
@Mohyour your problem is, you're returning "No such contact"; after only checking 1 contact
your function always returns something on the first iteration of the loop
so it doesn't check all the contacts
what you need to do is remove this:
if (contacts[i].firstName!==firstName){
        return "No such contact";
        }
and just add return "No such contact"; at the end of the loop
also you don't actually check if the contact's name matches in your "no such property" condition
Joel Santos
@St3ps
Jul 09 2016 02:00 UTC
@llamatarianism it works ;) sorry for the slow answer, i'm dead tired and i suck major balls with my touchpad
@llamatarianism thanks man
CamperBot
@camperbot
Jul 09 2016 02:00 UTC
st3ps sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 930 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Moyosore Sosan
@Mohyour
Jul 09 2016 02:01 UTC
@llamatarianism I'm not clear on that please
patrickcshan
@patrickcshan
Jul 09 2016 02:02 UTC
@Mohyour @llamatarianism For the loop, no matter what he does it will return on the first one. What about using a boolean to keep track of whether or not the person is in the list, and then if it is, does it have the property. Then if it is he can return the correct statement after the loop iterates through.
John Kolade
@JKolade936
Jul 09 2016 02:03 UTC

I need help on a string that is supposed to display this:

FirstLine
\SecondLine\
ThirdLine

My current string looks like this:
myStr = "Firstline\n \Secondline\ \rThirdLine"

What am I doing wrong?

Moyosore Sosan
@Mohyour
Jul 09 2016 02:04 UTC
@patrickcshan can you please help with a snippet, I'm confused
Joel Santos
@St3ps
Jul 09 2016 02:10 UTC
@JKolade936 try "Firstline\n\Secondline\\rThirdLine"
patrickcshan
@patrickcshan
Jul 09 2016 02:10 UTC
@mohyour try something like
var noContact = true;
var noProp = true;
IF the contact is in the list
noContact = noContact && false;
IF the property is in the contact
noProp = noProp && false;
then after the loop
depending on what noContact is
and noProp is
you can return the right response
(sorry I'm in the middle of osmething else right now)
Joel Santos
@St3ps
Jul 09 2016 02:12 UTC
@JKolade936 hold on sorry
@JKolade936 myStr = "Firstline\n\Secondline\\rThirdLine"
wtf
Moyosore Sosan
@Mohyour
Jul 09 2016 02:12 UTC
@patrickcshan thanks...will try that
CamperBot
@camperbot
Jul 09 2016 02:12 UTC
mohyour sends brownie points to @patrickcshan :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @patrickcshan |http://www.freecodecamp.com/patrickcshan
Joel Santos
@St3ps
Jul 09 2016 02:13 UTC
I literally can't have double escape characters on chat haha
@JKolade936 on SecondLine you need to have 2 of these \ before, and after. i can't type it out because if i do, it gets filtered or something.
Kevin
@KevinBruland
Jul 09 2016 02:24 UTC
\\
just escape it twice @St3ps :)
so 4 \'s in a row = \\
Mr.Jois
@Sumanthjois
Jul 09 2016 02:26 UTC
https://github.com/Sumanthjois/DataBox please check this out repo!! and please contribute if you can! It's an api for making jdbc easier :D please do check it out! :D
Matt
@TheeMattOliver
Jul 09 2016 02:27 UTC
@JKolade936 @St3ps you have to paste the code into chat :)
var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
Jonathan Mitchell
@Vanhealen
Jul 09 2016 02:28 UTC
What is a quick way to check if an object’s value is a function
or if there is a method inside a current object
Darshan
@Dave1089
Jul 09 2016 02:29 UTC
What am I doing wrong in this code?
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];  
  // Only change code below this line
 var cnt = 0; 
keys = Object.keys(source);
  for(var i=0;i<collection.length;i++){
    for(var x in collection[i]){
       for(var j=0;j<keys.length;j++){
          if(x.hasOwnProperty(keys[j]) && x[keys[j]] == source[keys[j]])
          cnt = 1;
         else
          cnt = 0;

       }
          if(cnt === 1){
            arr.push(x);
            }

       }
    }
  // Only change code above this line
return arr;
//  return keys;
}
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Brian
@BrianCodes33
Jul 09 2016 02:32 UTC
function confirmEnding(str, target) {
  return str.substr(-target.length) === target;
}
why does str.substr(-target.length) return the last character in the str?
Aaron Hanna
@AaronHanna
Jul 09 2016 02:32 UTC
aaaah recursion hurts my brain!
llamatarianism
@llamatarianism
Jul 09 2016 02:33 UTC
@BrianCodes33 it doesn't always
it only does that if target.length == 1
and it does that because that's just how things work.
if you use a negative number in things like String.prototype.substr and String.prototype.slice
TechPointYT
@TechPointYT
Jul 09 2016 02:34 UTC
please
help
CamperBot
@camperbot
Jul 09 2016 02:34 UTC

CamperBot

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

Basic Commands:

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

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

llamatarianism
@llamatarianism
Jul 09 2016 02:34 UTC
then it indexes it backwards
@TechPointYT what's the problem
TechPointYT
@TechPointYT
Jul 09 2016 02:35 UTC
what are you suppose to do in the record collection challenge ? i am absolutely lost when it comes the function one is suppose to write
llamatarianism
@llamatarianism
Jul 09 2016 02:38 UTC
just use some if statements
TechPointYT
@TechPointYT
Jul 09 2016 02:39 UTC
oh . i think i was over thinking . LOL
i tend to do that whoops
thanks @llamatarianism
CamperBot
@camperbot
Jul 09 2016 02:40 UTC
:cookie: 931 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
techpointyt sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
TechPointYT
@TechPointYT
Jul 09 2016 02:40 UTC
lol
clintonjohn
@clintonjohn
Jul 09 2016 02:40 UTC
Can immutable data obviate the need for a database?
Darshan
@Dave1089
Jul 09 2016 02:40 UTC
@Vanhealen if(typeof obj.propName == 'function') may be
clintonjohn
@clintonjohn
Jul 09 2016 02:41 UTC
or rather be used to create one?
llamatarianism
@llamatarianism
Jul 09 2016 02:41 UTC
well nah not really
clintonjohn
@clintonjohn
Jul 09 2016 02:41 UTC
im wondering what the relationship between immutable and mongodb is
llamatarianism
@llamatarianism
Jul 09 2016 02:41 UTC
cuz it's still stored in memory
patrickcshan
@patrickcshan
Jul 09 2016 02:41 UTC
This message was deleted
This message was deleted
Or how do I get the cool picture
llamatarianism
@llamatarianism
Jul 09 2016 02:41 UTC
you don't want your entire DB to disappear every time you restart the server
patrickcshan
@patrickcshan
Jul 09 2016 02:42 UTC
<script src="https://gist.github.com/patrickcshan/c880e7287055983b13cbbfb15e85461a.js"></script>
clintonjohn
@clintonjohn
Jul 09 2016 02:43 UTC
So mongodb can accommodate immutable data structures, how does mongodn
llamatarianism
@llamatarianism
Jul 09 2016 02:43 UTC
I dunno man
clintonjohn
@clintonjohn
Jul 09 2016 02:43 UTC
ok
llamatarianism
@llamatarianism
Jul 09 2016 02:43 UTC
I don't use mongo
too brittle
Jonathan Mitchell
@Vanhealen
Jul 09 2016 02:43 UTC
@Dave1089 property name is unknown
llamatarianism
@llamatarianism
Jul 09 2016 02:43 UTC
but yeah
Jonathan Mitchell
@Vanhealen
Jul 09 2016 02:43 UTC
@ndburrus property name is unknown
llamatarianism
@llamatarianism
Jul 09 2016 02:43 UTC
immutable.js and a database are in no way comparable
immutable.js just adds some new data types
clintonjohn
@clintonjohn
Jul 09 2016 02:44 UTC
@llamatarianism thanks!
CamperBot
@camperbot
Jul 09 2016 02:44 UTC
clintonjohn sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 932 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
patrickcshan
@patrickcshan
Jul 09 2016 02:45 UTC
This message was deleted
clintonjohn
@clintonjohn
Jul 09 2016 02:48 UTC
I've seen two full stack tutorials for react web apps that don't mention a database
clintonjohn
@clintonjohn
Jul 09 2016 02:49 UTC
only libraries: redux, immutable,
llamatarianism
@llamatarianism
Jul 09 2016 02:49 UTC
are you sure they're for full stack applications?
because if they're focused on react
they're probably just gonna focus on the front end
react is purely a front end thing
also, the app might just not require a db of any kind
clintonjohn
@clintonjohn
Jul 09 2016 02:50 UTC
I see
Wali Gauvin
@Docwali777
Jul 09 2016 02:57 UTC
Need help for NESTING FOR LOOPS- multiply Array = \--

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

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

{
for (var k=0; k < arr[i][j].length; i++)
{
result *= arr[i][j][k];
}

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

do i need to create a variable for arr
TechPointYT
@TechPointYT
Jul 09 2016 02:58 UTC
in the if statements it thinks .push is an object
how could i fix that to add to the array inside the property
Norvin Burrus
@ndburrus
Jul 09 2016 03:00 UTC
@Docwali777 arr is a variable, and given. only two loops are necessary...
note, here (instructions): Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr ...how many sub arrays are there?
TechPointYT
@TechPointYT
Jul 09 2016 03:01 UTC
anyone ?
Wali Gauvin
@Docwali777
Jul 09 2016 03:02 UTC
@ndburrus there are 3 subarrays?
Norvin Burrus
@ndburrus
Jul 09 2016 03:02 UTC
@Vanhealen any luck?
Wali Gauvin
@Docwali777
Jul 09 2016 03:03 UTC
@ndburrus 1 sub array!
Norvin Burrus
@ndburrus
Jul 09 2016 03:05 UTC
@Docwali777 let's take a look at a sample test function call: multiplyAll([[1],[2],[3]]); here we have the whole thing: [[1],[2],[3]]as an array, that's one (1). next we have an inner level, of arrays: [1], [2], and [3]that makes two (levels of arrays)...
or one/1 array, and one /1 subarray... per se
clear as mud?
Jonathan Mitchell
@Vanhealen
Jul 09 2016 03:06 UTC
@ndburrus not at all
Wali Gauvin
@Docwali777
Jul 09 2016 03:07 UTC
@ndburrus I deleted my erroneously added array.. Now I have two... I am getting an error - object not found for arr[i].length
willcodes
@willcodes
Jul 09 2016 03:07 UTC
anyone around?
Norvin Burrus
@ndburrus
Jul 09 2016 03:07 UTC
@Docwali777 did you adjust the result calculation?
Jonathan Mitchell
@Vanhealen
Jul 09 2016 03:08 UTC
@ndburrus I need a simple way, inside of one conditional statement to check if an object contains a value that is a function without knowing the propertyname that holds that function
var myObj = {
  prop: function(){},
  propp: undefined
}

if (ENTER conditional here) {
  return ‘{}'
}

I cant use Object.contains(function), or Object.includes(function)

there has to be a way of using (typeof value === ‘function) or something but Its difficult

willcodes
@willcodes
Jul 09 2016 03:09 UTC
```js

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


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

  for(var i = 0; i < contacts.length; i++){
    if (contacts.firstName[i] === firstName)
    {
      contactFound = true;
      if ((contacts[i]).hasOwnProperty(prop)); {
        return contacts[i].prop;
      }}
      else { 
      return "No such Property";
      }
        }
  if (contactFound === true) {
    return contacts[i];
  }
  else {
    return "No such contact";
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
JohnWright24
@JohnWright24
Jul 09 2016 03:10 UTC
Hey guys, I'm working on the "Quoting Strings with Single Quotes"
exercise. Can anyone help me solve it?
willcodes
@willcodes
Jul 09 2016 03:10 UTC
I know common question but I'm having a hard time with the explanations
patrickcshan
@patrickcshan
Jul 09 2016 03:10 UTC
@willcodes does your code work and you want an explanation, or does it not work and you want to get it fixed + explanation?
Norvin Burrus
@ndburrus
Jul 09 2016 03:11 UTC
@Vanhealen so, you want to determine if myObj.prop == function() ?
willcodes
@willcodes
Jul 09 2016 03:11 UTC
doesnt work and need explain lol
patrickcshan
@patrickcshan
Jul 09 2016 03:11 UTC
ok
gimme a second
Peter Weinberg
@no-stack-dub-sack
Jul 09 2016 03:11 UTC
so this code is working fine as is in codepen, but can anyone tell me why it doesn't work when I wrap the javascript in $(document).ready(function(){ --code here-- }) ??
<form action="" onsubmit="callWikiApi(); return false;">
  <input type="text" placeholder="Enter Search..." id="searchString"/>
</form>

<script>
  function callWikiApi() {
           var searchTerms = document.getElementById('searchString').value;
         searchTerms = searchTerms.split(" ");
         searchTerms = searchTerms.join("%");
         console.log(searchTerms)
         $.getJSON("https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=" + searchTerms + "&format=json&callback=?&utf8=", function(json) {
    console.log(json);
  });
       };
</script>
willcodes
@willcodes
Jul 09 2016 03:11 UTC
I dont really want the solution lol I think I need step by step
Pericles
@periman2
Jul 09 2016 03:11 UTC
hello there
I have a problem with the counting cards challenge
can someone help me ?
Norvin Burrus
@ndburrus
Jul 09 2016 03:12 UTC
@periman2 can you post?
Pericles
@periman2
Jul 09 2016 03:12 UTC

function cc(card) {
// Only change code below this line
var res;
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count-=1;
break;
}
if (count<=0){
res=count+"Hold";
}
else
res=count+"Bet";

return res;

that's the code
so far
patrickcshan
@patrickcshan
Jul 09 2016 03:12 UTC
@willcodes I think you have an extra parenthesis while you are returning the property if it has it
Pericles
@periman2
Jul 09 2016 03:12 UTC
what's wrong with it?
patrickcshan
@patrickcshan
Jul 09 2016 03:12 UTC
@willcodes if ((contacts[i]).hasOwnProperty(prop)); {
return contacts[i].prop;
}}
and also you should get rid of that semicolon after the if statement.
David Di Feo
@ddifeo
Jul 09 2016 03:13 UTC
@periman2 I think you need a space between the quotation and Hold. Same for Bet
Norvin Burrus
@ndburrus
Jul 09 2016 03:13 UTC
@periman2 add a space to the output... (hold/bet)
Wali Gauvin
@Docwali777
Jul 09 2016 03:14 UTC
@ndburrus yes.... Here is the updated code that is getting an error ////
for (var i = 0; i < arr.length; i++)
{
product = arr[i];
}
for (var j = 0; j < arr[i].length; i++)
{
product
= arr[i][j];
}
// Only change code above this line
return product;
}
Pericles
@periman2
Jul 09 2016 03:14 UTC
still doesn't work ..
JJMin
@JJMin
Jul 09 2016 03:14 UTC
blob
Any idea's why this isn't working :(
Pericles
@periman2
Jul 09 2016 03:15 UTC
wait it works
wrong side of space
omg I can't believe that they haven't let that error slide xD
@realxtensive @ndburrus Thank you !
CamperBot
@camperbot
Jul 09 2016 03:15 UTC
periman2 sends brownie points to @realxtensive and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 889 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 293 | @realxtensive |http://www.freecodecamp.com/realxtensive
patrickcshan
@patrickcshan
Jul 09 2016 03:15 UTC
@willcodes
@willcodes basically, your logic is correct, it's just misplaced brackets and semicolons.
Norvin Burrus
@ndburrus
Jul 09 2016 03:16 UTC
@Docwali777 we handle the product calculation based on the considering both iterations, right? so this: product = arr[i]; is not needed. make sense?
awalaja
@awalaja
Jul 09 2016 03:16 UTC
hello everyone
pls can someone help me with this

var userAge = parseInt(prompt("Please enter your age:")};

if (userAge == 0){
alert("So you are a baby!");
else if (userAge < 0 || userAge > 200)
alert("I think you may be lying about your age");
else
alert("That is a good age");
}

willcodes
@willcodes
Jul 09 2016 03:16 UTC
@patrickcshan something is misplaced still
Wali Gauvin
@Docwali777
Jul 09 2016 03:16 UTC
@JJMin you have the right concept but the order is wrong....
awalaja
@awalaja
Jul 09 2016 03:16 UTC
it does not work
Rajdeep Roy
@RajdeepRoy
Jul 09 2016 03:17 UTC

Can anyone help me with the Palindrome challenge. function palindrome(str) {
// Good luck!
var z=1;
var a=[];
for (j=0;j<=str.length-1;j++){
if (str[j]===" " || str[j]==="-" || str[j]==="_" || str[j]==="/" || str[j]==="."){

}
else {
  a.push(str[j]);
}

}

for (i=0;i<=a.length-1;i++){
if (a[i]==a[a.length-1]){
z += 1;
}
else {
z +=0;
}
}
if (z===str.length){
return true;
}
else {
return false;
}
}

palindrome("_eye");

patrickcshan
@patrickcshan
Jul 09 2016 03:17 UTC
@willcodes can you post your code in here again?
Norvin Burrus
@ndburrus
Jul 09 2016 03:17 UTC
@periman2 details, details.... nice work :cake:
Jonathan Mitchell
@Vanhealen
Jul 09 2016 03:18 UTC
@ndburrus no I want to determine if myObj contains a value that is a function.
Wali Gauvin
@Docwali777
Jul 09 2016 03:18 UTC
@ndburrus do I put--- product*=
Jonathan Mitchell
@Vanhealen
Jul 09 2016 03:18 UTC
@ndburrus as in, if myObj holds a key:value pair, and the value is a function
Wali Gauvin
@Docwali777
Jul 09 2016 03:20 UTC
@JJMin youhave the right conce
Norvin Burrus
@ndburrus
Jul 09 2016 03:20 UTC
@Docwali777 :point_up: July 8, 2016 11:16 PM also, here: result *= arr[i][j][k]; remove the third loop information... getting clearer?
willcodes
@willcodes
Jul 09 2016 03:20 UTC

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


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

  for(var i = 0; i < contacts.length; i++){
    if (contacts.firstName[i] === firstName)
    {
      contactFound = true;
      if ((contacts[i]).hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      else  
      return "No such property";

    }
  }
  if (contactFound === true) {
    return contacts[i];
  }

  else    
    return "No such contact";


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
I changed it a bit but now i'm getting cannot read property of 0

patrickcshan
@patrickcshan
Jul 09 2016 03:20 UTC
@willcodes
In your first if statement you also call
contacts.firstName[i] === firstName
instead of:
contacts[i].firstName === firstName
Joseph
@revisualize
Jul 09 2016 03:21 UTC
@willcodes (contacts[i]) ????
willcodes
@willcodes
Jul 09 2016 03:21 UTC
shooot
Joseph
@revisualize
Jul 09 2016 03:21 UTC
about @revisualize
CamperBot
@camperbot
Jul 09 2016 03:21 UTC
:star2: 1391 | @revisualize |http://www.freecodecamp.com/revisualize
Wali Gauvin
@Docwali777
Jul 09 2016 03:22 UTC
@JJMin you have tghe right concept... Start with changing the order.....also you a hint is you need to start. By if () { if
willcodes
@willcodes
Jul 09 2016 03:22 UTC
@patrickcshan thanks
CamperBot
@camperbot
Jul 09 2016 03:22 UTC
willcodes sends brownie points to @patrickcshan :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @patrickcshan |http://www.freecodecamp.com/patrickcshan
Joseph
@revisualize
Jul 09 2016 03:22 UTC
@willcodes I'm going to PM you.
willcodes
@willcodes
Jul 09 2016 03:22 UTC
@patrickcshan that was the trick
patrickcshan
@patrickcshan
Jul 09 2016 03:22 UTC
@willcodes
your logic is correct though:
you are running through the list of contacts.
if you find it -> check for property -> if property there give them property. If it is not there, say no property.
If you don't find it -> you tell them you don't have the person.
willcodes
@willcodes
Jul 09 2016 03:22 UTC
@revisualize i got it
Wali Gauvin
@Docwali777
Jul 09 2016 03:23 UTC
@ndburrus yes I remove the third loop
for (var i = 0; i < arr.length; i++)
{
product = arr[i];
}
for (var j = 0; j < arr[i].length; i++)
{
product
= arr[i][j];
}
// Only change code above this line
return product;
}
Joseph
@revisualize
Jul 09 2016 03:23 UTC
@willcodes So, I still PM'd you.
patrickcshan
@patrickcshan
Jul 09 2016 03:23 UTC
@willcodes
There's a few more things you could do to make it a bit more efficient (you could cut out the "Contact found step" entirely).
But that's a really small thing.
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:23 UTC
im confused with the Stand in Line challenge can anybody help me out please?
Joseph
@revisualize
Jul 09 2016 03:24 UTC
@holy-jowi Sure.
@holy-jowi
// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // Add the number to the end of the array,

    // then remove the first element of array.
    // The nextInLine function should 
    // then return the element that was removed.
    return item; // Change this line
}
JJMin
@JJMin
Jul 09 2016 03:25 UTC
how do i add an array to a JSON
Joseph
@revisualize
Jul 09 2016 03:25 UTC
@holy-jowi How do you add a number (item) to the end of an array (arr)?
@holy-jowi How do you remove the first element from an array (arr) ?
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:25 UTC
how do i add?
@revisualize
Joseph
@revisualize
Jul 09 2016 03:26 UTC
@JJMin myObj["array_name"] = [];
@holy-jowi That is what I'm asking you.
JJMin
@JJMin
Jul 09 2016 03:26 UTC
Record Collection
You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.
how do i add an array to this
Joseph
@revisualize
Jul 09 2016 03:26 UTC
@JJMin How do you create an array?
JJMin
@JJMin
Jul 09 2016 03:27 UTC
blob
Joseph
@revisualize
Jul 09 2016 03:27 UTC
@JJMin Thanks for that.
CamperBot
@camperbot
Jul 09 2016 03:27 UTC
revisualize sends brownie points to @jjmin :sparkles: :thumbsup: :sparkles:
:cookie: 211 | @jjmin |http://www.freecodecamp.com/jjmin
Joseph
@revisualize
Jul 09 2016 03:27 UTC
@JJMin How do you create an array?
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:27 UTC
@revisualize with .push() right?
Joseph
@revisualize
Jul 09 2016 03:27 UTC
@holy-jowi Okay.
@holy-jowi Next question?
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:28 UTC
@revisualize and to remove you use .shift()
Joseph
@revisualize
Jul 09 2016 03:28 UTC
@holy-jowi Great.
@holy-jowi How are you stuck with the challenge?
JJMin
@JJMin
Jul 09 2016 03:28 UTC
I don't know
Joseph
@revisualize
Jul 09 2016 03:29 UTC
@JJMin Let me get this straight.. You're currently at Record Collection and you don't know how to create a basic array?
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:30 UTC

```function nextInLine(arr, item) {
// Your code here
arr.push();
item = arr.shift();

return item; // Change this line
}``` this is what i thought the answer was but im not exactly sure what it is im doing wrong

Joseph
@revisualize
Jul 09 2016 03:31 UTC
@holy-jowi Look up Shift()
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:31 UTC
@revisualize how do i take the code and show it the way you did when you first mentioned me?
Joseph
@revisualize
Jul 09 2016 03:31 UTC
@holy-jowi Also, re-read the text.
@holy-jowi How do you add a number (item) to the end of an array (arr)?
help .push
CamperBot
@camperbot
Jul 09 2016 03:32 UTC

:point_right: challenge manipulate arrays with push [wiki]

Challenge Manipulate Arrays With push

Not only can you pop() data off of the end of an array, you can also push() data onto the end of an array.

myArray.push(["dog", 3]);

:pencil: read more about challenge manipulate arrays with push on the FCC Wiki

Norvin Burrus
@ndburrus
Jul 09 2016 03:32 UTC
@holy-jowi this may be helpful: :sparkles:
JJMin
@JJMin
Jul 09 2016 03:33 UTC
blob
Joseph
@revisualize
Jul 09 2016 03:33 UTC

Record Collection: (I have added the instructions to the comments.)

// Write a function which takes an album's id (like 2548), 
// a property prop (like "artist" or "tracks"), 
// and a value (like "Addicted to Love")
function updateRecords(id, prop, value) {
// If prop isn't "tracks" and value isn't blank, 
// update or set the value for that record album's property.
    // Your code here

// If prop is "tracks" and value isn't blank, 
// push the value onto the end of the album's existing tracks array.
  // If prop is "tracks" but the album doesn't have a "tracks" property, 
  // create an empty array before adding the new value to the album's 
  // corresponding property.
    // Your code here

// If value is blank, 
// delete that property from the album.
    // Your code here

  return collection;
}

Hints:
Use bracket notation when accessing object properties with variables.
https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables

Push is an array method you can read about on Mozilla Developer Network.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push

Extra Hint:
Testing Objects for Properties
https://www.freecodecamp.com/challenges/testing-objects-for-properties

Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:33 UTC
@ndburrus okay im going to check it out right now!
Norvin Burrus
@ndburrus
Jul 09 2016 03:34 UTC
@holy-jowi i think you'll like it :+1:
Joseph
@revisualize
Jul 09 2016 03:36 UTC
@JJMin Look that over.
Florencia
@flopywood
Jul 09 2016 03:36 UTC
Hello, can anyone help me?
Joseph
@revisualize
Jul 09 2016 03:37 UTC
@flopywood Depends.
Florencia
@flopywood
Jul 09 2016 03:37 UTC
I need help with the challenge "Use Objects for Lookups"
  var val = {
     alpha: "Adams",
     bravo: "Boston",
     charlie: "Chicago",
     delta: "Denver",
     echo: "Easy",
     foxtrot: "Frank"
  };
Joseph
@revisualize
Jul 09 2016 03:37 UTC
@flopywood What is the object supposed to be called?
Florencia
@flopywood
Jul 09 2016 03:37 UTC
@revisualize Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Joseph
@revisualize
Jul 09 2016 03:38 UTC
Great.
@flopywood What is your object named?
Florencia
@flopywood
Jul 09 2016 03:39 UTC
lookup?
Joseph
@revisualize
Jul 09 2016 03:39 UTC
@flopywood It is?
Florencia
@flopywood
Jul 09 2016 03:39 UTC
oh no its val
Joseph
@revisualize
Jul 09 2016 03:39 UTC
Not from the code that you posted.
Wali Gauvin
@Docwali777
Jul 09 2016 03:39 UTC

@ndburrus function multiplyAll(arr) {
var product = 1;
// Only change code below this line

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

Florencia
@flopywood
Jul 09 2016 03:39 UTC
yeah right I'll change it
Ok great changed
still not working I need to do something else with the result
Joseph
@revisualize
Jul 09 2016 03:40 UTC
@flopywood How do you "Accessing Objects Properties with Variables"?
Florencia
@flopywood
Jul 09 2016 03:41 UTC
ahhhhhhh
JJMin
@JJMin
Jul 09 2016 03:43 UTC
could someone show me their solution to Record Collection problem set
Joseph
@revisualize
Jul 09 2016 03:44 UTC
@JJMin Could you show me your solution?
@JJMin Look, I'm not trying to be an ass here.. But, Record Collection is a CheckPoint that takes all of your previous knowledge about working with JavaScript Objects and ties them ALL together.
@JJMin Working with objects is critical if you want to move into the industry.
@JJMin You need to understand the whole group if you want to pass the challenge.
@JJMin You have MOST of the code. You just need to add an extra if statement.
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:46 UTC
thanks @revisualize
CamperBot
@camperbot
Jul 09 2016 03:46 UTC
holy-jowi sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1392 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 09 2016 03:46 UTC
@holy-jowi :+1:
@JJMin Look, if you want to say.. F IT! You can.. I have two different answers on my profile page in my code base. But, I implore you to understand the problem and solve it on your own.
In fact, I need to update it with the new instruction set.
Jowi Nyangweso
@holy-jowi
Jul 09 2016 03:48 UTC
@revisualize i usually dont ask for help because i feel like im bothering people but i appreciate the help!
Joseph
@revisualize
Jul 09 2016 03:49 UTC
@holy-jowi You're good... I ask for help all the time.
Florencia
@flopywood
Jul 09 2016 03:49 UTC
@holy-jowi helping each other is the reason for this community but what you shouldn't do is ask for the result without trying to solve it on your own first
lettda
@lettda
Jul 09 2016 03:50 UTC
What does it mean by "str.splice() is not a function"?
Wali Gauvin
@Docwali777
Jul 09 2016 03:51 UTC
Help with nesting for LOOPs
CamperBot
@camperbot
Jul 09 2016 03:51 UTC
no wiki entry for: with nesting for loops
Wali Gauvin
@Docwali777
Jul 09 2016 03:51 UTC

for (var i=0; i < arr.length; p++)
{
for (var j = 0; j <= arr[i].length; i++)
{
product = arr[i][j] * product;

}

}

Joseph
@revisualize
Jul 09 2016 03:52 UTC
@lettda Are you trying to .splice() a string?
lettda
@lettda
Jul 09 2016 03:52 UTC
yea
Joseph
@revisualize
Jul 09 2016 03:52 UTC
@lettda Prove it.
lettda
@lettda
Jul 09 2016 03:52 UTC

function truncateString(str, num) {
  //if length of string is longer than num
  if (str.length > num) {
      //truncate to length of num
    return str.splice(0, num) + "...";
  }
  return false;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Joseph
@revisualize
Jul 09 2016 03:53 UTC
@lettda Well, that's your problem.
@lettda Array.prototype.splice()
@lettda There is no String.splice() method.
lettda
@lettda
Jul 09 2016 03:54 UTC
@revisualize String.prototype.slice() is what it give me
@lettda so the challenge lied to me? --
Joseph
@revisualize
Jul 09 2016 03:55 UTC
@lettda It did?
lettda
@lettda
Jul 09 2016 03:55 UTC
@revisualize yea that's the helplink for that algorithm
Joseph
@revisualize
Jul 09 2016 03:55 UTC
@lettda String.prototype.slice() is what the link gave you... But... str.splice(0,
slice vs splice ?
lettda
@lettda
Jul 09 2016 03:56 UTC
..........
Florencia
@flopywood
Jul 09 2016 03:56 UTC
@revisualize I have a question
var lookup = {
     alpha: "Adams",
     bravo: "Boston",
     charlie: "Chicago",
     delta: "Denver",
     echo: "Easy",
     foxtrot: "Frank"
  };

var phoneticLookup = #;
lookup[result];
lettda
@lettda
Jul 09 2016 03:56 UTC
no one saw that carry on
Joseph
@revisualize
Jul 09 2016 03:56 UTC
@lettda :)
@flopywood That isn't correct.
@flopywood Instructions
Convert the switch statement into a lookup table called lookup. <-- You've done this.
Use it to lookup val and assign the associated string to the result variable.
Florencia
@flopywood
Jul 09 2016 03:57 UTC
@revisualize yeah, I know. It's just that I don't really know how to end the challenge and I've realized I had the same problem in the Accessing Object Properties with Variables challenge.
Joseph
@revisualize
Jul 09 2016 03:58 UTC
@flopywood Slow down and read the instructions .... Use it to .... lookup val and assign it to result variable.
falconpunch12
@falconpunch12
Jul 09 2016 03:59 UTC
can someone please explain to me what im doing wrong here? its for the update records lesson
''' var value = [];
for (var i=0;i<contacts.length;i++){
if (contacts[i][0] == firstName){
if(contacts[i][prop]==prop){
contacts[i][prop].push(value);
}
else{
return "No such contact";
}
}
}'''
CamperBot
@camperbot
Jul 09 2016 03:59 UTC
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Jul 09 2016 03:59 UTC
assign result the lookup val
awalaja
@awalaja
Jul 09 2016 03:59 UTC
var myStr = "\ \ \t \t \r \n"; // Change this line
encoded text?
Joseph
@revisualize
Jul 09 2016 04:00 UTC
var myStr = "\\ \\ \t \t \r \n"; // Change this line ... Which challenge is this?
falconpunch12
@falconpunch12
Jul 09 2016 04:00 UTC
*can someone please explain to me what im doing wrong here? its for the update records lesson
var value = []; for (var i=0;i<contacts.length;i++){ if (contacts[i][0] == firstName){ if(contacts[i][prop]==prop){ contacts[i][prop].push(value); } else{ return "No such contact"; } } }
JJMin
@JJMin
Jul 09 2016 04:00 UTC
@revisualize turns out I didn't even see this part of the question "If prop isn't "tracks" and value isn't blank, update or set the value for that record album's property."...sigh, oh well I figured it out after 15 min of staring down my solution and desperate to give up
@revisualize cheers, thanks for trying to help
CamperBot
@camperbot
Jul 09 2016 04:00 UTC
jjmin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1393 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 09 2016 04:02 UTC
@JJMin There should be no giving up. This can be hard but, if you slow down take your time and read the problems. They give you the answers.
Wali Gauvin
@Docwali777
Jul 09 2016 04:04 UTC
@JJMin took me a week of staring..... And headache and still couldnt do it alone...... Ifyou are desperaste ... Check out the wiki above
Florencia
@flopywood
Jul 09 2016 04:06 UTC
@revisualize OK, I got it. I did it well but I don't fully understand how I did it, like, I passed the challenge but I'm not conscious of what I have to do when I have a challenge like this.
@revisualize
var lookup = {
     alpha: "Adams",
     bravo: "Boston",
     charlie: "Chicago",
     delta: "Denver",
     echo: "Easy",
     foxtrot: "Frank"
  };

  return lookup[val];
@revisualize do you know any other place where I can practice Objects with difficult challenges?
Joseph
@revisualize
Jul 09 2016 04:08 UTC
@flopywood That works but, the instructions state you're supposed to do result = lookup[val]; Then return result;
Florencia
@flopywood
Jul 09 2016 04:08 UTC
oh ok @revisualize I'll change it
@revisualize thanks!!!
CamperBot
@camperbot
Jul 09 2016 04:08 UTC
flopywood sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1394 | @revisualize |http://www.freecodecamp.com/revisualize
falconpunch12
@falconpunch12
Jul 09 2016 04:09 UTC
@revisualize do you have a sec to look at my code? having trouble with profile lookup
Joseph
@revisualize
Jul 09 2016 04:09 UTC
@falconpunch12 Just the function please.
@falconpunch12 The object is too large.
falconpunch12
@falconpunch12
Jul 09 2016 04:10 UTC
gotcha, its
var value = [];
for (var i=0;i<contacts.length;i++){
if (contacts[i][0] == firstName){
if(contacts[i][prop]==prop){
contacts[i][prop].push(value);
}
else{
return "No such contact";
}
sorry not sure how to enter it into the black window...
Joseph
@revisualize
Jul 09 2016 04:10 UTC
help format
CamperBot
@camperbot
Jul 09 2016 04:10 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Joseph
@revisualize
Jul 09 2016 04:10 UTC
```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
```
@falconpunch12 @falconpunch12 That isn't the function.. That's part of the function.
falconpunch12
@falconpunch12
Jul 09 2016 04:11 UTC
function lookUpProfile(firstName, prop){
// Only change code below this line
  var value = [];
for (var i=0;i<contacts.length;i++){
  if (contacts[i][0] == firstName){
    if(contacts[i][prop]==prop){
     contacts[i][prop].push(value); 
    }
    else{
      return "No such contact";
    }

  }
}
// Only change code above this line
}
sorry
i feel like im completely butchering this..
Joseph
@revisualize
Jul 09 2016 04:13 UTC
@falconpunch12 Okay... That isn't correct. If the (contacts[i][0] == firstName) ... that means the contact exists.
David Di Feo
@ddifeo
Jul 09 2016 04:13 UTC
@flopywood I suggest re reading/ re doing the challenge, Accessing Objects Properties with Variables. Objects can be confusing when you are first starting out and sometimes re reading the explanation really helps to understand. Also objects are pretty important, so its best to learn them now than later
Joseph
@revisualize
Jul 09 2016 04:13 UTC
@falconpunch12 Let me back up for a second and ask you some questions.. Side bar this problem for a second.
falconpunch12
@falconpunch12
Jul 09 2016 04:13 UTC
ok
Joseph
@revisualize
Jul 09 2016 04:14 UTC
log
CamperBot
@camperbot
Jul 09 2016 04:14 UTC
Archives for HelpJavaScript
Joseph
@revisualize
Jul 09 2016 04:14 UTC
Grr... One second.
falconpunch12
@falconpunch12
Jul 09 2016 04:14 UTC
k
Florencia
@flopywood
Jul 09 2016 04:15 UTC
@realxtensive thanks!!!!!
CamperBot
@camperbot
Jul 09 2016 04:15 UTC
flopywood sends brownie points to @realxtensive :sparkles: :thumbsup: :sparkles:
:cookie: 294 | @realxtensive |http://www.freecodecamp.com/realxtensive
Joseph
@revisualize
Jul 09 2016 04:16 UTC
@falconpunch12 I found what I'm looking for...
@falconpunch12 Okay.. Ready.. New though process.
Let's say .. I am standing directly in front of you.. and I have a deck of cards in my hand.
Now.. I shuffle them. And pull out a random chunk.
Then I burn the random chunk that I pulled out. I don't know what they were.. You don't know what they were.
I hand you the new stack of cards and ask you for one.
falconpunch12
@falconpunch12
Jul 09 2016 04:17 UTC
sorry, are you asking me or flopy?
Joseph
@revisualize
Jul 09 2016 04:18 UTC
Fixed.
falconpunch12
@falconpunch12
Jul 09 2016 04:18 UTC
gotcha, i read it and im following you so far
Juan Moraza
@Morazajuan
Jul 09 2016 04:19 UTC
whats wrong with my code:

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

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

    if (str[i]==alp[j]){
      if((j+13)>26){
        var sum =(j+13)-26;
         str [i] = alp[sum];

      }else{

        str [i] = alp[j+13];

      }
    }
  }

}

  return str;
}

// Change the inputs below to test
rot13(("SERR CVMMN!"));
Joseph
@revisualize
Jul 09 2016 04:19 UTC
@falconpunch12 First you need to look through the stack. (The whole stack) ... If the card is there... you can stop and ...
You hand it to me.
But, to know that the card isn't there.. You need to still go through all of them first.
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:19 UTC
Need help in javascript Seek and Destroy algo
rohanshah2599
@rohanshah2599
Jul 09 2016 04:19 UTC

Can anybody help me solve this: https://www.freecodecamp.com/challenges/stand-in-line

i am unable to understand what to do!

Juan Moraza
@Morazajuan
Jul 09 2016 04:19 UTC
it should return " FREE PIZZA!"
and instead returns "feee cimm"null"!"
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:20 UTC
@rohanshah2599 whats the prob
Joseph
@revisualize
Jul 09 2016 04:20 UTC
@rohanshah2599
// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // Add the number to the end of the array,

    // then remove the first element of array.
    // The nextInLine function should 
    // then return the element that was removed.
    return item; // Change this line
}
David Di Feo
@ddifeo
Jul 09 2016 04:21 UTC
@rohanshah2599 lets take it step by step. it first asks you to add the number to the end of the array. how would you do this?
Joseph
@revisualize
Jul 09 2016 04:21 UTC
@rohanshah2599
How do you add a number (item) to the end of an array (arr)?
How do you remove the first element from an array (arr) ?
falconpunch12
@falconpunch12
Jul 09 2016 04:21 UTC
hmm ok, im following you so far
Joseph
@revisualize
Jul 09 2016 04:21 UTC
@falconpunch12 Do you see where I'm going with the side example?
@falconpunch12 How does that directly play into this challenge?
rohanshah2599
@rohanshah2599
Jul 09 2016 04:22 UTC
@revisualize arr + item ?
Joseph
@revisualize
Jul 09 2016 04:22 UTC
@rohanshah2599 Sorry, that's not it.
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:23 UTC
@revisualize sir would u please help me in seek and Destroy algo in javascript
Clark Weckmann
@clarkhacks
Jul 09 2016 04:24 UTC
i would like to send a string (url) to goo.gl and then retrieve the output to display on my website. Can someone help me? I've been struggling with this for awhile and so have a few of my friends.
Joseph
@revisualize
Jul 09 2016 04:24 UTC
@abhishekdevinfo Let me give you a bit of understanding.. Seek and Destroy took me two hours a day across four days ... I then skipped it and came back to it after completing another challenge.
falconpunch12
@falconpunch12
Jul 09 2016 04:24 UTC
it looks like i may be focusing on a single portion of each array? I need to filter through everything because the properties can be anywhere?
Joseph
@revisualize
Jul 09 2016 04:25 UTC
@falconpunch12 What if the last contact in the list is the one you're looking for?
@abhishekdevinfo I do NOT like that challenge.
falconpunch12
@falconpunch12
Jul 09 2016 04:26 UTC
@revisualize it was my understanding that this line would guide the function through the entire array for (var i=0;i<contacts.length;i++)
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:27 UTC
@revisualize if u dont mind
i just want to confirm only a line
[1, 2, 3, 1, 2, 3], 2, 3 its not look like an array
falconpunch12
@falconpunch12
Jul 09 2016 04:28 UTC
@revisualize or do i need to follow up with something like this for(var x=0;contacts[i].length;x++) and then filter through each item
*property
Joseph
@revisualize
Jul 09 2016 04:29 UTC
@falconpunch12 Check through the object check if the object value matches the first name... if it does ... check if it has the property. After you get through the whole object.. You didn't find the object value that matched so.. you output that you didn't find a match.
@abhishekdevinfo That is not an array.
@abhishekdevinfo It is an argument with an array in it.
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:31 UTC
@revisualize thanks for the link
CamperBot
@camperbot
Jul 09 2016 04:31 UTC
abhishekdevinfo sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1395 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 09 2016 04:32 UTC
@abhishekdevinfo The arguments object is an Array-like object corresponding to the arguments passed to a function.
@abhishekdevinfo Arguments also scope to the function that they are called from.
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:34 UTC
@revisualize thanks for the info
CamperBot
@camperbot
Jul 09 2016 04:34 UTC
abhishekdevinfo sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: abhishekdevinfo already gave revisualize points
Joseph
@revisualize
Jul 09 2016 04:34 UTC
@abhishekdevinfo Do you understand the basics of filter?
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:35 UTC
@revisualize yes i think
Joseph
@revisualize
Jul 09 2016 04:37 UTC
@abhishekdevinfo Any evaluation that returns FALSE is removed.
[true, true, false, false, true].filter( function (x) { return x; });
// => [true, true, true]
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 04:38 UTC
@revisualize i think i have to study more about filter
any link where filter explaned
falconpunch12
@falconpunch12
Jul 09 2016 04:39 UTC
@revisualize is this a better start
function lookUpProfile(firstName, prop){
// Only change code below this line
  var value = [];
for (var i=0;i<contacts.length;i++){
  for(var x=0;contacts[i].length;x++)
  if (contacts[i][x].hasOwnProperty(firstName))
Juan Moraza
@Morazajuan
Jul 09 2016 04:39 UTC
need help... whats wrong with else statement?
it returns the wrong array element...

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

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

    if (str[i]==alp[j]){
      if((j+13)>26){
        var sum =(j+13)-26;
         str [i] = alp[sum];

      }else{
        var sum2 = j+13;
        str [i] = alp[sum2];
      }
    }
  }

}

  return str;
}

// Change the inputs below to test
rot13(("SERR CVMMN!"));
Joseph
@revisualize
Jul 09 2016 04:40 UTC
@falconpunch12 That's better. But, you don't need the second for loop.
silver537
@silver537
Jul 09 2016 04:42 UTC
got this one on first try.
function pairElement(str) {
  var arr= str.split("");
  for(var s=0;s<arr.length;s++){
      switch (arr[s]){
        case "A":
          arr.splice(s,1,[arr[s],"T"]);
          break;

        case "T":
          arr.splice(s,1,[arr[s],"A"]);
          break;

        case "G":
          arr.splice(s,1,[arr[s],"C"]);
          break;

        case "C":
          arr.splice(s,1,[arr[s],"G"]);
          break;
      }
    }
  return arr;
}

pairElement("GCG");
falconpunch12
@falconpunch12
Jul 09 2016 04:42 UTC
@revisualize hmm wouldnt that cause the function to focus on the arrays on a macro level? i throught the second for loop would allow it to look at the contents of each array
Joseph
@revisualize
Jul 09 2016 04:42 UTC
@falconpunch12 "Profile Lookup" ???
bradulz
@bradulz
Jul 09 2016 04:43 UTC
which regex would I need to match all instances except ones at the start?
falconpunch12
@falconpunch12
Jul 09 2016 04:44 UTC
@revisualize ? im sorry i dont understand
Joseph
@revisualize
Jul 09 2016 04:44 UTC
@falconpunch12 I'm asking you if that is the challenge that you're working on.
@falconpunch12 If it is.. You only need 1 for loop.
@falconpunch12 Look at the instructions.. You don't NEED to search the array.
falconpunch12
@falconpunch12
Jul 09 2016 04:46 UTC
@revisualize gotcha, thank you for the clarification
CamperBot
@camperbot
Jul 09 2016 04:46 UTC
falconpunch12 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1396 | @revisualize |http://www.freecodecamp.com/revisualize
bradulz
@bradulz
Jul 09 2016 04:46 UTC
anyone good with regexp?
Juan Moraza
@Morazajuan
Jul 09 2016 04:47 UTC

help help....

need help... whats wrong with else statement?
it returns the wrong array element...
```

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

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

if (str[i]==alp[j]){
  if((j+13)>26){
    var sum =(j+13)-26;
     str [i] = alp[sum];

  }else{
    var sum2 = j+13;
    str [i] = alp[sum2];
  }
}

}

}

return str;
}

// Change the inputs below to test
rot13(("SERR CVMMN!"));
```

CamperBot
@camperbot
Jul 09 2016 04:47 UTC
no wiki entry for: help need help whats wrong with else statementit returns the wrong array elementfunction rot13str lbh qvq vg var alp abcdefghijklmnopqrstuvwxyzsplit str strsplitfor var i 0 istrlength i forvar j 0 jalplength j if strialpj ifj1326 var sum j13-26 str i alpsum else var sum2 j13 str i alpsum2 return str change the inputs below to testrot13serr cvmmn
Juan Moraza
@Morazajuan
Jul 09 2016 04:47 UTC
sorry wrong code
function rot13(str) { // LBH QVQ VG!
  var alp= "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
   str = str.split("");
for (var i =0; i<str.length; i++ ){

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

    if (str[i]==alp[j]){
      if((j+13)>26){
        var sum =(j+13)-26;
         str [i] = alp[sum];

      }else{
        var sum2 = j+13;
        str [i] = alp[sum2];
      }
    }
  }

}

  return str;
}

// Change the inputs below to test
rot13(("SERR CVMMN!"));
this is the right one
silver537
@silver537
Jul 09 2016 04:48 UTC
@Morazajuan you have to use ASCII numbers in order to solve this
Juan Moraza
@Morazajuan
Jul 09 2016 04:48 UTC
somehow at the line " str[i] = alp [sum2];" something weird is going on. because i just plug some other value greater than 13 and it gave me the wrong array element
@silver537 but this should work should it?
Greg Duncan
@GregatGit
Jul 09 2016 04:50 UTC
I keep getting the error TypeError: arr1.indexOf is not a function but can't figure out why
function sym(args) {    
    function mergeArr(arr1, arr2){
        //var arr = [];
        for (var i in arr2){
            if (arr1.indexOf(arr2[i]) === -1)
                arr1 = arr1.push(arr2[i]);
            else
                arr1.splice(i, 1);
        }
        return arr1;
    }
    var arr = mergeArr(arguments[0], arguments[1]);    
  return arr;
}
sym([1, 2, 3], [5, 2, 1, 4]);
Deepak Yadav
@ydeepk
Jul 09 2016 04:52 UTC

Whrerefore art thou cahllange

my code:

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
for(var i = 0; i < collection.length; i++) {
if( collection[i].hasOwnProperty(Object.keys(source)) ) {
for(var key in collection[i]) {
if(collection[i][key] == source[key]) {
arr.push(collection[i]);
}
}
}
}
// Only change code above this line
return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Not working for these two cases:

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 }) should return [{ "a": 1, "b": 2 }, { "a": 1, "b": 2, "c": 2 }].
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 }) should return [{ "a": 1, "b": 2, "c": 2 }].

silver537
@silver537
Jul 09 2016 04:53 UTC
@Morazajuan explain your code.
Nick Irvine
@irvin3
Jul 09 2016 04:53 UTC
hey i was hoping someone could give my Spinal Tap code a lookover? I cant seem to find a way to incorporate a hyphen after uppercase letters that arent followed by a space
Greg Duncan
@GregatGit
Jul 09 2016 04:53 UTC
@irvin3 sure
Deepak Yadav
@ydeepk
Jul 09 2016 04:54 UTC

Whrerefore art thou cahllange

my code:

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
for(var i = 0; i < collection.length; i++) {
if( collection[i].hasOwnProperty(Object.keys(source)) ) {
for(var key in collection[i]) {
if(collection[i][key] == source[key]) {
arr.push(collection[i]);
}
}
}
}
// Only change code above this line
return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Not working for these two cases:

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 }) should return [{ "a": 1, "b": 2 }, { "a": 1, "b": 2, "c": 2 }].
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "c": 2 }) should return [{ "a": 1, "b": 2, "c": 2 }].

Nick Irvine
@irvin3
Jul 09 2016 04:54 UTC

'''function spinalCase(str) {

var pos = str.split('');

for(var i = 0; i < pos.length; i++){
switch(pos[i]){
case ' ':
pos[i] = '-';
break;
case '_':
pos[i] = '-';
break;
}
}

pos = pos.join('');
pos = pos.toLowerCase();

console.log(pos);

}

spinalCase('This Is Spinal Tap');
spinalCase("Teletubbies say Eh-oh");
spinalCase("thisIsSpinalTap");

CamperBot
@camperbot
Jul 09 2016 04:54 UTC
:bulb: to format code use backticks! ``` more info
Nick Irvine
@irvin3
Jul 09 2016 04:54 UTC
function spinalCase(str) {

var pos = str.split('');



for(var i = 0; i < pos.length; i++){
  switch(pos[i]){
    case ' ':
      pos[i] = '-';
      break;
    case '_':
      pos[i] = '-';
      break;
  }
}


pos = pos.join('');
pos = pos.toLowerCase();

console.log(pos);

}

spinalCase('This Is Spinal Tap');
spinalCase("Teletubbies say Eh-oh");
spinalCase("thisIsSpinalTap");
silver537
@silver537
Jul 09 2016 04:55 UTC
@Morazajuan what is this for?
if((j+13)>26){
        var sum =(j+13)-26;
Nick Irvine
@irvin3
Jul 09 2016 04:55 UTC
I feel like i need to use regex or something, I just dont completely understand how to go about that
bradulz
@bradulz
Jul 09 2016 04:55 UTC
/^\s|\s$/gi why won't this get rid of start and end spaces?
target them*
Markus Kiili
@Masd925
Jul 09 2016 04:57 UTC
@ydeepk You need two loops through collection and source keys.
And only push if the property values match for all the source keys, not just one.
Nick Irvine
@irvin3
Jul 09 2016 04:58 UTC
@GregatGit did you see the code I posted?
Ngô Ngọc Đức Huy
@Huy-Ngo
Jul 09 2016 04:58 UTC
@irvin3 use regex for dashes, spaces and A-Z
bradulz
@bradulz
Jul 09 2016 04:58 UTC
@irvin3 whats wrong with it?
Nick Irvine
@irvin3
Jul 09 2016 04:58 UTC
yea thats what im thinking, I guess I need to try to understand regex a little better
@bradulz it doesnt handle the last test case
bradulz
@bradulz
Jul 09 2016 04:59 UTC
@irvin3 oh yeah you need some complex regex for that
Greg Duncan
@GregatGit
Jul 09 2016 04:59 UTC
@irvin3 yes - I think both reg ex and replace - also you can't always just look at the one character - you have to look at teh one before it
Juan Moraza
@Morazajuan
Jul 09 2016 04:59 UTC
@silver537 thats if the array(alp=[a,b,c...z]") j is greater than 26(number of arrays in var alp) then sum will subtract that to 13+j so that gives a value inside the range of the array
Luis Espinal
@lespinalrivera
Jul 09 2016 04:59 UTC
@irvin3 ehat you are trying to do is to getrid of the symbols and spaces?
Deepak Yadav
@ydeepk
Jul 09 2016 05:00 UTC
@Masd925
bradulz
@bradulz
Jul 09 2016 05:00 UTC
@irvin3 http://regexone.com/ this helped me so much
if you have the time
Deepak Yadav
@ydeepk
Jul 09 2016 05:01 UTC
@Masd925 for(var key in obj) loop for source inside the first one ??
Juan Moraza
@Morazajuan
Jul 09 2016 05:01 UTC
@silver537 but that if statmeant gives the right letters! the else statement is the one that gives the weird values
Nick Irvine
@irvin3
Jul 09 2016 05:01 UTC
thanks @bradulz ill give it a look, the regexp notation just looks so foreign to me
CamperBot
@camperbot
Jul 09 2016 05:01 UTC
irvin3 sends brownie points to @bradulz :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @bradulz |http://www.freecodecamp.com/bradulz
Markus Kiili
@Masd925
Jul 09 2016 05:02 UTC
@ydeepk Yes, inner loop over source's keys.
Luis Espinal
@lespinalrivera
Jul 09 2016 05:02 UTC
@irvin3 bro for symbols= W and for spaces = s
Greg Duncan
@GregatGit
Jul 09 2016 05:02 UTC
@irvin3
replace(/ |_/g, '-'); // would do the same
Juan Moraza
@Morazajuan
Jul 09 2016 05:02 UTC
i also try to change it just one value so insted of having str[i] = alp[sum2] i did str[i] = alp[0] and it gave A then i increased it and it kept giving the right value until i reach 14 it went back to letter B from the alphabet
Luis Espinal
@lespinalrivera
Jul 09 2016 05:03 UTC
Yep= replace is the key
So: text.replace(/[\W]+/g, '') will remove all the symbols but not the spaces
Juan Moraza
@Morazajuan
Jul 09 2016 05:05 UTC
    str [i] = alp[14]; gave the latter "B"
but when i change the return to alp14 it gave the right value which is "O". @silver537
Luis Espinal
@lespinalrivera
Jul 09 2016 05:05 UTC
And repeat the replace after to remove the spaces
silver537
@silver537
Jul 09 2016 05:07 UTC
@Morazajuan ah man im stump by your code. im sorry but i cant help you. i did it a different way and im not that well in parsing other people's code.
bradulz
@bradulz
Jul 09 2016 05:08 UTC
/^\s|\s$/ anyone know why this won't match start and ending spaces?
falconpunch12
@falconpunch12
Jul 09 2016 05:10 UTC
would like further guidance with profile lookup if anyone has time
function lookUpProfile(firstName, prop){
// Only change code below this line
  var value = [];
for (var i=0;i<contacts.length;i++){
  if (contacts[i].hasOwnProperty(firstName)){
    if(contacts[i].hasOwnProperty(prop) && contacts[i][firstName] == "firstName"){
     contacts[i][prop].push(value); 
    }
    else{
      return "No such property";
    }
    }
  else{
      return "No such contact";
  }
}
// Only change code above this line
}
Avinash Kuduvalli
@manicmarvin
Jul 09 2016 05:11 UTC
@falconpunch12 What's your question?
falconpunch12
@falconpunch12
Jul 09 2016 05:12 UTC
it isnt going through for me. im not sure where my mistake is honestly
bradulz
@bradulz
Jul 09 2016 05:12 UTC
@falconpunch12 hasOwnProperty('') must be surrounded in quotes
the firstName part
falconpunch12
@falconpunch12
Jul 09 2016 05:13 UTC
hmm, alright ill go ahead and change that. anything else that you see that's off?
Deepak Yadav
@ydeepk
Jul 09 2016 05:14 UTC
@Masd925
Joseph
@revisualize
Jul 09 2016 05:15 UTC
@falconpunch12 You're REALLY close.
@falconpunch12 Can I just PM you?
Deepak Yadav
@ydeepk
Jul 09 2016 05:15 UTC

@Masd925 not woking..

here's the code

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
for(var i = 0; i < collection.length; i++) {
if( collection[i].hasOwnProperty(Object.keys(source)) ) {
for(var key in collection[i]) {
for(var key in source) {
if(collection[i][key] == source[key]) {arr.push(collection[i]); }
}
}
}
}
// Only change code above this li
return arr;
}
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });

bradulz
@bradulz
Jul 09 2016 05:15 UTC
heres a tip: If anything is undefined, equal to 0, null, or NaN, it will return false within an if statement, hasOwnProperty isnt even needed becuase if the property doesn't exist it will ring false anyway
falconpunch12
@falconpunch12
Jul 09 2016 05:15 UTC
@revisualize of course
Avinash Kuduvalli
@manicmarvin
Jul 09 2016 05:17 UTC
This message was deleted
Markus Kiili
@Masd925
Jul 09 2016 05:18 UTC
@ydeepk Make two nested loops. One through collection and one through source keys. Then code inside inner loop block, where you test if the property exists and property values match. If that holds for all the source keys, push.
Norvin Burrus
@ndburrus
Jul 09 2016 05:25 UTC
@Docwali777 here: for (var j = 0; j < arr[i].length; i++) i++ should be j++ , right?
j - inner array/s iterations....
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:33 UTC
Need help
Avinash Kuduvalli
@manicmarvin
Jul 09 2016 05:34 UTC
@abhishekdevinfo With?
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:34 UTC
why this code not working
in seek and destroy algo in java script
bradulz
@bradulz
Jul 09 2016 05:34 UTC
can anyone tell me what return song.split('WUB').filter(Boolean).join(' '); what boolean part does?
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:35 UTC
function destroyer(arr) {
    function check(value) {
        if (value != check.arguments[1] && value != check.arguments[2]) {
            return value;
        }
    }
    var newarr = arguments[0].filter(check);
    return newarr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

i want this

destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1]

bradulz
@bradulz
Jul 09 2016 05:36 UTC
why are you filtering check?
didnt even think you could have nested functions
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:37 UTC
@bradulz to delete/filter the arguments1 and arguments2 from arguments[0]
and i think i am confuse also u use filter and arguments
bradulz
@bradulz
Jul 09 2016 05:38 UTC
var newarr = arguments[0].filter(function(val){return val != arguments1 || val != arguments2});
actually its probably && instead of ||
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:39 UTC
This message was deleted
ok
bradulz
@bradulz
Jul 09 2016 05:40 UTC
theres no need for nested functions either
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:40 UTC
one more think
what if
i dont know how many aruments i have to check
like in this case there are 3 to remove destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return 1.
bradulz
@bradulz
Jul 09 2016 05:41 UTC
oh you have to check if arg4 exists with if(!arguments[4])
what was the challenge name?
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:42 UTC
Seek and Destroy
bradulz
@bradulz
Jul 09 2016 05:43 UTC

function destroyer(arr) {
  // Remove all the values
  a = arguments[1];
  b = arguments[2];
  c = arguments[3];


  arr = arr.filter(function(val){
    return val != a && val != b && val != c;
  });
  return arr;
}
you don't even need to check if it exists
Craig
@zeropoint101
Jul 09 2016 05:44 UTC
Hi everyone.
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:44 UTC
@bradulz but what if there will be more than 3 arguments
bradulz
@bradulz
Jul 09 2016 05:44 UTC
the proper way to do it is to loop through the arguments with arguments.length and then compare each one to cater for any amount of inputs but this is fine
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:45 UTC
ok
@bradulz Thanks for the help
CamperBot
@camperbot
Jul 09 2016 05:45 UTC
abhishekdevinfo sends brownie points to @bradulz :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @bradulz |http://www.freecodecamp.com/bradulz
KnoX
@knox97
Jul 09 2016 05:45 UTC
@abhishekdevinfo you need two loops
bradulz
@bradulz
Jul 09 2016 05:45 UTC
no dramas
KnoX
@knox97
Jul 09 2016 05:45 UTC
one to loop through array
and than one inside of that one
that will loop through array again and see if there is same value as the value of current index
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:46 UTC
ok
Craig
@zeropoint101
Jul 09 2016 05:46 UTC
I have a question about multi-line strings(from a different tutorial site actually). Why do I need to use backslashes for new lines? If my text editor or IDE wraps text anyway, why do I need to create multi-line strings like that? Is it just for code readability for others? or? Am I misunderstanding something?
KnoX
@knox97
Jul 09 2016 05:48 UTC
@zeropoint101 No because when javascript reads the code if there is no \n it will display it single-line
ScottReinmuth
@ScottReinmuth
Jul 09 2016 05:49 UTC
Hello everyone. I have a question about the javascript fahrenheiht project. how should it look with the 9/5 +32?
KnoX
@knox97
Jul 09 2016 05:49 UTC
\n => New Line this wont be printed in your console when you log it @zeropoint101
Craig
@zeropoint101
Jul 09 2016 05:49 UTC
@knox97 I know, but... why would I want to break it up? I haven't done anything really practical yet, but if I'm putting a long paragraph in a webpage somewhere, isn't it already going to wrap inside the html element?
KnoX
@knox97
Jul 09 2016 05:50 UTC
yes it will if you use word-wrap: break-word; in your css
but it all depends on what you want to do
Simon Situ
@ssitu001
Jul 09 2016 05:50 UTC
checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return "Insufficient Funds".
why?
bradulz
@bradulz
Jul 09 2016 05:51 UTC
@knox97 can I see your seek&destroy code? I tried to use for loops but ended up needing 3
KnoX
@knox97
Jul 09 2016 05:51 UTC
but be aware that if you use \n in the text that you will be printing in html it will out put this
<p>Some text\n Not really a new line just a text, but <br>This is a new line</p>
Craig
@zeropoint101
Jul 09 2016 05:51 UTC
@knox97 hm, ok. but don't <p> paragraphs automatically wrap in the div or whatever element they're in? I've never had to use word-wrap: break-word for them to wrap naturally.
KnoX
@knox97
Jul 09 2016 05:52 UTC
@bradulz I didn't finished it I'm on codecademy first to warm up for FCC :D
@bradulz But I'm curious now, why did you need 3? can you send code here if its not too big? or in my private chat
bradulz
@bradulz
Jul 09 2016 05:53 UTC
@knox97 already got rid of it and left it how it was :(
KnoX
@knox97
Jul 09 2016 05:54 UTC
@bradulz I don't know really 3 may actually be the correct answer
I just though of it in my head, but 1.0 in anything is never correct, except for HTML&CSS
lol
bradulz
@bradulz
Jul 09 2016 05:55 UTC
yeah off the top of my head it seemed like 2 as well
but its tricky
KnoX
@knox97
Jul 09 2016 05:56 UTC
I believe its more complex than two loops now that I think about it
  1. loop array
  1. find ones that match to current index
  1. delete recorded indexes
Chance103
@Chance103
Jul 09 2016 05:57 UTC
This message was deleted
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:58 UTC
@bradulz would u please check my code once again i modified it
Craig
@zeropoint101
Jul 09 2016 05:59 UTC
oh well
Chance103
@Chance103
Jul 09 2016 05:59 UTC
This message was deleted
bradulz
@bradulz
Jul 09 2016 05:59 UTC
@abhishekdevinfo sure
Joseph
@revisualize
Jul 09 2016 05:59 UTC
@Chance103 It's there.. I'm in it.
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 05:59 UTC

function destroyer(arr) {
  var argLen = arguments.length;
  var newArr = arguments[0].filter(function(val) {
    for(var i = 1; i <= argLen; i++) {
      if(val != arguments[i]) {
        return val;
      }
    }
  });
  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Chance103
@Chance103
Jul 09 2016 05:59 UTC
This message was deleted
KnoX
@knox97
Jul 09 2016 06:00 UTC
@abhishekdevinfo I think you need to use arr to manage input array
Joseph
@revisualize
Jul 09 2016 06:00 UTC
@abhishekdevinfo Remember that comment that I made about arguments being scoped to the function that is calling them?
KnoX
@knox97
Jul 09 2016 06:01 UTC
aaa, no no, I was wrong arguments is an object
Chance103
@Chance103
Jul 09 2016 06:01 UTC
This message was deleted
Joseph
@revisualize
Jul 09 2016 06:01 UTC
@Chance103 You have a problem. I just refreshed the page.
@revisualize In fact, let me close my web browser. BRB.
bradulz
@bradulz
Jul 09 2016 06:02 UTC
whats the error? One would be that you are using the newarr variable while it is being initialised
@abhishekdevinfo
but what is fcc saying the problem is?
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:02 UTC
@bradulz the result is [1,2,3,1,2,3]
and the error are
destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1].
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1].
destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return 1.
destroyer([2, 3, 2, 3], 2, 3) should return [].
destroyer(["tree", "hamburger", 53], "tree", 53) should return ["hamburger"].
all of them
@bradulz i think the the argument i am using in val function that is work for val arguments not for destroyer
Chance103
@Chance103
Jul 09 2016 06:05 UTC
This message was deleted
This message was deleted
bradulz
@bradulz
Jul 09 2016 06:06 UTC
hard to explain but the values are always being returned because all numbers are not arguments1 or arguments2
@abhishekdevinfo

function destroyer(arr) {
  var argLen = arguments.length;
  var newArr = arguments[0].filter(function(val) {
    for(var i = 1; i <= argLen; i++) {
      if(val != arguments[i]) {
        return val;
      }
    }
  });
  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
one sec
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:06 UTC
ok
Joseph
@revisualize
Jul 09 2016 06:07 UTC
@Chance103 you did. You were soamming.
bradulz
@bradulz
Jul 09 2016 06:07 UTC

function destroyer(arr) {
var verify = true;
  var argLen = arguments.length;
  var newArr = arguments[0].filter(function(val) {
    for(var i = 1; i <= argLen; i++) {
var verify = true;
      if(val != arguments[i]) {
verify = false;

      }
if(verify) return val;
    }
  });
  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@abhishekdevinfo might need to fiddle with the syntax but this is essentially what you need
oh and i initialised verify twice ..
Chance103
@Chance103
Jul 09 2016 06:10 UTC
This message was deleted
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:10 UTC
@bradulz but your code give me [] this result and not fulfill the errors
Joseph
@revisualize
Jul 09 2016 06:10 UTC
@Chance103 With?
bradulz
@bradulz
Jul 09 2016 06:10 UTC
@abhishekdevinfo give me some time, ill perfect it
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:11 UTC
@bradulz noproblem
Chance103
@Chance103
Jul 09 2016 06:11 UTC
This message was deleted
Joseph
@revisualize
Jul 09 2016 06:11 UTC
@Chance103 Name of the lesson?
kirbyedy
@kirbyedy
Jul 09 2016 06:11 UTC
@Chance103 watch the spaces
Joseph
@revisualize
Jul 09 2016 06:11 UTC
I don't remember doing that one.
Chance103
@Chance103
Jul 09 2016 06:12 UTC
This message was deleted
This message was deleted
kirbyedy
@kirbyedy
Jul 09 2016 06:12 UTC
@revisualize they changed it... twice :D
Joseph
@revisualize
Jul 09 2016 06:12 UTC
@Chance103 myStr should have encoded text with the proper escape sequences and no spacing.
KnoX
@knox97
Jul 09 2016 06:13 UTC
carriage return is \r not \n
@Chance103
Chance103
@Chance103
Jul 09 2016 06:13 UTC
This message was deleted
This message was deleted
Joseph
@revisualize
Jul 09 2016 06:13 UTC
@Chance103 Solved it.
That was easy.
Chance103
@Chance103
Jul 09 2016 06:14 UTC
This message was deleted
Joseph
@revisualize
Jul 09 2016 06:14 UTC
@kirbyedy Thanks.
CamperBot
@camperbot
Jul 09 2016 06:14 UTC
revisualize sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1204 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Joseph
@revisualize
Jul 09 2016 06:14 UTC
@Chance103 You have spaces.
kirbyedy
@kirbyedy
Jul 09 2016 06:14 UTC
yes, spaces are important
also @Chance103 you have \n instead of \r
second one
Chance103
@Chance103
Jul 09 2016 06:15 UTC
This message was deleted
KnoX
@knox97
Jul 09 2016 06:15 UTC
@Chance103
var myStr = "FirstLine \n\\SecondLine\\\r ThirdLine"; // Change this line
Joseph
@revisualize
Jul 09 2016 06:15 UTC

@Chance103 Look at the evaluation:
myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \\

FirstLine newline backslash SecondLine backslash carriage-return ThirdLine

var myStr = "FirstLine\n\\SecondLine\\\rThirdLine"; // Change this line
Chance103
@Chance103
Jul 09 2016 06:16 UTC
This message was deleted
This message was deleted
KnoX
@knox97
Jul 09 2016 06:16 UTC
@Chance103 It's all written here
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.
"pasted from lesson"
Joseph
@revisualize
Jul 09 2016 06:16 UTC
INSTRUCTIONZ! I readz themz?
Chance103
@Chance103
Jul 09 2016 06:17 UTC
This message was deleted
Joseph
@revisualize
Jul 09 2016 06:18 UTC
Damn.. I was going to to play pool tonight.
Chance103
@Chance103
Jul 09 2016 06:18 UTC
This message was deleted
CamperBot
@camperbot
Jul 09 2016 06:18 UTC
:warning: chance103 already gave knox97 points
chance103 sends brownie points to @knox97 :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
Jul 09 2016 06:18 UTC
Now it is 1118pm. :(
C'est la vie.
KnoX
@knox97
Jul 09 2016 06:18 UTC
@Chance103 You are welcome
Chance103
@Chance103
Jul 09 2016 06:18 UTC
This message was deleted
Joseph
@revisualize
Jul 09 2016 06:18 UTC
maybe I'll just go to bed instead.
Grab my Surface and head to bed for a little youtube.
KnoX
@knox97
Jul 09 2016 06:18 UTC
where are you from?
@Chance103
Chance103
@Chance103
Jul 09 2016 06:19 UTC
This message was deleted
This message was deleted
Joseph
@revisualize
Jul 09 2016 06:19 UTC
Yeah.. I'm going to take the Surface and head to bed.
:v:
kirbyedy
@kirbyedy
Jul 09 2016 06:19 UTC
@knox97 lovely avatar :D
bradulz
@bradulz
Jul 09 2016 06:19 UTC

function destroyer(arr) {


var verify = true;
  var argLen = arguments.length;

  var newArr = arguments[0].filter(function(val) {//for each array element

    for(var i = 1; i <= argLen; i++) {//for each arg
      verify = true;
        console.log(val);
        console.log(arguments[i]);

      if(val == arguments[i]) {
        verify = false;

      }
      if(verify) return val;
    }
  });
  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@abhishekdevinfo this is what I have so far although I issue with this whole thing. arguments is referring to the filter function not the entire functions args. Ill need to rework it some more
kirbyedy
@kirbyedy
Jul 09 2016 06:19 UTC
@revisualize see ya
KnoX
@knox97
Jul 09 2016 06:19 UTC
@kirbyedy haha thank you
CamperBot
@camperbot
Jul 09 2016 06:19 UTC
knox97 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1205 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Chance103
@Chance103
Jul 09 2016 06:20 UTC
This message was deleted
kirbyedy
@kirbyedy
Jul 09 2016 06:20 UTC
about @knox97
CamperBot
@camperbot
Jul 09 2016 06:20 UTC
:cookie: 183 | @knox97 |http://www.freecodecamp.com/knox97
KnoX
@knox97
Jul 09 2016 06:20 UTC
@kirbyedy by the way man fuck you I refreshed page two times and than realize your picture is actually loaded
:D
kirbyedy
@kirbyedy
Jul 09 2016 06:20 UTC
jebiga :)
KnoX
@knox97
Jul 09 2016 06:21 UTC
opaa
odakle si?
about @kirbyedy
CamperBot
@camperbot
Jul 09 2016 06:21 UTC
:star2: 1205 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Jul 09 2016 06:21 UTC
not living there for the past 10+ years :)
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:22 UTC
@bradulz i am trying also
kirbyedy
@kirbyedy
Jul 09 2016 06:22 UTC
I used to live 100km north from you ;)
KnoX
@knox97
Jul 09 2016 06:22 UTC
You are from balkan?
Subotica?
kirbyedy
@kirbyedy
Jul 09 2016 06:22 UTC
da
KnoX
@knox97
Jul 09 2016 06:22 UTC
nicee
where are you now?
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:22 UTC
Hey guys need help on Stand in Line challenge, cant understand the instructions correctly
kirbyedy
@kirbyedy
Jul 09 2016 06:22 UTC
if I tell you that I will have to hunt you down and kill you :D
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:23 UTC

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

//testArr.pop(); // Change this line
item = testArr.pop();
testArr.push(6);
return item;
}
// Test Setup
var testArr = [5,6,7,8,9];

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

```
KnoX
@knox97
Jul 09 2016 06:23 UTC
oh fuck off liam neeson haha
kirbyedy
@kirbyedy
Jul 09 2016 06:23 UTC
cyprus
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:23 UTC

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

//testArr.pop(); // Change this line
item = testArr.pop();
testArr.push(6);
return item;
}
// Test Setup
var testArr = [5,6,7,8,9];

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

KnoX
@knox97
Jul 09 2016 06:23 UTC
you work there or?
kirbyedy
@kirbyedy
Jul 09 2016 06:23 UTC
yea
KnoX
@knox97
Jul 09 2016 06:23 UTC
are you full stack back front?
kirbyedy
@kirbyedy
Jul 09 2016 06:23 UTC
and no, not as a programmer, this is my free time hobby
KnoX
@knox97
Jul 09 2016 06:24 UTC
so what do you do?
kirbyedy
@kirbyedy
Jul 09 2016 06:24 UTC
only 6months into this, newbie
graphics and crap, printing
KnoX
@knox97
Jul 09 2016 06:24 UTC
Well progress is whats important
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:24 UTC
function nextInLine(testArr, item) {
  // Your code here

  //testArr.pop();  // Change this line
  item = testArr.pop();
  testArr.push(6);
  return item;
}
// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
KnoX
@knox97
Jul 09 2016 06:24 UTC
Thats not bad either
Craig
@zeropoint101
Jul 09 2016 06:25 UTC
Hi. Can someone explain multi-line strings to me? Why would I ever need one? I'm doing a tutorial that says I need to use backslashes for long strings because javascript automatically inserts semicolons at the end of any new lines. I don't understand why I would need this if my text editor or IDE is already wrapping the line, or the html automatically wraps it.
KnoX
@knox97
Jul 09 2016 06:26 UTC
@zeropoint101 Switch to FreeCodeCamp.com, problem solved...
Craig
@zeropoint101
Jul 09 2016 06:26 UTC
anyone with an actual helpful answer?
KnoX
@knox97
Jul 09 2016 06:27 UTC
@zeropoint101 Did you tryed googling it?
Craig
@zeropoint101
Jul 09 2016 06:27 UTC
@knox97 yes
kirbyedy
@kirbyedy
Jul 09 2016 06:27 UTC
@rohogaka you sure you need pop()
KnoX
@knox97
Jul 09 2016 06:27 UTC
I don't know man than
Craig
@zeropoint101
Jul 09 2016 06:28 UTC
@knox97 I didn't expect you specifically to know. Was just hoping someone here did.
bradulz
@bradulz
Jul 09 2016 06:29 UTC
function destroyer(arr) {

var verify = true;
  var argLen = arguments.length;
  var args = [];
  for(var j = 1;j<arguments.length;j++)
    {
      args.push(arguments[j]);

    }

  var newArr = arguments[0].filter(function(val) {//for each array element
    verify = true;
    for(var i = 0; i <= args.length ; i++) {//for each arg

        console.log(val + " " + args[i]);
      if(val == args[i]) {
        verify = false;

      }

    }if(verify) return val;
  });
  return newArr;
}



destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@abhishekdevinfo aaaaaaaaayyy finally
Anoosha keen
@anookeen
Jul 09 2016 06:30 UTC
Can't understand this.
kirbyedy
@kirbyedy
Jul 09 2016 06:30 UTC
@zeropoint101 well I dont know exactly how to explain, but javascript is a bit strange
bradulz
@bradulz
Jul 09 2016 06:30 UTC
@Chance103
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:31 UTC
@bradulz give me some time to understand this
kirbyedy
@kirbyedy
Jul 09 2016 06:31 UTC
@zeropoint101 you might want to check this video from douglas crackford
Anoosha keen
@anookeen
Jul 09 2016 06:31 UTC
nextInLine([],1) returns 0,nextInLine(2, 1) returns 2.
Chance103
@Chance103
Jul 09 2016 06:31 UTC
This message was deleted
Anoosha keen
@anookeen
Jul 09 2016 06:31 UTC
but nextInLine([5,6,7,8,9], 1) does not return 5
Craig
@zeropoint101
Jul 09 2016 06:32 UTC
@kirbyedy well... hmm.. do you happen to know at what point in the hour long video it explains the new line thing?
kirbyedy
@kirbyedy
Jul 09 2016 06:32 UTC
@zeropoint101 around 30min. he explains some styling issues and how javascript interprets the code, so you might understand
Craig
@zeropoint101
Jul 09 2016 06:32 UTC
@kirbyedy derp, whoops
@kirbyedy k thanks ill check it out
CamperBot
@camperbot
Jul 09 2016 06:32 UTC
zeropoint101 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1206 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:32 UTC
@anookeen im stuck on the same part, whats your code?
kirbyedy
@kirbyedy
Jul 09 2016 06:33 UTC
@zeropoint101 but if you have time, watch the whole thing
javascript is weird :)
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:33 UTC
@bradulz u create an array for arguments except arguments then check
awesome trick
@bradulz really appreciates your work
bradulz
@bradulz
Jul 09 2016 06:35 UTC
yeah feels terrible becuase the args were already in an array but had to becuase of the scope. I really wander what the best way to do this is, because I feel like I'm way off but can't imagine any other way
Craig
@zeropoint101
Jul 09 2016 06:35 UTC
@kirbyedy To be honest, I get overwhelmed with videos like that, which is why I like the small chunks on here and codecademy, but I'll try to find the part you're talking about.
Anoosha keen
@anookeen
Jul 09 2016 06:35 UTC

@rohogaka this is my code
function nextInLine(arr, item) {
// Your code here
testArr.push(arr);
item=testArr.shift();
//console.log(testArr);
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([], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
console.log(nextInLine(2, 1));
console.log("After: " + JSON.stringify(testArr));
console.log(nextInLine([5,6,7,8,9], 1));
console.log("After: " + JSON.stringify(testArr));
//console.log(nextInLine(testArr,10));
//console.log("After: " + JSON.stringify(testArr));

Rohit Gaikwad
@rohogaka
Jul 09 2016 06:36 UTC
@anookeen oh ok im doing it differently
kirbyedy
@kirbyedy
Jul 09 2016 06:37 UTC
@anookeen I dont see where you push the item into your array
Anoosha keen
@anookeen
Jul 09 2016 06:38 UTC
@rohogaka testArr.push(arr);
what is your code??
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:38 UTC
did you try testArr.push(arr);
Anoosha keen
@anookeen
Jul 09 2016 06:38 UTC
yes
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:38 UTC
sorry testArr.push(item);
Anoosha keen
@anookeen
Jul 09 2016 06:38 UTC
lemme see
it works but does not return 5
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:42 UTC
@anookeen same :(
@anookeen tbh i dint quite understand the instructions on this one
Craig
@zeropoint101
Jul 09 2016 06:43 UTC
@kirbyedy hey. ok i think i watched the part you were referring to. I understand automatic semicolon insertion(well enough for now at least), but what I'm trying to understand is this... it's only going to do that if I hit enter, therefore creating a newline, correct? So if I'm just writing a long paragraph, and not entering any newlines, is there some reason I'd need to break up the string to be multi-line instead of just letting it wrap normally? Does that make sense?
Anoosha keen
@anookeen
Jul 09 2016 06:43 UTC
me too
Craig
@zeropoint101
Jul 09 2016 06:47 UTC
did everyone leave?
Anoosha keen
@anookeen
Jul 09 2016 06:47 UTC
@rohogaka is there anyway to go to next task, leaving the previous one?
Mustafijur rahman
@Dinar717
Jul 09 2016 06:48 UTC
@anookeen yes . just click the next lesson link from freecodecamp.com/map
Craig
@zeropoint101
Jul 09 2016 06:48 UTC
does anyone else know the answer to my question asked above?
i guess kirby left
bradulz
@bradulz
Jul 09 2016 06:50 UTC
@abhishekdevinfo apparently var args = Array.prototype.slice.call(arguments,1); works instead of that first for statement. Just for future reference
Anoosha keen
@anookeen
Jul 09 2016 06:50 UTC
@Dinar717 thank you.
CamperBot
@camperbot
Jul 09 2016 06:50 UTC
anookeen sends brownie points to @dinar717 :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @dinar717 |http://www.freecodecamp.com/dinar717
Mustafijur rahman
@Dinar717
Jul 09 2016 06:50 UTC
@anookeen :+1:
Abhishek Baliyan
@abhishekdevinfo
Jul 09 2016 06:50 UTC
@bradulz ok
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:52 UTC
@anookeen so you skipped that part then?
Anoosha keen
@anookeen
Jul 09 2016 06:53 UTC
Yes I skipped that
I will return to it
afterwards
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:54 UTC
@rohogaka hmm ok, wish my OCD would let me do the same lol
Craig
@zeropoint101
Jul 09 2016 06:55 UTC
@rohogaka you just said that to yourself. :P
@rohogaka i think you might have MPD as well as OCD
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:55 UTC
@zeropoint101 i know so tired i couldnt bother changing it, and right, MPD as well
FML
Craig
@zeropoint101
Jul 09 2016 06:56 UTC
@rohogaka lol, i understand about the OCD though. it's truly hindering to my learning process here
Keone Martin
@Athaman
Jul 09 2016 06:56 UTC
morning folks
Craig
@zeropoint101
Jul 09 2016 06:56 UTC
@Athaman morning
Keone Martin
@Athaman
Jul 09 2016 06:57 UTC
any outstanding questions? too lazy to scroll up >.>
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:58 UTC
@Athaman yes sir, stand in line challenge
Craig
@zeropoint101
Jul 09 2016 06:58 UTC
@Athaman i have one. lemme find it cuz IM too lazy to retype it lol
Keone Martin
@Athaman
Jul 09 2016 06:58 UTC
@anookeen if you haven't gotten a solution yet you need to be using arr not testArr inside your function. otherwise should be ok
@rohogaka send us your code so far?
Rohit Gaikwad
@rohogaka
Jul 09 2016 06:58 UTC

function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);

  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));
just need to write a line to pop
Mustafijur rahman
@Dinar717
Jul 09 2016 06:59 UTC
@rohogaka you only pushed . remove one from first of the array with shift
Keone Martin
@Athaman
Jul 09 2016 06:59 UTC
same thing, so testArr is the variable being declared outside the function, but when it gets passed to the function it gets a new variable name, arr (in the parens()) so you should always use that name inside the function
also from there you also need to use the .shift() method which is JS's version of popping from the front of the array
Craig
@zeropoint101
Jul 09 2016 07:00 UTC
@Athaman ok nm, ill just ask again. im doing another tutorial where it's talking about using backslashes for long strings to make them multi=line because javascript automatically puts semicolons when you create a newline. but if im not hitting enter, im not creating a new line, right? so why would I ever need this if I'm just writing a long paragraph?
Keone Martin
@Athaman
Jul 09 2016 07:00 UTC
This message was deleted
Anoosha keen
@anookeen
Jul 09 2016 07:01 UTC
@Dinar717 I removed the element too but return 5 didn't work
Rohit Gaikwad
@rohogaka
Jul 09 2016 07:01 UTC
gets a new variable name
.shift()
^lemme try that @Athaman
Keone Martin
@Athaman
Jul 09 2016 07:03 UTC
@zeropoint101 there are a few challenges on using backslash to escape literal characters, and it can be pretty important in coding, using them to escape quotes and stuff. you can also use \n to print a new line inside your string... so say you want to have "this line on one\nthis line on another" that is a single string that you can pass around but will always print on different lines
var oneLine = "This string will print on one line
                              even though i've written it over two lines in my code";
var twoLines = "this string will print on two lines \n even though i've written it on one line in code"; // be careful with spaces around the \n it was just easier to read
Rohit Gaikwad
@rohogaka
Jul 09 2016 07:04 UTC
nextInLine([2], 1) should return 2 how do i test this

function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  testArr.shift();

  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));
Craig
@zeropoint101
Jul 09 2016 07:04 UTC
@Athaman no thats not what i mean. its actually on a codecademy lesson. lemme see if i can link it.
Keone Martin
@Athaman
Jul 09 2016 07:05 UTC
sure
Rohit Gaikwad
@rohogaka
Jul 09 2016 07:05 UTC
@Athaman ^
Keone Martin
@Athaman
Jul 09 2016 07:05 UTC
@rohogaka the .shift() function returns the value that is removed from the array, but you have to catch it to use it. either with var something = arr.shift() or by returning it
also you're still using the testArr variable, you need to use arr
Mustafijur rahman
@Dinar717
Jul 09 2016 07:06 UTC
@rohogaka var val = testArr.shift(); then return val
Keone Martin
@Athaman
Jul 09 2016 07:06 UTC
you shouldn't be using testArr @Dinar717 @rohogaka
@Athaman does that show up properly for you?
Mustafijur rahman
@Dinar717
Jul 09 2016 07:07 UTC
@Athaman yes @rohogaka its arr I didn't look
Anoosha keen
@anookeen
Jul 09 2016 07:07 UTC

@rohogaka this is the code
function nextInLine(arr, item) {
// Your code here

arr.push(item);
item=arr.shift();
//console.log(testArr);
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([], 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
console.log(nextInLine(2, 1));
console.log("After: " + JSON.stringify(testArr));
console.log(nextInLine([5,6,7,8,9], 1));
console.log("After: " + JSON.stringify(testArr));

@Athaman why to use arr instead of testArr??
Rohit Gaikwad
@rohogaka
Jul 09 2016 07:08 UTC
blob
Keone Martin
@Athaman
Jul 09 2016 07:08 UTC
@zeropoint101 yeah, sort of, except it goes to my version of the codecademy challenge >.>
Rohit Gaikwad
@rohogaka
Jul 09 2016 07:08 UTC
@Athaman thats you!
@anookeen i got it done in a lot less

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var val = arr.shift();

  return val;  // 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));
@Athaman thanks @Dinar717
CamperBot
@camperbot