These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Feb 2016
Tarik Nachat
@intertarik
Feb 13 2016 00:00
can someone help me understanding this
"If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop."
Michael Mason
@boone2016
Feb 13 2016 00:00
can you help me with profile lookup. Try to explain the logic to me because im having trouble figuring out how to write a specific conditional statement. @Takumar
@intertarik "if" is the keyword
If (.......
Tarik Nachat
@intertarik
Feb 13 2016 00:00
this is my code "
if(value !== "" && prop !== "tracks"){
collection.id.prop = value;
Michael Mason
@boone2016
Feb 13 2016 00:01
Bracket notation for arrays
@intertarik
Tarik Nachat
@intertarik
Feb 13 2016 00:01
i think it's a object
Michael Mason
@boone2016
Feb 13 2016 00:01
`collection[id][prop] = value
Aleksander Gębicki
@Takumar
Feb 13 2016 00:01
@intertarik you have to use bracket notation because id and prop are variables (parameters), you cannot use periods in such case.
Moisés Man
@moigithub
Feb 13 2016 00:01
@carpediem1213 slice return part of an array.. from startIndex to endIndex, if not enough data.. it will just pick from startIndex, to whatever u have n the array, thats why u last element is only [8] instead of size elements
Jemal Mohammed
@JemalMoha
Feb 13 2016 00:03

@moigithub function update(id, prop, value) {

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

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

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

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

return collection;
}

hellotojello
@hellotojello
Feb 13 2016 00:03

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
i need a hint here. no answer pls..i feel like im close but my head hurts from being so lost

Jason
@carpediem1213
Feb 13 2016 00:03
@moigithub it's good the method does that! I was surprised how quickly it passed all checks after finishing that code. So what happens in the for loop if it has no array to push to the md_array?
Tarik Nachat
@intertarik
Feb 13 2016 00:03
yeeeh working, thanks @Takumar @boone2016 @JemalMoha
CamperBot
@camperbot
Feb 13 2016 00:03
intertarik sends brownie points to @takumar and @boone2016 and @jemalmoha :sparkles: :thumbsup: :sparkles:
:star: 2305 | @takumar | http://www.freecodecamp.com/takumar
:star: 6 | @boone2016 | http://www.freecodecamp.com/boone2016
:star: 121 | @jemalmoha | http://www.freecodecamp.com/jemalmoha
Josiah Anderson
@Josiahdanderson
Feb 13 2016 00:04
having trouble with waypoint "Testing Objects for Properties" don't quite know where to get started. I've tried switches and if/else statements but they don't seem to make sense with what the waypoint is about. could someone perhaps clear up the instructions for me and point me in the right direction?
Michael Mason
@boone2016
Feb 13 2016 00:04
@JemalMoha looks good
Bill
@kirah1314
Feb 13 2016 00:04
@hellotojello check your closing } brackets
Jemal Mohammed
@JemalMoha
Feb 13 2016 00:05
@boone2016 still some problem with update when it passes empty value
Aleksander Gębicki
@Takumar
Feb 13 2016 00:06
@Josiahdanderson apart from using if-else statement you should use hasOwnProperty() method to check if property checkProp exists in your object.
Josiah Anderson
@Josiahdanderson
Feb 13 2016 00:06
here is the setup code for that waypoint:
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
Jemal Mohammed
@JemalMoha
Feb 13 2016 00:06
@moigithub the function is set for empty value
hellotojello
@hellotojello
Feb 13 2016 00:06
@kirah1314 thanks..man this semicolons and brackets are kicking my ass today!
CamperBot
@camperbot
Feb 13 2016 00:06
hellotojello sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 950 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Jason
@carpediem1213
Feb 13 2016 00:06
@hellotojello move your return :)
Michael Mason
@boone2016
Feb 13 2016 00:07
@JemalMoha the only thing I really see is === on the second else if make ==
hellotojello
@hellotojello
Feb 13 2016 00:07
@carpediem1213 thanks i just found it..man that was frustrating
CamperBot
@camperbot
Feb 13 2016 00:07
hellotojello sends brownie points to @carpediem1213 :sparkles: :thumbsup: :sparkles:
:star: 278 | @carpediem1213 | http://www.freecodecamp.com/carpediem1213
Bill
@kirah1314
Feb 13 2016 00:07
it happens to everyone, no worries @hellotojello
Aleksander Gębicki
@Takumar
Feb 13 2016 00:07
@Josiahdanderson when the condition in if part is true, you should return value of property checkProp of object myObj, in other case "Not Found" string.
Moisés Man
@moigithub
Feb 13 2016 00:07
@JemalMoha emtpy value is just "" <--- without SPACES inside the quotes
if u add space inside.. ur condition saying.. if value is an space (which is different than empty)
Michael Mason
@boone2016
Feb 13 2016 00:08
thank you @Takumar
CamperBot
@camperbot
Feb 13 2016 00:08
boone2016 sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2306 | @takumar | http://www.freecodecamp.com/takumar
Jemal Mohammed
@JemalMoha
Feb 13 2016 00:09
@moigithub and @boone2016 thanks
CamperBot
@camperbot
Feb 13 2016 00:09
jemalmoha sends brownie points to @moigithub and @boone2016 :sparkles: :thumbsup: :sparkles:
:star: 563 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 7 | @boone2016 | http://www.freecodecamp.com/boone2016
Moisés Man
@moigithub
Feb 13 2016 00:12
@carpediem1213 if u try to slice a non existing data.. ur index is out of bound,, u will get a empty array... so.. ur md_array.push will be adding a empty array
bitgrower
@bitgrower
Feb 13 2016 00:14
@dcnr -- this is the reg expression to use ... /\w\S*/ ... no look behind necessary ...
Collin
@collinferry
Feb 13 2016 00:14
None of my outbound links seem to work on CodePen - is this a design feature or a am I doing something wrong?
Caleb A
@calebasher
Feb 13 2016 00:15

Hi friendly people. I'm doing the JavaScript Pig Latin challenge and can't get my second if statement to return. I'm probably overlooking something really really straightforward. Much appreciated if any one can help shed some light on it. ```function translate(str) {
var test = str;
var way = "way";
var ay = "ay";
var noVowel = test.substr(1,test.length);

if (test[0] !== "a" || "e" || "i" || "o" || "u") {
return noVowel+test[0]+ay;
}

else if (test[0] == "a" || "e" || "i" || "o" || "u") {
return test+way;
}

}

translate("eight");```

bitgrower
@bitgrower
Feb 13 2016 00:15
@calebasher -- look up how to do a test ... you can't test multiple values like that ...
Caleb A
@calebasher
Feb 13 2016 00:16
no test is just the variable name
hkesar
@hkesar
Feb 13 2016 00:16
js
function update(id, prop, value) {

if((value !== "") && prop !== "tracks"){
   collection.id[prop] = value;  
}
 else if (prop === "track" && value !== "") {
   collection.id.tracks.push(value);
 }
  else if (value ==="") {
    delete container.id.prop;
  }
  return collection;
}
Jonathan Hawryluk
@jhawryluk
Feb 13 2016 00:16
@calebasher, you can't do and/or statements like you are
bitgrower
@bitgrower
Feb 13 2016 00:16
anything within an if statement () is a test @calebasher
hkesar
@hkesar
Feb 13 2016 00:16
@efhjones
Caleb A
@calebasher
Feb 13 2016 00:17
@bitgrower oh. hmm. thanks.
CamperBot
@camperbot
Feb 13 2016 00:17
calebasher sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 494 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 13 2016 00:17
@bitgrower sent you a pm
Rob Welan
@robwelan
Feb 13 2016 00:17
getting a couple of weird issues in Advanced Algorithm Scripting: Make A Person, the errors are "Object.keys(bob).length should return 6 (despite having 6 prototype functions set up and working), and bob.firstName and bob.lastName are supposed to return undefined. every other test is working (which means my 6 prototype functions must actually exist despite the first test reporting an error (???) My code:
var Person = function(firstAndLast) {
this.firstName = "";
this.lastName = "";
this.fullName = "";
this.setFullName(firstAndLast);
};
Person.prototype.getFirstName = function() {
return this.firstName;
};
Person.prototype.getLastName = function() {
return this.lastName;
};
Person.prototype.getFullName = function() {
return this.fullName;
};
Person.prototype.setFirstName = function(firstName) {
this.firstName = firstName;
this.fullName = firstName + " " + this.lastName;
};
Person.prototype.setLastName = function(lastName) {
this.lastName = lastName;
this.fullName = this.firstName + " " + lastName;
};
Person.prototype.setFullName = function(firstAndLast) {
var arr = firstAndLast.split(" ");
this.firstName = arr[0];
this.lastName = arr1;
this.fullName = firstAndLast;
};
Michael Mason
@boone2016
Feb 13 2016 00:17
@hkesar you only need one set of () in the first if statment
Norman Dela Cruz
@dcnr
Feb 13 2016 00:17
@robwelan don't extend proto, just put them inside, or make some fake properties to get your length to 6
Rob Welan
@robwelan
Feb 13 2016 00:18
i might do the fake property one... cheers
Michael Mason
@boone2016
Feb 13 2016 00:18
@hkesar your missing an s in "tracks" in the second statement
Norman Dela Cruz
@dcnr
Feb 13 2016 00:18
@robwelan yeah I did too lol
Bill
@kirah1314
Feb 13 2016 00:19
@hkesar id is a variable just like prop so you have to use bracket notation
Michael Mason
@boone2016
Feb 13 2016 00:19
@hkesar use bracket notation collection[id][prop] = value; is the first one
Rob Welan
@robwelan
Feb 13 2016 00:20
thanks for tip @dcnr
CamperBot
@camperbot
Feb 13 2016 00:20
robwelan sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 610 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 13 2016 00:20
no prob, thanks too @robwelan
CamperBot
@camperbot
Feb 13 2016 00:20
dcnr sends brownie points to @robwelan :sparkles: :thumbsup: :sparkles:
:star: 358 | @robwelan | http://www.freecodecamp.com/robwelan
Michael Mason
@boone2016
Feb 13 2016 00:21
@kirah1314 can you help with profile lookup?
Bill
@kirah1314
Feb 13 2016 00:22
@boone2016 sure, what you need help with? :)
hkesar
@hkesar
Feb 13 2016 00:22
thanks @boone2016 and @kirah1314
CamperBot
@camperbot
Feb 13 2016 00:22
hkesar sends brownie points to @boone2016 and @kirah1314 :sparkles: :thumbsup: :sparkles:
:warning: hkesar already gave boone2016 points
:star: 951 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Bill
@kirah1314
Feb 13 2016 00:22
@hkesar :thumbsup:
Michael Mason
@boone2016
Feb 13 2016 00:23
//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 lookUp(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName && contacts[i] === contacts.firstname[prop]) {
  return contacts[firstName][prop];
}
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
it tells me likes is undefined??? this is a tough one for me
Bill
@kirah1314
Feb 13 2016 00:24
@boone2016 yeah, this challenge is a bit more complicated and not so straight-forward
Michael Mason
@boone2016
Feb 13 2016 00:25
//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 lookUp(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName && contacts[i] === contacts.firstname[prop]) {
  return contacts[firstName][prop];
}
    else if (contacts[i].firstName !== firstName) {
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
@kirah1314
Caleb A
@calebasher
Feb 13 2016 00:26
@bitgrower When you say "testing multiple values" are you referring to the "||" or operators? I don't think that's the problem that code seems to work fine. I can't switch the if statements around and the first one always works, but the second "else" statement never does.
function translate(str) {
  var test = str;
  var way = "way";
  var ay = "ay";
  var noVowel = test.substr(1,test.length);

   if (test[0] !== "a" || "e" || "i" || "o" || "u") {
    return noVowel+test[0]+ay;
  }

   else if (test[0] == "a" || "e" || "i" || "o" || "u") {
    return test+way;
  }

}

translate("eight");
Bill
@kirah1314
Feb 13 2016 00:26
@boone2016 you'll want to use hasOwnProperty in there somewhere
Caleb A
@calebasher
Feb 13 2016 00:27
  • can switch around, I mean.
Michael Mason
@boone2016
Feb 13 2016 00:27
@kirah1314 Thank you i gotta take a break real quick my head hurts
CamperBot
@camperbot
Feb 13 2016 00:27
boone2016 sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 952 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Moisés Man
@moigithub
Feb 13 2016 00:28

@boone2016
contacts is an Array of object... so to access each elements u need an index...
like this part of ur code... if (contacts[i]
then u have...
contacts[i] === contacts.firstname[prop]
this is wrong contacts.firstname[prop] remember how to access array elemtns u forgot the index
also
contacts[i] is a whole object.. .like

{
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }

and contacts[i].firstname[prop] is just a string.. both will never be equal.. as u doin in ur if condition
here u also forgot the index return contacts[firstName][prop]; and should not be [firstName][prop]

Bill
@kirah1314
Feb 13 2016 00:29
@boone2016 ok a few things. Looks like @moigithub pointed out quite a bit :point_up_2: lol
Caleb A
@calebasher
Feb 13 2016 00:30
Anyone?
Moisés Man
@moigithub
Feb 13 2016 00:31
@calebasher should be... like
if (test[0] !== "a" || test[0] !== "e" || test[0] !== "i" ||etc
Caleb A
@calebasher
Feb 13 2016 00:31
ahhhhhh, thank you @moigithub
CamperBot
@camperbot
Feb 13 2016 00:31
calebasher sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 564 | @moigithub | http://www.freecodecamp.com/moigithub
Caleb A
@calebasher
Feb 13 2016 00:34
that didn't actually make a difference unfortunately
Enrique Cahua
@enriquecahua
Feb 13 2016 00:35
help pig latin
CamperBot
@camperbot
Feb 13 2016 00:35

:point_right: algorithm pig latin [wiki]

Problem Explanation:

  • You need to create a program that will translate from English to Pig Latin. Check the instructions for converting to Pig Latin from the initial description or the wiki page. It might not be obvious but you need to remove all the consonants up to the first vowel in the case there letter does not start with a vowel.
:pencil: read more about algorithm pig latin on the FCC Wiki
Moisés Man
@moigithub
Feb 13 2016 00:37
@calebasher if start with vowel works ??
Michael Mason
@boone2016
Feb 13 2016 00:38
thank you @moigithub
CamperBot
@camperbot
Feb 13 2016 00:38
boone2016 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 565 | @moigithub | http://www.freecodecamp.com/moigithub
Caleb A
@calebasher
Feb 13 2016 00:39
yeah, it does
Moisés Man
@moigithub
Feb 13 2016 00:39
not only the first character
Caleb A
@calebasher
Feb 13 2016 00:39
the whole thing works
i just can't get the second if statement to return
Moisés Man
@moigithub
Feb 13 2016 00:39
@calebasher if start with consonant.. you need to remove all the consonants up to the first vowel
Caleb A
@calebasher
Feb 13 2016 00:40
right, i'm not there yet. I just want to figure out why the second if statement isn't getting read
Josiah Anderson
@Josiahdanderson
Feb 13 2016 00:44
I'm really stuck on this Testing Objects for Properties waypoint. I just cant figure it out. I think that maybe if i could see the solution and have it explained i would understand it. anyone willing to Private Message me the solution or walk me through it?
Norman Dela Cruz
@dcnr
Feb 13 2016 00:44

@calebasher you test multiple values like this

if ( char === 'a' || char === 'e' || char ... etc

You can't "shortcut" by just doing char === 'a' || 'e' || 'i' ... etc

@calebasher your else if is never entered because if test[0] !== "a" is false, "e" is always true
@calebasher you're just saying
"check if test[0] !== "a" OR "e" OR "i" etc...
and with OR expressions you only need one to be true for the whole expression to be true
Caleb A
@calebasher
Feb 13 2016 00:51
thanks for that. I understand now.
Zoe
@roamroam
Feb 13 2016 01:06
```
function destroyer(arr) {
  var first = arguments[0];
  var newArr = [];
  newArr = first.filter(function(val){
    for(var i = 1; i < arr.length; i++){
      return val !== arguments[i];
    }
  });
  return newArr;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
i can't seem to get the for loop to run through the arguments. Has anyone done this problem?
bitgrower
@bitgrower
Feb 13 2016 01:08
This message was deleted
what do you think arr is, @slowoddchild ?
Zoe
@roamroam
Feb 13 2016 01:09
arr is the argument array
Norman Dela Cruz
@dcnr
Feb 13 2016 01:10
@slowoddchild arr is argument[0]
bitgrower
@bitgrower
Feb 13 2016 01:10
yeah, that's what I thought when I did this exercise, but it is as @dcnr says ...
Zoe
@roamroam
Feb 13 2016 01:10
ah that makes more sense
bitgrower
@bitgrower
Feb 13 2016 01:10
next question is ... do you know WHY ?
Norman Dela Cruz
@dcnr
Feb 13 2016 01:10
oh hey I can shameless plug again!
:D
bitgrower
@bitgrower
Feb 13 2016 01:10
yes,, you can, @dcnr
Norman Dela Cruz
@dcnr
Feb 13 2016 01:10
with the new improved one!
bitgrower
@bitgrower
Feb 13 2016 01:11
well don't just talk about it, do it, @dcnr ...
Zoe
@roamroam
Feb 13 2016 01:11
no why is ```arr = argument[0]?
Norman Dela Cruz
@dcnr
Feb 13 2016 01:12
@slowoddchild Here please read my shamelessly plugged promotion
bitgrower @bitgrower patiently waits for @dcnr to post his shameless plug ...
Norman Dela Cruz
@dcnr
Feb 13 2016 01:12
@bitgrower XDD
you know I want to contribute it to the fcc wiki, but i'm scared
bitgrower
@bitgrower
Feb 13 2016 01:12
the underlying reason has to do with the fact that you can pass any number of arguments to ANY js function ...
so, it becomes a matter of which arguments actually are "named" in the function definition list ...
Norman Dela Cruz
@dcnr
Feb 13 2016 01:13
@slowoddchild it's a long read, but I think I've explained it sufficiently enough
bitgrower
@bitgrower
Feb 13 2016 01:14
LOL ... just do it, @dcnr -- they can always reject if it they don't like it ... but if they do ... more brownie points for you!!!
Norman Dela Cruz
@dcnr
Feb 13 2016 01:14
@slowoddchild the "In closing" section is especially relevant to seek and destroy
@bitgrower I already sent it :P :point_up: February 13, 2016 9:12 AM
bitgrower
@bitgrower
Feb 13 2016 01:14
ahhhh!!!! good deal, @dcnr ... congrats !!!
dcnr @bitgrower readies her Wand of Magic Missiles
Norman Dela Cruz
@dcnr
Feb 13 2016 01:15
lol thanks @bitgrower
CamperBot
@camperbot
Feb 13 2016 01:15
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 495 | @bitgrower | http://www.freecodecamp.com/bitgrower
Zoe
@roamroam
Feb 13 2016 01:15
ok cool. I will read this through. Thanks @bitgrower @ dcnr
bitgrower
@bitgrower
Feb 13 2016 01:15
oh wait ... I did NOT type that ... some sort of easter egg ?
Norman Dela Cruz
@dcnr
Feb 13 2016 01:16
@bitgrower :smiling_imp:
bitgrower
@bitgrower
Feb 13 2016 01:16
this -- I didn't type, originally ...
This message was deleted
bitgrower @bitgrower readies her Wand of Magic Missiles
dcnr @bitgrower slaps @camperbot around a bit with a large trout
bitgrower
@bitgrower
Feb 13 2016 01:17
hmm ... interesting ...

@bitgrower slaps @camperbot around a bit with a large trout

did not type this either ... and saw it reference someone else, first ...

Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:19
function palindrome(str) {
  // Good luck!
  var newString = str.replace(/\W/g, '').toLowerCase();

  var array = [];
  array = newString.split("").reverse();
  var newString_2 = array.join("");


  if (newString_2 == newString)
    return true;
  else
    return false;
}



palindrome("0_0 (: /-\ :) 0-0");
excuse me, I wanna ask why this function would return false?
bitgrower
@bitgrower
Feb 13 2016 01:20
@Cure100061148 -- have you tried outputting intermediate variables in console.log to see what's happening?
like, what the values of newString_2 and newString are ?
Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:21
@bitgrower thanks! I found that two values aren't equalXD
CamperBot
@camperbot
Feb 13 2016 01:21
cure100061148 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 496 | @bitgrower | http://www.freecodecamp.com/bitgrower
Jonathan Mitchell
@Vanhealen
Feb 13 2016 01:21
Anybody have any idea why this would return true?
function end(string, target) {
var arr = string.split(' ').reverse();
var dif = arr[0].length - target.length;
  if (arr[0].indexOf(target) === dif) {
      return true;
  }    else {
      return false;
  }
}

end("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain”)
bitgrower
@bitgrower
Feb 13 2016 01:22
is it always returning true, @Vanhealen ?
this looks like a weird amalgam of "in the end" with find longest word ...
eeflores
@eeflores
Feb 13 2016 01:23
This message was deleted
Jonathan Mitchell
@Vanhealen
Feb 13 2016 01:24
no
not if the word is more than 2 letters
something to do with the split(‘ ‘ )
or join
and the spaces in ‘ ‘
eeflores
@eeflores
Feb 13 2016 01:24
sorry thought the split was single char
Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:25
function palindrome(str) {
  // Good luck!
  var newString = str.replace(/\W/g, '').toLowerCase();

  var array = [];
  array = newString.split("").reverse();

  var newString_2 = array.join("");


  if (newString_2 == newString)
    return true;
  else
    return false;
}



palindrome("0_0 (: /-\ :) 0-0");
bitgrower
@bitgrower
Feb 13 2016 01:25
well ... you are comparing target ... a string with what is now an array, yes ?
or wait ... maybe not ...
Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:25
I still have a question here about why the answer should be true
newString should be 0_000
newString_2 should be 000_0
then why the answer should be true
I don't think 0_000 would be a palindrome
bitgrower
@bitgrower
Feb 13 2016 01:26
@VanHealen -- you are just going to find the position of the word in that longer string, which you've converted to an array ... you aren't going to find where it starts in the string as a subset ...
Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:27
or it should be 0000 instead of 0_000?
bitgrower
@bitgrower
Feb 13 2016 01:27
should be, or what are you seeing in console.log @Cure100061148
Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:27
0_000
Venkataraman Srinivasan
@vsrinivasan
Feb 13 2016 01:28
Hello... regarding mutation ... is there a easier way to solve this ... my code is below
Norman Dela Cruz
@dcnr
Feb 13 2016 01:28
@Vanhealen
This is why it's returning true
"mountain".length = 8
"nothing".length = 7
dif = 7 - 8 // -1

if ("nothing".indexOf("mountain") === dif)
            -1                    ===  -1
         // true
Venkataraman Srinivasan
@vsrinivasan
Feb 13 2016 01:28

function mutation(arr) {
a = arr[0];
b = arr1;
a1 = a.toLowerCase().split("");
b1 = b.toLowerCase().split("");
a1Length = a1.length;
b1Length = b1.length;
a1Array = [];
b1Array = [];
for (i=0;i<=(a1Length-1);i++){
a1Array.push(b1.indexOf(a1[i]));
}
for (i=0;i<=(b1Length-1);i++){
b1Array.push(a1.indexOf(b1[i]));
}
a1ArrayMin = Math.min.apply(Math,a1Array);
b1ArrayMin = Math.min.apply(Math,b1Array);
if (a1ArrayMin>=0||b1ArrayMin>=0) return true;
return false;

}

mutation(["floor", "for"]);

Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:28
@bitgrower then what's wrong with str.replace(/\W/g, '')?
bitgrower
@bitgrower
Feb 13 2016 01:28
good catch, @dcnr ...
@Cure100061148 -- probably is doing something you don't expect ...
or not doing something you think it should ...
review the definitions for the set of characters that \W does or does not match ...
@vsrinivasan -- the answer, 99% of the time is ... for any programming problem in the world ... yes ...
Chih-Yu Yeh
@cyyeh
Feb 13 2016 01:30
oh @bitgrower I see the reason.... it says a word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character
no wonder...haha thanks @bitgrower
CamperBot
@camperbot
Feb 13 2016 01:31
cure100061148 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: cure100061148 already gave bitgrower points
bitgrower
@bitgrower
Feb 13 2016 01:31
yw @Cure100061148
happy coding ...
Norman Dela Cruz
@dcnr
Feb 13 2016 01:36
@slowoddchild Hi, have you figured it out?
bitgrower
@bitgrower
Feb 13 2016 01:39
@vsrinivasan first
explain format
CamperBot
@camperbot
Feb 13 2016 01:39

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

bitgrower
@bitgrower
Feb 13 2016 01:39
second, you can do mutation without using push at all ...
Jonathan Mitchell
@Vanhealen
Feb 13 2016 01:40
@dcnr so I should have it be like (not equals to -1) and (equals dif)
bitgrower
@bitgrower
Feb 13 2016 01:41
@vanhealen -- what, exactly, are you trying to do ?
Norman Dela Cruz
@dcnr
Feb 13 2016 01:41
@bitgrower this one :P :point_up: February 13, 2016 9:21 AM
arjunpunnam
@arjunpunnam
Feb 13 2016 01:42
Hi,
function lookUp(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length; i++){
if(contacts[i].firstName == firstName && contacts[i].prop in contacts){
return contacts[i].prop;
}
else if(contacts[i].firstName !== firstName){
return "No such contact";
}else if(contacts[i].prop === ""){
return "No such property";
}
// Only change code above this line
}
}
im unable to debug my code here
couldnt find the mistake
bitgrower
@bitgrower
Feb 13 2016 01:43
umm ... well ... I think you can do that challenge without using arrays, @Vanhealen ... just sayin'
Jonathan Mitchell
@Vanhealen
Feb 13 2016 01:43
ya how
bitgrower
@bitgrower
Feb 13 2016 01:43
@arjunpunnam
explain format
CamperBot
@camperbot
Feb 13 2016 01:43

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

bitgrower
@bitgrower
Feb 13 2016 01:43
by using the lengths of the strings & substring ...
er, substr
arjunpunnam
@arjunpunnam
Feb 13 2016 01:44
@bitgrower didnt get you
Norman Dela Cruz
@dcnr
Feb 13 2016 01:44

@Vanhealen
Yeah you can do

if (arr[0].indexOf(target) === dif && dif !== -1) {

and it will work but you can greatly shorten your code by using something like String.prototype.slice, it's the one line solution to Confirm the Ending

arjunpunnam
@arjunpunnam
Feb 13 2016 01:45
function lookUp(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length; i++){
if(contacts[i].firstName == firstName && prop in contacts){
return contacts[i].prop;
}
else if(contacts[i].firstName !== firstName){
return "No such contact";
}else if(prop in contacts){
return "No such property";
}
this is the updated code
and the requirement is
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
bitgrower
@bitgrower
Feb 13 2016 01:46
@dcnr -- String has a slice function ??? I don't think I knew that ...
you can do a one-line solution also with ES6 ..
@arjunpunnam -- read what camperbot posted, follow the instructions ... in detail ... :)
Norman Dela Cruz
@dcnr
Feb 13 2016 01:47
@bitgrower oh endsWith was it? lol
bitgrower
@bitgrower
Feb 13 2016 01:47
yeah ..
you could make the other one we discussed earlier into a 1 line soln with a ternary operator ...
Norman Dela Cruz
@dcnr
Feb 13 2016 01:49
@bitgrower which other one?
Brandyn Lucinsky
@appbeza
Feb 13 2016 01:49
Is it good practice to never use the '==' operator? I think implicit conversion is a very bad idea.
Norman Dela Cruz
@dcnr
Feb 13 2016 01:51
@appbeza yes, I try to avoid it as much as possible!
@appbeza if you use a linter you can use something like "eqeqeq": true, I think it works for jslint and eshint too
Brandyn Lucinsky
@appbeza
Feb 13 2016 01:53
Now I see why people loath JavaScript.
Jonathan Mitchell
@Vanhealen
Feb 13 2016 01:53
@dcnr
This does not work, in face it passes less tests than before
function end(string, target) {
var arr = string.split(' ').reverse().join(' ');
var dif = arr[0].length - target.length;
  if ((arr[0].indexOf(target) === dif)  && (dif !== -1)){
      return true;
  }  else {
  return false;
}
}
Brandyn Lucinsky
@appbeza
Feb 13 2016 01:54
@Vanhealen 'String' is a reserved keyword. Use something like _string.
Jonathan Mitchell
@Vanhealen
Feb 13 2016 01:55
ohh
i needed to take out the join
thanks @dcnr
CamperBot
@camperbot
Feb 13 2016 01:55
vanhealen sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 611 | @dcnr | http://www.freecodecamp.com/dcnr
Jonathan Mitchell
@Vanhealen
Feb 13 2016 01:55
@appbeza that wasn’t the issue
arjunpunnam
@arjunpunnam
Feb 13 2016 01:55
//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 lookUp(firstName, prop){
// Only change code below this line  
  for(var i=0; i<contacts.length; i++){
if(contacts[i].firstName == firstName && contacts.hasOwnProperty(prop) ){
  return contacts[i].prop;
}
    else if(contacts[i].firstName !== firstName){
      return "No such contact";
    }else if(prop in contacts){
      return "No such property";
    }
// Only change code above this line
}
}
// Change these values to test your function
lookUp("Kristian", "lastName");
Brandyn Lucinsky
@appbeza
Feb 13 2016 01:56
@Vanhealen Sorry. I've been corrupted by C#.
arjunpunnam
@arjunpunnam
Feb 13 2016 01:57
can anyone please help im unable to find mistake in my code
Franco Zapata
@Francozt01
Feb 13 2016 01:57
@Vanhealen as he said String is reserved word u might have saw the exercices using "str" as parameter instead of string :D
bitgrower
@bitgrower
Feb 13 2016 01:58
@arjunpunnan ... have you tried using console.log to look at intermediate values ?
Norman Dela Cruz
@dcnr
Feb 13 2016 01:59
@arjunpunnam quoting @bitgrower :D :point_up: February 11, 2016 12:01 PM
arjunpunnam
@arjunpunnam
Feb 13 2016 02:00
yes it returns true
Mafalda
@otmeek
Feb 13 2016 02:00
How can I convert 60 to 60.00 without using toFixed(2)? Because toFixed turns it into a string?
bitgrower
@bitgrower
Feb 13 2016 02:01
is this for a particular challenge? Why would you need it to be 60.00 internally ?
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:02
This message was deleted
This message was deleted
bitgrower
@bitgrower
Feb 13 2016 02:03
I was gonna say ... LOL ...
Mafalda
@otmeek
Feb 13 2016 02:03
I'm actually really confused. It's for the advanced algorithm Exact Change, and there is the following test:
bitgrower
@bitgrower
Feb 13 2016 02:03
@appbeza -- you can remove those "duh" posts :)
Mafalda
@otmeek
Feb 13 2016 02:04
drawer(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]) should return [["TWENTY", 60.00], ["TEN", 20.00], ["FIVE", 15], ["ONE", 1], ["QUARTER", 0.50], ["DIME", 0.20], ["PENNY", 0.04]].
oops that didnt format so well
but it should return [["TWENTY", 60.00], ["TEN", 20.00], ["FIVE", 15], ["ONE", 1], ["QUARTER", 0.50], ["DIME", 0.20], ["PENNY", 0.04]].
It's really confusing that it requires TWENTY ot be 60.00, but FIVE to be 15 not 15.00
bitgrower
@bitgrower
Feb 13 2016 02:05
@arjunpunnam -- okay ... there are 3 things that you need to return ... my guess is, you are having trouble with when to return "no such contact" ... yes ?
arjunpunnam
@arjunpunnam
Feb 13 2016 02:06
nono "no such contact" is the only case thats passing
other cases are not passinf
Norman Dela Cruz
@dcnr
Feb 13 2016 02:06
@arjunpunnam contacts.hasOwnProperty(prop) you're missing the index
arjunpunnam
@arjunpunnam
Feb 13 2016 02:07
yeah realised and changed but no luck
bitgrower
@bitgrower
Feb 13 2016 02:07
@arjunpunnam -- are you getting complaints from the editor ...
Norman Dela Cruz
@dcnr
Feb 13 2016 02:07
@arjunpunnam yeah your "no such contacts" is the problem
that's why I quoted @bitgrower 's marbles
bitgrower
@bitgrower
Feb 13 2016 02:07
well, you'll have worse luck if you don't have it in there ... LOL
oh, you did, @dcnr ? I missed it completely ...
Norman Dela Cruz
@dcnr
Feb 13 2016 02:08
@bitgrower :point_up: February 13, 2016 9:59 AM
Zachary Hyder
@zacharyhyder
Feb 13 2016 02:08
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

var singleVal = array.reduce(function(previousVal, currentVal) {
  return previousVal + currentVal;
});

singleVal = array;
bitgrower
@bitgrower
Feb 13 2016 02:08
:blush: thanks @dcnr
CamperBot
@camperbot
Feb 13 2016 02:08
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 612 | @dcnr | http://www.freecodecamp.com/dcnr
Zachary Hyder
@zacharyhyder
Feb 13 2016 02:08
singleVal should be equal to the sum of all items in the array variable.
Norman Dela Cruz
@dcnr
Feb 13 2016 02:08
@zacharyhyder remove singleVal = array;
Zachary Hyder
@zacharyhyder
Feb 13 2016 02:08
@dcnr well then xD
Norman Dela Cruz
@dcnr
Feb 13 2016 02:08
@zacharyhyder you're actually supposed to append .reduce .... etc to that line
:P

@zacharyhyder maybe they should change it to something like

singleVal = array; // modify this line for reduce

or something

bitgrower
@bitgrower
Feb 13 2016 02:10
looks to me like array is a reserved word, as well ... hence the red syntax coloring ...
Mariya
@mariyadiminsky
Feb 13 2016 02:10
So I just made my portfolio page...And realized that now there are only 2 basic Javascript Projects?? Weren't there like 5 before? What happened?
bitgrower
@bitgrower
Feb 13 2016 02:11
really ?!? ...
well dang!!!!
no tic tac toe, no simon ...
and they moved random quote machine to intermediate web projects ...
interesting ...
Norman Dela Cruz
@dcnr
Feb 13 2016 02:13
@bitgrower good thing I didn't do anything else after the algos!
bitgrower
@bitgrower
Feb 13 2016 02:15

okay, previously we had, portfolio, random quote, calculator & pomodoro clock ...

now we have ... tribute page & portfolio page ... in the basic projects

local weather, stylized stories on camper news, wikipedia viewer, twitch.tv json api , tic tac toe & simon ...

and now we have ...

intermediate, local weather, wikipedia viewer, & use twitch.tv json app

Norman Dela Cruz
@dcnr
Feb 13 2016 02:17
@bitgrower the calc, pomodoro, xo, and simon where moved to advanced
bitgrower
@bitgrower
Feb 13 2016 02:18
ahhh ...
so sounds like they are still all there ... plus a tribute page ...
hellotojello
@hellotojello
Feb 13 2016 02:21
Can someone tell me what I should go over approach the challenge Profile Lookup better? it seems to be way over my head...
to approach*
arjunpunnam
@arjunpunnam
Feb 13 2016 02:22
@bitgrower @dcnr window.alert((contacts.hasOwnProperty("lastName"))) does it check the entire array for the property
Norman Dela Cruz
@dcnr
Feb 13 2016 02:23
@hellotojello Hi, for this challenge you should have a good grasp of how to access object properties, and also accessing array elements
hellotojello
@hellotojello
Feb 13 2016 02:23
thank you @dcnr..shit just got next level for me
CamperBot
@camperbot
Feb 13 2016 02:23
hellotojello sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 613 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 13 2016 02:24
@arjunpunnam contacts is your entire array, so it's looking at your array object for the property lastName which it won't have
@arjunpunnam because the objects inside contacts are the ones you should be checking
@hellotojello I wrote a little something about accessing object props, maybe can have a look?
@arjunpunnam contacts[i].firstName is getting the firstName property of the object at contacts[i] right? It should also be the same for hasOwnProperty
arjunpunnam
@arjunpunnam
Feb 13 2016 02:27
@dcnr then contacts[i].hasOwnProperty(prop) should work but it isnt because it is looking at one object for iteration,right?
Norman Dela Cruz
@dcnr
Feb 13 2016 02:28
@arjunpunnam will you post your current code now?
bitgrower

@bitgrower never did find @dcnr use my marble analogy ...

What time after the hour did you post it ?

Norman Dela Cruz
@dcnr
Feb 13 2016 02:28
@bitgrower :point_up: February 13, 2016 10:08 AM
hellotojello
@hellotojello
Feb 13 2016 02:29
i'm taking a look now. i'm finding it hard to access the properties and do iteration at the same time...hopefully after the read ill understand more. thanks for ur patience.
Norman Dela Cruz
@dcnr
Feb 13 2016 02:29
@bitgrower click on the date darnit :P
@hellotojello ah yes I get what you mean, but you first break down the concepts. Accessing, iterating, etc
Casey Heath
@ExhibitArts
Feb 13 2016 02:30
Hello World!
CamperBot
@camperbot
Feb 13 2016 02:30

welcome to FreeCodeCamp @ExhibitArts!

Norman Dela Cruz
@dcnr
Feb 13 2016 02:30
@hellotojello you'll get it!
bitgrower
@bitgrower
Feb 13 2016 02:31
how do you do that ... @dcnr ... ?
Casey Heath
@ExhibitArts
Feb 13 2016 02:31
I'm trying to create a smooth scroll for my anchor link. I can't get my js code to work and it says "Unexpected token <". I don't see any typos. Anyone know what it could be? - https://gist.github.com/anonymous/7fa4ec423416281b67cb
Norman Dela Cruz
@dcnr
Feb 13 2016 02:31
@bitgrower the stringified spatial links?!
@bitgrower hover over the timestamp and alt+click
bitgrower
@bitgrower
Feb 13 2016 02:32
ahhh ... hang on ... let me try that !!!
@ExhibitArts -- try the FrontEnd room ...
Norman Dela Cruz
@dcnr
Feb 13 2016 02:33
@ExhibitArts also try the main room, people here are mostly about the easier stuffs :P
Casey Heath
@ExhibitArts
Feb 13 2016 02:34
@bitgrower I've done that but there are so many people asking questions that no one has gotten to mine. I don't want to annoy anyone by asking it over and over again.
I'll try the front end room though.
bitgrower
@bitgrower
Feb 13 2016 02:34
coolness ... @dcnr ... yeah, it can get that way in here, as well, @ExhibitArts .. but @dcnr & I probably can't help you ... so, you're likely to find more people who have the expertise you need ...
okay ... what other wiki pages do you have @dcnr ?
Norman Dela Cruz
@dcnr
Feb 13 2016 02:37
@ExhibitArts I'm sorry I can't help you with that problem, I haven't really touched any "real world javascript" :(
Casey Heath
@ExhibitArts
Feb 13 2016 02:37
@bitgrower @dcnr it's okay. Thanks though.
CamperBot
@camperbot
Feb 13 2016 02:37
exhibitarts sends brownie points to @bitgrower and @dcnr :sparkles: :thumbsup: :sparkles:
:star: 614 | @dcnr | http://www.freecodecamp.com/dcnr
:star: 497 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 13 2016 02:38
@bitgrower I was thinking of doing some random stuffs like short circuits
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:39
This message was deleted
Norman Dela Cruz
@dcnr
Feb 13 2016 02:39
@appbeza ei I haven't read it fully yet :P
bitgrower
@bitgrower
Feb 13 2016 02:39
ahhh cool ... where's the one for destroyer again ?
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:40
Sorry. Pressed enter by accident :P
Casey Heath
@ExhibitArts
Feb 13 2016 02:40
tf are brownie points? sorry I'm new here.
bitgrower
@bitgrower
Feb 13 2016 02:40
what is tf ?
help brownie points
CamperBot
@camperbot
Feb 13 2016 02:40

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

Norman Dela Cruz
@dcnr
Feb 13 2016 02:40
@bitgrower I think it stands for "the fong"
like "I WILL FONG YOU!"
bitgrower
@bitgrower
Feb 13 2016 02:41
@ExhibitArts -- if you are looking for GENERAL web dev help, I recommend you try stackexchange ... people in the rooms here are really focused on helping each other out in the specific FCC challenges ...
hkesar
@hkesar
Feb 13 2016 02:41
thanks @efhjones !
CamperBot
@camperbot
Feb 13 2016 02:41
hkesar sends brownie points to @efhjones :sparkles: :thumbsup: :sparkles:
:star: 250 | @efhjones | http://www.freecodecamp.com/efhjones
bitgrower
@bitgrower
Feb 13 2016 02:42
oh ... LOL ... the tf in wtf ...
hey -- I want to know how @efhjones is doing !!!
hellotojello
@hellotojello
Feb 13 2016 02:42
@dcnr backpack["clothes"][2]["Underpants"][2]; // "Thongs"
I don't understand why there is a 2 next to clothes..doesn't the 2 already access underpants? why is it a 2 and then underpants?
bitgrower
@bitgrower
Feb 13 2016 02:43
@hellotojello -- post code ...
explain format
CamperBot
@camperbot
Feb 13 2016 02:43

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

Norman Dela Cruz
@dcnr
Feb 13 2016 02:43
@bitgrower how vulgar! I will fong you!
bitgrower
@bitgrower
Feb 13 2016 02:43
This message was deleted
bitgrower
@bitgrower
Feb 13 2016 02:43
ahhhhhhh ...
Norman Dela Cruz
@dcnr
Feb 13 2016 02:44
@hellotojello AH I'll explain that I forgot to upload the new details to wiki hold on
hellotojello
@hellotojello
Feb 13 2016 02:44
i don't get how come there is a 2 after clothes..? and then underpants? doesn't the 2 access the 3rd element, which is underpants? why put underpants again?
bitgrower
@bitgrower
Feb 13 2016 02:44
LOL ... reply showed up incorrectly in the stream ...
hellotojello
@hellotojello
Feb 13 2016 02:44
oh ok..thanks im mad confused
bitgrower
@bitgrower
Feb 13 2016 02:45
where are you in the challenges, @hellotojello ...
hellotojello
@hellotojello
Feb 13 2016 02:45
profile lookup
bitgrower
@bitgrower
Feb 13 2016 02:45
maybe you're not quite ready for @dcnr's page ?
ahhh ... okay ...
hellotojello
@hellotojello
Feb 13 2016 02:45
i need to study more..i spent way too much time on that challenge and got nowhere really
bitgrower
@bitgrower
Feb 13 2016 02:45
can you post your code ?
hellotojello
@hellotojello
Feb 13 2016 02:46
i reset ..i had many diff attempts
Norman Dela Cruz
@dcnr
Feb 13 2016 02:49
@hellotojello
var backpack = {
  food: {
    fruits: ['Apple', 'Persimmon', 'Gooseberry'],
    candies: ['Nougat', 'Gum', 'Toffee']
  },
  clothes: [
    'Shirt',
    'Pants',
    {
      Underpants: ['Boxers', 'Briefs', 'Thongs']
    }
  ]
};

backpack["clothes"][2]["Underpants"][2];

backpack // the object
backpack["clothes"] /* the clothes property of backpack 
                       which refers to array, so its elements needs to be
                       accessed with brackets */
backpack["clothes"][2] /* since backpack.clothes refers to an array
                          backpacks.clothes[2] is the 3rd element
                          which is the object { Underpants...}
                          */
backpack["clothes"][2]["Underpants"] /* now we access the property of the 
                                        object. Note that Underpants refers to
                                        an array */
backpack["clothes"][2]["Underpants"][2] /* get the 3rd item which is Thongs */
@hellotojello the trick to reading this kind of nesting is to STEP INTO IT ONE AT A TIME
bitgrower
@bitgrower
Feb 13 2016 02:50
or ... as @bitgrower likes to say ... "it's all about addressing...."
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:50
Anyone have any pet peeves with the different contexts of the word 'value'? Sometimes it's used in the context of only having a 'stuff' component. Other times it's used in the context of the 'stuff' component being anchored by a 'datatype' component. When the former is used ,'datatype' is used separately. For example, in the strict quality operator challenge, they said that it compares 'value' and 'datatype'. That doesn't makes sense to me. It only compares value (the latter context), because the first context is just some abstraction that makes two things, such as 20 and "20", the same. Those are not the same. Then, that means that saying the '==' operator only the value (the former context), is not so right. Wouldn't it make more sense to say that it tests the value (latter context) after it's implicitly converted?
bitgrower
@bitgrower
Feb 13 2016 02:51
LOL @appbeza tl;dr
what is your background @appbeza ? I think I can understand why you are confused ...
Norman Dela Cruz
@dcnr
Feb 13 2016 02:52
@hellotojello here it is broken down once more
backpack["clothes"] = ['Shirt', 'Pants', {Underpants: ['Boxers', 'Briefs', 'Thongs']}]
backpack["clothes"][2] = { Underpants: ['Boxers', 'Briefs', 'Thongs'] }
backpack["clothes"][2]["Underpants"] = ['Boxers', 'Briefs', 'Thongs']
backpack["clothes"][2]["Underpants"][2] = 'Thongs'
bitgrower
@bitgrower
Feb 13 2016 02:52
because there ARE many different kinds of "values" -- mostly, though, it has to do with how deep you have to go to get the "value" within the particular context ...
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:52
@bitgrower I'm just complaining about semantics. I've always done that.
bitgrower
@bitgrower
Feb 13 2016 02:53
@appbeza ... any previous programming background ?
I had a disagreement with one of my clients recently about what is the best programming language to start with ... he said js, I said python ...
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:54
Yes, python, and now c#. I quit python because of this semantic problem. Microsoft's documentation is sooo much better.
bitgrower
@bitgrower
Feb 13 2016 02:54
I think we are both right -- it depends on the context ... but js can be a hard language to learn because so much is dynamic ...
Norman Dela Cruz
@dcnr
Feb 13 2016 02:54
@bitgrower pfft let's all just drop this and learn golang
bitgrower
@bitgrower
Feb 13 2016 02:54
hahahahaha @dcnr ...
well -- C# has the benefit of a previous language, and a LOT of money to hire tech writers ... :)
so what of MSFT's documentation do you like ?
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:56
@bitgrower It's concise and example-orientated. Made me understand enums easily.
Norman Dela Cruz
@dcnr
Feb 13 2016 02:57
wish JS have enums, without resorting to some library, or wizardry
Venkataraman Srinivasan
@vsrinivasan
Feb 13 2016 02:58
@dcnr .. will try your suggestion
Brandyn Lucinsky
@appbeza
Feb 13 2016 02:58
I just love C#. I will never look back to those high-level days.
Norman Dela Cruz
@dcnr
Feb 13 2016 02:58
@vsrinivasan I'm sorry what did I suggest again?
Casey Heath
@ExhibitArts
Feb 13 2016 03:00

FeelTheBern

Norman Dela Cruz
@dcnr
Feb 13 2016 03:00
@bitgrower hey we got another supporter @ExhibitArts
bitgrower
@bitgrower
Feb 13 2016 03:01
lol -- well, if I write some code documentation, I'll try to remember to pass it by you, @appbeza ... you can take a look at @dcnr (who is gonna hate on me now ... LOL) -- his wiki on github ... and see if you like it ...
??? @dcnr ?
Norman Dela Cruz
@dcnr
Feb 13 2016 03:01
@bitgrower :point_up: February 13, 2016 11:00 AM
bitgrower
@bitgrower
Feb 13 2016 03:01
hahahahahaha ...
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:02
<h1><b>FeelTheCold</b</h1>
hellotojello
@hellotojello
Feb 13 2016 03:02
since no ones talking about challenges. does anyone know around what challenge can you be hirable for a junior dev job? also if money isn't a factor and i need to be hirable in the shortest time period possible, is a bootcamp the most viable choice?
Casey Heath
@ExhibitArts
Feb 13 2016 03:02
@dcnr haha. watching a re-run of last nights debate.
bitgrower
@bitgrower
Feb 13 2016 03:02
get thru the frontend cert, @hellotojello
and start digging into objects REALLY REALLY FAST
Norman Dela Cruz
@dcnr
Feb 13 2016 03:02
@appbeza please, that wiki can't be called a documentation, it's more like ... some stuff
@bitgrower
hellotojello
@hellotojello
Feb 13 2016 03:03
@bitgrower what does digging into objects mean?
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:03
@dcnr Well.. 'some stuff' is better than nothing. Everything has value, even if it's 99% crap.
bitgrower
@bitgrower
Feb 13 2016 03:04
@hellotojello -- best way to get hired ... although it's been over a decade since I've been involved in making hiring decisions for programmers ... is demonstrate what you can do ...
Norman Dela Cruz
@dcnr
Feb 13 2016 03:04
@hellotojello I think there's a dedicated fcc jobs gitter room!
@hellotojello for your kind of question :D
hellotojello
@hellotojello
Feb 13 2016 03:04
@dcnr ok sok sorry
bitgrower
@bitgrower
Feb 13 2016 03:04
@hellotojello -- knowing them backwards & forwards ... knowing how to use them, know their different methods, etc ... (well, and know arrays, too ... but arrays are rather easier...)
help rooms
CamperBot
@camperbot
Feb 13 2016 03:04

:point_right: help rooms [wiki]

Help Rooms

Choose the right room for your question!

:pencil: read more about help rooms on the FCC Wiki

Norman Dela Cruz
@dcnr
Feb 13 2016 03:05
@hellotojello oh no don't be sorry it's just a suggestion :P
bitgrower
@bitgrower
Feb 13 2016 03:05
hmmm not in that list
help jobs
CamperBot
@camperbot
Feb 13 2016 03:05
no wiki entry for: jobs
bitgrower
@bitgrower
Feb 13 2016 03:05
you can also go up to the "world" icon top right and get a list of all the FCC rooms ...
E
@efhjones
Feb 13 2016 03:05

Hey @bitgrower, I'm back, I think I understand why I was so confused... talking about Profile Lookup still. So, in the for loop, I think what was hard to understand semantically was that they give you firstName as a value, which is also the name of a property, so when I saw

if(contacts[i].firstName === firstName

the story didn't work in my head. Changed the

function lookUp(firstNameGiven, prop){

so I was then reading "if contacts -> .firstname equals firstNameGiven is true

Norman Dela Cruz
@dcnr
Feb 13 2016 03:06
bitgrower
@bitgrower
Feb 13 2016 03:06
yes ... that IS confusing ... I think they did that intentionally, @efhjones
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:06
Even the crap stuff has lessons to be learnt...
bitgrower
@bitgrower
Feb 13 2016 03:07
yeah, but you'll get further faster if you consume the stuff which is only 1% crap ... :)
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:07
@bitgrower :P
Norman Dela Cruz
@dcnr
Feb 13 2016 03:07
Eh, there are many kinds of crap (interpretation) anyway. I stopped using python cause of the style crap.
bitgrower
@bitgrower
Feb 13 2016 03:08
so, got any code we can look at @efhjones -- and maybe help you a bit more ?
Eric
@ezagala
Feb 13 2016 03:13
The instructions for the "Stand in Line" challenge don't seem very clear. Anyone have a minute to clarify?
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:13
@dcnr I stopped using it because of the tutorials mostly. The reference documentation could have been more clear, as well. However, I could have outsourced. But I only learn when the official learning material is well done.
bitgrower
@bitgrower
Feb 13 2016 03:15
@ezagala -- sure ... it's a very short challenge, you only need like 2 lines of code ...
Norman Dela Cruz
@dcnr
Feb 13 2016 03:16
@appbeza Ah I understand, everyone has their own style of learning. I myself prefer books more than official documentations, but some things can't be helped, and I'll have to delve into it sooner or later. I used to not like JS so much because it used to be primarily a browser language. It was when Node really kicked off that I revisited it again.
@ezagala for stand in line you need to
  1. insert item to the end of arr
  2. remove the first element of arr
  3. return that removed element
E
@efhjones
Feb 13 2016 03:19
@bitgrower so I'm currently trying to figure out why you can't nest all the if statements in one for loop.
trying to figure out exactly what it's doing as it iterates
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:20
@dcnr I don't mind outsourcing to books and such, but having that peace of mind when the guys who made the thing put effort into the documentation of said thing, verifies that they also put effort into that thing.
bitgrower
@bitgrower
Feb 13 2016 03:20
click on the link, @efhjones ...
my other advice is this ...
you have 3 different things to return ... a value in one case, and 2 different error messages...
think about each problem separately -- how would you solve each problem (if you've solved 2 of them, and not "no contacts found" ... my link is ESPECIALLY for you ...
Norman Dela Cruz
@dcnr
Feb 13 2016 03:24
@appbeza we just give in to our preferences :P there are many other things that we should look for in a language, especially community support and prevalence/acceptance
E
@efhjones
Feb 13 2016 03:27
@bitgrower ok I think I see, so for instance, let's say I'm testing for Kristian, lastName, if all the if's were nested in one for loop, it would be continually checking the first data set in contacts for the conditions, and the first data set is this?
{
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:28
Are there different types of data stuctures (i.e. abstract, non-abstract)? I know that datatypes, which is just a fancy word for classes, have abstract and non-abstract versions.
bitgrower
@bitgrower
Feb 13 2016 03:28
@efhjones -- something like that ...
Zoe
@roamroam
Feb 13 2016 03:28
@dcnr I'm back at it now, but I think I understand what you were pointing out.
Since I have 2 functions, the arguments[x] mean something different in each function
bitgrower
@bitgrower
Feb 13 2016 03:29
well..."datatypes" kind precede classes, tbh ...
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:29
@bitgrower True. But the past is the past.
bitgrower
@bitgrower
Feb 13 2016 03:30
and sometimes worth knowing ... :)
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:30
Classes are more dominent now :P
bitgrower
@bitgrower
Feb 13 2016 03:30
really depends on where you are coding, @appbeza
there are many, many, many coding worlds ...
Norman Dela Cruz
@dcnr
Feb 13 2016 03:31
@slowoddchild YES! :D destroyer's arguments are different from your filter that's why you can't just use arguments[i] inside filter and expect it to be 2, 3 .. etc (from destroyer's
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:31
@bitgrower I guess... let's just agree to disagree... classes will prevail!
bitgrower
@bitgrower
Feb 13 2016 03:31

LOL .. until the next programming paradigm ....

...but, yeah, classes are very common ...

...but they weren't even in js until this past summer, with the release of ES6 ...

Brandyn Lucinsky
@appbeza
Feb 13 2016 03:32
We will see...
Norman Dela Cruz
@dcnr
Feb 13 2016 03:32
@bitgrower something REST vs GraphQL something
Zoe
@roamroam
Feb 13 2016 03:33
@dcnr thanks for the great write up on argument objects
CamperBot
@camperbot
Feb 13 2016 03:33
slowoddchild sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 615 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Feb 13 2016 03:33
@ppbeza .... that's why the past is worth knowing ... :) of course, some of us lived it ... :)
Norman Dela Cruz
@dcnr
Feb 13 2016 03:33
you're welcome thank you for reading too @slowoddchild please tell me if there are parts I could have said better
CamperBot
@camperbot
Feb 13 2016 03:33
dcnr sends brownie points to @slowoddchild :sparkles: :thumbsup: :sparkles:
:star: 262 | @slowoddchild | http://www.freecodecamp.com/slowoddchild
Zoe
@roamroam
Feb 13 2016 03:33
but i'm still trying to figure out how to pass the other numbers through the filter function
bitgrower
@bitgrower
Feb 13 2016 03:34
you're ahead of me on that one, @dcnr ... :)
Norman Dela Cruz
@dcnr
Feb 13 2016 03:34
@slowoddchild you can take something else's arguments, copy it and use that inside the other function? :P
bitgrower @bitgrower steals @dcnr 's reading materials ...
Norman Dela Cruz
@dcnr
Feb 13 2016 03:34
@slowoddchild it's only because they are all named arguments that they shadow themselves :P
@bitgrower oooh how do I share my kindle book list?
bitgrower
@bitgrower
Feb 13 2016 03:35
good question ... have you tried googling it ?
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:36
@dcnr What's in your kindle list?
bitgrower
@bitgrower
Feb 13 2016 03:36
did you know you can share kindle books, just like you would share a print book -- only better (since you don't have to be in geo proximity)
bitgrower @bitgrower wants to create an object out of all parts of a 2-D array ... in one easy line ...
Norman Dela Cruz
@dcnr
Feb 13 2016 03:37
@bitgrower use .reduce
@appbeza mostly fantasy stuffs lol
@appbeza and lots of freebies :P
bitgrower
@bitgrower
Feb 13 2016 03:38
ahh ... yeah, that would do it ... I was hoping for something along the line of Object.apply(null, myVar); -- but it only seems to pop off the first subarray ... :(
so, just slap that puppy into a reduce callback, eh ?
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:40
@dcnr Can I get a copy of that list, if you don't mind? I prefer reading stuff that others have read, because they most have likely been through the horrible judge-before-buying thing.
Norman Dela Cruz
@dcnr
Feb 13 2016 03:41
@bitgrower
I was thinking something like
[['chickens', 12], ['cows', 30], ['sheep', 1000]].reduce(function(obj, animals) {
  return (obj[animals[0]] = animals[1], obj);
}, {});

{ chickens: 12, cows: 30, sheep: 1000 }
@bitgrower I don't know your case though so it might not be what you need :P
bitgrower
@bitgrower
Feb 13 2016 03:42
Exact Change ... I'm trying to to create an assoc array with it ...
that looks like it could work ...
dang, that's impressive, @dcnr ... thanks ...
CamperBot
@camperbot
Feb 13 2016 03:43
bitgrower sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 616 | @dcnr | http://www.freecodecamp.com/dcnr
Norman Dela Cruz
@dcnr
Feb 13 2016 03:44
@bitgrower oh yeah I used this trick for updating the cid with the cash values and stuff
E
@efhjones
Feb 13 2016 03:44
@bitgrower thanks for all your help today!
CamperBot
@camperbot
Feb 13 2016 03:44
efhjones sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 498 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 13 2016 03:44
you are most welcome .. how's it coming ?
ahhhhhhhh @dcnr ... NOW I get why they recommend using reduce !!!
Norman Dela Cruz
@dcnr
Feb 13 2016 03:46
@appbeza If it has Forgotten Realms on it, it's most likely on my list :P
hellotojello
@hellotojello
Feb 13 2016 03:50
can someone give me a hint..on how to check the given property (prop) is a property of that contact?
for(var i = 0; i < contacts.length; i++){
if (firstName === contacts[i].firstName && prop === contacts[i][firstName][prop]){
i know it's because i can't get to "likes" i can only get to what's inside likes..which is pizza, coding and brownie points
Norman Dela Cruz
@dcnr
Feb 13 2016 03:51
@hellotojello hi .hasOwnProperty checks if your object has a given property :D
@hellotojello
obj.hasOwnProperty(property) // true or false
@hellotojello or the reckless alternative way just obj[property] if using in a conditional statement
@hellotojello
also contacts[i][firstName][prop] this would be undefined because firstName is a string, and it won't have property prop
Zoe
@roamroam
Feb 13 2016 03:55
@dcnr i got it!
function destroyer(arr) {
  var newArr = [];
  var test = [];
  for(var i = 1; i < arguments.length; i++){
    test.push(arguments[i]);
  }

  newArr = arr.filter(function(val){
    for(var j = 0; j < test.length; j++){
      return test.indexOf(val) === -1;
    }
  });
  return newArr;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
Norman Dela Cruz
@dcnr
Feb 13 2016 03:55
@slowoddchild PERFECT :D
that's awesome, thanks! @slowoddchild
CamperBot
@camperbot
Feb 13 2016 03:55
dcnr sends brownie points to @slowoddchild :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave slowoddchild points
bitgrower
@bitgrower
Feb 13 2016 03:56
congrats, @slowoddchild ... tax it to the next level
CamperBot
@camperbot
Feb 13 2016 03:56
bitgrower sends brownie points to @slowoddchild :sparkles: :thumbsup: :sparkles:
:star: 263 | @slowoddchild | http://www.freecodecamp.com/slowoddchild
Norman Dela Cruz
@dcnr
Feb 13 2016 03:57
@slowoddchild
here's a tip though you can use .indexOf so you don't have to do a for loop inside your filter
bitgrower
@bitgrower
Feb 13 2016 03:57
@dcnr -- we were missing it all along ... the upcoming model is functional programming ... :)
Norman Dela Cruz
@dcnr
Feb 13 2016 03:58
@slowoddchild
function destroyer(arr) {
  var newArr = [];
  var test = [];
  for(var i = 1; i < arguments.length; i++){
    test.push(arguments[i]);
  }

  newArr = arr.filter(function(val){
      return test.indexOf(val) === -1;
  });
  return newArr;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
@bitgrower I like functional programming.... to some extent
Brandyn Lucinsky
@appbeza
Feb 13 2016 03:59
@dcnr Have you looked at Haskel?
Norman Dela Cruz
@dcnr
Feb 13 2016 04:00
Extravagant ES6 version
function destroyer(arr) {
  'use strict';

  const args = Array.apply(null, new Array(arguments.length));
  for (let i = 0; i < arguments.length; ++i) {
    args[i] = arguments[i];
  }

  return arr.filter(val => !~args.indexOf(val));
}
E
@efhjones
Feb 13 2016 04:00
@bitgrower what was the link you sent me earlier to see what each step in my code was doing?
bitgrower
@bitgrower
Feb 13 2016 04:01
hang on, @efhjones ... let me go get it ...
Norman Dela Cruz
@dcnr
Feb 13 2016 04:01
@appbeza nope, I only ever dabbled with C, C++, Python, Ruby. I spent most of the time with C++ but didn't really keep up with up to c11
E
@efhjones
Feb 13 2016 04:01
thanks!
bitgrower
@bitgrower
Feb 13 2016 04:02
yw ...
Brandyn Lucinsky
@appbeza
Feb 13 2016 04:02
Can I outsource to another IDE with some sort of API? I miss VS's snippets :(
nakarinh14
@Holydark30
Feb 13 2016 04:03
hey guys, for Profile Lookup my solution is really messy, I want to know your guys solution to this challenge..
function lookUp(firstName, prop){
// Only change code below this line
  var save;
  for(var list in contacts){
    if(contacts[list].firstName == firstName){
      var saveTwo;
      for(var a in contacts[list]){
        if(a == prop){
          return contacts[list][a];  
        }
        else{
          saveTwo = "No such property";
        }
      }
      return saveTwo;
    }
    else{
      save = "No such contact";
    }
  }
  return save;
// Only change code above this line
}
bitgrower
@bitgrower
Feb 13 2016 04:04
@Holydark30 -- if you want a solution -- you can get one from the FCC wiki ... if you want to know how to find the solution --we can help with that ... :)
help format
CamperBot
@camperbot
Feb 13 2016 04:04

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

nakarinh14
@Holydark30
Feb 13 2016 04:05
@bitgrower aaa! forget about the way to format, i will check the wiki , thx!
CamperBot
@camperbot
Feb 13 2016 04:05
holydark30 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 499 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 13 2016 04:05
@Holydark -- you don't want to use for...in here ... because it will try to access ALL the properties attached to the object in something called the prototype chain ...
Zoe
@roamroam
Feb 13 2016 04:07
thanks for the support! @bitgrower
@dcnr I saw that I didn't need the for loop in the filter after haha
CamperBot
@camperbot
Feb 13 2016 04:07
slowoddchild sends brownie points to @bitgrower and @dcnr :sparkles: :thumbsup: :sparkles:
:warning: slowoddchild already gave dcnr points
:star: 500 | @bitgrower | http://www.freecodecamp.com/bitgrower
hellotojello
@hellotojello
Feb 13 2016 04:08

function lookUp(firstName, prop){
 for(var i = 0; i < contacts.length; i++){
  if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)=== true
     ){
    return contacts[i][prop];
  }
    else if(firstName !== contacts[i]){
      return "No such contact";
    }
    else{
      "No such property"
bitgrower
@bitgrower
Feb 13 2016 04:08
you are all very welcome ... YAY!!! I got to 500 !!!
hellotojello
@hellotojello
Feb 13 2016 04:09
the first if statement passes but when i write the else if statement..the first if statement doesn't work anymore and only "no such contact" passes
E
@efhjones
Feb 13 2016 04:09
Hey guys, I'm working on Generate Random Whole Numbers within a Range, trying to understand why
Math.floor(Math.random() * (max - min + 1)) + min
would generate a random number
bitgrower
@bitgrower
Feb 13 2016 04:10
because Math.random does all the heavy lifting ...
the rest is to just create a range for your random number ...
nakarinh14
@Holydark30
Feb 13 2016 04:16
@bitgrower @hellotojello aa thanks
i seem to find the solution

function lookUp(firstName, prop){
// Only change code below this line
  for(i = 0; i < contacts.length ; i++){
    if(contacts[i].firstName == firstName){
      if(contacts[i][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
lookUp("Kristian", "lastName");

but in the if statement

if(contacts[i][prop]){
     ...
}

will the return for this condition, is true or false boolean or something else?

Norman Dela Cruz
@dcnr
Feb 13 2016 04:17
thanks @bitgrower
CamperBot
@camperbot
Feb 13 2016 04:17
dcnr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 501 | @bitgrower | http://www.freecodecamp.com/bitgrower
Norman Dela Cruz
@dcnr
Feb 13 2016 04:17
about @bitgrower
wiki @bitgrower
help @bitgrower
about @camperbot
CamperBot
@camperbot
Feb 13 2016 04:18
:star: 1168 | @camperbot | http://www.freecodecamp.com/camperbot
Norman Dela Cruz
@dcnr
Feb 13 2016 04:18
hmmmm
Brian
@sludge256
Feb 13 2016 04:19
are we taunting @bitgrower @bitgrower @bitgrower ?
or summoning through the bathroom mirror
bitgrower
@bitgrower
Feb 13 2016 04:19
maybe only people with magic powers can access those, @dcnr ...
LOL @sludge256 -- how interesting you should now appear ...
rphares
@rphares
Feb 13 2016 04:20
intriguiing, what about @bitgrower ?
bitgrower
@bitgrower
Feb 13 2016 04:20
well this is fun ...
wonder what kind of event listeners are hung on the chat ...
Norman Dela Cruz
@dcnr
Feb 13 2016 04:21
@sludge256 has event listeners to everything
E
@efhjones
Feb 13 2016 04:21
lol @sludge256 I like your new hat
Norman Dela Cruz
@dcnr
Feb 13 2016 04:21
I don't know that type of Poring @sludge256 :(

@Holydark30

if(contacts[i][prop]){
     ...
}

If the prop doesn't exists it will be undefined, and that would be false :D

Brian
@sludge256
Feb 13 2016 04:23
poring?
oh i get it
Norman Dela Cruz
@dcnr
Feb 13 2016 04:28
@sludge256 did you remember or did you search :wink:
Brian
@sludge256
Feb 13 2016 04:28
:worried:
I never played RO
Norman Dela Cruz
@dcnr
Feb 13 2016 04:29
good for you..
Brian
@sludge256
Feb 13 2016 04:32
Years of your life spent on RO?
E
@efhjones
Feb 13 2016 04:33

So in math.random, to generate a random number in a range:

So say you had a min 3 and a max 7.
(7 - 3 + 1) = 5 + 3 = 8

Say you had -4 and -2
(-2 - -4 + 1) = 3 + -4 = -1

Max 20 Min -15

(20 - -15) = 35 + 1 = 36 + -15 = 21

Why can't you just do Math.random() * (max + 1) to create a range?

Norman Dela Cruz
@dcnr
Feb 13 2016 04:35
thanks @bitgrower @sludge256
CamperBot
@camperbot
Feb 13 2016 04:35
dcnr sends brownie points to @bitgrower and @sludge256 :sparkles: :thumbsup: :sparkles:
:warning: dcnr already gave bitgrower points
:star: 1452 | @sludge256 | http://www.freecodecamp.com/sludge256
Brian
@sludge256
Feb 13 2016 04:35
You're welcome?
@efhjones it'd be a range from 0 to max
assuming you also use floor (for a whole number range)
James Good
@TajYemaj
Feb 13 2016 04:38

// Example
function ourFunction(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}

// Setup
function myFunction(wasThatTrue) {

// Only change code below this line.
if (true) {
return "That was true";
}return "That was false";
// Only change code above this line.
}
// Change this value to test
myFunction(false);

I'm getting a return of true with this.
when running myFunction
And I would've expected an else statement to be necessary in this code.
Can anyone please elaborate?
E
@efhjones
Feb 13 2016 04:39
How do you ask the computer what Math.floor does?
in this chat?
help Math.floor
CamperBot
@camperbot
Feb 13 2016 04:40
no wiki entry for: mathfloor
Brian
@sludge256
Feb 13 2016 04:42
Try yelling at it
James Good
@TajYemaj
Feb 13 2016 04:42
That's a grand suggestion.
E
@efhjones
Feb 13 2016 04:42
@camperbot WHAT DOES MATH.FLOOR MEAN
lol
Rumen1982
@Rumen1982
Feb 13 2016 04:44
Guys i need help i am stuck in one challenge for a while..!!
Brian
@sludge256
Feb 13 2016 04:44
@TajYemaj it's because your code won't evaluate false
if (true) {
I think you meant to put something else inside that
Rumen1982
@Rumen1982
Feb 13 2016 04:45
i am stuck in Global Scope and Functions
Brian
@sludge256
Feb 13 2016 04:45
E
@efhjones
Feb 13 2016 04:45
lol. thanks @sludge256
CamperBot
@camperbot
Feb 13 2016 04:45
efhjones sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1455 | @sludge256 | http://www.freecodecamp.com/sludge256
Brian
@sludge256
Feb 13 2016 04:46
@Rumen1982 What's your code?
Rumen1982
@Rumen1982
Feb 13 2016 04:47

// Declare your variable here

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

}

// 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);
}
@sludge256

instructions:: myGlobal should be defined
myGlobal should have a value of 10
myGlobal should be declared using the var keyword
oopsGlobal should have a value of 5
Do not declare oopsGlobal using the var keyword
Global Scope and Functions @sludge256
E
@efhjones
Feb 13 2016 04:48
@Rumen1982 I don't see anywhere where you declared a global variable myGlobal
You need to declare it outside of any function
Brian
@sludge256
Feb 13 2016 04:49
@efhjones Is your site supposed to be down?
Rumen1982
@Rumen1982
Feb 13 2016 04:49
i am confused how to declare @sludge256
Brian
@sludge256
Feb 13 2016 04:50
You've created variables before
it's not difffent in this case
Rumen1982
@Rumen1982
Feb 13 2016 04:50
and how to give it a value of 10 @sludge256
E
@efhjones
Feb 13 2016 04:50
@sludge256 yeah. I bought the domain and came here to learn how to code it
James Good
@TajYemaj
Feb 13 2016 04:50
@sludge256 function myFunction(wasThatTrue) { // Only change code below this line.
if (false) {
return "That was true";
}
return "That was false"; } myFunction(false); returns "That was false" Something doesn't seem right here. The return should most certainly be "That was true."
James Good
@TajYemaj
Feb 13 2016 04:52
Anything other than the value in the if() position should return false, right?
Brian
@sludge256
Feb 13 2016 04:53
@TajYemaj
function myFunction(wasThatTrue) { // wasThatTrue is a function parameter. You can treat it like a local variable
  if (false) {//use the variable inside your if to check if the variable is true or false
    return "That was true";
  }
  return "That was false";
}
myFunction(false);//here is where you call the function and pass in an argument. The argument will passed into the parameter.
Rumen1982
@Rumen1982
Feb 13 2016 04:53
Thanks a loi @sludge256
CamperBot
@camperbot
Feb 13 2016 04:53
rumen1982 sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1456 | @sludge256 | http://www.freecodecamp.com/sludge256
Brian
@sludge256
Feb 13 2016 04:53
@efhjones I see. I vaguely remember your picture being different too.
James Good
@TajYemaj
Feb 13 2016 04:56
Okay, I'm following that, but the result that should be returned is wrong every time.
with your example with myFunction(false); having if (false) would be true, but that's not what I'm getting. Could it be possible that it's just a bug in the exercise?
Brian
@sludge256
Feb 13 2016 04:59

you're not supposed to have

if (false)

or

if (true)
you want the function to work regardless of what the input is
So you have to check the input with your if statement
Here's a crude example:
function checkIfNumberIsTwo(number) {
  if (1) {
    return "Yes it's two";
  }
  return "Nope";
}
checkIfNumberIsTwo(4);
Notice how even though I'm passing in the number 4
It never actually uses that value to see if it's 2?
No matter what value I put into the last line of code (the function call), the code will always have the same result.
Brian
@sludge256
Feb 13 2016 05:05
Quiet in here tonight.
rphares
@rphares
Feb 13 2016 05:05
i know, i dont know what to do, lol
James Good
@TajYemaj
Feb 13 2016 05:07
With if(wasThatTrue) I got a the first "That was true" statement if myFunction(true); and the "that was false" if myFunction(false);
I'm still having a difficult time understanding why the value placed within if() doesn't have an effect on the outcome.
Brian
@sludge256
Feb 13 2016 05:09
It does. You just said you got different results for myFunction(true); and myFunction(false);

If you use something besides a variable inside the if such as

if(true)

or

if(false)

It will always return the same answer because the thing you are checking never changes. That's why you place a variable inside your if statement

James Good
@TajYemaj
Feb 13 2016 05:11
Well, yes that's true, but it seems to depend more heavily on the way you write the if statements.
the first statement will always be run if true
and the second if ran with false
rewrite the first statement to be "That was false" and the second "That was true" and a myFunction(true); will return "That was false"
Brian
@sludge256
Feb 13 2016 05:13
Well yea that's why you have structure your code and the messages to make sense.
James Good
@TajYemaj
Feb 13 2016 05:13
as for your example with numbers being utilized, I don't even know what kind of results would be returned if you were checking for an exact number
So with no else statement
Brian
@sludge256
Feb 13 2016 05:14
I don't know why you would intentionally switch the messages.
James Good
@TajYemaj
Feb 13 2016 05:14
boolean values in if() don't matter?
but if you're using else/if then they would?
i mean if/else
Brian
@sludge256
Feb 13 2016 05:14
They matter but you can set the message to whatever you want
Maybe I'm just not getting the real intention of your question.
E
@efhjones
Feb 13 2016 05:16
I'm a little confused about what's going on behind Math.floor. So for example, I have a min of 3 and a max of 7. I'm gonna walk through it so you know what I'm talking bout....
function randomRange(myMin, myMax) {
//           (round down)(random number: .2) * ( 7 - 3 + 1) + 3 
//              so (round down)(.2)*(8) 
//                so (round down)(1.6)
//               How does this function not return the value 2? 
  return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin; // Change this line

}
James Good
@TajYemaj
Feb 13 2016 05:16
This if statement seems as though it would be useless for checking for anything other than whether something is true or false.
I can't see how it would be efficient for getting a correct return if you were attempting to check for the number 2.
Brian
@sludge256
Feb 13 2016 05:19
Well my example was how not to do it
James Good
@TajYemaj
Feb 13 2016 05:19
I suppose my question is just that. Is this type of if statement only possible to use with true or false inputs?
Brian
@sludge256
Feb 13 2016 05:19
Nope. The stuff within the quotes will evaluate to true or false though. Let me write up another example
James Good
@TajYemaj
Feb 13 2016 05:21
At first I figured the value in if() was being entered and replacing the (wasThatTrue) part in myFunction(wasThatTrue)
Brian
@sludge256
Feb 13 2016 05:22
nope the value if() is whatever you put in yourself
if you put in a variable it will take on the value of the variable
James Good
@TajYemaj
Feb 13 2016 05:24
Ahh okay, that clears things up a bit.
so would entering if(wasThatTrue === true) have worked?
looks like it does
Brian
@sludge256
Feb 13 2016 05:25
yea but it works the same with the === true
James Good
@TajYemaj
Feb 13 2016 05:26
all right
Brian
@sludge256
Feb 13 2016 05:26
since it's already a boolean
Depending on what you're comparing you can use that shortcut
James Good
@TajYemaj
Feb 13 2016 05:26
Well, thank you for putting up with my nub questions
Brian
@sludge256
Feb 13 2016 05:27
No problem :+1:
@efhjones Next please :P
James Good
@TajYemaj
Feb 13 2016 05:27
How do you give those brownie points?
E
@efhjones
Feb 13 2016 05:27
Haha yay!
Brian
@sludge256
Feb 13 2016 05:27
Just say thanks and their @ name
in the same message
James Good
@TajYemaj
Feb 13 2016 05:27
thanks @slude256
CamperBot
@camperbot
Feb 13 2016 05:27
tajyemaj sends brownie points to @slude256 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for slude256
James Good
@TajYemaj
Feb 13 2016 05:28
oops
Brian
@sludge256
Feb 13 2016 05:28
You can click on a user's name too instead of typing it out
James Good
@TajYemaj
Feb 13 2016 05:28
thanks @sludge256
CamperBot
@camperbot
Feb 13 2016 05:28
tajyemaj sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1457 | @sludge256 | http://www.freecodecamp.com/sludge256
rphares
@rphares
Feb 13 2016 05:28
@sludge256 , is it too soon?
CamperBot
@camperbot
Feb 13 2016 05:28
rphares sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:warning: rphares already gave sludge256 points
rphares
@rphares
Feb 13 2016 05:29
:pensive:
Brian
@sludge256
Feb 13 2016 05:32
@efhjones Pay attention to order of operations for .2 * (7 - 3 + 1) + 3
E
@efhjones
Feb 13 2016 05:35
ah. Sneaky math. Thanks @sludge256
CamperBot
@camperbot
Feb 13 2016 05:35
efhjones sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:warning: efhjones already gave sludge256 points
Brian
@sludge256
Feb 13 2016 05:35
@efhjones also 1.6 (if that were the answer) wouldn't round down to 2
that would be rounding up ;)
Which is what Math.ceil() is for
E
@efhjones
Feb 13 2016 05:37
lol :blush: oops, thanks
Brian
@sludge256
Feb 13 2016 05:39
There's also Math.round() for traditional rounding.
Rumen1982
@Rumen1982
Feb 13 2016 05:46
hey @sludge256 i need help in Stand in Line
E
@efhjones
Feb 13 2016 05:46
So I'm getting close to the end of the javascript chapter, but I still feel like I know nothing about how to implement javascript on the web... does that come with the challenges?
What's your question @Rumen1982
Rumen1982
@Rumen1982
Feb 13 2016 05:47
instruction;; queue([], 1) should return 1
queue(2, 1) should return 2
queue([5,6,7,8,9], 1) should return 5
After queue(testArr, 10), myArr[4] should be 10

function queue(arr, item) {
queue();

return item; // Change this line
}

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

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

Brian
@sludge256
Feb 13 2016 05:48
Review the lessons named "Manipulating Arrays..."
E
@efhjones
Feb 13 2016 05:48
@Rumen1982 post your code in between 3 tics. Tics are the button next to the 1 (on the mac at least). i.e.:
tic tic tic
past code here
tic tic tic
help format
CamperBot
@camperbot
Feb 13 2016 05:49

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

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

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

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

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

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

Rumen1982
@Rumen1982
Feb 13 2016 05:49

```function queue(arr, item) {
queue();

return item; // Change this line
}

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

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

E
@efhjones
Feb 13 2016 05:50
almost but before you paste hit shift-enter again to paste on a new line
This message was deleted
Rumen1982
@Rumen1982
Feb 13 2016 05:52
function queue(arr, item) {
  queue();

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
i think i got it at last
E
@efhjones
Feb 13 2016 05:53
yay! :clap:
Rumen1982
@Rumen1982
Feb 13 2016 05:56
queue([], 1) should return 1
queue([2], 1) should return 2
queue([5,6,7,8,9], 1) should return 5
After queue(testArr, 10), myArr[4] should be 10
cannelflow
@cannelflow
Feb 13 2016 05:56
@Rumen1982 ?
E
@efhjones
Feb 13 2016 05:56
Ok so you need to figure out how you're going to add the number(aka 'item') to the end of the array, then remove the first element of the array.
Rumen1982
@Rumen1982
Feb 13 2016 05:56
i dont understand wat number should i assighn
please tell me hoe todo
cannelflow
@cannelflow
Feb 13 2016 05:57
function queue(arr, item) {
 Add the number to the end of the array, then remove the first element of array. then return element that was removed.
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@Rumen1982
E
@efhjones
Feb 13 2016 05:57
So for example, if you ran your function like this:
function queue(arr, 5) {
declare an array that takes arr
push 5 onto the end of the array
remove the first digit of the array
Rumen1982
@Rumen1982
Feb 13 2016 05:57
@efhjones
do you mean var arr
E
@efhjones
Feb 13 2016 06:01
If you decide to declare a var called arr, sure
but that var doesn't exist in your function yet
so queue(arr, item) are just standins for what will later be passed through the function. you don't need to worry about what those are, you just need to figure out what to do with them
Rumen1982
@Rumen1982
Feb 13 2016 06:04
[ am still not clear
E
@efhjones
Feb 13 2016 06:05
what exactly is confusing you?
Rumen1982
@Rumen1982
Feb 13 2016 06:07
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
its showing your code here now wat am i going to put ther..??
@efhjones
E
@efhjones
Feb 13 2016 06:09
Ok so since queue(arr, item) is going to put an array and an item into the function, we need to figure out what to do with those once they're in there. So first of all you need to declare var to push the given (arr) onto
go ahead and post your code again when you've done that
Brian
@sludge256
Feb 13 2016 06:13
no need to any variable declarations btw ;)
You just have to use the correct array methods
E
@efhjones
Feb 13 2016 06:14
Oh ok, that's how I did it
I thought shift() kind of demanded that you create a var?
This message was deleted
rphares
@rphares
Feb 13 2016 06:15
that is, but you dont need to declare anything,
but-- its fine, too :blush:
Brian
@sludge256
Feb 13 2016 06:16
@efhjones There's more than one way to do it
normally you would assign the shift value to something if you ever wanted to use it for something
but in this case you don't need it besides returning it
Rumen1982
@Rumen1982
Feb 13 2016 06:17
so do i need to use .push and .shift
E
@efhjones
Feb 13 2016 06:17
yep
Brian
@sludge256
Feb 13 2016 06:17
Now we're cooking!
cannelflow
@cannelflow
Feb 13 2016 06:18
@Rumen1982 yes
Rumen1982
@Rumen1982
Feb 13 2016 06:20
thanks guys i am so tired i cant think any more see you another day...
thanks for your response...
E
@efhjones
Feb 13 2016 06:20
Always makes more sense in the morning @Rumen1982 good night
rphares
@rphares
Feb 13 2016 06:20
@efhjones , @cannelflow , @sludge256 tax
CamperBot
@camperbot
Feb 13 2016 06:20
rphares sends brownie points to @efhjones and @cannelflow and @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 794 | @cannelflow | http://www.freecodecamp.com/cannelflow
:star: 261 | @efhjones | http://www.freecodecamp.com/efhjones
:star: 1458 | @sludge256 | http://www.freecodecamp.com/sludge256
Brian
@sludge256
Feb 13 2016 06:22

@efhjones

So I'm getting close to the end of the javascript chapter, but I still feel like I know nothing about how to implement javascript on the web... does that come with the challenges?

I think there is some lack of support in this transition but it's not too different than what you did in the jQuery lessons.

cannelflow
@cannelflow
Feb 13 2016 06:22
hello @rphares :cake: for you
:+1:
rphares
@rphares
Feb 13 2016 06:22
:blush:
E
@efhjones
Feb 13 2016 06:25
Just finished the basic javascript section! :dancer: :confetti_ball: :tada: That was a steep hill. Couldn't have done it without all the help on here.... thanks to everyone and @sludge256 @bitgrower @rphares @mms3232
CamperBot
@camperbot
Feb 13 2016 06:25
efhjones sends brownie points to @sludge256 and @bitgrower and @rphares and @mms3232 :sparkles: :thumbsup: :sparkles:
:star: 2720 | @rphares | http://www.freecodecamp.com/rphares
:star: 1459 | @sludge256 | http://www.freecodecamp.com/sludge256
:star: 229 | @mms3232 | http://www.freecodecamp.com/mms3232
:star: 503 | @bitgrower | http://www.freecodecamp.com/bitgrower
rphares
@rphares
Feb 13 2016 06:25
COngrats!!
Brian
@sludge256
Feb 13 2016 06:25
:+1: :tada:
E
@efhjones
Feb 13 2016 06:25
thanks! :grin:
@sludge256 ok, yeah the jQuery section was a breeze but it felt a lot more like css than javascript...
Brian
@sludge256
Feb 13 2016 06:30
There's more you can do with it than is shown.
You won't really need JavaScript for the first few front-end projects either (unless you want to use it)
Rex Schrader
@SaintPeter
Feb 13 2016 06:31
@sludge256 Actually . . . now that the basic front end projects have moved, theoretically they will need to use JS straight away . . .
sludge256 @sludge256 checks the map
Brian
@sludge256
Feb 13 2016 06:32
I was talking about "Tribute" and "Portfolio" specifically
Rex Schrader
@SaintPeter
Feb 13 2016 06:33
Yeah - but now they come before JS
I suppose they'll need to "go back" to do them
Brian
@sludge256
Feb 13 2016 06:33
What JS would they need for those two projects?
SaintPeter @SaintPeter shakes his head
SaintPeter @SaintPeter fails at communication
sludge256 @sludge256 listens with open ears
Rex Schrader
@SaintPeter
Feb 13 2016 06:34
I mean that now when they finish basic javascript they will go right into projects that DO require JS.
rphares
@rphares
Feb 13 2016 06:34
you are both great at communication, easy misunderstanding with the update timing :)
Rex Schrader
@SaintPeter
Feb 13 2016 06:34
They'll have already finished the two that do not.
Brian
@sludge256
Feb 13 2016 06:35
Gotcha
So we were talking about different things.
Rex Schrader
@SaintPeter
Feb 13 2016 06:35
Is your hat a tribute to the detective miller from The Expanse?
Or are you just going noir on me?
Brian
@sludge256
Feb 13 2016 06:35

Oh

Just finished the basic javascript section! :dancer: :confetti_ball: :tada: That was a steep hill. Couldn't have done it without all the help on here

I get where you're coming from now.
Rex Schrader
@SaintPeter
Feb 13 2016 06:36
"It was a busy day in the chat rooms, but I was feeling blue, as a cold wind rolled across the Gitter"
E
@efhjones
Feb 13 2016 06:36
HA! @SaintPeter :laughing:
rphares
@rphares
Feb 13 2016 06:36
lol
Brian
@sludge256
Feb 13 2016 06:36
We did start using noir speak in the main chat
Rex Schrader
@SaintPeter
Feb 13 2016 06:37
"@rphares was a sassy dame, penguins up to here, if you know what I mean"
Brian
@sludge256
Feb 13 2016 06:37
It's not a direct reference to anything that I'm aware of. I think Spatzerny just searched "fedora" during the original conception of this avatar.
Chih-Yu Yeh
@cyyeh
Feb 13 2016 06:37
function destroyer(arr) {
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
rphares
@rphares
Feb 13 2016 06:37
lol! (rphares wishes she were better at fake noir speak to return honour )
Chih-Yu Yeh
@cyyeh
Feb 13 2016 06:38
hello, I wanna ask that why there is no argument mistake in the function destroyer
Brian
@sludge256
Feb 13 2016 06:38
because JS has an arguments object
Rex Schrader
@SaintPeter
Feb 13 2016 06:38
@Cure100061148 They're looking for you to pull the arguments from the arguements object.
wiki js arguments
CamperBot
@camperbot
Feb 13 2016 06:38

:point_right: js arguments [wiki]

The arguments object is an array-like object (meaning that it looks like an array but it's not) that stores all of the arguments that you passed to a function and is proprietary to that function in particular. If you were to pass 3 arguments to a function, say storeNames(), those 3 arguments would be stored inside an object called arguments and it would look like this when we pass the arguments storeNames("Mulder", "Scully", "Alex Krycek") to our function:

  • First, we declare a function and make it return the arguments object.

    function storeNames() { return arguments; }
  • Then, when we execute that function with n arguments, 3 in this case, it will return the object to us and it will look like an array. We can convert it to an array, but more on that later...

    // If we execute the following line in the console:
    storeNames("Mulder", "Scully", "Alex Kryceck");
    // The output will be: ["Mulder", "Scully", "Alex Kryceck"]

If you want to know more about this, such as converting it to an array or the optimization problem that comes with using the slice() method and how to solve it, click on read more (Gitter Chat Only).

:pencil: read more about js arguments on the FCC Wiki

Rex Schrader
@SaintPeter
Feb 13 2016 06:39
@Cure100061148 It's sort of a synthetic local variable that contains all of the arguments that are passed into the function.
Brian
@sludge256
Feb 13 2016 06:39
This avatar was actually made last month
It's only recently that chat decided to go noir mode
Rex Schrader
@SaintPeter
Feb 13 2016 06:39
Are you a member of the Avatar-of-the-Month-Club?
Brian
@sludge256
Feb 13 2016 06:40
No. Where do I sign up?
Rex Schrader
@SaintPeter
Feb 13 2016 06:40
That's what I wanted to know!
bitgrower
@bitgrower
Feb 13 2016 06:40
Woohoo @efhjones !!!!! Excited to hear about your progress !!!!
Chih-Yu Yeh
@cyyeh
Feb 13 2016 06:40
then how I can access 2 and 3 from the function
rphares
@rphares
Feb 13 2016 06:40
lol-- @SaintPeter , i dont know that you'd be in that club, i dont think I've seen yours ever change...?
Rex Schrader
@SaintPeter
Feb 13 2016 06:41
@Cure100061148 You need to access arguments[1] or arguments[2], etc. But it's a bit more complex than that, since you really need the remainder of the arguments as an array so you can loop through them.
@rphares I actually changed mine a month or two back and there was much wailing and gnashing of teeth. I used to be much less sinister.
Brian
@sludge256
Feb 13 2016 06:41
Where is everyone tonight? Here we are holding a casual conversation in a help room.
rphares
@rphares
Feb 13 2016 06:42
Right? Which i normally try and nip in the bud, but...
Chih-Yu Yeh
@cyyeh
Feb 13 2016 06:42
@SaintPeter OK thanks! I will study about it
CamperBot
@camperbot
Feb 13 2016 06:42
cure100061148 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2484 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Feb 13 2016 06:42
@Cure100061148 Sure thing :D
Brian
@sludge256
Feb 13 2016 06:42
I guess that's what they pay me for. To find out what's been clogging the arteries of this dark dying city.
rphares
@rphares
Feb 13 2016 06:43
today doesn't even feel real, I'm used to jumping in and feeling like I've done something while having coffee... i can't make myself start my day yet, lol
Rex Schrader
@SaintPeter
Feb 13 2016 06:43
@rphares @sludge256 Oh no! I'm a bad influence!
@sludge256 LOL
rphares
@rphares
Feb 13 2016 06:43
no- its been silent, maybe 4 questions here in the last 3 hours?
Shawn Watson
@its-swats
Feb 13 2016 06:43
Having a logic problem on "Profile Lookup" in JS. I'm iterating through the array and can find when something matches, but I can't logic out how to see if something doesn't exist.
function lookUp(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
  }


// Only change code above this line
}
rphares @rphares grudgingly starts day... cheers, all!
Shawn Watson
@its-swats
Feb 13 2016 06:44
if I add an else for something not existing, it triggers too often (after each index)
Rex Schrader
@SaintPeter
Feb 13 2016 06:45
@its-swats Well, it's sort of an inductive logic problem. You can easily tell when you've found it, but you can only tell that you have NOT when you're done searching through the array. You cannot telling from inside the array if you have not fount it because you'll always have another element to check . . .
@its-swats So think about when you CAN definitively say that you have NOT found it . . .
bitgrower
@bitgrower
Feb 13 2016 06:45
yeah, it was quieter earlier, too ... :)
Chih-Yu Yeh
@cyyeh
Feb 13 2016 06:46
@SaintPeter so can I say that, technically no matter how many elements I want to pass into the function, my function definition can always be written as function example(arg) {} instead of function example (arg1, arg2,...)?
Shawn Watson
@its-swats
Feb 13 2016 06:46
yeah, so I have to be able to tell if either "firstName" didn't match, or when "prop" didn't match. so if it makes it past the loop, I know nothing was found, but not which nothing
bitgrower
@bitgrower
Feb 13 2016 06:46
ahh ... I see you got it, @its-swats -- nvm ... too late ...
Rex Schrader
@SaintPeter
Feb 13 2016 06:47
@its-swats Exactly.
@Cure100061148 Correct. In fact, you don't even have to define ANY parameters in your function definition to be able to access them via the arguements object.
bitgrower
@bitgrower
Feb 13 2016 06:47
@Cure100061148 -- in javascript functions can take any number of arguments ...
Bryce Turner
@AbryceT
Feb 13 2016 06:48
I need a little help for the record collection. I have been trying to us 'if' statements but Blauelf last night say it's not right...having a lot of trouble with this one...
// 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 update(id, prop, value) {
    if (collection[id].hasOwnProperty != "tracks") {

     if (collection[id][prop].hasOwnProperty(value !== "")) {

     console.log(id, prop, value);

  }else if (collection[id].prop == "tracks") {

     if (collection.id.prop.hasOwnProperty(value !== "")) {

      collection.push(value);

  }else if (collection.id.prop.hasOwnProperty(value =""))
      delete collection("prop");     
            }         
  }

  return collection;
}


// Alter values below to test your code
update(5439, "artist", "ABBA");
bitgrower
@bitgrower
Feb 13 2016 06:48
this will be handy in understanding arguments optional... which is sort of the reverse ...
Rex Schrader
@SaintPeter
Feb 13 2016 06:49
@its-swats You may need to check to see if the name matches and THEN check to see if the property exists. You can nest an if statement.
@AbryceT :point_up: February 12, 2016 10:45 PM
Shawn Watson
@its-swats
Feb 13 2016 06:49
Hah, that's exactly it. Thank you.
Rex Schrader
@SaintPeter
Feb 13 2016 06:49
NP
Bryce Turner
@AbryceT
Feb 13 2016 06:50
@SaintPeter ok, let me work on this a bit
Chih-Yu Yeh
@cyyeh
Feb 13 2016 06:50
@SaintPeter thanks again.
CamperBot
@camperbot
Feb 13 2016 06:50
:warning: cure100061148 already gave saintpeter points
cure100061148 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
Mohammed Shehab
@mshehab93
Feb 13 2016 06:51
can someone help me with this code? I've been stuck on it since yesterday
n9exorcist
@n9exorcist
Feb 13 2016 06:51

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

 case "a":
 answer  = "apple";
  break;

  case "b":
 answer  = "bird";
  break;

  case "c":
  answer = "cat";
  break;

  default:
  answer="stuff";

}

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

// Change this value to test
myTest(a)

Rex Schrader
@SaintPeter
Feb 13 2016 06:51
@Cure100061148 :D :D
n9exorcist
@n9exorcist
Feb 13 2016 06:51
ReferenceError: a is not defined.
Mohammed Shehab
@mshehab93
Feb 13 2016 06:51
function lookUp(firstName, prop){
// Only change code below this line

  if (firstName === contacts.firstName && prop === contacts.hasOwnProperty(prop)) {
    return contacts.prop;
  } else if (firstName !== contacts.firstName) {
    return "No such contact";
  } else if (prop !== contact.prop) {
    return "No such property";
  }
n9exorcist
@n9exorcist
Feb 13 2016 06:51
whats wrong here
Mohammed Shehab
@mshehab93
Feb 13 2016 06:51

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

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

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

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

bitgrower
@bitgrower
Feb 13 2016 06:51
it is lookup night here !!!!
greg
@wearenotgroot
Feb 13 2016 06:51
@n9exorcist means there is no variable named a
Shawn Watson
@its-swats
Feb 13 2016 06:51
exorcist: you're passing in (a), not ("a")
Rex Schrader
@SaintPeter
Feb 13 2016 06:51
@mshehab93 :point_up: February 12, 2016 10:45 PM
greg
@wearenotgroot
Feb 13 2016 06:52
@n9exorcist the js engine was like what there is an a where?<------------------- myTest(a) should be literal a as in 'a'-------->myTest('a')
bitgrower
@bitgrower
Feb 13 2016 06:52
isn't that a cute trick, @SaintPeter ... ? @dcnr taught me that one ...
n9exorcist
@n9exorcist
Feb 13 2016 06:53
@its-swats after changing the values, to case a:
answer = "apple";
break;
  case b:
 answer  = "bird";
  break;

  case c:
  answer = "cat";
  break;                                 I get the same error
Shawn Watson
@its-swats
Feb 13 2016 06:53
so when you just use a letter, not a string, what does that represent?
n9exorcist
@n9exorcist
Feb 13 2016 06:56
@wearenotgroot after inputting, as myTest('a'); I still have the same error
Shawn Watson
@its-swats
Feb 13 2016 06:56
did you switch the cases back to case "a", case "b" etc?
Mohammed Shehab
@mshehab93
Feb 13 2016 06:56
@SaintPeter thanks
greg
@wearenotgroot
Feb 13 2016 06:56
@n9exorcist try and enclosed the letters on the switch cases in "" or ''m just like @its-swats said ^
n9exorcist
@n9exorcist
Feb 13 2016 06:57
@its-swats I didnt switch the cases back to case "a"
greg
@wearenotgroot
Feb 13 2016 06:57
@n9exorcist do it with every letter on the cases
Shawn Watson
@its-swats
Feb 13 2016 06:57
you're passing in a string, so you want to be checking for strings in your cases
E
@efhjones
Feb 13 2016 06:58
Off to bed. G'night rrybody
bitgrower
@bitgrower
Feb 13 2016 06:58
g'night @efhjones -- and congrats again !!!!
n9exorcist
@n9exorcist
Feb 13 2016 06:58

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

 case "a":
 answer  = "apple";
  break;

  case "b":
 answer  = "bird";
  break;

  case "c":
  answer = "cat";
  break;

  default:
  answer="stuff";

}

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

// Change this value to test
myTest('a');
This code is working now.

Mohammed Shehab
@mshehab93
Feb 13 2016 06:58
hey btw i got a book recommended by someone here called "Eloquent Javascript" are there any other books (books !== wiki || books !== internet) that I can read to get a good hold of JS?
E
@efhjones
Feb 13 2016 06:59
thanks @bitgrower :grin:
CamperBot
@camperbot
Feb 13 2016 06:59
efhjones sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: efhjones already gave bitgrower points
n9exorcist
@n9exorcist
Feb 13 2016 06:59
@its-swats Thank you, I understood it now
CamperBot
@camperbot
Feb 13 2016 06:59
n9exorcist sends brownie points to @its-swats :sparkles: :thumbsup: :sparkles:
:star: 140 | @its-swats | http://www.freecodecamp.com/its-swats
bitgrower
@bitgrower
Feb 13 2016 06:59
help js resources
n9exorcist
@n9exorcist
Feb 13 2016 06:59
@wearenotgroot Thanks for the suggestions
greg
@wearenotgroot
Feb 13 2016 07:00
@n9exorcist :+1:
bitgrower
@bitgrower
Feb 13 2016 07:00
as you can see, eloquent js is on the list of helpful resources ... a number of us have been raving about udemy course -- if you search around the web you can find udemy coupons for $10 ... the course is WELL worth $10
you can watch the first 3.5 hrs for free on a yt video -- just search out the name
Mohammed Shehab
@mshehab93
Feb 13 2016 07:01
@bitgrower thanks
CamperBot
@camperbot
Feb 13 2016 07:01
mshehab93 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 506 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Feb 13 2016 07:01
yw !!!
Brian
@sludge256
Feb 13 2016 07:02
I think Udemy is moving up to $15 courses now
Rex Schrader
@SaintPeter
Feb 13 2016 07:02
I heard that Free Code Camp was going to double their prices. Everyone is outraged!
bitgrower
@bitgrower
Feb 13 2016 07:03
maybe, @sludge256 -- but I've seen them offer $15 coupons and then go back to $10 coupons ...
sludge256 @sludge256 shakes fist
bitgrower
@bitgrower
Feb 13 2016 07:03
and I've seen both happen at the same time ...