These are chat archives for FreeCodeCamp/HelpJavaScript

31st
Aug 2016
Klaus Mana
@KlausMana
Aug 31 2016 00:00
so i think i have messed everything up
jtippetts12
@jtippetts12
Aug 31 2016 00:00
thanks all - I'll report back
Klaus Mana
@KlausMana
Aug 31 2016 00:00
challenge
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%20%20%2F%2FTakes%20the%20collection's%20parameters.%0A%20%20var%20a%20%3D%20collection%5Bid%5D%3B%20%2F%2FTakes%20the%20Id%20to%20modify%20it.%0A%20%20var%20b%20%3D%20collection%5Bid%5D%5Bprop%5D%3B%20%2F%2FTakes%20the%20prop%20to%20modify%20it.%0A%20%20if(prop%20%3D%3D%20%22tracks%22)%7B%0A%20%20var%20c%20%3D%20collection%5Bid%5D%5Bprop%5D%5Bvalue%5D%3B%20%2F%2FTakes%20the%20value%20to%20modify%20it.%0A%20%20%0A%20%20%2F%2FCondition%201%0A%20%20if(b%20!%3D%20%22tracks%22%20%26%26%20c%20!%3D%3D%20%22%22)%7B%0A%20%20%20%20b.pop()%3B%0A%20%20%20%20b.push(c)%3B%0A%20%20%7D%0A%20%20%20%20%0A%20%20%2F%2FCondition%202%0A%20%20%20%20if(b%20%3D%3D%20%22tracks%22%20%26%26%20!a.tracks)%7B%0A%20%20%20%20%20%20b.tracks%20%3D%20%5B%5D%3B%0A%20%20%20%20%20%20b.push(c)%3B%0A%20%20%20%20%7D%0A%20%20%2F%2FCondition%203%0A%20%20%20%20if(b%20%3D%3D%20%22tracks%22%20%26%26%20c%20!%3D%3D%20%22%22)%7B%0A%20%20%20%20%20%20b.push(c)%3B%0A%20%20%20%20%7D%0A%20%20%20%2F%2FCondition%204%0A%20%20%20%20if(c%20%3D%3D%3D%20%22%22)%7B%0A%20%20%20%20%20%20delete%20collection%5Bid%5D%5Bprop%5D%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A%0A
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:00
so @jtippetts12 , don't look, I'll past my code
Klaus Mana
@KlausMana
Aug 31 2016 00:00
Record Collection
code
jtippetts12
@jtippetts12
Aug 31 2016 00:00
minimizes window
Klaus Mana
@KlausMana
Aug 31 2016 00:00

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

// Only change code below this line
function updateRecords(id, prop, value) {
  //Takes the collection's parameters.
  var a = collection[id]; //Takes the Id to modify it.
  var b = collection[id][prop]; //Takes the prop to modify it.
  if(prop == "tracks"){
  var c = collection[id][prop][value]; //Takes the value to modify it.

  //Condition 1
  if(b != "tracks" && c !== ""){
    b.pop();
    b.push(c);
  }

  //Condition 2
    if(b == "tracks" && !a.tracks){
      b.tracks = [];
      b.push(c);
    }
  //Condition 3
    if(b == "tracks" && c !== ""){
      b.push(c);
    }
   //Condition 4
    if(c === ""){
      delete collection[id][prop];
    }
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:00
my code this is spamming!! lol
Klaus Mana
@KlausMana
Aug 31 2016 00:01
help me pls
CamperBot
@camperbot
Aug 31 2016 00:01
no wiki entry for: me pls
Klaus Mana
@KlausMana
Aug 31 2016 00:01
omg any1 help me?
@Brandons42 u still here?
Shola Abaogun
@codephoo
Aug 31 2016 00:01
@KlausMana what error are you getting?
Klaus Mana
@KlausMana
Aug 31 2016 00:01
no error
just i am not fulfilling the user stories
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:02
can someone tell me if I cheated ? here's my code. (Seek and Destroy challenge)
Shola Abaogun
@codephoo
Aug 31 2016 00:02
Which of the user stories?
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:02
function toKeep(value){
  return value !== arg;
}

function destroyer(arr) {
  var args = Array.from(arguments);
  arg = 0;
  var newArray = args.shift();
  var finalArray = [];

  for (i = 0; i < args.length; i++){     //boucle des éléments à enlever de la suite (for)
    arg = args[i];  //changer la variable globale
    newArray = newArray.filter(toKeep);  //filtrer
    console.log(finalArray);
  }//fin de la boucle

  return newArray;            //retourner l'array finale
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Klaus Mana
@KlausMana
Aug 31 2016 00:02
all of them xD
i just... idk
it seems to me that i did what is required
still the user stories are all incomplete
oh w8 w8 i got some ideas
Shola Abaogun
@codephoo
Aug 31 2016 00:06
Let's start with condition 1
Klaus Mana
@KlausMana
Aug 31 2016 00:06
?
Shola Abaogun
@codephoo
Aug 31 2016 00:07
If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.
Klaus Mana
@KlausMana
Aug 31 2016 00:07
yea ikr i got that kind of wrong
Shola Abaogun
@codephoo
Aug 31 2016 00:07
Your condition 1 doesn't fulfil this condition
  //Condition 1
  if(b!= "tracks" && c !== ""){
    b.pop();
    b.push(c);
  }
why pop and push?
Klaus Mana
@KlausMana
Aug 31 2016 00:08
yea yea fixing it
i just need to reassign or cre8
i misinterpreted the whole thing
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:09
@KlausMana sometimes it's not bad to Reset
Klaus Mana
@KlausMana
Aug 31 2016 00:09
ty anyways @codephoo
CamperBot
@camperbot
Aug 31 2016 00:09
klausmana sends brownie points to @codephoo :sparkles: :thumbsup: :sparkles:
:cookie: 396 | @codephoo |http://www.freecodecamp.com/codephoo
Klaus Mana
@KlausMana
Aug 31 2016 00:09
and Pierre lol
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:09
you can past your code in your IDE and reset :P
Shola Abaogun
@codephoo
Aug 31 2016 00:11
Goodluck fixing it @KlausMana
Klaus Mana
@KlausMana
Aug 31 2016 00:11
ty :smiley:
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:13
so now
me
:P
Dallas
@dallashall
Aug 31 2016 00:14
For the Inventory Update Advanced Algorithm challenge, is there a particular method that I am expected to use. I see the MDN Global Array Object reference, but my first thought was to turn the arrays into objects. Just want to make sure I'm not missing out on the lesson-to-be-learned.
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:15
if you scroll up a bit, I pasted my code for the Seek and Destroy challenge. I've completed the challenge but I'm wondering if I cheat with my global variable....
Shola Abaogun
@codephoo
Aug 31 2016 00:15
@dallashall so long it works, use whatever you are comfortable with
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:15
it's the only way I found...
i'm on it since yesterday 9pm lol
Dallas
@dallashall
Aug 31 2016 00:16
@codephoo Thanks! Looks like I'm taking a shortcut, then.
CamperBot
@camperbot
Aug 31 2016 00:16
dallashall sends brownie points to @codephoo :sparkles: :thumbsup: :sparkles:
:cookie: 397 | @codephoo |http://www.freecodecamp.com/codephoo
llamatarianism
@llamatarianism
Aug 31 2016 00:17
@novativmedias what global variable
oh right, arg
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:17
arg
llamatarianism
@llamatarianism
Aug 31 2016 00:17
well like
there are definitely ways you can do it without global variables
but I wouldn't exactly call it cheating
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:18
what would you have done ? just in text, no code...
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:19
just pass an anonymous function into filter
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:19
anonymous function ?
Klaus Mana
@KlausMana
Aug 31 2016 00:19
i know i am becoming frustrating but i've got yet another problem :stuck_out_tongue:
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:19
hum... they didn't teach me that one
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:19
newArray.filter(val => val !== arg);
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:20
you can do that ?!?!
woooaah
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:20
or
newArray.filter(function (val) {
  return val !== arg;
});
yep
those both do the same thing
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:20
oh you can do that TOO ?!
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:20
you can indeed
functions are functions
Shola Abaogun
@codephoo
Aug 31 2016 00:20
or newArray.filter(function(val){return val !== arg});
Klaus Mana
@KlausMana
Aug 31 2016 00:20
I'm getting an error
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:21
that's not really good style, @codephoo
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:21
ok thanks @codephoo ... I must assimilate that function into a function, lol
CamperBot
@camperbot
Aug 31 2016 00:21
novativmedias sends brownie points to @codephoo :sparkles: :thumbsup: :sparkles:
:cookie: 398 | @codephoo |http://www.freecodecamp.com/codephoo
Jacob Stewart
@JacobStewart1
Aug 31 2016 00:21

hey im on the pig latin challenge and my code keeps returning a number can you help me
function translatePigLatin(str) {
str = str.split('').push(str[0]);

return str;
}

Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:21
unless you're writing an arrow function you shouldn't define it in-line
Daniel
@DanielMW34
Aug 31 2016 00:21
This message was deleted
Shola Abaogun
@codephoo
Aug 31 2016 00:22
@Haseeb-Qureshi it's just an example, I wouldn't do that for real
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:22
anyway it opens a lot of door in my mind
I don't have the reflex yet to do that... always function separatly instead of inlined
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:23
that's good to do anyway :)
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:23
may need more challenges :P
Klaus Mana
@KlausMana
Aug 31 2016 00:24
hey me next
again...
so i have an error when i run this completely idiotic code
Shola Abaogun
@codephoo
Aug 31 2016 00:24
@JacobStewart1 your problem is the push method
@JacobStewart1 push returns a number
Klaus Mana
@KlausMana
Aug 31 2016 00:24
@codephoo can you help me?
Jacob Stewart
@JacobStewart1
Aug 31 2016 00:24
@codephoo ok is there a way to change that
Klaus Mana
@KlausMana
Aug 31 2016 00:25
```

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

// Only change code below this line
function updateRecords(id, prop, value) {
  //Takes the collection's parameters.
  var a = collection[id]; //Takes the Id to modify it.
  var b = collection[id][prop]; //Takes the prop to modify it.
  if(prop == "tracks"){
  var c = collection[id][prop][value]; //Takes the value to modify it.

  //Condition 2
    if(b == "tracks" && !a.tracks){
      b.tracks = [];
      b.push(c);
    }
  //Condition 3
    if(b == "tracks" && c !== ""){
      b.push(c);
    }
   //Condition 4
    if(c === ""){
      delete collection[id][prop];
    }
  }
  if(b != "tracks"){
    var d = collection[id][prop].collection[value];
   if(d !== ""){
     a[prop] = prop;
   }
  }
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
i get an error saying that it can't read the property collection from undefined
Shola Abaogun
@codephoo
Aug 31 2016 00:25
just call push and don't assign the result @JacobStewart1
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:25
@novativmedias you can also solve this without a global variable using this:
newArray = newArray.filter(toKeep.bind(null, arg));
Jacob Stewart
@JacobStewart1
Aug 31 2016 00:26
ok thanks @codephoo
CamperBot
@camperbot
Aug 31 2016 00:26
jacobstewart1 sends brownie points to @codephoo :sparkles: :thumbsup: :sparkles:
:cookie: 399 | @codephoo |http://www.freecodecamp.com/codephoo
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:26
and redefining your function to take two arguments
Klaus Mana
@KlausMana
Aug 31 2016 00:26
i need help too :(
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:26
function toKeep(arg, value){
  return value !== arg;
}
David Ornellas
@Ornellasd
Aug 31 2016 00:26
hello, i need some help with nesting for loops if anyone wants to pm me
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:26
that will allow you to pass the correct arguments to the function via currying, and still keep it external :)
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:26
@Haseeb-Qureshi my god.. you kinda lost me here ... cause I'm not sure I've yet learned what .bind is
KindenRB
@KindenRB
Aug 31 2016 00:27
Hey, I'm having trouble with the record collection challenge. I get the error 'Cannot read property push of undefined'. I'm pretty sure the problem is I'm not creating a new array, but I'm not sure how to go about it.
Klaus Mana
@KlausMana
Aug 31 2016 00:27
me 2!
KindenRB
@KindenRB
Aug 31 2016 00:27
Here's my code
function updateRecords(id, prop, value) {
    if (value === '') {
    delete collection[id][prop];
  } else if (prop !== 'tracks') {
    collection[id][prop] = value;
  } else {
    collection[id][prop].push(value);
  }


  return collection;
}
Klaus Mana
@KlausMana
Aug 31 2016 00:27
not that error
but that challenge
Alexander Køpke
@alexanderkopke
Aug 31 2016 00:27
@DanielMW34 $("#wikiButton").on("click", function() { <-- this should be an anonymous function as shown here because you call it when you click it..
var x = document.getElementById("inputField").value; <--- notice getElementById <<- small d. You had ID
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 00:27
don't worry about it then, just keep it on the backburner ;)
Klaus Mana
@KlausMana
Aug 31 2016 00:28
@KindenRB
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:28
thanks anyway :)
i'll read on .bind just out of curiosity
Steven B. Oladipo
@stevenboladipo
Aug 31 2016 00:28
Global Scope and Functions Javascript problem here is my solution :
Shola Abaogun
@codephoo
Aug 31 2016 00:28
@KlausMana you are suppose to check prop and not b
you should just reset
Steven B. Oladipo
@stevenboladipo
Aug 31 2016 00:28

var myGlobal = 10;
oopsGlobal();
// Declare your variable here

function fun1() {
oopsGlobal = 5;// Assign 5 to oopsGlobal Here

}
console.log();

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Daniel
@DanielMW34
Aug 31 2016 00:28

Problem solved ...

document.getElementById()

versus

document.getElementByID()
Steven B. Oladipo
@stevenboladipo
Aug 31 2016 00:28
can anybody point me in the right directtion?
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:29
@DanielMW34 : you sure?
Klaus Mana
@KlausMana
Aug 31 2016 00:29
ok then i reset i'll try take everything gradually now
Daniel
@DanielMW34
Aug 31 2016 00:29
@alexanderkopke thank you. I saw that right after I asked the question
CamperBot
@camperbot
Aug 31 2016 00:29
danielmw34 sends brownie points to @alexanderkopke :sparkles: :thumbsup: :sparkles:
:cookie: 731 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Daniel
@DanielMW34
Aug 31 2016 00:29
@novativmedias what do you mean?
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:29
@KlausMana try to write comments first... and then code. and use console.log to see the results and variables you're creating
@DanielMW34 you pasted the same thing 2 times
Daniel
@DanielMW34
Aug 31 2016 00:30
look closer
Shola Abaogun
@codephoo
Aug 31 2016 00:30
@stevenboladipo what do you need help with?
Steven B. Oladipo
@stevenboladipo
Aug 31 2016 00:31
I keep getting oopsGlobal is not a function
Shola Abaogun
@codephoo
Aug 31 2016 00:32
oopsGlobal is not a function truly, its an Integer
remove () from oopsGlobal()
Steven B. Oladipo
@stevenboladipo
Aug 31 2016 00:32
thanks man @codephoo
CamperBot
@camperbot
Aug 31 2016 00:32
stevenboladipo sends brownie points to @codephoo :sparkles: :thumbsup: :sparkles:
KindenRB
@KindenRB
Aug 31 2016 00:32
Anyone have any suggestions?
CamperBot
@camperbot
Aug 31 2016 00:32
:cookie: 400 | @codephoo |http://www.freecodecamp.com/codephoo
Daniel
@DanielMW34
Aug 31 2016 00:33
@novativmedias the capital "D" versus the lowercase "d" --- failure versus success
@KindenRB what is your question please?
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:33
oh damn, sorry @DanielMW34
Daniel
@DanielMW34
Aug 31 2016 00:33
no worries
Shola Abaogun
@codephoo
Aug 31 2016 00:34
@KindenRB ?
Pierre-Léon Simard-Lemoyne
@novativmedias
Aug 31 2016 00:34
haha, must be a common error then
KindenRB
@KindenRB
Aug 31 2016 00:34
Keep getting the error ' cannot read property of push of undefined' on the record collection challenge
function updateRecords(id, prop, value) {
    if (value === '') {
    delete collection[id][prop];
  } else if (prop !== 'tracks') {
    collection[id][prop] = value;
  } else {
    collection[id][prop].push(value);
  }
I'm pretty sure it's because I'm not creating a new array but I'm not sure how
Shola Abaogun
@codephoo
Aug 31 2016 00:35
that is because `collection[id][prop] is undefined at some point
@KindenRB you need to check if the value of collection[id][prop] is not undefined before pushing
KindenRB
@KindenRB
Aug 31 2016 00:37
You're right, I don't think it is. It doesn't exist yet for that object, I need to create an empty one but whenever I try to I get different error messages
Nevermind, I just got it. Thanks for the help though guys!
Elizabeth Crummy
@lizzyac
Aug 31 2016 00:48
```
function chunkArrayInGroups(arr, size) {
 var groupedArrays = [];

 for (i=0; i<arr.length; i++) {
 groupOne = arr.splice(0,size);
 groupTwo = arr.splice((size + 1), arr.length);
 groupedArrays = groupOne.push(groupTwo);
 }



  return groupedArrays;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
I'm pretty lost on this challenge (Chunky Monkey splitting arrays into groups of a certain size). I keep getting a number returned instead of arrays.
Coy Sanders
@coymeetsworld
Aug 31 2016 00:52
i would make sure that the splicing is working as you expect @lizzyac, you can use console.log() function for debugging to see what your code is doing
Elizabeth Crummy
@lizzyac
Aug 31 2016 00:53
@coymeetsworld Alright, I'll try that.
Coy Sanders
@coymeetsworld
Aug 31 2016 00:53
i don't think you need that groupTwo variable or the 2nd arr.splice call
splice will mutate that array in place, Mozilla has some good documentation and examples on it https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
Elizabeth Crummy
@lizzyac
Aug 31 2016 00:55
@coymeetsworld Yeah, it doesn't return anything with console.log. Could the functions used in groupTwo just be placed in the push function?
Coy Sanders
@coymeetsworld
Aug 31 2016 00:55
i don't think you need groupTwo at all, after you call the splice function it will mutate arr @lizzyac
heres an example from the link i showed:
// myFish is ['angel', 'clown', 'drum', 'mandarin', 'surgeon'] 
// removes 1 element from index 3
removed = myFish.splice(3, 1);
// myFish is ['angel', 'clown', 'drum', 'surgeon']
// removed is ['mandarin']
Elizabeth Crummy
@lizzyac
Aug 31 2016 00:56
@coymeetsworld Yep, I'm looking at the link now. Forgot you could add elements using splice.
Coy Sanders
@coymeetsworld
Aug 31 2016 00:56
yeah but push works better in this case @lizzyac since you're just adding it to the end
so you need on command to remove items from the array and put it into a subarray (splice), and another to put those subarrays into a new array (push).
German Illanes
@gerillanes7
Aug 31 2016 00:59
do you tell me tips for learn js?
Aashil Patel
@aashil
Aug 31 2016 01:05
function palindrome(str) {
  str.replace(/[^0-9a-zA-Z]/g, '');
  str.toLowerCase();
  return str === str.split("").reverse().join("");
}

palindrome("eye");
Can anyone tell me what's wrong with my code to check if a string is palindrome or not ?
Ryan Garant
@protoEvangelion
Aug 31 2016 01:05
Is anybody on "Advanced Algorithm Scripting" that would like to pair?
Coy Sanders
@coymeetsworld
Aug 31 2016 01:06
toLowerCase doesn't mutate str itself @aashil, it returns a new string
same goes with replace
Aashil Patel
@aashil
Aug 31 2016 01:07
@coymeetsworld Thanks Coy. Solved the problem.
CamperBot
@camperbot
Aug 31 2016 01:07
aashil sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1336 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Anthony Drane
@Antiaccess
Aug 31 2016 01:08
Hey guys, I'm confused trying to add an API to my codepen... it's the geolocation API. Can anyone hint how to import it? Here's the link: https://dev.w3.org/geo/api/spec-source.html
gautamsapra
@gautamsapra
Aug 31 2016 01:10

hello this is my var myVar = 87;

// Only change code below this line
myVar = ++myVar;
and I am getting this error: myVar = myVar should be changed

Anthony Drane
@Antiaccess
Aug 31 2016 01:10
myVar += myVar @gautamsapra
gautamsapra
@gautamsapra
Aug 31 2016 01:11
nope, the answer is now 174 instead of 88
++ is basically 1 and equal sign and thus its 88 which is correct. but I cannot understand the error
Norvin Burrus
@ndburrus
Aug 31 2016 01:13

@gautamsapra :sparkles:

  • we can follow the format/syntax of the example code, here: i++;
  • as noted in the instructions, the above statement
    is the equivalent of i = i + 1;
  • so, we need to use to: use the ++ operator on myVar.

how do we do that?

Anthony Drane
@Antiaccess
Aug 31 2016 01:14
myVar++;
gautamsapra
@gautamsapra
Aug 31 2016 01:14
okay i is myVar which is written, so what exactly should I do, I'm getting confused
Anthony Drane
@Antiaccess
Aug 31 2016 01:14
@ndburrus
@gautamsapra if you want to just add one then: `myVar++;
gautamsapra
@gautamsapra
Aug 31 2016 01:15
I wrote like this ++myVar which is giving me 88 what I want. but there is different
myVar++ gives me 87 so cant use that
Norvin Burrus
@ndburrus
Aug 31 2016 01:15
@gautamsapra :sparkles:
  • is the ++ on the left or right side of the variable (in the example code)?
  • do we need punctuation at the end of the code line?
  • what is myVar declared to be initially?
    reference first test case, here: myVar should equal 88
    so, you received a value of 87... :)
Anthony Drane
@Antiaccess
Aug 31 2016 01:16
if you know how much you want to add, then why don't you just do myVar+=1;
gautamsapra
@gautamsapra
Aug 31 2016 01:16
myVar = ++myVar; this is what I wrote and it's correct in total 88 but this is the error I am getting: myVar = myVar should be changed
llamatarianism
@llamatarianism
Aug 31 2016 01:17
@gautamsapra the myVar = part is unnecessary
++ already changes myVar
gautamsapra
@gautamsapra
Aug 31 2016 01:17

var myVar = 87;

// Only change code below this line
myVar = ++myVar;
this is the total code through which I do get 88 but the error I can't understand

llamatarianism
@llamatarianism
Aug 31 2016 01:17
so just do myVar++ without the myVar = part.
Liew Xun
@damakuno
Aug 31 2016 01:18
myVar++ is basically the shorthand for myVar = myVar + 1
gautamsapra
@gautamsapra
Aug 31 2016 01:18
@llamatarianism thank you yes it did it. removed the first myVar and did it. thanks
CamperBot
@camperbot
Aug 31 2016 01:18
gautamsapra sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1312 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
German Illanes
@gerillanes7
Aug 31 2016 01:18
Do you recommended me learn c#?
Liew Xun
@damakuno
Aug 31 2016 01:18
@gautamsapra so it was redundant
German Illanes
@gerillanes7
Aug 31 2016 01:18
Thanks you, Norvin.
llamatarianism
@llamatarianism
Aug 31 2016 01:18
@damakuno ++myVar is
myVar++ is weirder.
Liew Xun
@damakuno
Aug 31 2016 01:18
oh
is it?
llamatarianism
@llamatarianism
Aug 31 2016 01:18
yeah
Liew Xun
@damakuno
Aug 31 2016 01:19
lol
Norvin Burrus
@ndburrus
Aug 31 2016 01:19
@gerillanes7 you're welcome! :+1:
llamatarianism
@llamatarianism
Aug 31 2016 01:19
var x = 5;
var y = x++;
console.log(x); // 6
console.log(y); // 5
whereas if you use ++ then they're the same.
var y = ++x;
// or
var y = (x = x + 1);
same thing.
German Illanes
@gerillanes7
Aug 31 2016 01:19
@ndburrus Do you recommend me learn c# and MVC?
Liew Xun
@damakuno
Aug 31 2016 01:20
yeah, ++x returns the value after the increment
x++ returns the value before the increment
Norvin Burrus
@ndburrus
Aug 31 2016 01:20
@gerillanes7 i don't have enough experience/knowledge to make a recommendation :(
i'm learning! :)
Liew Xun
@damakuno
Aug 31 2016 01:21
@gerillanes7 I'm using asp.net webforms
German Illanes
@gerillanes7
Aug 31 2016 01:21
@damakuno with c# ?
Liew Xun
@damakuno
Aug 31 2016 01:21
@gerillanes7 yep
@gerillanes7 if you want to use asp.net to develop you should learn C#
German Illanes
@gerillanes7
Aug 31 2016 01:22
@damakuno i'm confused, because i'm noob with code, and i don't know that learn first
Liew Xun
@damakuno
Aug 31 2016 01:23
@gerillanes7 if you're completely new, don't think of the framework you're going to use just yet, just learn the basics first
after you understand more do some of your own research to see what you want to do
@gerillanes7 I assume you're already familiar with HTML, CSS and Javascript?
German Illanes
@gerillanes7
Aug 31 2016 01:24
@damakuno i'm not completely new, i know basics concepts
@damakuno yes
llamatarianism
@llamatarianism
Aug 31 2016 01:25
@gerillanes7 it's an alright language. learn it if you want.
Liew Xun
@damakuno
Aug 31 2016 01:25
@gerillanes7 ok, so you know those are just on the client side, and you're thinking of moving on to server side right?
yeah C# is nice
German Illanes
@gerillanes7
Aug 31 2016 01:26
@damakuno no, just frontend
llamatarianism
@llamatarianism
Aug 31 2016 01:26
you can't use C# for frontend stuff
Liew Xun
@damakuno
Aug 31 2016 01:26
@gerillanes7 C# is for backend
@llamatarianism desktop apps?
German Illanes
@gerillanes7
Aug 31 2016 01:27
I dont like it xd
llamatarianism
@llamatarianism
Aug 31 2016 01:27
ok fine
front end WEB stuff :P
Liew Xun
@damakuno
Aug 31 2016 01:27
@llamatarianism yep lol
llamatarianism
@llamatarianism
Aug 31 2016 01:27
or alternatively
front end non-windows stuff
Liew Xun
@damakuno
Aug 31 2016 01:27
@gerillanes7 if you want to focus on front end, maybe use some js frameworks?
llamatarianism
@llamatarianism
Aug 31 2016 01:27
and don't give me that mono/.net core crap
Liew Xun
@damakuno
Aug 31 2016 01:27
@llamatarianism yeah, it's only windows
I don't know how mono works
German Illanes
@gerillanes7
Aug 31 2016 01:28
@damakuno for example?
llamatarianism
@llamatarianism
Aug 31 2016 01:28
mono is like normal .net
except it works on linux and mac
German Illanes
@gerillanes7
Aug 31 2016 01:28
@damakuno angular, etc?
llamatarianism
@llamatarianism
Aug 31 2016 01:28
and is very annoying
Liew Xun
@damakuno
Aug 31 2016 01:28
@gerillanes7 yeah, those
it's up to you what you want to do really
if you want to build a single page web app, angular is good
German Illanes
@gerillanes7
Aug 31 2016 01:29
@damakuno I would like create web apps, web pages, and more
@damakuno nodejs is good?
well, it depends
German Illanes
@gerillanes7
Aug 31 2016 01:32
@damakuno thanks, but I will take to read because my english is not good
CamperBot
@camperbot
Aug 31 2016 01:32
gerillanes7 sends brownie points to @damakuno :sparkles: :thumbsup: :sparkles:
:cookie: 49 | @damakuno |http://www.freecodecamp.com/damakuno
Liew Xun
@damakuno
Aug 31 2016 01:32
on what kind of page you want to do
@gerillanes7 anyway once you use the node.js platform it wouldn't just be front end anymore
German Illanes
@gerillanes7
Aug 31 2016 01:34
Thanks
Liew Xun
@damakuno
Aug 31 2016 01:34
@gerillanes7 to know more you really, as I said, have to do your own research
because I don't know what exactly you'd like :X
German Illanes
@gerillanes7
Aug 31 2016 01:35
Yes, I know, but I don't know whereby start
German Illanes
@gerillanes7
Aug 31 2016 01:38
I bought a c# course and not be if done
Jason Holder
@stoutpanda
Aug 31 2016 01:49

Hello all. I am working on the “Factorialize a Number” challenge. I am seeing that my code returns all the correct values from the test cases but will not pass the test. Anyone provide some feedback? ```js var total = 1;
function factorialize(num) {
for(i = num; i > 0; i--)
{

  total *= i;

}

return total;
}

factorialize(5);
factorialize(10);
factorialize(20);
factorialize(0);

```

Well, I screwed that up.
Brandon
@Brandons42
Aug 31 2016 01:50
Can someone help me out with arguments optional?
Jason Holder
@stoutpanda
Aug 31 2016 01:51
Here is my code in the nice and pretty block.
var total = 1;
function factorialize(num) {
  for(i = num; i > 0; i--)
    {

      total *= i;

    }

  return total;
}

factorialize(5);
factorialize(10);
factorialize(20);
factorialize(0);
Oh, wow. I figured it out. I just needed to move the total variable inside the function! (whoops!) >.>
Gang Zhao
@crumpx
Aug 31 2016 01:55
omg roman converter lol
finally done
Wali Gauvin
@Docwali777
Aug 31 2016 02:01
Diff Array - everything I try return the opposite of what the answer should be.. I am finding where the arrays intersect but not the difference...
function diffArray(arr1, arr2) {
  var newArr = [];

var arrCon = arr1.concat(arr2).sort(function(a,b){return a-b;});

  var a = arr1.filter(function(val){
 if (val in arr1 == val in arr2){
   return arrCon.splice(val);                             
 }
});
  return a;
}

diffArray(["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"]);
I have been working on this for three days.. is it time to move on???
Gang Zhao
@crumpx
Aug 31 2016 02:02
no :P
I finished this yesterday and I was happy about it.
took me 4 hours
you will be much happier when you solve it
llamatarianism
@llamatarianism
Aug 31 2016 02:05
@Docwali777 that's not how in works
because JS is silly,
Gang Zhao
@crumpx
Aug 31 2016 02:06
@Docwali777 basically, you use first array to compare with second array, and save result of their difference in a variable.
llamatarianism
@llamatarianism
Aug 31 2016 02:06
in doesn't check if something is inside a collection
it checks if something is inside the keys of an object
so 1 in ["foo", "bar", "baz"] is true
Gang Zhao
@crumpx
Aug 31 2016 02:06
and you use second array to compare with the first array, save result in another variable
llamatarianism
@llamatarianism
Aug 31 2016 02:06
and "foo" in ["foo", "bar", "baz"] is false
Gang Zhao
@crumpx
Aug 31 2016 02:06
then you concat them! boom!!!
llamatarianism
@llamatarianism
Aug 31 2016 02:07
return arrCon.splice(val);
splice returns the stuff it removes.
This message was deleted
This message was deleted
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:07

In the "Stand in Line" challenge I fulfilled the first and last criteria but not the second and third what do I do? Here is my code: function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.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));

llamatarianism
@llamatarianism
Aug 31 2016 02:08
if (val in arr1 == val in arr2)
then you return something
and something is truthy
so val doesn't get removed
if it's not, then you don't return anything
so it gets removed
Gang Zhao
@crumpx
Aug 31 2016 02:08
yea, filter is confusing...
at first
they should come up with a better naming
llamatarianism
@llamatarianism
Aug 31 2016 02:09
meh
most of the confusion just comes from JS weirdness
Wali Gauvin
@Docwali777
Aug 31 2016 02:10
Ok... I will try a different method... back to the drwing board.. Is there a good reference to use becauseI am going aroundin circles
llamatarianism
@llamatarianism
Aug 31 2016 02:10
if JS didn't have annoying bloody truthiness rules and didn't pass a bunch of extra arguments to filter and map and whatnot, it'd be fine.
you never see anyone complaining about it in sensible languages like clojure or haskell.
Gang Zhao
@crumpx
Aug 31 2016 02:11
@Docwali777 remember, filter first array with second, filter second array with first, then concat. once you done it, you can write it in one line...
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:11
@llamatarianism I don't have a second array are you telling me to make one?
Gang Zhao
@crumpx
Aug 31 2016 02:12
arr1, arr2
llamatarianism
@llamatarianism
Aug 31 2016 02:12
@hitmanorion I didn't say anything to you
Gang Zhao
@crumpx
Aug 31 2016 02:12
you have 2 arrays
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:12
Sorry.
Gang Zhao
@crumpx
Aug 31 2016 02:12
chat is confusing too lol
llamatarianism
@llamatarianism
Aug 31 2016 02:12
@hitmanorion you're supposed to return the thing you remove
not item
so nextInLine([1, 2, 3, 4], 5) should return 1.
put 5 in at the end, take 1 out from the start and then return it.
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:13
@llamatarianism Give me a sec.

@llamatarianism Thank you, the code works. Here is the resulting code: function nextInLine(arr, item) {
// Your code here
arr.push(item);
item = arr.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));

CamperBot
@camperbot
Aug 31 2016 02:18
hitmanorion sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1313 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Gang Zhao
@crumpx
Aug 31 2016 02:24
i can't believe I spend whole afternoon trying to figure out how to turn IIII into IV with code....and all that I have to do is to add IV to my array table.............
Cr1msonFir3
@Cr1msonFir3
Aug 31 2016 02:29
i've been trying to figure out that one for 3 days now. figured i had to use push and shift but didn't know think of how to properly do it. now to study the answer.....
Gang Zhao
@crumpx
Aug 31 2016 02:30
which one? the roman converter?
nicop
@nicopcat
Aug 31 2016 02:30
anyone knows about Record Collection task? Lol
Cr1msonFir3
@Cr1msonFir3
Aug 31 2016 02:31
Stand in Line
Gang Zhao
@crumpx
Aug 31 2016 02:31
@nicopcat i do :D
Cr1msonFir3
@Cr1msonFir3
Aug 31 2016 02:31
the one Chris Wolfe just got help on
i need to do these when i'm not so tired....
Gang Zhao
@crumpx
Aug 31 2016 02:31
stand in line?
nicop
@nicopcat
Aug 31 2016 02:31
@crumpx need yr help~
r u chinese?
Gang Zhao
@crumpx
Aug 31 2016 02:32
@nicopcat say it :D
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:32
@Cr1msonFir3 Yo.
Gang Zhao
@crumpx
Aug 31 2016 02:32
yes
nicop
@nicopcat
Aug 31 2016 02:32
那不然中文交流吧:D
Gang Zhao
@crumpx
Aug 31 2016 02:32
pm me
Cr1msonFir3
@Cr1msonFir3
Aug 31 2016 02:33
just mentioned you Chris that's all
nicop
@nicopcat
Aug 31 2016 02:33
dont know how to pm:lol
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:34
@Cr1msonFir3 I know. Glad I helped your problem as well even though it was indirectly.
Milan Roy
@Milan9x
Aug 31 2016 02:34
hi all
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:34
@Milan9x What's up?
nicop
@nicopcat
Aug 31 2016 02:34
@crumpx dont know what does it means
Gang Zhao
@crumpx
Aug 31 2016 02:34
hover mouse to my avatar and click "Private Conversasion.
Adrian Kopytko
@adriankopytko
Aug 31 2016 02:34
Hello. I have problem with my regex (again regex, ugh)
I have an array:
[ 2, "*", 2 ]
How can I catch chars like */+- with regex? I use arr.indexOf(regex);
Cr1msonFir3
@Cr1msonFir3
Aug 31 2016 02:35
@hitmanorion It does help. indeed. I should look at chat more often. i start to understand it then the next day i'm dumber than a box of rocks
Adrian Kopytko
@adriankopytko
Aug 31 2016 02:35
I tried, but always arr.indexOf(regex) returns -1 :(
Gang Zhao
@crumpx
Aug 31 2016 02:36
ok @nicopcat what do you need help with :D
nicop
@nicopcat
Aug 31 2016 02:36
there are 3 param: id prop value
如果 value !='' 而且prop != 'tracks' ,collectionCopy[id][prop]=value;。
Chris Wolfe
@GreenBackHades
Aug 31 2016 02:38
@Cr1msonFir3 It's not being dumb per se, our minds can't think in code yet. It's not intelligence. E.g. I am really good in algebra that right now and I am teaching myself Calculus when I can. I also just graduated with a B.S in Information Systems Technology but even I have trouble thinking in code.
nicop
@nicopcat
Aug 31 2016 02:38
can't get it
Anthony Drane
@Antiaccess
Aug 31 2016 02:39
Can anyone help me figure out how to implement the weather API https://openweathermap.org/current#current_JSON into this codepen... it's not clicking for me:
https://codepen.io/antiaccess/pen/NRKyGO
Gang Zhao
@crumpx
Aug 31 2016 02:39
@nicopcat maybe you should post your code here
blob
or pm me
@Antiaccess it's got my coords.
Anthony Drane
@Antiaccess
Aug 31 2016 02:41
@crumpx they're from the inbuilt geo location, but I don't know how to import an external API like the one I linked
Gang Zhao
@crumpx
Aug 31 2016 02:41
@Antiaccess maybe you disabled your javascript alert window, it needs confirmation to get your location.
oh
you mean how to get coords?
Anthony Drane
@Antiaccess
Aug 31 2016 02:41
which is the weather app
no, using GEO data (coords) to get weather data
I've got the coords working
Gang Zhao
@crumpx
Aug 31 2016 02:43
oh. i can't help you with this i'm skipping to do algorithm...so someone else might help you. all i know is you need an api key for this api. :)
Anthony Drane
@Antiaccess
Aug 31 2016 02:43
thanks anyways @crumpx , I have a key just don't know how to implement
CamperBot
@camperbot
Aug 31 2016 02:43
antiaccess sends brownie points to @crumpx :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @crumpx |http://www.freecodecamp.com/crumpx
Christian Torres
@SlickChris95
Aug 31 2016 02:44
Hello I am having a bit of difficulty with the problem "Return Largest Numbers in Arrays" can someone give me a hand?

function largestOfFour(arr){
// You can do this!
// make an array that consists of the largest numbers from each sub-array
var largestNum = 0;
var largestNumArray = [];
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr[i].length; j++){
if (arr[j] > largestNum){
largestNum = arr[j];
largestNumArray.push(largestNum);
}
else if (arr[j] < largestNum){
largestNum = largestNum;
largestNumArray.push(largestNum);
}
}
}
return largestNumArray;
}

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

are there any obvious mistakes?
erick
@erickzhao
Aug 31 2016 02:45
I didn't look at the problem
but largestNum = largestNum; seems to stick out
in your else if statement
@SlickChris95
Jeff
@meankraken
Aug 31 2016 02:46
Has anyone here used the Yelp API and can help me?
Kedar
@kedarjoyner
Aug 31 2016 02:47
Did anyone else have trouble with the Record Collection assignment?
The entire time the docs say that you can use either bracket or dot notation, but it seems that only bracket notation works for a solution. I can't, for the life of me, figure out why.
erick
@erickzhao
Aug 31 2016 02:47
@kedarjoyner it's probably because dot notation doesn't support variables
if your property is stored in myVar, myObject.myVar will literally look for a property called myVar.
but myObject[myVar] will look up the property with the name stored in ur variable
Kedar
@kedarjoyner
Aug 31 2016 02:49
@erickzhao Ah!
That makes WAY more sense. Even MDN isn't that clear.
llamatarianism
@llamatarianism
Aug 31 2016 02:50
makes sense if you think about it
look at this:
var push = "foo";
var arr = [1, 2, 3];
arr.push(4);
if you could use variables with dot notation, then that example would make no sense.
how would it know whether to do arr[push](4) or arr['push'](4)?
Kedar
@kedarjoyner
Aug 31 2016 02:51
hmmm @llamatarianism that one I don't follow as well.
llamatarianism
@llamatarianism
Aug 31 2016 02:52
arr.push(4) is the same as arr['push'](4).
if you could use variables with dot notation
how would it decide between doing arr['push'](4) or arr[push](4)
Dear-Robert
@Dear-Robert
Aug 31 2016 02:52
Hello friends,who have flished Nesting For Loops ? Can I look the code?
erick
@erickzhao
Aug 31 2016 02:53
@llamatarianism Is that how it works? I was assuming that because you're calling a function rather than getting a property, JS just handles it entirely differently
llamatarianism
@llamatarianism
Aug 31 2016 02:53
@erickzhao no
just the same as anything else
var obj = {
  foo: function() {
    console.log('foo');
  },
};

console.log(obj.foo());
that's how everything works.
erick
@erickzhao
Aug 31 2016 02:54
ah
llamatarianism
@llamatarianism
Aug 31 2016 02:54
Array.prototype.push ain't any different to obj.foo
Kedar
@kedarjoyner
Aug 31 2016 02:54
is foo just a stand-in for a variable name?
erick
@erickzhao
Aug 31 2016 02:54
yeah foo and bar usually
llamatarianism
@llamatarianism
Aug 31 2016 02:55
I use foo, bar, baz, qux, bingo, im_running_out_of_ideas, and whatever
Gang Zhao
@crumpx
Aug 31 2016 02:55
what's the deal with foo bar....
Kedar
@kedarjoyner
Aug 31 2016 02:56
@llamatarianism I think I'm confused by the `var push = "foo" in the first example.
llamatarianism
@llamatarianism
Aug 31 2016 02:56
what's confusing about it
Gang Zhao
@crumpx
Aug 31 2016 02:57
@erickzhao ty
CamperBot
@camperbot
Aug 31 2016 02:57
crumpx sends brownie points to @erickzhao :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @erickzhao |http://www.freecodecamp.com/erickzhao
Gang Zhao
@crumpx
Aug 31 2016 02:57
i always use real variable name tho xD
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 02:57
I think an easier example to understand might be
Kedar
@kedarjoyner
Aug 31 2016 02:57
I think it's because it's the same name as the function push() - but we're not referencing it as a function here, right?
llamatarianism
@llamatarianism
Aug 31 2016 02:57
@kedarjoyner that's the point.
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 02:57
var push = "unshift";
var arr = [1, 2, 3];
arr.push(4);
llamatarianism
@llamatarianism
Aug 31 2016 02:57
if you could use dot notation with variables
how would it know whether to do arr.push or arr.foo
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 02:58
If you know what both push and unshift do
llamatarianism
@llamatarianism
Aug 31 2016 02:58
that's why JS distinguishes arr[push] from arr.push/arr['push']
it avoids ambiguity
Gang Zhao
@crumpx
Aug 31 2016 03:00
var push = "foo"; var arr = [1, 2, 3]; arr.push(4);
Norvin Burrus
@ndburrus
Aug 31 2016 03:00
@meankraken you may enjoy this: :sparkles:
Gang Zhao
@crumpx
Aug 31 2016 03:00
this really works....scary...
llamatarianism
@llamatarianism
Aug 31 2016 03:00
no it doesn't @crumpx that's the point
it works normally and pushes 4 into arr
JS is dumb as s### but it ain't THAT dumb as s### aight
erick
@erickzhao
Aug 31 2016 03:00
lol
Kedar
@kedarjoyner
Aug 31 2016 03:00
hahahaha
Gang Zhao
@crumpx
Aug 31 2016 03:01
LOL
llamatarianism
@llamatarianism
Aug 31 2016 03:01
isNaN('') === false tho
erick
@erickzhao
Aug 31 2016 03:01
The "no-repeats-please" algorithm needs recursion... right?
llamatarianism
@llamatarianism
Aug 31 2016 03:01
@erickzhao you can do it iteratively
if you want to feel pain
erick
@erickzhao
Aug 31 2016 03:01
lmao alright
llamatarianism
@llamatarianism
Aug 31 2016 03:01
pretty much anything recursively can also be done iteratively, it's just kind of annoying sometimes
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:02
isNaN('') === false is fine, there are a lot worse sins in JavaScript
llamatarianism
@llamatarianism
Aug 31 2016 03:02
anything involving trees is a good thing to do recursively
and permutations are tree-ish
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:02
like skipping null values in map/reduce
/forEach
llamatarianism
@llamatarianism
Aug 31 2016 03:02
wow does it really do that
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:02
yep
try it
that's why everyone uses other libraries
llamatarianism
@llamatarianism
Aug 31 2016 03:02
doesn't do it for me
[null, null, null].map(x => x || 5);
// => [5, 5, 5]
just typed that into the node console
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:03
hmm... let me see. I know this happens in ES5
ah, sorry. I was mistaken. The behavior applies to arrays "with holes"
and undefined, not null
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:10
like so:
var arr = [];
arr[0] = "start";
arr[3] = "end";
arr.map(x => 0) // === [ 0, , , 0 ]
llamatarianism
@llamatarianism
Aug 31 2016 03:10
@Haseeb-Qureshi weird.
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:10
basically it doesn't yield undefined even though arr[1] would be undefined. producing different behavior when iterating with a for loop vs. forEach
this is because arrays are technically maps in javascript.
llamatarianism
@llamatarianism
Aug 31 2016 03:11
Array.from works though, weirdly.
Array.from(arr, _ => 0)
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:11
Does Array.from populate it with undefineds?
Gang Zhao
@crumpx
Aug 31 2016 03:11
your code broke my typeof function = =
ZZPot
@ZZPot
Aug 31 2016 03:11
jquery.css() works very slow. It waits while css will be aplied. How to do it async way?
llamatarianism
@llamatarianism
Aug 31 2016 03:12
lemme check
Leo
@hkleowong
Aug 31 2016 03:12
hi everyone i have a question about 'Mutations' exercise

function mutation(arr) {
var test = arr1.toLowerCase();
var target = arr[0].toLowerCase();

for (i=0;i<test.length;i++) {
if (target.indexOf(test[i]) < 0) {
return false;
} else {
return true;
}
}
}

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

Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:12
looks like it does.
llamatarianism
@llamatarianism
Aug 31 2016 03:12
yep
Leo
@hkleowong
Aug 31 2016 03:12
i dont know why it doesnt work
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:12
yeah so it's converting what would otherwise be a map into an actual array
the magic of javascript.
Stephen James
@sjames1958gm
Aug 31 2016 03:12
@hkleowong You need to check all the values before returning true
llamatarianism
@llamatarianism
Aug 31 2016 03:12
@hkleowong return ends the loop
JS is basically the new perl
erick
@erickzhao
Aug 31 2016 03:13
@hkleowong also var test = arr1.toLowerCase(); typo
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:13
more like php...
ZZPot
@ZZPot
Aug 31 2016 03:13
jquery.css() works very slow. It waits while css will be aplied. How to do it async way?
llamatarianism
@llamatarianism
Aug 31 2016 03:13
nah
PHP ain't as bloated
Stephen James
@sjames1958gm
Aug 31 2016 03:13
@erickzhao thats the markddown hiding characters
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:14
well it's got a similarly stupid standard library
Gang Zhao
@crumpx
Aug 31 2016 03:14
> var array = [];
undefined
> array
> array
[]
> array
> array
[]
> array
> array
[]
>
my node is acting weird.....
is it normal? = =
Haseeb Qureshi
@Haseeb-Qureshi
Aug 31 2016 03:14
i think that means you've entered the matrix
Stephen James
@sjames1958gm
Aug 31 2016 03:14
@ZZPot use html5 functions
llamatarianism
@llamatarianism
Aug 31 2016 03:14
@crumpx have you modified any builtins?
like, anything in the String.prototype?
Gang Zhao
@crumpx
Aug 31 2016 03:14
nothing
llamatarianism
@llamatarianism
Aug 31 2016 03:14
weird
I changed String.prototype.replace once and that made it go crazy :P
Gang Zhao
@crumpx
Aug 31 2016 03:15
> var s = arr.map(x => 0) // === [ 0, , , 0 ]

> s
0, , , 0 ]
> s[1]

> s[0]
0
> typeof(s[0])
'number'
> typeof(s[0]);

> typeof(s[0])

> s
0, , , 0 ]
> typeof(s[0])

> typeof(s[1])

> typeof(s)

>
i did this lol
erick
@erickzhao
Aug 31 2016 03:15
This message was deleted
Gang Zhao
@crumpx
Aug 31 2016 03:15
that's why i said that breaks my typeof()
and seem like everything else ....
xDDD
Stephen James
@sjames1958gm
Aug 31 2016 03:16
@erickzhao put backquotes to have it not processed by mark down
ZZPot
@ZZPot
Aug 31 2016 03:17
@sjames1958gm any other way to do simply work?
Christian Torres
@SlickChris95
Aug 31 2016 03:18
I solved this problem with some help and there is only one thing i do not understand. Why is it necessary to declare the variable largestNum inside of the loop?

function largestOfFour(arr){
// You can do this!
// make an array that consists of the largest numbers from each sub-array
var largestNumArray = [];
for (var i = 0; i < arr.length; i++){
// the only thing that i don't understand is why we declare this variable inside of the for loop
var largestNum = 0;
for (var j = 0; j < arr[i].length; j++){
if (arr[i][j] > largestNum){
largestNum = arr[i][j];
}
}

largestNumArray[i] = largestNum;

}
return largestNumArray;
}

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

Gang Zhao
@crumpx
Aug 31 2016 03:18
probably time to upgrade nodejs ...to 6.5.0...
Finn_Reo
@Finn199587
Aug 31 2016 03:21
who did the "Check for Palindromes"?
Gang Zhao
@crumpx
Aug 31 2016 03:22
what's up
Stephen James
@sjames1958gm
Aug 31 2016 03:22
@SlickChris95 You don't have to declare it in there, but you have to reset it each time.
@Finn199587 YEs
ZZPot
@ZZPot
Aug 31 2016 03:23
@sjames1958gm how many elements would it get if there is more than one lemenet on the page?
THalletProtech
@THalletProtech
Aug 31 2016 03:24
js
function chunkArrayInGroups(arr, size) {
  // Break it up.
   var nArr = [];
  var r = 0;
  if( size % 2 !== 0){
    r = size % 2;
  }
  var n = arr.lenght / (size - r);
  for(i = 0; i < n; i++){
    var obj = [];
    obj = arr.slice(i*size, Math.pow(size, i+1));
   nArr.push.apply(nArr , obj);
  }

     return  nArr;
}

chunkArrayInGroups([1, "b" , 3, "d", 5, "F"], 2);
push statment seems to not be working can some one help
Stephen James
@sjames1958gm
Aug 31 2016 03:25
@ZZPot Looks like you would have to set each individually -
THalletProtech
@THalletProtech
Aug 31 2016 03:25
i cant just add two arrays together
Stephen James
@sjames1958gm
Aug 31 2016 03:26
@THalletProtech You mean like array.concat()?
Esteban Rodriguez
@dynelight
Aug 31 2016 03:26
Hey how do I paste code for it to look on that nifty sublime format?
Gang Zhao
@crumpx
Aug 31 2016 03:27
@dynelight Markdown Help
Stephen James
@sjames1958gm
Aug 31 2016 03:27
@THalletProtech I think array.concat is what you want instead of the push.apply
THalletProtech
@THalletProtech
Aug 31 2016 03:27
'''
js
'''
CamperBot
@camperbot
Aug 31 2016 03:27
:bulb: to format code use backticks! ``` more info
ZZPot
@ZZPot
Aug 31 2016 03:27
@sjames1958gm still lag
Gang Zhao
@crumpx
Aug 31 2016 03:27
@THalletProtech ```
not '''
CamperBot
@camperbot
Aug 31 2016 03:27
:bulb: to format code use backticks! ``` more info
THalletProtech
@THalletProtech
Aug 31 2016 03:27
@sjames1958gm ill try
i know but it wont read
ZZPot
@ZZPot
Aug 31 2016 03:27
Why I can't just rotate element via jquery.animate()? Why should I always set css properties?
wtf?
Esteban Rodriguez
@dynelight
Aug 31 2016 03:28

Thanks!
So I was wondering, I am trying to use reduce to get the length of the highest array in an array of strings...
However, previousVal is undefined.

Any ideas?

js

function findLongestWord(str) {
  result = str.split(' ').reduce(function(previousVal, currentVal){
    if (currentVal.length > previousVal.length){
      return currentVal.length;
    }
  }, 0);
}

findLongestWord("The quick brown fox jumped over the lazy dog");
CamperBot
@camperbot
Aug 31 2016 03:28
:bulb: to format code use backticks! ``` more info
ZZPot
@ZZPot
Aug 31 2016 03:28
Should I run one thread per object for such simple action?
Gang Zhao
@crumpx
Aug 31 2016 03:28
@dynelight ``` is under your esc key
ZZPot
@ZZPot
Aug 31 2016 03:28
Yeah, I should run another browser for it
i will work fine
connection with MPI
c'mon.
and RPC
hard and un-logic
THalletProtech
@THalletProtech
Aug 31 2016 03:30
OMG cant geet concat to work
Esteban Rodriguez
@dynelight
Aug 31 2016 03:30
I could do it with a for, but I figured it would be more elegant to use reduce.
Leo
@hkleowong
Aug 31 2016 03:30
@llamatarianism @sjames1958gm oh so that is why 'return true' has to be outside the loop?
THalletProtech
@THalletProtech
Aug 31 2016 03:30
nArr = nArr.concat(obj);
Leo
@hkleowong
Aug 31 2016 03:30
@llamatarianism @sjames1958gm like so?
function mutation(arr) {
var test = arr1.toLowerCase();
var target = arr[0].toLowerCase();
for (i=0;i<test.length;i++) {
if (target.indexOf(test[i]) < 0)
return false;
}
return true;
}
Islam Ibakaev
@dagman
Aug 31 2016 03:34
@dynelight
function findLongestWord(str) {
  return str.split(' ').reduce(function(previousVal, currentVal){
    if (currentVal.length > previousVal.length){
      return currentVal;
    }
    return previousVal;
  }).length;
}
THalletProtech
@THalletProtech
Aug 31 2016 03:35
js
function chunkArrayInGroups(arr, size) {
  // Break it up.
   var nArr = [];
  var r = 0;
  if( size % 2 !== 0){
    r = size % 2;
  }
  var n = arr.lenght / (size - r);
  for(i = 0; i < n; i++){
    var obj = [];
    obj = arr.slice(i*size, Math.pow(size, i+1));
   nArr = nArr.concat(obj);
  }

     return  nArr;
}

chunkArrayInGroups([1, "b" , 3, "d", 5, "F"], 2);
concat not working now??? whats wrong
Islam Ibakaev
@dagman
Aug 31 2016 03:37
@THalletProtech can you give more meaningful names to your variables please in order for us to figure out easely
THalletProtech
@THalletProtech
Aug 31 2016 03:37
un momento por favor senor
Islam Ibakaev
@dagman
Aug 31 2016 03:38
cos it hard to read
seriously
Miguel Benevento
@KSMOknot
Aug 31 2016 03:38

JS
```

var string = "Split me into an array";
var array = [];

var x = string.split(" ");

array = [x];

Islam Ibakaev
@dagman
Aug 31 2016 03:38
no sarcasm please
Miguel Benevento
@KSMOknot
Aug 31 2016 03:38

var string = "Split me into an array";
var array = []; 

var x = string.split(" ");

array = [x];
I need help with this. trying to print the array without the spaces
Matt Davis
@chewieee
Aug 31 2016 03:44
hey all, need some help with Stand in Line
THalletProtech
@THalletProtech
Aug 31 2016 03:44
js
function chunkArrayInGroups(arr, size) {
  // Break it up.
   var newArr = [];
  var remainder = 0;
  if( size % 2 !== 0){
    remainder = size % 2;
  }
  var newSize = arr.lenght / (size - remainder);
  for(i = 0; i < newSize; i++){
    var object = [];
    object = arr.slice(i*size, Math.pow(size, i+1));
   newArr = newArr.concat(object);
  }

     return  newArr;
}

chunkArrayInGroups([1, "b" , 3, "d", 5, "F"], 2);
Matt Davis
@chewieee
Aug 31 2016 03:44
this is what i have:

function nextInLine(arr, item) {
var newArray = arr.push(item);

var result = newArray.pop();

return result;

}

i'm getting an error "typeError: newArray.pop is not a function"
THalletProtech
@THalletProtech
Aug 31 2016 03:45
oh i see the prob now
misspell
ok works now sorry yall
dissregard my stupidity
Matt Davis
@chewieee
Aug 31 2016 03:46
@THalletProtech haha not stupidity, missing ";" happen all the time
THalletProtech
@THalletProtech
Aug 31 2016 03:47
no lenght
not length
lol
Matt Davis
@chewieee
Aug 31 2016 03:47
i know but i mean mistakes like leaving ; off happen all the time, mispells are a coder's nightmare too
Gang Zhao
@crumpx
Aug 31 2016 03:47
@KSMOknot what do you mean without space?
Splitmeintoanarray like this?
Miguel Benevento
@KSMOknot
Aug 31 2016 03:48
@crumpx my bad, i mean split the string by its spaces
Gang Zhao
@crumpx
Aug 31 2016 03:48
oh
split(' ')
THalletProtech
@THalletProtech
Aug 31 2016 03:49
it was wierd i put the object in the return val it was working fine and then nothing would come up... i have to finish the challenge still and make a spot for the remainderrs
Gang Zhao
@crumpx
Aug 31 2016 03:49
there is a space in ' '
Miguel Benevento
@KSMOknot
Aug 31 2016 03:49
@crumpx thats what I tried at first but it didnt work :/
Gang Zhao
@crumpx
Aug 31 2016 03:49
there's no space in your array

```> array = [x];
[ [ 'Split', 'me', 'into', 'an', 'array' ] ]

x
[ 'Split', 'me', 'into', 'an', 'array' ]```

> array = [x];
[ [ 'Split', 'me', 'into', 'an', 'array' ] ]
> x
[ 'Split', 'me', 'into', 'an', 'array' ]
Islam Ibakaev
@dagman
Aug 31 2016 03:50
@THalletProtech i am not sure but this should work
function chunkArrayInGroups(arr, size) {
    var output = [],
        len = arr.length,
        i = 0;

    for(i = 0 ; i < len; i += size) {
        output.push(arr.slice(i, i + size));
    }    

    return output;
}
Gang Zhao
@crumpx
Aug 31 2016 03:51
if you're talking about the space between 'Split', 'me'
it's complete normal isn't it?
Egoscio
@Egoscio
Aug 31 2016 03:51
@dagman I'd .map() that.
Islam Ibakaev
@dagman
Aug 31 2016 03:52
@Egoscio i am not sure .map() is ok here
sean9
@sean9
Aug 31 2016 03:52
hey guys ive been stuck on this for a day now
Gang Zhao
@crumpx
Aug 31 2016 03:52
@KSMOknot array = [x]; does nothing here
sean9
@sean9
Aug 31 2016 03:52

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

return collection;
}
```

Islam Ibakaev
@dagman
Aug 31 2016 03:52
@Egoscio can you share you version
Egoscio
@Egoscio
Aug 31 2016 03:52
trying right now in REPL
Kalina Edwards
@kalina-edwards
Aug 31 2016 03:53
Question. Does it take a while to learn how to piece together just short
Islam Ibakaev
@dagman
Aug 31 2016 03:53
@Egoscio i am not sure you are able do it with .map()
Kalina Edwards
@kalina-edwards
Aug 31 2016 03:53
Piece together a j.s. program.
Islam Ibakaev
@dagman
Aug 31 2016 03:54
@kalina-edwards yep
sean9
@sean9
Aug 31 2016 03:54
how do i post code into here
so its formatted
Kalina Edwards
@kalina-edwards
Aug 31 2016 03:54
Because I understand what a var is a function is an array is but I'm getting g stuck when it's time to put everything together
@dagman
Islam Ibakaev
@dagman
Aug 31 2016 03:55
@Egoscio let me know if you somehow manage it with .map() :smile:
Kedar
@kedarjoyner
Aug 31 2016 03:55
@sean9 Hey Sean! I have been stuck on that too. After the ``` you have to press shift + enter
Islam Ibakaev
@dagman
Aug 31 2016 03:55
@kalina-edwards i didn't have this feeling :smile:
Esteban Rodriguez
@dynelight
Aug 31 2016 03:55
@dagman Why must I always return a value? So it can be used by the next iterator?
Egoscio
@Egoscio
Aug 31 2016 03:55
@dagman Oh shoot! I didn't notice you're incrementing with size
sean9
@sean9
Aug 31 2016 03:55
function updateRecords(id, prop, value) {
  if (prop == "tracks" && value !== "") {
    collection[id][prop][value] = value;
  } else if (prop == "tracks" && !collection[id].hasOwnProperty("tracks")) {
    collection[id][prop] = [];
  } else if (prop == "tracks" && value !== "") {
    collection[id][prop].push(value);    
  } else if (value === "") {
    delete collection[id][prop][value];
  }

  return collection;
}
Kedar
@kedarjoyner
Aug 31 2016 03:56
@sean9 there you go!
sean9
@sean9
Aug 31 2016 03:56
thanks @kedarjoyner
CamperBot
@camperbot
Aug 31 2016 03:56
sean9 sends brownie points to @kedarjoyner :sparkles: :thumbsup: :sparkles:
:cookie: 227 | @kedarjoyner |http://www.freecodecamp.com/kedarjoyner
Islam Ibakaev
@dagman
Aug 31 2016 03:56
@dynelight what do you mean?
Kalina Edwards
@kalina-edwards
Aug 31 2016 03:56
I just started. But I don't feel confident to put all of them together in a program
Esteban Rodriguez
@dynelight
Aug 31 2016 03:56
@dagman I posted a bit ago, do you need me to repost?
Islam Ibakaev
@dagman
Aug 31 2016 03:56
@kalina-edwards so don't try put them together for now
Egoscio
@Egoscio
Aug 31 2016 03:57

@dagman I apologize for my cockiness, it just looked like a general map-wannabe forloop.

function chunkArrayInGroups(arr, size) {
    return arr.map(function(val, i) {
        return val.slice(i, i + size)
    })
}

was what I was thinking

Kalina Edwards
@kalina-edwards
Aug 31 2016 03:57
Hmmm. What would be a good way to make sure I understand to create a program @dagman
sean9
@sean9
Aug 31 2016 03:57
@kedarjoyner i did this challenge a few months ago but they seem to have changed the requirements but I mean I forgot what I did before but I just cant get it nore
now
Islam Ibakaev
@dagman
Aug 31 2016 03:57
@Egoscio fail
Kedar
@kedarjoyner
Aug 31 2016 03:58
@sean9 Yeah, after doing some research online I noticed that people have been complaining about the wording of the new rendition.
Egoscio
@Egoscio
Aug 31 2016 03:58
There was one thing stopping it from being mappable ;)
Kedar
@kedarjoyner
Aug 31 2016 03:58
^ It's confusing, for sure.
Islam Ibakaev
@dagman
Aug 31 2016 03:58
@kalina-edwards try learning step by step if you don't understand it give yourself a time then return
sean9
@sean9
Aug 31 2016 03:58
Anyone <3
function updateRecords(id, prop, value) {
  if (prop == "tracks" && value !== "") {
    collection[id][prop][value] = value;
  } else if (prop == "tracks" && !collection[id].hasOwnProperty("tracks")) {
    collection[id][prop] = [];
  } else if (prop == "tracks" && value !== "") {
    collection[id][prop].push(value);    
  } else if (value === "") {
    delete collection[id][prop][value];
  }

  return collection;
}
Kalina Edwards
@kalina-edwards
Aug 31 2016 03:59
Thanks for the advice. I appreciate it. @dagman
CamperBot
@camperbot
Aug 31 2016 03:59
kalina-edwards sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:cookie: 634 | @dagman |http://www.freecodecamp.com/dagman
Kedar
@kedarjoyner
Aug 31 2016 03:59
@sean9 I have a link to a solution (mine was ALMOST there) that I can send you if you'd like. It's very similar to yours. It may help you to analyze how they did it.
Islam Ibakaev
@dagman
Aug 31 2016 03:59
@kalina-edwards yw just keep doing it :smile:
Kalina Edwards
@kalina-edwards
Aug 31 2016 03:59
Thank you. 😄
@dagman
Islam Ibakaev
@dagman
Aug 31 2016 03:59
that the only what matters
Kalina Edwards
@kalina-edwards
Aug 31 2016 04:00
I guess I just feel behind like I'm never going to get passed j.s. lol
sean9
@sean9
Aug 31 2016 04:01
@kalina-edwards sure that would help me
Kalina Edwards
@kalina-edwards
Aug 31 2016 04:01
And fully understand it. @dagman
Islam Ibakaev
@dagman
Aug 31 2016 04:02
@kalina-edwards that's exactly what everyone one feels(and me too) and you know what...it is normal feeling :smile:
Kalina Edwards
@kalina-edwards
Aug 31 2016 04:03
Hahah thank you for the pep talk. I appreciate it @dagman and even everyone else.
CamperBot
@camperbot
Aug 31 2016 04:03
kalina-edwards sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:warning: kalina-edwards already gave dagman points
Alexander Køpke
@alexanderkopke
Aug 31 2016 04:03
Gang Zhao
@crumpx
Aug 31 2016 04:04

again, you should check

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

first, because if it's true you don't have to check anything else :D

Kalina Edwards
@kalina-edwards
Aug 31 2016 04:04
Also I'm documenting my coding journey here if anyone is interested. Youtube.com/user/kalina407
Kedar
@kedarjoyner
Aug 31 2016 04:05
@sean9 This person had two solutions. Mine was closest to the first one, which is also where you were headed: goo.gl/8Vlfr8
Kalina Edwards
@kalina-edwards
Aug 31 2016 04:05
Thanks everyone, good night.
Kedar
@kedarjoyner
Aug 31 2016 04:05
@sean9 This is an even a simpler solution which took me 2 hours to even understand: https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Challenge-Record-Collection. I like how simple it is though. I learned a lot from reading through this one.
@sean9 I am going to practice other problems similar to this one to make sure I know what I'm doing. Feel free to send me a PM if you want to do them together!
Gang Zhao
@crumpx
Aug 31 2016 04:06
function updateRecords(id, prop, value) {
  if (value==="") {
   delete collection[id][prop];
    return collection;
  }

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

  }

  return collection;
}
sean9
@sean9
Aug 31 2016 04:08
@kedarjoyner thanks, when I tried doing .push before I would get an error since collection is an object not an array
CamperBot
@camperbot
Aug 31 2016 04:08
sean9 sends brownie points to @kedarjoyner :sparkles: :thumbsup: :sparkles:
:warning: sean9 already gave kedarjoyner points
Kedar
@kedarjoyner
Aug 31 2016 04:10
@crumpx the nested else if and if really trip me up on these solutions.
@sean9 that happened to me too.
@crumpx can you explain what's happening in the else if statement? Why couldn't it be else if (prop === "tracks" && collection[id][prop] == undefined)
Mahmoud ElNaggar
@lenaggar
Aug 31 2016 04:13
hello!
help!
:D
Gang Zhao
@crumpx
Aug 31 2016 04:14
@kedarjoyner because that's what challenge requires.
Kedar
@kedarjoyner
Aug 31 2016 04:15
@crumpx It doesn't say to nest those, though?
Egoscio
@Egoscio
Aug 31 2016 04:15
@kedarjoyner That would suggest that the value can only be changed if it does not exist. What if you want it to be updatable?
Gang Zhao
@crumpx
Aug 31 2016 04:15
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.
therefore if (collection[id][prop] === undefined) { collection[id][prop] = [value];
Kedar
@kedarjoyner
Aug 31 2016 04:17
@crumpx but where is the empty array being created? wouldn't it then be collection[id][prop] = []?
Mahmoud ElNaggar
@lenaggar
Aug 31 2016 04:18
I am stuck at the Steamroller challenge.
is this the right place to ask for help or am I in the wrong place?
Egoscio
@Egoscio
Aug 31 2016 04:18
@lenaggar Yeah, "Get help on our basic JavaScript and Algorithms Challenges"
Kedar
@kedarjoyner
Aug 31 2016 04:18
@Egoscio That's true, it just seems so odd to have an if statement being the argument for an else if statement. I'm not sure why it's not clicking for me.
sean9
@sean9
Aug 31 2016 04:19
Why does it matter whether it is (value !== " && prop !== "tracks) or (prop !== "tracks" && value !== "")
i had it flipped and it wasnt working, now that I switched it its working "better"
Gang Zhao
@crumpx
Aug 31 2016 04:20
collection[id][prop] = [value];
it create empty array and put value in it? xD
Kedar
@kedarjoyner
Aug 31 2016 04:20
@crumpx OH! I didn't realize it was doing both.
@crumpx so much to learrrrrnnnnnnn.....
Michael Karpinski
@karpimpski
Aug 31 2016 04:21
do any of you guys know a way to generate sass code with pure, vanilla JavaScript? I'm making a fairly large-scale front-end project without using any front-end frameworks. vanilla JS, HTML, and CSS (with only a teeny bit of pre-processing :P )
and so far it's including a ton of repetitive sass code/files that i wish i could put into a function
Kedar
@kedarjoyner
Aug 31 2016 04:21
Thanks for your help @crumpx
CamperBot
@camperbot
Aug 31 2016 04:21
kedarjoyner sends brownie points to @crumpx :sparkles: :thumbsup: :sparkles:
Mahmoud ElNaggar
@lenaggar
Aug 31 2016 04:21

@Egoscio ok, so the challenge was about writing an algorithm that flattens a nested array (varying levels of nesting)

"var arrNew = [];

function steamrollArray(arr) {
for(var i = 0; i < arr.length; i++) {
if(!Array.isArray(arr[i])) {
arrNew.push(arr[i]);
} else {
steamrollArray(arr[i]);
}
}
return arrNew;
}

steamrollArray([[["a"]], [["b"]]]);

CamperBot
@camperbot
Aug 31 2016 04:21
:cookie: 280 | @crumpx |http://www.freecodecamp.com/crumpx
Gang Zhao
@crumpx
Aug 31 2016 04:21
np
sean9
@sean9
Aug 31 2016 04:21
@sean9
Why does it matter whether it is (value !== " && prop !== "tracks) or (prop !== "tracks" && value !== "")
i had it flipped and it wasnt working, now that I switched it its working "better"
Mahmoud ElNaggar
@lenaggar
Aug 31 2016 04:22
how can I post a code snippet?
Gang Zhao
@crumpx
Aug 31 2016 04:22
else it would be collection[id][prop] = value, and it wouldn't be an array but a string.
Kedar
@kedarjoyner
Aug 31 2016 04:23
@karpimpski Are you doing the Under 10K project?
Egoscio
@Egoscio
Aug 31 2016 04:23
@lenaggar '''
CamperBot
@camperbot
Aug 31 2016 04:23
:bulb: to format code use backticks! ``` more info
Mahmoud ElNaggar
@lenaggar
Aug 31 2016 04:23
@Egoscio ok, so the challenge was about writing an algorithm that flattens a nested array (varying levels of nesting)
var arrNew = [];

function steamrollArray(arr) {
  for(var i = 0; i < arr.length; i++) {
    if(!Array.isArray(arr[i])) {
      arrNew.push(arr[i]);
    } else {
      steamrollArray(arr[i]);
    }
  }
  return arrNew;
}

steamrollArray([[["a"]], [["b"]]]);
Egoscio
@Egoscio
Aug 31 2016 04:24
Just curious, is [[["a"]], [["b"]]]the actual argument the exercise provides?
Kedar
@kedarjoyner
Aug 31 2016 04:24
@karpimpski: https://a-k-apart.com/ :)
Mahmoud ElNaggar
@lenaggar
Aug 31 2016 04:24
@Egoscio yes, one of the ones to test the code
Gang Zhao
@crumpx
Aug 31 2016 04:25
@sean9 (value !== " && prop !== "tracks) huh?
what's up with those " s
Michael Karpinski
@karpimpski
Aug 31 2016 04:26
@kedarjoyner no, I'm using JavaScript, just without frameworks :/
that looks very interesting though!
sean9
@sean9
Aug 31 2016 04:26
I didnt read over it but you should understand what I mean
i just reversed the values and the function works now, is there any reason for working one way and not the other
Gang Zhao
@crumpx
Aug 31 2016 04:27
@kedarjoyner my code above if (prop != "tracks" && value !== "") { collection[id][prop] = value; I don't even need this && value !== "" part
Michael Karpinski
@karpimpski
Aug 31 2016 04:28
@kedarjoyner weird though, looking at the submissions people are using js as well as php
Gang Zhao
@crumpx
Aug 31 2016 04:30
  if (value==="") {
   delete collection[id][prop];
    return collection;
  }
at the begining takes care off of empty values.
wrote this 2 days ago, i was a baby :P
Mahmoud ElNaggar
@lenaggar
Aug 31 2016 04:31
@Egoscio the code runs but FCC doesn't accept it, and I don't know why ... I tried to do it using recursion
Kedar
@kedarjoyner
Aug 31 2016 04:31
@karpimpski Yeah! They're discouraging frameworks. If your site ends up being under 10K you should definitely submit it to the project ! Is there any reason you don't want to use a sass compiler like Codekit or gulp?
Egoscio
@Egoscio
Aug 31 2016 04:31
@lenaggar First, I tried to remove your invocation of the function, and it passed the first test
Michael Karpinski
@karpimpski
Aug 31 2016 04:33
@kedarjoyner well right now I'm working on learning back-end Ruby. I decided to take a break to refine some of my front-end skills and take on a pretty big game project! I don't like frameworks like jQuery and Bootstrap because I think they're restricting and I'd rather avoid performance issues. I don't want to learn Gulp which seems like my obvious solution because I'd rather complete this and then continue learning Ruby asap
Kedar
@kedarjoyner
Aug 31 2016 04:34
@karpimpski Completely understandable. You might like just using something simple like Codekit if Sass is the only thing you're needing it for. You just plop your project in, tell Codekit to compile your style.scss file into your style.css file and it'll watch the changes for you as you build.
Raj Sharma
@rajsharma1612
Aug 31 2016 04:35
I couldn't understand this question..
Could someone help me to understand this..
Michael Karpinski
@karpimpski
Aug 31 2016 04:35
@kedarjoyner oh I have a preprocessor. I want to write sass code from JavaScript, because the code I'm writing for class animations is very repetitive
i'm actually kinda cheating and using the sass gem to watch for me :P
Kedar
@kedarjoyner
Aug 31 2016 04:36
@karpimpski Oh! I'm so sorry. I completely misunderstood you.
haha! I've done that too :D
Michael Karpinski
@karpimpski
Aug 31 2016 04:38
@kedarjoyner yeah, I like to sneak a bit of Ruby into my front-end projects for little things like that to make things easier :)
Kedar
@kedarjoyner
Aug 31 2016 04:39
@karpimpski I might not be on the right track still, but couldn't you just use the addClass() js function to grab the classes you've written in your sass files? Then you would only need to write the style once, and add the class via javascript wherever its needed. Although I think that'll cause a performance hit for user.
@karpimpski Awesome! The closest I've ever gotten to Ruby is using jekyll. I'm really jealous that you're learning it.
Michael Karpinski
@karpimpski
Aug 31 2016 04:40
@kedarjoyner yep! addClass() is jQuery, so I append to .className, but I'm writing separate classes for all of my separate ids and it's just a bit tedious. and I'm not so sure that Ruby is a good choice. it seems like PHP or Node may be a smarter idea
I love Ruby, but PHP seems to be much more popular and in demand
Kedar
@kedarjoyner
Aug 31 2016 04:42
@karpimpski shoot, yeah, I'm not too sure about that one. Yeah that's tough! We use php at work everyday because we're a Wordpress shop, but there's a super successful Ruby dev shop just down the street. I think it just depends on where you are ^.^ That's one thing I hate about development, is you just never know what to focus on the most!
Alan M.
@Am3ra
Aug 31 2016 04:43
hey guys, quick question, why does arr[i][0]= arr[i][0].toUpperCase(); not work?
Michael Karpinski
@karpimpski
Aug 31 2016 04:43
@kedarjoyner man I wish I lived in your town! the closest thing I have to a dev shop is a run-down computer repair shop a few miles from my house
Michael Karpinski
@karpimpski
Aug 31 2016 04:44
and yeah, it is a bit daunting. but I'm just trying to learn a little bit of all of this to see where I fit best
Gang Zhao
@crumpx
Aug 31 2016 04:44
Strings are immutable
Alan M.
@Am3ra
Aug 31 2016 04:45
@marienhof try putting spaces between words?
@crumpx alright, so how does that affect it?
Michael Karpinski
@karpimpski
Aug 31 2016 04:45
@marienhof it wants you to put things between the words you are given, like a Mad Libs
Gang Zhao
@crumpx
Aug 31 2016 04:46
@marienhof put words in there to make a sentence. See the link in question
Alan M.
@Am3ra
Aug 31 2016 04:46
@karpimpski oh, yup
Gang Zhao
@crumpx
Aug 31 2016 04:47
@jp2kk2 I'm guessing your arr[i][0] is a string
The first character of a string?
Alan M.
@Am3ra
Aug 31 2016 04:48
yeah
well, i made it so theres only one character anyways

function titleCase(str) {
  var arr=[];
  var a = str.toLowerCase().split(' ');
  for (i=0;i<a.length;i++){
    arr.push([]);
    console.log(arr);
    arr[i].push(a[i].split(''))
    //arr[i][0]= arr[i][0].toUpperCase();
  }
  console.log(arr);
}

titleCase("I'm a little tea pot");
Sergie Marienhof
@marienhof
Aug 31 2016 04:50
@crumpx I still don't get it :(
Markus Kiili
@Masd925
Aug 31 2016 04:51
@jp2kk2 You are trying to set a character of a string. Strings are immutable, so that is not possible.
@jp2kk2 Therefore you always make new strings from the old.
Alan M.
@Am3ra
Aug 31 2016 04:51
right, @Masd925
hence the
arr[i][0]= arr[i][0].toUpperCase();
so is that wrong?
idk how to fix...
Gang Zhao
@crumpx
Aug 31 2016 04:53
I think you can use regex you just came across
My code is very different from yours :p#
Alan M.
@Am3ra
Aug 31 2016 04:54
hahahahaha
What process did you use?
Gang Zhao
@crumpx
Aug 31 2016 04:56
I use .replace
Markus Kiili
@Masd925
Aug 31 2016 04:57
@jp2kk2 It should be arr[i] = arr[i].charAt(0).toUpperCase()+... <- rest of arr[i] here lowercased
Alan M.
@Am3ra
Aug 31 2016 04:58
@Masd925 lemme try that real quick
maybe with a for loop so its simpler?
Markus Kiili
@Masd925
Aug 31 2016 04:59
@jp2kk2 Split and loop.
Alan M.
@Am3ra
Aug 31 2016 04:59
yeah, thats what i have so far
Gang Zhao
@crumpx
Aug 31 2016 05:00
@marienhof it's a mind game really, it make you think too much
Alan M.
@Am3ra
Aug 31 2016 05:00
real time sharing
Gang Zhao
@crumpx
Aug 31 2016 05:00
It's super simple
Really
result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;
See those " "?
Fill in what whatever you want and make it a sentence
Alan M.
@Am3ra
Aug 31 2016 05:05
@Masd925 so close....
Markus Kiili
@Masd925
Aug 31 2016 05:07
@jp2kk2 Map method would be an option instead of for loop.
Alan M.
@Am3ra
Aug 31 2016 05:08
dont know it too well :P
Gang Zhao
@crumpx
Aug 31 2016 05:08
i post mine
Right under yours
I commented out my first version to use map
Both works the same
Alan M.
@Am3ra
Aug 31 2016 05:12
where?
Alan M.
@Am3ra
Aug 31 2016 05:15
doesnt show for some reason...
maybe on jsfiddle?
Gang Zhao
@crumpx
Aug 31 2016 05:17

function titleCase(str) {
  str = str.toLowerCase().split(' ');
  var regex= /^[\w]/;

  /*for (var i=0; i<str.length; i++){
    str[i] = str[i].replace(regex, str[i].split('')[0].toUpperCase());
  }

  str=str.join(' ');

  return str;*/

  return str.map(function(val){
    return val.replace(regex, val.split('')[0].toUpperCase());
  }).join(' ');
   //return str;
}

titleCase("I'm a little tea pot");
Alan M.
@Am3ra
Aug 31 2016 05:20
ok
ill try and figure it out tomorrow man
good night
thanks, @crumpx
CamperBot
@camperbot
Aug 31 2016 05:21
jp2kk2 sends brownie points to @crumpx :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @crumpx |http://www.freecodecamp.com/crumpx
Markus Kiili
@Masd925
Aug 31 2016 05:21
@crumpx I think it as simpler and more efficient to just do:
function titleCase(str) {
  return str.split(' ').map(function(val){
    return val.charAt(0).toUpperCase() + val.substr(1).toLowerCase();
  }).join(' ');
}
Gang Zhao
@crumpx
Aug 31 2016 05:23
Yea I didn't know about charAt 2 days ago :P
Nowhere in these challenges mentions that so ...
I was too young too simple, sometimes naive 2 days ago. And I'm still learning :)
Alan M.
@Am3ra
Aug 31 2016 05:25
@Masd925 Wizard.
Gang Zhao
@crumpx
Aug 31 2016 05:25
Lol good night everyone :)
Alan M.
@Am3ra
Aug 31 2016 05:25
hahahahahahahaha
dude, that map and .subtr() use is awesome
wtffff
Gang Zhao
@crumpx
Aug 31 2016 05:27
Lol
Markus Kiili
@Masd925
Aug 31 2016 05:28
@jp2kk2 Stop eating mushroom and do the next challenge ;)
Gang Zhao
@crumpx
Aug 31 2016 05:28
My mind blown multiple times in these 6 days. One week tomorrow wow
Alan M.
@Am3ra
Aug 31 2016 05:28
@Masd925 hahahahaha will do
thanks man! @Masd925
CamperBot
@camperbot
Aug 31 2016 05:28
jp2kk2 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2414 | @masd925 |http://www.freecodecamp.com/masd925
Esteban Rodriguez
@dynelight
Aug 31 2016 05:28

Hello. I am sorry I posted earlier the same question but I got lost with the reply.

I am stuck using the reduce() function. I am getting a previousVal is undefined error

Alan M.
@Am3ra
Aug 31 2016 05:29
night guys
Esteban Rodriguez
@dynelight
Aug 31 2016 05:29
js

function findLongestWord(str) {
  result = str.split(' ').reduce(function(previousVal, currentVal){
    if (currentVal.length > previousVal.length){
      return currentVal.length;
    }
    else {
      return previousVal.length;
    }
  }, 0);
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Gang Zhao
@crumpx
Aug 31 2016 05:30
You can't use reduce with this
Use map
Esteban Rodriguez
@dynelight
Aug 31 2016 05:30
Thanks @crumpx
CamperBot
@camperbot
Aug 31 2016 05:30
dynelight sends brownie points to @crumpx :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @crumpx |http://www.freecodecamp.com/crumpx
Gang Zhao
@crumpx
Aug 31 2016 05:30
Because you will fail first call
Markus Kiili
@Masd925
Aug 31 2016 05:30
@dynelight It seems that previousVal and the return value from the callback are (should be) numbers }, 0);
Vishon
@Symbolistic
Aug 31 2016 05:31
I gotta say, Freecodecademy has really made coding a lot more fun for me. I actually just thought to myself while making this new website, "wow coding is pretty fun"
Gang Zhao
@crumpx
Aug 31 2016 05:31
Unless you don't try to use any method
Because first pre will be undefined
Vishon
@Symbolistic
Aug 31 2016 05:31
although those algorithm challenges still make me wanna smash my head into the desk
Gang Zhao
@crumpx
Aug 31 2016 05:31
Undefined.length = ???
Esteban Rodriguez
@dynelight
Aug 31 2016 05:32
@crumpx That is why I thought this could be initialized.
Markus Kiili
@Masd925
Aug 31 2016 05:32
@dynelight previousVal is a number so don't use previousVal.length
Gang Zhao
@crumpx
Aug 31 2016 05:33
It's not a number, you can still do like put strings together
Esteban Rodriguez
@dynelight
Aug 31 2016 05:33
It worked!
@Masd925 Thanks a lot!!
CamperBot
@camperbot
Aug 31 2016 05:34
dynelight sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2415 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 31 2016 05:34
@crumpx Reduce is one of the best ways to solve this challenge.
Gang Zhao
@crumpx
Aug 31 2016 05:34
Undefined + "string" will not give you error
But undefined.length will throw error
Esteban Rodriguez
@dynelight
Aug 31 2016 05:34
Solution @Masd925

function findLongestWord(str) {
  result = str.split(' ').reduce(function(previousVal, currentVal){
    if (currentVal.length > previousVal){
      return currentVal.length;
    }
    else {
      return previousVal;
    }
  }, 0);
  return result;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Daniel
@DanielMW34
Aug 31 2016 05:35
Anybody complete the Wikipedia exercise yet? I have a question regarding the structure of displaying the data. For loop? What do you think works best?
Gang Zhao
@crumpx
Aug 31 2016 05:35
Ok.. But why xD
Markus Kiili
@Masd925
Aug 31 2016 05:36
@dynelight You have implemented Math.max there yourselves, so you could use Math.max instead. Here are a couple of elegant solutions:
function findLongestWord(str) {
  return Math.max.apply(null, str.split(' ').map(function(elem){return elem.length;}));
}

function findLongestWord(str) {
  return str.split(' ').reduce(function(prev, curr) {
    return Math.max(prev, curr.length);
  }, 0);
}
Esteban Rodriguez
@dynelight
Aug 31 2016 05:37
@crumpx I think I'm getting the hang of this. The previous value is not the previous value of the array, its a calculated value in this case. The current value is the iterator.
Is it a bad thing if I am going somewhat quickly over the whole course by the way? I do have experience programming.. This was supposed to take 50 hours but its taken me significantly less.
Markus Kiili
@Masd925
Aug 31 2016 05:38
@dynelight A better name for the first parameter is accumulator of running value, not previous value.
Gang Zhao
@crumpx
Aug 31 2016 05:38
I used for loop to solve this.
Oh that's why
Markus Kiili
@Masd925
Aug 31 2016 05:39
For loop is fine too of course.
Esteban Rodriguez
@dynelight
Aug 31 2016 05:40
I figured I could use loop
But I wanted to solve it different
expand my mind a bit hah
Gang Zhao
@crumpx
Aug 31 2016 05:40
I didn't know reduce or map when I do that one :D
Neil
@MysteryN
Aug 31 2016 05:41
SOS, does anyone know what is wrong? (From the basic JavaScript "Record Collection")
function updateRecords(id, prop, value) {  
  if (value === ""){
    delete collection[id][prop];
  } else {
    if (prop == "tracks"){
      if (collection[id].hasOwnProperty("tracks") === false) {
        collection[id].tracks = "";
        collection[id].tracks = value;
      } else {
        collection[id][prop].push(value);
      }
    } else {
      collection[id][prop] = value;
    }
  }
  return collection;
}
Gang Zhao
@crumpx
Aug 31 2016 05:41
So I learn a bit about reduce also thanks @Masd925 @dynelight
CamperBot
@camperbot
Aug 31 2016 05:41
crumpx sends brownie points to @masd925 and @dynelight :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @dynelight |http://www.freecodecamp.com/dynelight
:star2: 2416 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 31 2016 05:42
@MysteryN If tracks property is absent, assign [] or [value]
@crumpx It is the faucet and the goose of array manipulation.
Gang Zhao
@crumpx
Aug 31 2016 05:43
I feel like 100 people join freecodecamp with me the same day... I saw this update record question all day long hahah
Neil
@MysteryN
Aug 31 2016 05:45
@Masd925 I changed it to collection[id].tracks = []; but it still can not pass :worried:
Gang Zhao
@crumpx
Aug 31 2016 05:45
Ok really have to sleep now
Daniel Lee
@twdaniel
Aug 31 2016 05:45
~~~
Gang Zhao
@crumpx
Aug 31 2016 05:46
[id][prop] maybe?
Markus Kiili
@Masd925
Aug 31 2016 05:46
@MysteryN On your logic, I think you need to assign [value]
@crumpx .tracks is the same as [prop] there.
Christopher Pangilinan
@newbielike
Aug 31 2016 05:47

function findLongestWord(str) 
{
  var strWords = str.split(" ");
  var x;
  var y = 1;
  for(x = 0; x < strWords; x++,y += 2)
    {
      if(strWords[x].length > strWords[y].length)
        {
          strAns = strWords[x].length;
        }
      else
        {
          strAns = strWords[y].length;
      }
    }
  return strAns;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
What Seems to be the problem with my code?
Neil
@MysteryN
Aug 31 2016 05:47
@Masd925 It worked! Thank you very much!
CamperBot
@camperbot
Aug 31 2016 05:47
mysteryn sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2417 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 31 2016 05:47
@MysteryN You're welcome.
Christopher Pangilinan
@newbielike
Aug 31 2016 05:48
dont mind the y+=2 i can change that
Markus Kiili
@Masd925
Aug 31 2016 05:48
@newbielike One index is enough.
This message was deleted
Esteban Rodriguez
@dynelight
Aug 31 2016 05:51
Yay I got cookies!
So I really don't want to sound arrogant (I really am not), but is it okay if I am going thru these faster than the time mentioned for each section?
I did this 50 hour section in 4 hours... but like I said I do have a background on programming
Gang Zhao
@crumpx
Aug 31 2016 05:53
@Masd925 didn't read his code :p I would prefer to use variable name over hard code one :)
Markus Kiili
@Masd925
Aug 31 2016 05:54
@dynelight They are not so hard if you have programmed something before. Some who just have started can use a week on one tough challenge.
Matt Davis
@chewieee
Aug 31 2016 05:54
quick question, how do you share a capture of the console?
Markus Kiili
@Masd925
Aug 31 2016 05:56
explain format
CamperBot
@camperbot
Aug 31 2016 05:56
no wiki entry for: format
Matt Davis
@chewieee
Aug 31 2016 05:57
anyone?
Esteban Rodriguez
@dynelight
Aug 31 2016 05:58
@chewieee You want to take a screen shot of the console? Or just show us the code?
Kyze Gozo
@Kyze-Gozo
Aug 31 2016 05:58
I just started the javascript section and i dont know what to do
Markus Kiili
@Masd925
Aug 31 2016 05:58
@chewieee Three backticks before and after the copy/pasted code does it.
Matt Davis
@chewieee
Aug 31 2016 05:58
show the code, like @newbielike a few scrolls up
Esteban Rodriguez
@dynelight
Aug 31 2016 05:58
Also, this solved this problem, but is there a more elegant way? Is there a way to call filter with parameters, or not declaring a global variable?

var current_value = -1;

function destroyer(arr) {
  for(var i = 1; i < arguments.length; i++){
    current_value = arguments[i];
    arr = arr.filter(toRemove); 
  }
  return arr;
}

function toRemove(val){
  return val != current_value;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I'm having a problem with that current_value
Markus Kiili
@Masd925
Aug 31 2016 05:59
@dynelight It is better if you only filter once and put the loop inside the callback function.
Kyze Gozo
@Kyze-Gozo
Aug 31 2016 05:59
how do i post a picture of my code in the chat
Matt Davis
@chewieee
Aug 31 2016 05:59

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

function checkObj(checkProp) {
// Your Code Here

if(myObj.hasOwnProperty[checkProp]){
return myObj[checkProp];
}
else{
return "Not Found";
}
}

// Test your code by modifying these values

checkObj("gift");

Markus Kiili
@Masd925
Aug 31 2016 05:59
@dynelight Global variables also mess up FCC tests.
Esteban Rodriguez
@dynelight
Aug 31 2016 05:59
@Kyze-Gozo Use before and after your code
Matt Davis
@chewieee
Aug 31 2016 06:00
@Masd925 back ticks??
Esteban Rodriguez
@dynelight
Aug 31 2016 06:00
@Kyze-Gozo ```
Matt Davis
@chewieee
Aug 31 2016 06:00
oh right right
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  if(myObj.hasOwnProperty[checkProp]){
    return myObj[checkProp];
  }
  else{
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
Esteban Rodriguez
@dynelight
Aug 31 2016 06:00
@Masd925 That is why I am asking if there is a better way :)
Matt Davis
@chewieee
Aug 31 2016 06:00
o0o0o0o thanks guys
Kyze Gozo
@Kyze-Gozo
Aug 31 2016 06:01

'''// Setup
var a;
var b = 2;

// Only change code below this line

'''

CamperBot
@camperbot
Aug 31 2016 06:01
:bulb: to format code use backticks! ``` more info
Matt Davis
@chewieee
Aug 31 2016 06:02
can someone quickly spot what's wring with my code? I thought I was accessing the object correctly :(
apparently my if statement isn't correct, the function jumps straight to the return "Not Found" line
Esteban Rodriguez
@dynelight
Aug 31 2016 06:03
@chewieee Are you changing the code below the comments?
@chewieee Also, use back ticks. ``` and not '''
CamperBot
@camperbot
Aug 31 2016 06:03
:bulb: to format code use backticks! ``` more info
Kyze Gozo
@Kyze-Gozo
Aug 31 2016 06:04
// Setup
var a;
var b = 2;

// Only change code below this line
Matt Davis
@chewieee
Aug 31 2016 06:04
no, only code under "Your Code Here" is altered
checkObj("gift" should return "pony" but only 'checkObj("house") should return "Not Found"' is returning correctly
oh nvm i think I know what's wrong
Kyze Gozo
@Kyze-Gozo
Aug 31 2016 06:07
// Setup
var a;
var b = 2;

// Only change code below this line

Instructions
Assign the value 7 to variable a.

Assign the contents of a to variable b.

what am i supposed to do its my first time using an actual programming language
Christopher Pangilinan
@newbielike
Aug 31 2016 06:08
value means the number or String after the equal sign
c0d0er
@c0d0er
Aug 31 2016 06:09
Hi, could anybody help me on the following codes, why my two codes both wrong? this is for "Profile Lookup " challenge, https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afor(var%20i%3D0%3B%20i%3Ccontacts.length%3B%20i%2B%2B)%7B%0A%20%20%2F%2Fwhy%20doesnt%20this%20code%20work%3F%0A%20%20%2F%2Fif(contacts%5Bi%5D.firstName%3D%3D%3DfirstName%20%26%26%20contacts%5Bi%5D.hasOwnProperty(prop))%7Breturn%20contacts%5Bi%5D%5Bprop%5D%3B%7D%0A%20%20%2F%2Fif(contacts%5Bi%5D.firstName!%3D%3DfirstName)%7Breturn%20%22No%20such%20contact%22%3B%7D%0A%20%20%2F%2Fif(!contacts%5Bi%5D.hasOwnProperty(prop))%7Breturn%20%22No%20such%20property%22%3B%7D%0A%20%20%0A%20%20%2F%2Fwhy%20doesnt%20this%20code%20work%3F%20%0A%20%20%2F*if(contacts%5Bi%5D.firstName%3D%3D%3DfirstName)%7B%0A%20%20%20%20if(contacts%5Bi%5D.hasOwnProperty(prop))%7B%0A%20%20%20%20%20%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%7Breturn%20%22No%20such%20property%22%3B%7D%0A%20%20%7D%0A%20%20else%7Breturn%20%22No%20such%20contact%22%3B%7D%0A%7D*%2F%0A%20%20if(contacts%5Bi%5D.firstName%3D%3D%3DfirstName)%7B%0A%20%20%20%20if(contacts%5Bi%5D.hasOwnProperty(prop))%7B%0A%20%20%20%20%20%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%7Breturn%20%22No%20such%20property%22%3B%7D%0A%20%20%7D%0A%20%20%2F%2Felse%7Breturn%20%22No%20such%20contact%22%3B%7D%0A%7D%0A%20%20return%20%22No%20such%20contact%22%3B%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
//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
for(var i=0; i<contacts.length; i++){
  //why doesnt this code work?
  //if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)){return contacts[i][prop];}
  //if(contacts[i].firstName!==firstName){return "No such contact";}
  //if(!contacts[i].hasOwnProper
Kyze Gozo
@Kyze-Gozo
Aug 31 2016 06:09
// Setup
var a;
a=7;
var b = 2;

// Only change code below this line
now what do i do
Christopher Pangilinan
@newbielike
Aug 31 2016 06:10
@Kyze-Gozo you can assign value in this king of format
var a = 7;
c0d0er
@c0d0er
Aug 31 2016 06:10
sorry, should be this following:
//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
for(var i=0; i<contacts.length; i++){
  //why doesnt this code work?
  //if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)){return contacts[i][prop];}
  //if(contacts[i].firstName!==firstName){return "No such contact";}
  //if(!contacts[i].hasOwnProperty(prop)){return "No such property";}

  //why doesnt this code work? 
  /*if(contacts[i].firstName===firstName){
    if(contacts[i].hasOwnProperty(prop)){
      return contacts[i][prop];
    }
    else{return "No such property";}
  }
  else{return "No such contact";}
}*/
  if(contacts[i].firstName===firstName){
    if(contacts[i].hasOwnProperty(prop)){
      return contacts[i][prop];
    }
    else{return "No such property";}
  }

}
  return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
DarkManeiac
@DarkManeiac
Aug 31 2016 06:16
hi guys! i need some help... i must make a webpage... and it should have a button to show me a new random quote.. but i dont know how to code that
mamun
@fsdmamun
Aug 31 2016 06:19
what if I don't want to ignore the CASE : /software/gi; ?
Coy Sanders
@coymeetsworld
Aug 31 2016 06:20
remove the i
Andrew Kay
@andrewjkay
Aug 31 2016 06:20
I'm having some trouble with the Where do I Belong Challenge. This code passes 5/7 tests
function getIndexToIns(arr, num) {
  var array = arguments[0];
  var sortee = arguments[1];
  var finalPos;
  array.sort();
  for(i=0;i<array.length;i++) {
    if (sortee > array[i]) {
      finalPos = (i+1);
    }
  }  
    return finalPos;
}

getIndexToIns([10, 20, 30, 40, 50], 35);
also just realized I may not need the first two vars, but that's not what's causing the problem afaik
mamun
@fsdmamun
Aug 31 2016 06:23
removing i returns error: can not read property!
Darth Skywalker
@adityaparab
Aug 31 2016 06:27
@andrewjkay : You don't need these 2 since number of parameters is fixed, unlike what we had in the destroyer challenge
var array = arguments[0];
var sortee = arguments[1];
you can simply use arr and num for these two
Esteban Rodriguez
@dynelight
Aug 31 2016 06:28
@andrewjkay If you have [10, 20, 20, 30] and you are looking for 20, where does the index finish and where is it supposed to actually finish?
Andrew Kay
@andrewjkay
Aug 31 2016 06:28
It's supposed to sort the number to before the first identical instance, if an identical instance exists.
Changed it to this, now it passes the inverse tests, so 2/7
function getIndexToIns(arr, num) {
  var array = arguments[0];
  var sortee = arguments[1];
  var finalPos
  array.sort();
  for(i=0;i<array.length;i++) {
    if (array[i] < sortee) {
      finalPos = (i)
    }
    if (finalPos === undefined) {
      finalPos = 0
    }
  }  
    console.log(finalPos)
}

getIndexToIns([3, 10, 5], 3)
console.log should be return, forgot to change it. same problem though
@adityaparab got it, will remove them once I get this thing to work
Esteban Rodriguez
@dynelight
Aug 31 2016 06:30
@andrewjkay But if you have sortee of 20... and you array is in 20, should it pass to the next value or not? I believe it does, so you need to do (array[i] <= sortee) instead of (array[i] < sortee)
Andrew Kay
@andrewjkay
Aug 31 2016 06:30
oh man it should be <=
@dynelight typed before I read, thanks