These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Jul 2016
bitgrower
@bitgrower
Jul 10 2016 00:00
tbh -- I hated commuting so much, I think I have a bit of PSTD from some of the traffic I used to have to deal with ...
llamatarianism
@llamatarianism
Jul 10 2016 00:00
god I hated word problems
Joseph
@revisualize
Jul 10 2016 00:00
It would be 100% commuting by bus.
llamatarianism
@llamatarianism
Jul 10 2016 00:00
every single one of them is like
bitgrower
@bitgrower
Jul 10 2016 00:01
@luke1513 well, if you're a teen-ass, you should have even more time !!! And great future opportunities ... :)
llamatarianism
@llamatarianism
Jul 10 2016 00:01
"muhammad has 3 apples. maria has 7. it is a tuesday.
"calculate the surface area of phobos."
bitgrower
@bitgrower
Jul 10 2016 00:02
ahhh ... 100% commuting by bus for a 20% pay raise + additional commute time ... but then it's not REALLY commute time ... because you can do stuff on the bus (well, sorta).
my first tech job I used to catch a train from San Bruno at 6:00am to Palo Alto, where I caught the bus to be at work by 8:00 am ... fortunately, the train & the conductor were great fun ...
Diego Mayer
@Chrono79
Jul 10 2016 00:03
@bitgrower unless you're the bus driver :P
bitgrower
@bitgrower
Jul 10 2016 00:03
touche @Chrono79
Diego Mayer
@Chrono79
Jul 10 2016 00:03
but that'd be an extra income too ;)
bitgrower
@bitgrower
Jul 10 2016 00:05
@llamatarianism -- yeah, that's about how calc word problems looked at me ... but more it was a man is walking away from a pole with a shadow at 45% ... after walking 10 minutes the angle is now 30% ... how fast was he walking ?
llamatarianism
@llamatarianism
Jul 10 2016 00:06
ok I dunno if this makes me racist/sexist or something
but I always thought there were like
no white male names in word problems in school
willcodes
@willcodes
Jul 10 2016 00:06
can you put multiple replaces together?
Moisés Man
@moigithub
Jul 10 2016 00:06
ofc @willcodes
FM
@mafelix
Jul 10 2016 00:06
you can string as many as you want
@willcodes
willcodes
@willcodes
Jul 10 2016 00:06
ohhh ahahha ok
thanks!
llamatarianism
@llamatarianism
Jul 10 2016 00:07
they were all either middle eastern names or female names
FM
@mafelix
Jul 10 2016 00:07
str.replace(a,b).replace(c,d).replace(e,f)
bammmmmmmmmmm
gimme a cookie
just joking
bitgrower
@bitgrower
Jul 10 2016 00:07
it's a sad aspect of human nature that we like to generalize -- or over-generalize -- give us black and white thinking and we jump at it like starved puppies ...
FM
@mafelix
Jul 10 2016 00:07
got work to do
llamatarianism
@llamatarianism
Jul 10 2016 00:07
@willcodes chances are you don't need multiple replacements
I assume you're doing the palindrome challenge?
FM
@mafelix
Jul 10 2016 00:07
@bitgrower as a programming though logic is in black and white
Diego Mayer
@Chrono79
Jul 10 2016 00:07
@willcodes but sometimes what you need is a better regex expression
FM
@mafelix
Jul 10 2016 00:08
it either works or doesn't work
bitgrower
@bitgrower
Jul 10 2016 00:08
no white male names in word problems in school <-- I don't remember ANY names, tbh
llamatarianism
@llamatarianism
Jul 10 2016 00:08
there were plenty in all the ones I did
they usually involved
"this person has this, that person has that"
or "this person is doing this"
I'm talking about like, primary school stuff though
bitgrower
@bitgrower
Jul 10 2016 00:09
@mafelix well ... except there are lots of them ... some black, some white ... when you add up all the variations you have nice gradients from black to white ... :)
llamatarianism
@llamatarianism
Jul 10 2016 00:09
I barely do any word problems nowadays
and now they include fewer names
FM
@mafelix
Jul 10 2016 00:09
@bitgrower nah. you can come to the same answer or functionality in multiple different ways. BUT it's still the right way or wrong way
llamatarianism
@llamatarianism
Jul 10 2016 00:09
like you said, usually stuff to do with poles
willcodes
@willcodes
Jul 10 2016 00:09
@llamatarianism ya im stumped
bitgrower
@bitgrower
Jul 10 2016 00:10
the only thing I remember was our reading books which were "Dick and Jane" ... I actually swiped one and kept it ... but then turned it in ... I should've kept it ... it would be uber valuable now ...
llamatarianism
@llamatarianism
Jul 10 2016 00:10
@willcodes instead of doing
willcodes
@willcodes
Jul 10 2016 00:10
@llamatarianism but i dont want the solution ahahha
llamatarianism
@llamatarianism
Jul 10 2016 00:10
str.replace(a, "").replace(b, "").replace(c, "")
you can do
str.replace(abc, "")
willcodes
@willcodes
Jul 10 2016 00:10
ohh!
even with /\W/g?
llamatarianism
@llamatarianism
Jul 10 2016 00:10
so, let's say a = /\s/, b = /\d/ and c = /\W/
you can do
Pericles
@periman2
Jul 10 2016 00:10
can someone explain to me why return a-b works the way it does in sort function ?
llamatarianism
@llamatarianism
Jul 10 2016 00:10
str.replace(/\s|\d|\W/, "")
willcodes
@willcodes
Jul 10 2016 00:11
use |?
kk
llamatarianism
@llamatarianism
Jul 10 2016 00:11
instead of str.replace(/\s/, "").replace(/\d/, "").replace(/\W/, "")
Pericles
@periman2
Jul 10 2016 00:11
which a and which b does it actually compare ?
FM
@mafelix
Jul 10 2016 00:11
@periman2 you're saying sort this in a-b order
a < b
in the alphabet
yo
if you reversed it
b-a
llamatarianism
@llamatarianism
Jul 10 2016 00:11
@periman2 sort takes a function that returns a number
Pericles
@periman2
Jul 10 2016 00:11
yes I mean why does this actually work
FM
@mafelix
Jul 10 2016 00:11
it would sort from reverse
Moisés Man
@moigithub
Jul 10 2016 00:11
@periman2 returning positive, negative or zero values from callback determine the sort order
Pericles
@periman2
Jul 10 2016 00:12
why a-b gives an ordered array?
llamatarianism
@llamatarianism
Jul 10 2016 00:12
if a < b
then a - b will be negative
bitgrower
@bitgrower
Jul 10 2016 00:12
@mafelix part of my life I went looking for fields which required exactness ... sorry -- after seeing how much production code actually has bugs in it which have existed for years ... that's a gray to me ... :) I was always amused when i would find stuff and go ... "how long has this been in here ?!?" ... I used to go cleaning stuff up -- just because I'm obsessive that way ... and one day .. my boss said ... "who fixed the problem with the microscope?" .. I didn't even know what he was talking about ... but, apparently one of my code clean ups fixed it ...
llamatarianism
@llamatarianism
Jul 10 2016 00:12
if a >= b then a - b will be positive or 0
sort takes a function that returns a number
jrandallhansen
@jrandallhansen
Jul 10 2016 00:12
what does this regex mean /[^a-z0-9]/gi
?
llamatarianism
@llamatarianism
Jul 10 2016 00:12
I believe if that number is positive, it swaps them
Pericles
@periman2
Jul 10 2016 00:12
yes but what are the a and b ? what elements are these in the array ?
FM
@mafelix
Jul 10 2016 00:12
@bitgrower well you wouldn't have bugs to fix if everything was gray
llamatarianism
@llamatarianism
Jul 10 2016 00:12
and if it isn't, it leaves them in the same place.
Pericles
@periman2
Jul 10 2016 00:12
or they're not?
llamatarianism
@llamatarianism
Jul 10 2016 00:12
@periman2 all of them
it steps through the array and compares adjacent elements
so if you were sorting [1,2,3,4,5]
Pericles
@periman2
Jul 10 2016 00:13
oooh so it compares all of them with all of them?
FM
@mafelix
Jul 10 2016 00:13
@bitgrower you must remember computer compiles down 1s and 0s and that if not the ultimate black and white I don't know what is
llamatarianism
@llamatarianism
Jul 10 2016 00:13
it'd first do
((a, b) => a - b)(1, 2)
then ((a, b) => a - b)(2, 3)
and so on
Pericles
@periman2
Jul 10 2016 00:13
yes but that doesn't work
bitgrower
@bitgrower
Jul 10 2016 00:13
fields I looked at, just fyi -- accounting, electronics, medicine (like pharmacy) ... nope none of 'em... most exactly class I ever took? Electronics fabrication ... (made myself a soldering iron holder, I did!)
Pericles
@periman2
Jul 10 2016 00:13
that's what I'm saying
llamatarianism
@llamatarianism
Jul 10 2016 00:13
what do you mean it doesn't work
what doesn't work?
and how doesn't it work?
Pericles
@periman2
Jul 10 2016 00:14
@llamatarianism in this array
[1, 12, 21, 2]
Jeffery Dominick
@Dominije
Jul 10 2016 00:14
I still can't get these few lines of code to work:
else if (value === "") {
//delete the (value)
delete collection[id].prop;
}
llamatarianism
@llamatarianism
Jul 10 2016 00:14
works for me
> [1, 12, 21, 2].sort((a, b) => a - b)
[ 1, 2, 12, 21 ]
willcodes
@willcodes
Jul 10 2016 00:14
@llamatarianism not working
llamatarianism
@llamatarianism
Jul 10 2016 00:14
just typed it into the node console
Pericles
@periman2
Jul 10 2016 00:14
if you do what you just told me it will let the value 2 in the 3rd place
bitgrower
@bitgrower
Jul 10 2016 00:14
@mafelix sweetie, I probably know that far better than you do ... between digital electronics, writing boot rom code for a new computer, embedded systems and I don't know how many assembly languages ...
willcodes
@willcodes
Jul 10 2016 00:14
(/\W|\d+|\s/, "")
llamatarianism
@llamatarianism
Jul 10 2016 00:14
no, it wouldn't
willcodes
@willcodes
Jul 10 2016 00:14
is that right?
llamatarianism
@llamatarianism
Jul 10 2016 00:14
because it also swaps elements around
then it compares them
FM
@mafelix
Jul 10 2016 00:15
@bitgrower then how can you debate that programming essentially isn't black and white
llamatarianism
@llamatarianism
Jul 10 2016 00:15
@willcodes I wasn't literally saying you need to replace numbers and whitespace
I was just giving that as an example
bitgrower
@bitgrower
Jul 10 2016 00:15
at some point ... everything is "digital" ... where we define categories is interesting ...
llamatarianism
@llamatarianism
Jul 10 2016 00:15
remove the \d+|\s bit
don't take stuff I say that literally
willcodes
@willcodes
Jul 10 2016 00:15
you have to replace numbers no?
for that exercise
llamatarianism
@llamatarianism
Jul 10 2016 00:15
no
it says remove non-alphanumeric characters
FM
@mafelix
Jul 10 2016 00:16
even design of color schemes/UX I'm sure someone can come up with a formula that will appease 90% of the population on the planet
Pericles
@periman2
Jul 10 2016 00:17
look : [1, 12, 21, 2] 1-12=-11 so it stays the same then 12-21=-9 so it stays the same again but then it does 21-2 it's +19 so it becomes [1, 12, 2, 21] @llamatarianism
llamatarianism
@llamatarianism
Jul 10 2016 00:17
it does it repeatedly
not just once
Pericles
@periman2
Jul 10 2016 00:17
until it's all negative ?
llamatarianism
@llamatarianism
Jul 10 2016 00:18
yeah probably
Pericles
@periman2
Jul 10 2016 00:18
okay that makes more sense that's what I wanted to learn
bitgrower
@bitgrower
Jul 10 2016 00:18

@mafelix -- because context changes everything ... like one of my favorite software QA books mentioned how some sort of physics particle could come in and bombard your chip and change your code ... at some point, you can say everything is digital, I suppose, down at the bottom, it is either "on or off" ... but human perceptual/cogntive hunger for black and white far exceeds the subtlties that exist in the world ...

...oh well, enough philosophising for today ... I've had my fill for a couple of weeks ... but that's another story altogether ... good evening all !

Pericles
@periman2
Jul 10 2016 00:18
@llamatarianism Thank you !
CamperBot
@camperbot
Jul 10 2016 00:18
periman2 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 936 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
FM
@mafelix
Jul 10 2016 00:19
@bitgrower good night!
@bitgrower humans are different than computers
@bitgrower :D
Suzanne Atkinson
@AdventureBear
Jul 10 2016 00:19
@sjames1958gm I totally forgot that was an option
bitgrower
@bitgrower
Jul 10 2016 00:20
oh ... who was browsing Amazon ? I got hunger and was in bad need of a shopping trip -- after reviewing how much Amazon prime fresh would cost ... I made an order thru Google Express -- to get some of my favorite Costco consumables ... YAY!!!
(my first Google Express order ... .3 mo free trial...sweet)
Suzanne Atkinson
@AdventureBear
Jul 10 2016 00:21
So is exact change a greedy algorithm or not since there is no need for recursive evaluations of later choices ? It's just a single pass through the currency array
bitgrower
@bitgrower
Jul 10 2016 00:21
@mafelix g'night ... have fun ...
Zina Astafyeva
@tragetraje
Jul 10 2016 00:23
Hi all! I'm looking for some help with profile lookup...
Anybody eager to have a look at my code?
FM
@mafelix
Jul 10 2016 00:26
I has question for you smarties
you have two arrays with elements
same length
you can sort the arrays anyway you want
how would you go through the different permutations to see if it ALL elements in the same index sum >= k
willcodes
@willcodes
Jul 10 2016 00:29
```js
can i get a hint (no solution)

function palindrome(str) {
  var newStr = str.replace(/\W/g,"").toLowerCase();


  if (newStr.split("").reverse().join("") === newStr)
  {   
  return true;
  }
  else return false;
}




palindrome("eye");
FM
@mafelix
Jul 10 2016 00:29
for ex.
k = 10
arr_one = [1,2,3]
arr_two = [7,8,9]

#if you arrange arr_one in this order you full the condition
arr_one=[3,2,1]
arr_two=[7,8,9]

#for loop to sum the elements together would satisfy >= k
willcodes
@willcodes
Jul 10 2016 00:30
palindrome("0_0 (: /-\ :) 0-0") should return true.
palindrome("_eye") should return true.
Diego Mayer
@Chrono79
Jul 10 2016 00:30
@willcodes you need to get rid of underscore too
willcodes
@willcodes
Jul 10 2016 00:30
@Chrono79 oh its not included in W?
Diego Mayer
@Chrono79
Jul 10 2016 00:30
no
willcodes
@willcodes
Jul 10 2016 00:31
@Chrono79 do I have to keep the replacements in a var? I tried to string it all together and it didnt work
Diego Mayer
@Chrono79
Jul 10 2016 00:31
what did you do?
willcodes
@willcodes
Jul 10 2016 00:33
this passed

function palindrome(str) {
  var newStr = str.replace(/\W/g,"").replace( '_', "").toLowerCase();


  if (newStr.split("").reverse().join("") === newStr)
  {   
  return true;
  }
  else return false;
}




palindrome("eye");
This message was deleted

function palindrome(str) {



  if (str.replace(/\W/g,"").replace( '_', "").toLowerCase().split("").reverse().join("") === str)
  {   
  return true;
  }
  else return false;
}




palindrome("eye");
why does it have to be in a var?
Diego Mayer
@Chrono79
Jul 10 2016 00:36
@willcodes the second won't work, you're comparing with the original str without getting rid of all that's not a number or a letter and may contain capital letters
willcodes
@willcodes
Jul 10 2016 00:37
ohh so duplicate?
nvm
is doing it with the var the most efficient?
@Chrono79 thanks
CamperBot
@camperbot
Jul 10 2016 00:37
willcodes sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1462 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 10 2016 00:38
less writing sure
also check this: :point_up: 9 de julio de 2016 19:24 for not using 2 replaces
Zina Astafyeva
@tragetraje
Jul 10 2016 00:42
Please anybody help me with that...
function lookUpProfile(firstName, prop){
// Only change code below this line
        for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].hasOwnProperty(firstName)) {
          if (contacts[i].prop === prop) {
                return contacts[i].prop;
            } 
            return "No such property";
        }
        return "No such contact";
    }
// Only change code above this line
}
I've come up with this code and don't know where to move next and how to debug it..
Diego Mayer
@Chrono79
Jul 10 2016 00:44

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

Zina Astafyeva
@tragetraje
Jul 10 2016 00:44
Not looking for a solution but a hint on how to debug/what's wrong with my code...
Diego Mayer
@Chrono79
Jul 10 2016 00:45
@tragetraje those are the instructions, that's not what're your testing
Zina Astafyeva
@tragetraje
Jul 10 2016 00:45
Hi @Chrono79 why can't I check with that? contacts[i].hasOwnProperty(firstName)?
Diego Mayer
@Chrono79
Jul 10 2016 00:45
@tragetraje you can test that, but it's not needed, all the contacts have a firstName property
Zina Astafyeva
@tragetraje
Jul 10 2016 00:46
Somebody have told me that I should use that instead contacts[i].firstName === firstName... But I don't understand the difference at this moment...why can't I check for that with .hasOwnProperty..
Diego Mayer
@Chrono79
Jul 10 2016 00:47
@tragetraje with hasOwnProperty, you check the property exists, with contacts[i].firstName === firstName you are checking it exists and its value is the one contained in firstName (your function param)
Zina Astafyeva
@tragetraje
Jul 10 2016 00:48
ok, so since all of them do have first name...(u r right)...to check if it belongs to current contact I should do this contacts[i].firstName === firstName..?
Diego Mayer
@Chrono79
Jul 10 2016 00:48
yes
hasOwnProperty has to be used with prop, because if (contacts[i].prop === prop) { is not right
Zina Astafyeva
@tragetraje
Jul 10 2016 00:49
ok, now it's clear...what about the rest? do u see something which is wrong in the logic?
Norvin Burrus
@ndburrus
Jul 10 2016 00:49
@tragetraje this may be helpful: :sparkles:
Diego Mayer
@Chrono79
Jul 10 2016 00:50
only what I said before
Zina Astafyeva
@tragetraje
Jul 10 2016 00:51
Thanks @Chrono79 will give it a try..
CamperBot
@camperbot
Jul 10 2016 00:51
tragetraje sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1463 | @chrono79 |http://www.freecodecamp.com/chrono79
Zina Astafyeva
@tragetraje
Jul 10 2016 00:51
for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].firstName === firstName) {
          if (contacts[i].hasOwnProperty(prop)) {
                return contacts[i].prop;
            } 
            return "No such property";
        }
        return "No such contact";
    }
Diego Mayer
@Chrono79
Jul 10 2016 00:52
@tragetraje as @ndburrus said, check out that link
Zina Astafyeva
@tragetraje
Jul 10 2016 00:52
This way it still does pass only two of all the tests as before...
Diego Mayer
@Chrono79
Jul 10 2016 00:52

@tragetraje

var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }

There is no property named prop there, firstName is an actual property name, so you could use dot notation with that

Zina Astafyeva
@tragetraje
Jul 10 2016 00:53
ok @Chrono79 @ndburrus Thanks guys, will have a look at bracket notation once again and give it a go
CamperBot
@camperbot
Jul 10 2016 00:53
tragetraje sends brownie points to @chrono79 and @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: tragetraje already gave chrono79 points
:cookie: 909 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 10 2016 00:54
@tragetraje you're welcome! you'll be an expert in no time :sparkles:
Diego Mayer
@Chrono79
Jul 10 2016 00:54
@tragetraje I see another problem there, is No such contact inside the loop?
djoles2401
@djoles2401
Jul 10 2016 00:55
This message was deleted
This message was deleted
Diego Mayer
@Chrono79
Jul 10 2016 00:56
@djoles2401 reorder your ifs
djoles2401
@djoles2401
Jul 10 2016 01:05

function rot13(str) { // LBH QVQ VG!
var myStr=str.split('');var num;
var result=[];
for (i=0;i<myStr.length;i++){ if (myStr[i].charCodeAt(0)<65 || myStr[i].charCodeAt(0)>90){
result.push(myStr[i]);
}
if (myStr[i].charCodeAt(0)>77){
num=(myStr[i].charCodeAt(0))-13;
result.push(String.fromCharCode(num));
}
else {
num=myStr[i].charCodeAt(0)+13;
result.push(String.fromCharCode(num));
}

}
return result.join('')
;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
I tried like this. problem is in the output.
I get this
FREE -CODE -CAMP

Brice Ayres
@MyNameIsURL
Jul 10 2016 01:06
@djoles2401 are you trying to match letters ?
llamatarianism
@llamatarianism
Jul 10 2016 01:06
@djoles2401 you're pushing the thing into results
if it's not a letter
but you're also pushing the rotated version
if (myStr[i].charCodeAt(0)<65 || myStr[i].charCodeAt(0)>90){
  result.push(myStr[i]);
}
there's no continue here
so it keeps going through the rest of the loop anyway
you want to ignore it entirely
so add a continue statement
if (myStr[i].charCodeAt(0)<65 || myStr[i].charCodeAt(0)>90){
  result.push(myStr[i]);
  continue;
}
djoles2401
@djoles2401
Jul 10 2016 01:10
@llamatarianism That continue thing saved me.
llamatarianism
@llamatarianism
Jul 10 2016 01:10
:+1:
djoles2401
@djoles2401
Jul 10 2016 01:10
llamatarianism
@llamatarianism
Jul 10 2016 01:11
you also could have wrapped the rest of it in an else statement
if (myStr[i].charCodeAt(0)<65 || myStr[i].charCodeAt(0)>90){
  result.push(myStr[i]);
} else if (myStr[i].charCodeAt(0) > 77) {
  // the rest of the stuff
basically, you just need to ignore the rest of the code if myStr[i] isn't a letter
you were still executing the bit that rotates it
jiajinning
@jiajinning
Jul 10 2016 01:20
@jrandallhansen thank you ,i got it
CamperBot
@camperbot
Jul 10 2016 01:20
jiajinning sends brownie points to @jrandallhansen :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @jrandallhansen |http://www.freecodecamp.com/jrandallhansen
Nestor Carrasquillo
@blackhat3
Jul 10 2016 01:21
hi guys, new to JS and I'm trying to take the hang of it but don't know why it is so difficult in my head!
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:22
@djoles2401 If you just want to pluck out the letters you could do something like this,
var str = "1A2B3C4D5E6F7G!”;

console.log(str.match(/[a-zA-Z]+/gi).join(''));
llamatarianism
@llamatarianism
Jul 10 2016 01:22
@blackhat3 what's the problem
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:23
@djoles2401 that will return ‘ABCDEFG’
JohnnyMcMonny
@JohnnyMcMonny
Jul 10 2016 01:23

Could someone tell me why this is returning false? ``` var quarter = function(number) {
number / 4;
};

if (quarter(12) % 3 === 0 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}
```

Brice Ayres
@MyNameIsURL
Jul 10 2016 01:23
not sure if that was what you were trying to do but could be a helpful shortcut when trying to find letters
llamatarianism
@llamatarianism
Jul 10 2016 01:24
@JohnnyMcMonny quarter doesn't return anything
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:24
@JohnnyMcMonny you are missing the return statement
llamatarianism
@llamatarianism
Jul 10 2016 01:24
you need to say return number / 4;
not just number / 4;
so you're checking if undefined % 3 === 0
which it obviously isn't
JohnnyMcMonny
@JohnnyMcMonny
Jul 10 2016 01:24
Ah, I see... Thank you @llamatarianism and @MyNameIsURL
CamperBot
@camperbot
Jul 10 2016 01:24
johnnymcmonny sends brownie points to @llamatarianism and @mynameisurl :sparkles: :thumbsup: :sparkles:
:cookie: 27 | @mynameisurl |http://www.freecodecamp.com/mynameisurl
:cookie: 937 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:24
no prob
Nestor Carrasquillo
@blackhat3
Jul 10 2016 01:24
@llamatarianism I'm trying to understand the functions so they can make sense but everytime I feel like I'm getting how it works I'm lost again! been trying to learn JS for the last 8 years and always stop doing it because is too confusing. But I like it! I get along with most of HTML and CSS but JS is something else :(
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:28
@blackhat3 It can be overwhelming at first trying to learn to code. Best thing to do is go step by step to make sure you don’t have any knowledge gaps. You have to get a good foundation of understanding different data types (strings, numbers, objects, functions, array, etc). And then learn your control flows (for loops, while loops, if statements, etc). It all comes together at the end but get a good book and go page by page learning. Free Code Camp is good too and does a good job of going step by step as well.
llamatarianism
@llamatarianism
Jul 10 2016 01:28
@MyNameIsURL think you mean @blackhat3 ;)
Florencia
@flopywood
Jul 10 2016 01:28
Hello, everyone! I need some help with a challenge. Can anyone help me?
I'm doing the Manipulating Complex Objects
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:29
@llamatarianism I did, sorry about that
Florencia
@flopywood
Jul 10 2016 01:29
Instructions
Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings.
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:30
@flopywood What do you have so far?
Florencia
@flopywood
Jul 10 2016 01:31
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  myMusic.// Add record here
];
ZiedChekir
@ZiedChekir
Jul 10 2016 01:31
hello guys i m really stuck here ..... :( for like 1 h challenge name profile look up do u have the code please ?
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:32
@flopywood Not a problem, do you know which array method adds a new item to an array?
ZiedChekir
@ZiedChekir
Jul 10 2016 01:32
here is my code i dont know why it s not working
for(var i = 0; i < contacts.length; i ++)
  {

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

           if(contacts[i][prop] )
             {
               return contacts[i][prop];
             }
           else
             return "No such property";
         }
       else
         {
         return "No such contact";
         }
     }
Nathaniel Nasarow
@Torgian
Jul 10 2016 01:32
hey guys
Florencia
@flopywood
Jul 10 2016 01:32
@MyNameIsURL I was going to do myMusic.artist or use bracket notation
@MyNameIsURL but now I believe that's to add new properties to objects, not arrays
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:33
you can push a new item onto an array
willcodes
@willcodes
Jul 10 2016 01:33
```js
this can be done using a for loop too yah?

function findLongestWord(str) {
  var longest = str.split(" ");
  var word = longest.sort(function(a, b){
  return b.length - a.length;
});



  return word[0].length;

}

findLongestWord("The quick brown fox jumped over the lazy dog");
Florencia
@flopywood
Jul 10 2016 01:33
@MyNameIsURL ahhh right. I forgot about those ones. I'll try and come back later on. Thanks!
CamperBot
@camperbot
Jul 10 2016 01:33
:cookie: 28 | @mynameisurl |http://www.freecodecamp.com/mynameisurl
flopywood sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
Nathaniel Nasarow
@Torgian
Jul 10 2016 01:33
got a question, I'm trying to make my search box. I have it so that when the user hits Enter on his keyboard, it performs the search, but clicking the icon doesn't do anything. I want to be able to do both.
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:34
@flopywood So you can do something like myMusic.push({//your object here});
Nestor Carrasquillo
@blackhat3
Jul 10 2016 01:34
@llamatarianism I have the JS book that I bought long time ago but if you have a better one please let me know. I started with "JavaScript for the Worls Wide Web 5th Edition" and its really old since they are already at the 9th Edition
willcodes
@willcodes
Jul 10 2016 01:34
@Torgian are u using js or jquery?
llamatarianism
@llamatarianism
Jul 10 2016 01:34
@blackhat3 check out you don't know JS on github
Nathaniel Nasarow
@Torgian
Jul 10 2016 01:35
both, but mostly jQuery.
Nestor Carrasquillo
@blackhat3
Jul 10 2016 01:35
@llamatarianism hehe seriously?
llamatarianism
@llamatarianism
Jul 10 2016 01:35
yep
that's the name of the book
it's pretty good
eloquent JS is apparently also good
Nestor Carrasquillo
@blackhat3
Jul 10 2016 01:35
@llamatarianism ok thanks I'll look for it! thanks
CamperBot
@camperbot
Jul 10 2016 01:35
blackhat3 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 938 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
willcodes
@willcodes
Jul 10 2016 01:36
@Torgian you can use .keyup for the enter button and .click for the other
Nathaniel Nasarow
@Torgian
Jul 10 2016 01:36
ah ok
ZiedChekir
@ZiedChekir
Jul 10 2016 01:36
guys i m really stuck i kind of need help in profile look up challenge
Florencia
@flopywood
Jul 10 2016 01:37
@MyNameIsURL ok I did this:
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  myMusic.push(["artist"], ["title"], ["release_year"], ["formats"]);// Add record here
];
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:37
@flopywood You are doing the push inside the array…you want to do it after the array
willcodes
@willcodes
Jul 10 2016 01:38
@flopywood you dont need all that..
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:38
@flopywood
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
];
myMusic.push(
 {
    "artist": “Bob Jones",
    "title": “Making Music",
    "release_year": ‘1999',
    "formats": [ 
      "LP" ],
    "gold": false
  }
);
willcodes
@willcodes
Jul 10 2016 01:38
@flopywood just add a comma after the {, and add your own info
Florencia
@flopywood
Jul 10 2016 01:39
@willcodes I thought I had to do it with fuctions
willcodes
@willcodes
Jul 10 2016 01:39
@flopywood no bro
Florencia
@flopywood
Jul 10 2016 01:39
@MyNameIsURL oh, so you mean I have to type everything?
willcodes
@willcodes
Jul 10 2016 01:39
@flopywood just dont forget your comma after the first album closes
@flopywood yes type everything out
@flopywood and the ]; goes at the very end
ZiedChekir
@ZiedChekir
Jul 10 2016 01:40

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i ++)
{

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

       if(contacts[i][prop] )
         {
           return contacts[i][prop];
         }
       else
         return "No such property";
     }
   else
     {
     return "No such contact";
     }
 }

// Only change code above this line
}

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

``` it sno working .... is it like that to loop through objects of arrays ?

willcodes
@willcodes
Jul 10 2016 01:40
@flopywood you dont need myMusic.push
Florencia
@flopywood
Jul 10 2016 01:40
@willcodes ahhhh I thought I had to write a weird formula like in the rest of the exercises. Of course I wasn't getting it lol thanks!
CamperBot
@camperbot
Jul 10 2016 01:40
flopywood sends brownie points to @willcodes :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @willcodes |http://www.freecodecamp.com/willcodes
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:40
@flopywood The quesion wants you to add a new album (aka object) to the myMusic array. So you say myMusic.push( myObject )
and you tell it exactly what the object looks like and the values of each property
willcodes
@willcodes
Jul 10 2016 01:40
@MyNameIsURL you dont need the push
ZiedChekir
@ZiedChekir
Jul 10 2016 01:40
guys ?
Florencia
@flopywood
Jul 10 2016 01:41
@MyNameIsURL ah ok I'll try thanks!
CamperBot
@camperbot
Jul 10 2016 01:41
flopywood sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
:warning: flopywood already gave mynameisurl points
Robert Richey
@0x0936
Jul 10 2016 01:41
for anyone interested, recently finished streaming Basic Algorithms (~35min) and can be found here: stream
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:41
@willcodes How would you add a new object to the array?
Florencia
@flopywood
Jul 10 2016 01:41
@ZiedChekir sorry, I can't help you because you are more advanced than I am
ZiedChekir
@ZiedChekir
Jul 10 2016 01:41
it s okay maybe some one else xD :D
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:42
@willcodes You could splice it in or unshift it in as well I suppose
willcodes
@willcodes
Jul 10 2016 01:43
@0x0936 that is siiiiiiiiiiiiiiiick
Robert Richey
@0x0936
Jul 10 2016 01:43
@willcodes thanks ;)
CamperBot
@camperbot
Jul 10 2016 01:43
0x0936 sends brownie points to @willcodes :sparkles: :thumbsup: :sparkles:
willcodes
@willcodes
Jul 10 2016 01:43
@MyNameIsURL you just add it in individually one sec ill post the code
CamperBot
@camperbot
Jul 10 2016 01:43
:cookie: 246 | @willcodes |http://www.freecodecamp.com/willcodes
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:44
@willcodes Or you could say myMusic[myMusic.length] = { myObject }
ZiedChekir
@ZiedChekir
Jul 10 2016 01:44
@willcodes could you help me please ? :)
Davey Morales
@davey08
Jul 10 2016 01:45
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    1:"alpha",
     2: "Adams",

     3:"bravo", 
      4:result= "Boston",

     5:"charlie", 
      6:result = "Chicago",

     7:"delta",
      8:result = "Denver",

     9:"echo",
      result : "Easy",

     11:"foxtrot", 
      "Frank",
  };

  // Only change code above this line
  return result;
}
Can someone point me in the right direction?
i know im doing this wrong
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:45
@ZiedChekir I can help you out
Jose Mendoza
@jmendozav
Jul 10 2016 01:45
@ZiedChekir my solution
// Only change code below this line
var firstNameFlag = false;
var propFlag = false;

for (var i = 0; i < contacts.length; i++) {
  if(contacts[i].firstName === firstName) {
    firstNameFlag = true;
  }

  if (contacts[i].hasOwnProperty(prop)) {
    propFlag = true;
  }
  if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];
  }
}

if (firstNameFlag === false) {
  return "No such contact";
}

if (propFlag === false) {
  return "No such property";
}
// Only change code above this line
willcodes
@willcodes
Jul 10 2016 01:45
@MyNameIsURL send me the name of that lesson I cant find
ZiedChekir
@ZiedChekir
Jul 10 2016 01:46
@jmendozav did it work for u ?
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:46
@willcodes I don’t know the name of the lesson, I was just helping someone else add an object to an array
not sure what the question was
Jose Mendoza
@jmendozav
Jul 10 2016 01:46
@ZiedChekir yep
willcodes
@willcodes
Jul 10 2016 01:46
@MyNameIsURL its already in an array, theres many ways you can add it but that particular lesson wants you to just add it manually
Joseph
@revisualize
Jul 10 2016 01:47
@jmendozav Why is your solution so long?
Florencia
@flopywood
Jul 10 2016 01:47
@MyNameIsURL @willcodes I did this and I passed the challenge
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
];
myMusic.push(
    {
      "artist": "Spice Girls",
      "title": "Spice World",
      "release_year": 1996,
      "formats": [
        "CD",
        "cassette"]

    }
    );
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:47
@willcodes Oh okay, I misunderstood the question they were asking…so you just had to type in the values
willcodes
@willcodes
Jul 10 2016 01:47
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },

 {
    "artist": “Bob Jones",
    "title": “Making Music",
    "release_year": ‘1999',
    "formats": [ 
      "LP" ],
    "gold": false
  }
];
@MyNameIsURL ya hahaha
@flopywood both work, but this way you don't need to push
ZiedChekir
@ZiedChekir
Jul 10 2016 01:48
@jmendozav thanks :smile:
CamperBot
@camperbot
Jul 10 2016 01:48
ziedchekir sends brownie points to @jmendozav :sparkles: :thumbsup: :sparkles:
:cookie: 258 | @jmendozav |http://www.freecodecamp.com/jmendozav
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:48

@ZiedChekir Your code fails in the first if statement because you say

if(contacts[i][prop] )
         {
           return contacts[i][prop];
         }
       else
         return "No such property";
     }

which contacts[i][prop] returns the value of that property, it doesnt check if that property exists

willcodes
@willcodes
Jul 10 2016 01:48
@flopywood they are trying to teach you about nesting inside the array
Robert Richey
@0x0936
Jul 10 2016 01:48
@davey08 objects consist of key: value pairs. in that challenge, the keys are 'alpha', 'bravo', etc. the values are 'Adams', 'Boston', etc. no index numbers
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:49
@ZiedChekir so you need contacts.hasOwnProperty(prop)
ZiedChekir
@ZiedChekir
Jul 10 2016 01:49
@MyNameIsURL then how to check if it does exist maybe?
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:49
that will check if the property exists
ZiedChekir
@ZiedChekir
Jul 10 2016 01:49
ah yea yea ur right
Thanks alot
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:50
@ZiedChekir So in what you wrote, the object could have the property but the value could be undefined so it would fail your if statement test…when really it does have the property but just doesn’t have a value for that property, make sense?
Davey Morales
@davey08
Jul 10 2016 01:50
@0x0936 I kinda dont get what you are saying
ZiedChekir
@ZiedChekir
Jul 10 2016 01:50
yup i get it
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:51
@flopywood So @willcodes pointed out that the lesson you were working on…you don’t have to push a new object on the array, you just have to type it out
Jose Mendoza
@jmendozav
Jul 10 2016 01:51
@ZiedChekir You're welcome
Brice Ayres
@MyNameIsURL
Jul 10 2016 01:52
@davey08 I just read through your problem…are you trying to do a switch statement?
Robert Richey
@0x0936
Jul 10 2016 01:52
@davey08 lookup is an object with the following key: value pairs
var lookup = {
  'alpha': 'Adams',
  'bravo': 'Boston',
  // etc.
};
Davey Morales
@davey08
Jul 10 2016 01:53
no i converting from one to a look up table @MyNameIsURL
oh i get you thanks! @0x0936
CamperBot
@camperbot
Jul 10 2016 01:53
davey08 sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1492 | @0x0936 |http://www.freecodecamp.com/0x0936
Milo Hartsoe
@MiloATH
Jul 10 2016 01:56
Hi, I am having problems with jquery timing. my project is http://codepen.io/Miloath/pen/bZooKk?editors=1111
the quote loads before sliding up
all the way
Davey Morales
@davey08
Jul 10 2016 01:57
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    "alpha": "Adams",

     "bravo": "Boston",

     "charlie":"Chicago",

     "delta": "Denver",

     "eccho" : "Easy",

     "foxtrot":"Frank"
  };

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

// Change this value to test
phoneticLookup("charlie");
I did this and I didnt get it right is there soemthing else I have to do? @0x0936
Milo Hartsoe
@MiloATH
Jul 10 2016 01:58
is echo eccho
bsandusky
@bsandusky
Jul 10 2016 01:58
@davey08 eccho is echo typo
Davey Morales
@davey08
Jul 10 2016 02:00
i fixed it and still didnt pass it
Milo Hartsoe
@MiloATH
Jul 10 2016 02:00
you are returning the result
which is empty
return lookup[val];
Brice Ayres
@MyNameIsURL
Jul 10 2016 02:01
@davey08 You declared 2 variables…result and lookup…but you don’t actually doing anything in the funtion…then just return the empty string
Milo Hartsoe
@MiloATH
Jul 10 2016 02:01
result = lookup[val];
Brice Ayres
@MyNameIsURL
Jul 10 2016 02:01
@MiloATH has it
Milo Hartsoe
@MiloATH
Jul 10 2016 02:02
Can someone look at my random gen prj.
http://codepen.io/Miloath/pen/bZooKk?editors=1111
the quote updates before the animation
likely to do with:
      $( "#quote" ).slideUp( 400 ).slideDown( 400 );
      $( "#author" ).slideUp( 400 ).slideDown( 400 );
      $('#quote').text(" " + res.quote);
      $('#author').text("-" + res.author);
Robert Richey
@0x0936
Jul 10 2016 02:04

@MiloATH I made this change, seems to look good

$( "#quote" ).slideUp( 400, function() {
  $('#quote').text(" " + res.quote);
  $('#author').text("-" + res.author);
}).slideDown( 400 );

don't need the CSS that was previously here

Milo Hartsoe
@MiloATH
Jul 10 2016 02:05
thanks @0x0936
CamperBot
@camperbot
Jul 10 2016 02:05
miloath sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1493 | @0x0936 |http://www.freecodecamp.com/0x0936
Davey Morales
@davey08
Jul 10 2016 02:08

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

  // Only change code below this line

    "alpha":"Adams",

     "bravo": "Boston",

     "charlie":"Chicago",

     "delta": "Denver",

     "echo" : "Easy",

     "foxtrot":"Frank"
     return lookup[val]
  };


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

// Change this value to test
phoneticLookup("charlie");
Im pretty sure im still doing this wrong?
Diego Mayer
@Chrono79
Jul 10 2016 02:09
This message was deleted
Milo Hartsoe
@MiloATH
Jul 10 2016 02:10
@davey08 you had it correct but you just remove lookup
Davey Morales
@davey08
Jul 10 2016 02:10
dont need one @Chrono79
Diego Mayer
@Chrono79
Jul 10 2016 02:11
@davey08 you have to use objects don't you? Then forget my previous comment
Milo Hartsoe
@MiloATH
Jul 10 2016 02:11
lookup = {
    "alpha":"Adams",

     "bravo": "Boston",

     "charlie":"Chicago",

     "delta": "Denver",

     "echo" : "Easy",

     "foxtrot":"Frank"
  };

     result = lookup[val];
Suzanne Atkinson
@AdventureBear
Jul 10 2016 02:13
Dangit! I thought I had exact change finished...forgot to check to see if the cash drawer had enough bills to give the change. Almost...
Davey Morales
@davey08
Jul 10 2016 02:16
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  lookup = {
    "alpha":"Adams",

     "bravo": "Boston",

     "charlie":"Chicago",

     "delta": "Denver",

     "echo" : "Easy",

     "foxtrot":"Frank"
  };
  return =[val];

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

// Change this value to test
phoneticLookup("charlie");
wth Im still doing something wrong? @MiloATH
Suzanne Atkinson
@AdventureBear
Jul 10 2016 02:17
hey is this test case incorrect?
checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return "Insufficient Funds".
Milo Hartsoe
@MiloATH
Jul 10 2016 02:17
result = lookup[val] instead of return =[val]
no it is correct @AdventureBear
you can't make 50 cents change
Davey Morales
@davey08
Jul 10 2016 02:18
got it man thanks so much! @MiloATH
CamperBot
@camperbot
Jul 10 2016 02:18
davey08 sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @miloath |http://www.freecodecamp.com/miloath
Joseph
@revisualize
Jul 10 2016 02:22
log
CamperBot
@camperbot
Jul 10 2016 02:22
Archives for HelpJavaScript
Brian
@BrianCodes33
Jul 10 2016 02:22
someone mind helping me with chunky monkey algorithm?
Robert Richey
@0x0936
Jul 10 2016 02:24
@BrianCodes33 show us your code, and do you have a specific question?
Brian
@BrianCodes33
Jul 10 2016 02:25
no i just need some hand holding
Nathan Fowler
@nrfowler
Jul 10 2016 02:26
I have a question about the symmetric difference challenge
It has to do with the "args" parameter
What exactly does the args parameter consist of?
Milo Hartsoe
@MiloATH
Jul 10 2016 02:26
look into using arguments
There's already an args parameter, and I'm assuming we're supposed to parse from that
Suzanne Atkinson
@AdventureBear
Jul 10 2016 02:28
@MiloATH thanks, i had to go search the github issues and see that it is correct.
CamperBot
@camperbot
Jul 10 2016 02:28
adventurebear sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @miloath |http://www.freecodecamp.com/miloath
Milo Hartsoe
@MiloATH
Jul 10 2016 02:28
@nrfowler we don't know how many args we get
could be two arrays, or three arrays
arguments is an object of the args
Suzanne Atkinson
@AdventureBear
Jul 10 2016 02:29
although the error returned could be worded better. "Insufficient Funds" for a bank overdraft doesn't take into account what type of bills the bank has sitting in their vault. "Cannot make change right now" would be a better message to return.
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:29
hi
can anyone tell my why my solution for seek and destroy is not working
me*
Robert Richey
@0x0936
Jul 10 2016 02:30
@BrianCodes33 some pseudo code might help
// define new empty array
// iterate through array with an increment of size
//   push to new array, a slice of array of length size
// return new array
Nathan Fowler
@nrfowler
Jul 10 2016 02:31
The problem is this: function sym(args)
So I am wondering what args is.
@AbsoluteZero273 what is your code
@nrfowler args is an object
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:32
function destroyer(arr) {
  // Remove all the values
  return arr.filter(function(val) {
    for (var i = 1; i < arguments.length; i++) {
      if (val === arguments[i]) {
        return false;
      }
    }
    return true;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Nathan Fowler
@nrfowler
Jul 10 2016 02:32
@MiloATH So it's an arguments object?
Milo Hartsoe
@MiloATH
Jul 10 2016 02:33
it is a javascritp object. use arguments[i] to access the ith argument @nrfowler
Ash
@Ash717
Jul 10 2016 02:33
function destroyer(arr) {
  // Remove all the values
  var myArguments = [];
  for (var i = 1; i < arguments.length ; i++){
   myArguments.push(arguments[i]);  
  }
  return arr.filter(function(remove){
    return myArguments.indexOf(remove) < 0;
  });


}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Milo Hartsoe
@MiloATH
Jul 10 2016 02:34
@AbsoluteZero273 try with ==
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:34
ok
@MiloATH doesn not work
@Ash717 I understand your code. But I want to understand why my code is not working. Can you help me?
Ash
@Ash717
Jul 10 2016 02:35
@AbsoluteZero273 i'm trying to understand your code.
pizzapgh
@pizzapgh
Jul 10 2016 02:36
the word blanks challenge, anyone know how to print it out with document.write?
Ash
@Ash717
Jul 10 2016 02:37
@AbsoluteZero273 how are you removing the values?
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:38
by checking val = arguments[i] and returning false if it matches so the filter removes it
val == arguments[i]
Nathan Fowler
@nrfowler
Jul 10 2016 02:38
@MiloATH Okay thanks that solves it.
CamperBot
@camperbot
Jul 10 2016 02:38
nrfowler sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 288 | @miloath |http://www.freecodecamp.com/miloath
Junsuk Park
@park53kr
Jul 10 2016 02:39
Hi guys. I am stuck in "Escape Sequences in Strings"
my code is
var myStr=" \t \t \r \n";
Robert Richey
@0x0936
Jul 10 2016 02:39
@AbsoluteZero273 the arguments object holds the values of the most recent function, in this case, your callback function. also, val in your call back will be a single digit. you don't want to loop over a single digit misread
Ash
@Ash717
Jul 10 2016 02:39
don't you have to create a new array?
Junsuk Park
@park53kr
Jul 10 2016 02:39
I don't know why this code is not working..
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:42
@park53kr you should get the output :
\SecondLine\
ThirdLine
FirstLine
\SecondLine\
ThirdLine
Junsuk Park
@park53kr
Jul 10 2016 02:43
I try this code.. but not working.
var myStr="FirstLine\n\SecondLine\\n";
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:43
use \r too
to escape backslash you have to use \\
Brice Ayres
@MyNameIsURL
Jul 10 2016 02:45
@park53kr var myStr = "FirstLine\n\\SecondLine\\\rThirdLine"; // Change this line
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:45
@0x0936 you mean arguments take value of callbacl function not the arguments of destroyer?
Brice Ayres
@MyNameIsURL
Jul 10 2016 02:45
I think there is a bug if you have the new line and carriage return in different places
Robert Richey
@0x0936
Jul 10 2016 02:45
@AbsoluteZero273 yes :+1:
Junsuk Park
@park53kr
Jul 10 2016 02:46
@AbsoluteZero273 Thank you so much
CamperBot
@camperbot
Jul 10 2016 02:46
park53kr sends brownie points to @absolutezero273 :sparkles: :thumbsup: :sparkles:
:cookie: 131 | @absolutezero273 |http://www.freecodecamp.com/absolutezero273
Junsuk Park
@park53kr
Jul 10 2016 02:46
@MyNameIsURL Thank you :)
CamperBot
@camperbot
Jul 10 2016 02:46
park53kr sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
:cookie: 29 | @mynameisurl |http://www.freecodecamp.com/mynameisurl
Robert Richey
@0x0936
Jul 10 2016 02:46
@AbsoluteZero273 need to get your args before calling .filter()
Adam Rolfson
@DarthChowder
Jul 10 2016 02:46
Hey guys, I am trying to get the scroll to activate the “active” class as a user scrolls down the page. Can’t seem to get the code to work and I searched around for some examples of this. Can anyone take a look? http://codepen.io/DarthChowder/pen/GqmvKr/
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:46
@0x0936 Got it. Thansk!
@0x0936 BTW, what was the misread thing? I don't get it
Brice Ayres
@MyNameIsURL
Jul 10 2016 02:46
@park53kr No problem
Robert Richey
@0x0936
Jul 10 2016 02:46
@AbsoluteZero273 you weren't iterating over a single digit val, you were iterating over the arguments object
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:47
@0x0936 ahh okay :D
Milo Hartsoe
@MiloATH
Jul 10 2016 02:48
@AbsoluteZero273 there are 2 arguments. arguments from filter and arguments from the question
oh @0x0936 beat me to it
he is correct @0x0936
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:49
@MiloATH ya I get it :D Thanks
CamperBot
@camperbot
Jul 10 2016 02:49
absolutezero273 sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @miloath |http://www.freecodecamp.com/miloath
Jose Mendoza
@jmendozav
Jul 10 2016 02:50
@DarthChowder You can read about Scrollspy in bootstrap website.
Pratik Chaudhary
@abs-zero
Jul 10 2016 02:50
Thannks is a brownie point? O.o
Wesley Lewis
@Phatmanw
Jul 10 2016 02:50
hi all! having trouble with Manipulating Complex Object with javaScript and could use some help :)
Adam Rolfson
@DarthChowder
Jul 10 2016 02:50
@jmendozav Thanks, I will check that out. Didn’t realize boostrap had something about that.
CamperBot
@camperbot
Jul 10 2016 02:50
darthchowder sends brownie points to @jmendozav :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @jmendozav |http://www.freecodecamp.com/jmendozav
Davey Morales
@davey08
Jul 10 2016 02:51
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
if(myObj.hasOwnProperty(checkProp)){
  return myObj(checkProp);}
  else {
    return"Not Found";
  }
}
  // Your Code Here


}

// Test your code by modifying these values
checkObj("gift");
can anyone tell me why i am getting this wrong?
Akshay Vasant Nayak
@akshaynayak
Jul 10 2016 02:51
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(val){
return (val!==false && val!==null && val!==0 && val!=="" && val!==undefined && !isNaN(val));
});
}
pizzapgh
@pizzapgh
Jul 10 2016 02:52
how do I print out my results?
function sonics(player1, player2) {
var squad = ""
squad = player1 + " passed the ball to" + player2 + " for a slam dunk!";
return squad;
}
sonics("payton","kemp");
document.write(sonics);
Ash
@Ash717
Jul 10 2016 02:52
console.log
DJ
@qualitymanifest
Jul 10 2016 02:53
@davey08 return myObj(checkProp) you're using parenthesis here when you should be using square brackets
Akshay Vasant Nayak
@akshaynayak
Jul 10 2016 02:54
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr.filter(function(val){
    return (val!==false && val!==null && val!==0 && val!=="" && val!==undefined && !isNaN(val));
  });
}
The above code also removes strings. What am I doing wrong?
Jose Mendoza
@jmendozav
Jul 10 2016 02:54
@DarthChowder You can find it in Javascript tab.
Aaron Hanna
@AaronHanna
Jul 10 2016 02:55
var Person = function(firstAndLast) {

  var nameArray = firstAndLast.split(" ");
  var firstName = nameArray[0];
  var lastName = nameArray[1];

  return {

      "getFirstName": function() {

                         return firstName;
                      },
      "getLastName": function() {

                         return lastName;
                     },
      "getFullName": function() {

                         return firstName + " " + lastName;
                     },
      "setFirstName": function(first) {

                          firstName = first;
                      },
      "setLastName": function(last) {

                         lastName = last;
                     },
      "setFullName": function(firstAndLast) {

                         var array = firstAndLast.split(" ");

                         firstName = array[0];
                         lastName = array[1];
                     }
  };  
};

var bob = new Person('Bob Ross');
bob.getFullName();
All the tests pass except that > bob instanceof Person ....returns false. I've been reading the object documentation and don't understand why this does not return true. Does anyone here know what I'm doing wrong?
Davey Morales
@davey08
Jul 10 2016 02:56
@qualitymanifest i fixed it now it says illegal return statement?
DJ
@qualitymanifest
Jul 10 2016 02:56
` @davey08 what is the name of this challenge
Joseph
@revisualize
Jul 10 2016 02:56
@davey08 You're not using brackets to get your object.
@davey08 You have myObj(checkProp)it should be myObj[checkProp]
Davey Morales
@davey08
Jul 10 2016 02:57
@qualitymanifest Testing Objects for Properties
Joseph
@revisualize
Jul 10 2016 02:58
@davey08 ??? Did that work?
DJ
@qualitymanifest
Jul 10 2016 02:59
@revisualize i already had him change that bit
Joseph
@revisualize
Jul 10 2016 02:59
@davey08 Also, Where is your function?
Davey Morales
@davey08
Jul 10 2016 02:59
@revisualize i got it i deleted the function by accident
DJ
@qualitymanifest
Jul 10 2016 02:59
yeah i just saw that
Joseph
@revisualize
Jul 10 2016 03:00
Kind of difficult to call a function if you delete the function to be called.
Adam Rolfson
@DarthChowder
Jul 10 2016 03:00
@jmendozav Thanks, didn’t realize it was there. checking it out now.
CamperBot
@camperbot
Jul 10 2016 03:00
darthchowder sends brownie points to @jmendozav :sparkles: :thumbsup: :sparkles:
:warning: darthchowder already gave jmendozav points
Davey Morales
@davey08
Jul 10 2016 03:00
yea i didnt realized i deleted that as well thanks tho
DJ
@qualitymanifest
Jul 10 2016 03:01
@akshaynayak it's here: !isNaN(val) strings are NaN so you are removing them
@akshaynayak there is an easier way to go about this than trying to filter out every type of falsy value... only return the truthy values, instead
Akshay Vasant Nayak
@akshaynayak
Jul 10 2016 03:02
@qualitymanifest any suggestions on handling it?
oh ok
Zina Astafyeva
@tragetraje
Jul 10 2016 03:12
Hi guys! I've just solved profile lookup but don't understand why "No such contact" statement should be outside the for-loop... like so:
function lookUpProfile(firstName, prop){ for (var i = 0; i < contacts.length; i++) { if (contacts[i].firstName === firstName) { if (contacts[i].hasOwnProperty(prop)) { return contacts[i][prop]; } return "No such property"; } } return "No such contact"; }
This message was deleted
function lookUpProfile(firstName, prop){
    for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].firstName === firstName) {
            if (contacts[i].hasOwnProperty(prop)) {
                return contacts[i][prop];
            } 
            return "No such property";
        }
    }
    return "No such contact";
}
Can anybody explain me why "No such contact" should be outside the for-loop?
DJ
@qualitymanifest
Jul 10 2016 03:16
@tragetraje because you only want to return that AFTER you've looped through the whole thing. if you've made it that far (and not returned contacts[i][prop] or "No such property"), then that means the contact doesnt exist
Isis Tejeda
@latinadeveloper
Jul 10 2016 03:18
@tragetraje If the record with the matching firstName is found the code will return within the for loop. If none of the records match the for loop will end and the last statement will run.
Andrew
@westhofa
Jul 10 2016 03:21
var myStr = "Firstline\rFirstLine\n\SecondLine\ThirdLine";
Zina Astafyeva
@tragetraje
Jul 10 2016 03:21
Aha, im kinda closer to understanding but it'll take me some time to digest. Thank you @qualitymanifest @isisharris :+1:
CamperBot
@camperbot
Jul 10 2016 03:21
tragetraje sends brownie points to @qualitymanifest and @isisharris :sparkles: :thumbsup: :sparkles:
:star2: 1263 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
:cookie: 226 | @isisharris |http://www.freecodecamp.com/isisharris
Andrew
@westhofa
Jul 10 2016 03:22
how do I get ThirdLine to print on the next line
I can \n but bootcamp doesn't liek that
myStr should have encoded text with the proper escape sequences and no spacing. is the piece I am missing
Norvin Burrus
@ndburrus
Jul 10 2016 03:25
@westhofa why are there 2 FirstLine's ?
carefully map the sentence, and include the escape coding...
Andrew
@westhofa
Jul 10 2016 03:25
the task wants an /r escape
Norvin Burrus
@ndburrus
Jul 10 2016 03:27
@westhofa aahh... i think you're trying to map this: FirstLine \SecondLine\ ThirdLine which is incorrect. move down to the correct sentence. :) this one: FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
DJ
@qualitymanifest
Jul 10 2016 03:27
@westhofa well windows uses \r\n for newlines, whereas unix systems just use \n
Andrew
@westhofa
Jul 10 2016 03:29
@ndburrus I'm not sure I know what yo mean
goyalruchi90
@goyalruchi90
Jul 10 2016 03:29
Can anyone help me optimizing this code

function mutation(arr) {
  arr1=arr[0].split("");
  arr2=arr[1].split("");
  flag=false;
  for(var i=0;i<arr2.length;i++){
    for(var j=0;j<arr1.length;j++){
        if(arr2[i].toLowerCase()==arr1[j].toLowerCase()){
          flag=true;
          break;
        }
      else{
        flag=false;
      }
    }
    if(flag===false)
    {
      break;
    }
  }
  return flag;
}

mutation(["hello", "hey"]);
question :Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
Norvin Burrus
@ndburrus
Jul 10 2016 03:30
@westhofa see comment/s: :point_up: July 9, 2016 11:27 PM
DJ
@qualitymanifest
Jul 10 2016 03:32
@goyalruchi90 lowercase the strings at the beginning so you aren't running toLowerCase() twice per character. also, are you familiar with indexOf? you can shorten it a lot if you use that
goyalruchi90
@goyalruchi90
Jul 10 2016 03:33
kk..got it :+1:
hnry
@hnry
Jul 10 2016 03:33
@goyalruchi90 also set declare the variables with var for arr1 arr2
and flag
Joseph
@revisualize
Jul 10 2016 03:35
@goyalruchi90 Sure.
Luke
@lukede
Jul 10 2016 03:36
what does it mean when you write: var result = ""?
Why do you set a variable to two quotes?
Andrew
@westhofa
Jul 10 2016 03:36
@ndburrus ahh you're right. Do you know why this is wrong? var myStr = "Firstline\n\SecondLine\\rThirdLine";
Luke
@lukede
Jul 10 2016 03:36
as in ""
hnry
@hnry
Jul 10 2016 03:36
also personally i would prefer filter over indexOf @goyalruchi90
@lukede you set result to be an empty string
Joseph
@revisualize
Jul 10 2016 03:36
@lukede You're initializing the variable result with the value of "" ... Which is an empty string.
DJ
@qualitymanifest
Jul 10 2016 03:37
@hnry how would you do this with filter?
Luke
@lukede
Jul 10 2016 03:37
OK. Why do you need an empty string?
Norvin Burrus
@ndburrus
Jul 10 2016 03:37
@westhofa yes. because it is the wrong sentence. :point_up: July 9, 2016 11:27 PM :sparkles:
goyalruchi90
@goyalruchi90
Jul 10 2016 03:37
@hnry : why filter over indexOf?
Joseph
@revisualize
Jul 10 2016 03:37
@lukede You don't.
hnry
@hnry
Jul 10 2016 03:38
@goyalruchi90 mostly just preference
Luke
@lukede
Jul 10 2016 03:38
I don't get this wordBlanks challenge
Joseph
@revisualize
Jul 10 2016 03:38
@lukede Depends on what you're doing.
Luke
@lukede
Jul 10 2016 03:38

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

result = wordBlanks();
// Your code above this line
return result;
}

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

DJ
@qualitymanifest
Jul 10 2016 03:38
@hnry ok, but how? i don't see a good use for filter here
Luke
@lukede
Jul 10 2016 03:38
I don't really understand what a funtion is
Norvin Burrus
@ndburrus
Jul 10 2016 03:39
@lukede
the exercise is asking for a sentence to be built using the 4 word types given. it may be easiest to begin by making a complete (spacing & punctuation) sentence, using the 4 words. to make sense, the complete sentence will require a few "filler" words. once you have the sentence you'd like to build, then we can move on to constructing it! :sparkles:
Joseph
@revisualize
Jul 10 2016 03:39
@ndburrus You need to back up a little bit there buddy.
about @lukede
CamperBot
@camperbot
Jul 10 2016 03:39
:cookie: 166 | @lukede |http://www.freecodecamp.com/lukede
Joseph
@revisualize
Jul 10 2016 03:40
@lukede a function is a set of instructions.
Luke
@lukede
Jul 10 2016 03:40
@revisualize OK
Norvin Burrus
@ndburrus
Jul 10 2016 03:41
@westhofa how are we doing?
Andrew
@westhofa
Jul 10 2016 03:42
@ndburrus I am mapping the correct sentence now but still have the same error
Joseph
@revisualize
Jul 10 2016 03:42
@lukede Functions take a series of parameters called arguments.
liao chia hao
@nick0916
Jul 10 2016 03:42

Can anyone help??
ˋˋˋ
function getIndexToIns(arr, num) {
arr.push(num);
arr.sort(function(a, b){
return a > b;
});
for(var i in arr){
if(arr[i] == num) return Number(i);
}
}

getIndexToIns([10, 20, 30, 40, 50], 35);
ˋˋˋ

the question is :
Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.
The returned value should be a number.

why the return answer is 5 not 3 ?

Norvin Burrus
@ndburrus
Jul 10 2016 03:42
@westhofa can you post?
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:43
@lukede functions help you break up your code, otherwise you would have one giant page of code which would have to execute in order, you can use them to break up your code and make it more reuseable
Joseph
@revisualize
Jul 10 2016 03:43
@lukede Example:
function num (number) {
   return number;
}

num(5); // returns 5;
Andrew
@westhofa
Jul 10 2016 03:43
myStr should have encoded text with the proper escape sequences and no spacing.
Luke
@lukede
Jul 10 2016 03:43
@revisualize so why do you put number in the parenthesis?
Norvin Burrus
@ndburrus
Jul 10 2016 03:44
@westhofa can you post your code so far?
Joseph
@revisualize
Jul 10 2016 03:44
@lukede That is a parameter.
Luke
@lukede
Jul 10 2016 03:44
and then after the variable return?
hnry
@hnry
Jul 10 2016 03:44
@qualitymanifest whats the challenge name called?
Joseph
@revisualize
Jul 10 2016 03:44
@lukede You know how to create a variable?
Luke
@lukede
Jul 10 2016 03:44
@revisualize I guess I might not understand parameters
Andrew
@westhofa
Jul 10 2016 03:44
@ndburrus var myStr = "Firstline\n\SecondLine\\rThirdLine";
Joseph
@revisualize
Jul 10 2016 03:45
@lukede parameters are variables that are passed into a function.
Luke
@lukede
Jul 10 2016 03:45
yes. for example var return
DJ
@qualitymanifest
Jul 10 2016 03:45
@hnry Mutations. we were talking about this :point_up: July 9, 2016 8:29 PM i don't see how/why you would use filter there
Norvin Burrus
@ndburrus
Jul 10 2016 03:45
@westhofa it may be helpful to review the lesson requirements.
Luke
@lukede
Jul 10 2016 03:45
do you need to define parameters somewhere?
Joseph
@revisualize
Jul 10 2016 03:45
well. return is a keyword. so, it can't be used as a variable name.
@lukede yes. but, no.
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:45
@lukede
var guy1 = "Phil";
var guy2 = "Tom";
var guy3 = "Jerry";

function sayHello(name){
    console.log("Hello " + name);
}

sayHello(guy1);
sayHello(guy2);
sayHello(guy3);
that is a simple example…the function helps me out so I don’t have to repeat the typing of the console.log statement a bunch of times
hnry
@hnry
Jul 10 2016 03:46
@qualitymanifest ok so heres how it would look with filter
function mutation(arr) {
  return arr[1].toLowerCase().split("").filter(function(chr) {
    return arr[0].toLowerCase().split("").filter(function(chr2) {
      return chr === chr2
    }).length === 0
  }).length === 0
}
Olly Sholotan
@Ollysho
Jul 10 2016 03:46
Hey, would anyone be willing to help with the Profile Lookup?
Luke
@lukede
Jul 10 2016 03:46
what do you call the part for sayHello()
?
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:47
now this is a really short example, but imagine I was doing a bunch of things inside that sayHello function…then I would be saving a ton of time by not having to repeat myself everytime I wanted to run that set of instructions
Davey Morales
@davey08
Jul 10 2016 03:47
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line
myStorage.car["glove box"]; // Change this line
can someone help ive tried everything?
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:47
@lukede are you talking about at the bottom where I say sayHello(guy1);?
Luke
@lukede
Jul 10 2016 03:48
@MyNameIsURL yes, the bottom
you have your function up top, then you have this part at the bottom
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:48
when I say sayHello(guy1); that is called invoking the function
DJ
@qualitymanifest
Jul 10 2016 03:48
@hnry interesting. while i would still much rather use indexOf and forego filter, its always neat to see it done a different way
Luke
@lukede
Jul 10 2016 03:48
I don't remember learning that yet
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:48
that when you actually call it and tell it to run, and you specify what the actual parameter is
Andrew
@westhofa
Jul 10 2016 03:48
how do I copy/paste the actual black box?
Olly Sholotan
@Ollysho
Jul 10 2016 03:48
function lookUpProfile(firstName, prop) {
// Only change code below this line
  for (var i = 0; 1 < contacts.length; i++) {
    if (firstName === contacts[i].firstName) {
      console.log("yes");
    }
  }
}
Is my code but it says it cannot read property of undefined
DJ
@qualitymanifest
Jul 10 2016 03:49
@hnry so have a brownie for producing an example. thanks
CamperBot
@camperbot
Jul 10 2016 03:49
qualitymanifest sends brownie points to @hnry :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @hnry |http://www.freecodecamp.com/hnry
Olly Sholotan
@Ollysho
Jul 10 2016 03:49
isn't contacts already defined as a variable earlier?
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:50
@lukede So you define your function by saying function sayHello(name){…
Luke
@lukede
Jul 10 2016 03:50
@MyNameIsURL OK, thank you. So you have your function inside the curly brackets and then at the bottom you call it to run
CamperBot
@camperbot
Jul 10 2016 03:50
lukede sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
:cookie: 30 | @mynameisurl |http://www.freecodecamp.com/mynameisurl
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:50
@lukede but that function just exists now…it won’t actually run because you haven’t told it to run yet
@lukede exactly
Luke
@lukede
Jul 10 2016 03:51
This is starting to make sense!
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:51
its like writing down a set of instructions….but not actually doing what the instructions say just yet…until someone says to start
Luke
@lukede
Jul 10 2016 03:53
I see
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:56
@lukede An example would be, I tell you how to open a door (grab the door knob, turn to the right, then pull the door towards you). That is definining the function / instructions. Then I say close the front door. I gave you the instructions earlier….but now I have invoked the function (aka told you) to actually go do it.
Chance103
@Chance103
Jul 10 2016 03:56
This message was deleted
Luke
@lukede
Jul 10 2016 03:57
Would the closing and opening the front door be two different functions in this analogy?
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:57
Yes
Luke
@lukede
Jul 10 2016 03:58
Why do we need parameters?
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:58
But I can reuse the openDoor function multiple times
Luke
@lukede
Jul 10 2016 03:58
right
Brice Ayres
@MyNameIsURL
Jul 10 2016 03:58
We don’t always need parameters
but it is handy in this case
so I give you general instructions on how to open a door…but I have written my instructions so that they work for any door….but how do you know specifically which door to open when I invoke that function?
well…you can have parameters like function openDoor(theDoorToOpen){…}
Luke
@lukede
Jul 10 2016 03:59
ah
so a parameter could be frontDoor or backDoor
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:00
so now when we invoke the function I can say openDoor(theFrontDoor); where theFrontDoor is a variable I have already defined
Luke
@lukede
Jul 10 2016 04:00
and you define the parameters when you call the function
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:00
yup, so you have to tell the function what each of those items will be
so maybe we have doors in the house which turn different directions….so maybe we need a second parameter to tell us which way to turn the door knob
so it might be function openDoor( theDoorToOpen, directionToTurnKnob){…}
then we could invoke it with openDoor(“frontDoor”, “left”);
and the logic inside of the function would be written in such a way that it would handle each door differently based on the parameters (sometimes called arguments) passed into the function
Luke
@lukede
Jul 10 2016 04:04
@MyNameIsURL I don't get where frontDoor and theDoorToOpen link up
is frontDoor a string because it's in quotes?
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:05
yes, in this example it is a string
but it could be something else
Luke
@lukede
Jul 10 2016 04:05
so, the strings get called in the order they are called in the function?
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:05
exactly
Luke
@lukede
Jul 10 2016 04:06
and you always match the number?
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:06
so the first parameter, matches up to the first thing passed to the openDoor function
Luke
@lukede
Jul 10 2016 04:06
I see
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:07
so theDoorToOpen variable is first, so when I call the function…whatever is the first parameter passed will be represented in the function by theDoorToOpen variable
Khaleel Syed
@khaleelsyed
Jul 10 2016 04:07
Hi guys, I was wondering why the challenge "Get Geo-location" works when you run it in the Bonfire console but the exact replica of the code fails to work in my local machine or even on CodePen.
http://codepen.io/khaleelsyed/pen/VjrAdR/
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:07
so the first line of our function might be
if(theDoorToOpen === “frontDoor”){
   // do some special front door logic
}
Luke
@lukede
Jul 10 2016 04:08
In the this example, did we need to define the variables in the function (i.e. var theDoorToOpen) ?
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:08
you do not need to say var before it, it knows it is a variable because it is in the function definition
Luke
@lukede
Jul 10 2016 04:09
huh, that's good to know
why did you put 3 ='s in your example?
some syntax I don't know yet
I'm guessing
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:10
= is for assignment, == is for comparison, === is also for comparison
== says are they the same
=== says are the the same and the same type (ie string, number, etc)
Olly Sholotan
@Ollysho
Jul 10 2016 04:10
I keep getting the error code that it can't read the property of an undefined when my code is
```
function lookUpProfile(firstName, prop) {
// Only change code below this line
  for (var i = 0; 1 < contacts.length; i++) {
    if (firstName === contacts[i].firstName) {
      console.log("yes");
    }
  }
}
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:11
@lukede console.log("5"==5); that will come out as true
Olly Sholotan
@Ollysho
Jul 10 2016 04:11
contacts is already defined earlier in the javascript though
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:12
@Ollysho can you paste the full code ? I don’t see where contacts is defined
@lukede console.log(“5” === 5); is false because they are of different types
Olly Sholotan
@Ollysho
Jul 10 2016 04:13
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop) {
// Only change code below this line
  for (var i = 0; 1 < contacts.length; i++) {
    if (firstName === contacts.firstName) {
      console.log("yes");
    }
  }
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Luke
@lukede
Jul 10 2016 04:13
@MyNameIsURL Well, thank you very much. I learned a lot
CamperBot
@camperbot
Jul 10 2016 04:13
lukede sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
:warning: lukede already gave mynameisurl points
Khaleel Syed
@khaleelsyed
Jul 10 2016 04:14
Hi guys, I know I'm asking this again, but I'd really love some help please. I was wondering why the challenge "Get Geo-location" works when you run it in the Bonfire console but the exact replica of the code fails to work in my local machine or even on CodePen.
http://codepen.io/khaleelsyed/pen/VjrAdR/
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:14
@Ollysho contacts is an array
@Ollysho when you say if (firstName === contacts.firstName) { contacts.firstName doesn’t exist
since contacts is an array, you have to specify the array index
Olly Sholotan
@Ollysho
Jul 10 2016 04:15
yeah sorry that is supposed to real contacts[i].firstName I was messing around with something
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:15
@Ollysho yup, you got it!
Olly Sholotan
@Ollysho
Jul 10 2016 04:16
so even with I still get an error code of not being able to read a property of an undefined
Really I'm just trying to test it to get the console to read "yes" back to be atleast for now
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:18
@Ollysho for (var i = 0; 1 < contacts.length; i++) {
change the 1 to i
your loop was an infinite loop because 1 is always less than 4
so i would keep incrementing…so once it hit 5, the firstName property was no longer defined
esvevan
@esvevan
Jul 10 2016 04:20
I am stuck on map 192, failing the 3rd constraint, but meeting 1,2 & 3... no clue why. What is wrong here
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:20
because there are only 4 items in the array
esvevan
@esvevan
Jul 10 2016 04:20

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

return removedNextInLine; // Change this line
}

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

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

Olly Sholotan
@Ollysho
Jul 10 2016 04:20
@MyNameIsURL gotcha! it's a 1. wow that was such an oversight thank you!
CamperBot
@camperbot
Jul 10 2016 04:20
ollysho sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
:cookie: 31 | @mynameisurl |http://www.freecodecamp.com/mynameisurl
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:20
@Ollysho Thanks. How do I send brownie points to people?
CamperBot
@camperbot
Jul 10 2016 04:20
mynameisurl sends brownie points to @ollysho :sparkles: :thumbsup: :sparkles:
:cookie: 220 | @ollysho |http://www.freecodecamp.com/ollysho
Olly Sholotan
@Ollysho
Jul 10 2016 04:21
Welp. I think if you just say thanks and tag them in it it does is automatically
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:21
Guess I just sent you some haha
yea that 1 and the i look similar…that is a tought one to catch
@esvevan What is the name of the challenge?
esvevan
@esvevan
Jul 10 2016 04:23
Stand in line
Stand in Line @MyNameIsURL
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:25
@esvevan I am checking it out now. This is a good one. A question similar to this using queues landed me my first programming job
esvevan
@esvevan
Jul 10 2016 04:26
Thanks @MyNameIsURL I appreciate it
CamperBot
@camperbot
Jul 10 2016 04:26
esvevan sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
:cookie: 32 | @mynameisurl |http://www.freecodecamp.com/mynameisurl
Olly Sholotan
@Ollysho
Jul 10 2016 04:26
Basically @MyNameIsURL is god.
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:27
hahah
having a computer science degree helps too haha
esvevan
@esvevan
Jul 10 2016 04:28
There's obviously a much better way to enter my code into this chat rather than copy/paste, haven't figure out that one.
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:28
use three ticks `
Mustafijur rahman
@Dinar717
Jul 10 2016 04:28
@khaleelsyed your found any solution?
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:28
so 3 ticks, then your code and then 3 ticks
esvevan
@esvevan
Jul 10 2016 04:28

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

return removedNextInLine; // Change this line
}

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

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

CamperBot
@camperbot
Jul 10 2016 04:28
:bulb: to format code use backticks! ``` more info
Olly Sholotan
@Ollysho
Jul 10 2016 04:28
The tick is the tilde thing
It's usually right next to your 1 key. I didn't know that until like three days ago I won't lie to you
Khaleel Syed
@khaleelsyed
Jul 10 2016 04:29
@Dinar717 No, I'm still stuck
esvevan
@esvevan
Jul 10 2016 04:29
function nextInLine(arr, item) {
  testArr.push(item);
  var removedNextInLine = testArr.shift();// Your code here

  return removedNextInLine;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Ah thats way better now, it hurts my soul less
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:32
@esvevan I think there is a bug
I think they are probably looking for something specific
esvevan
@esvevan
Jul 10 2016 04:33
So this code should work @MyNameIsURL ?
Khaleel Syed
@khaleelsyed
Jul 10 2016 04:34
@Dinar717 Is it to do with my browser or something? I mean even the tutorial on W3schools is failing to work for me.
Mustafijur rahman
@Dinar717
Jul 10 2016 04:35
@khaleelsyed https://codepen.io/leemark/pen/ezhlD check this pen if your device has any problem
Suzanne Atkinson
@AdventureBear
Jul 10 2016 04:36
yahoo, I finally passed Exact Change!! thanks for your help everyone who contributed.
Khaleel Syed
@khaleelsyed
Jul 10 2016 04:36
@Dinar717 Error: [object PositionError] :(
Mustafijur rahman
@Dinar717
Jul 10 2016 04:37
@khaleelsyed I get my location using the above pen
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:37
@esvevan You have it
they just wanted it like this

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();  // Change this line
}
esvevan
@esvevan
Jul 10 2016 04:38
I just figured it out too. Thanks @MyNameIsURL , it makes sense you would call the original array into your function rather than the separate test array
CamperBot
@camperbot
Jul 10 2016 04:38
esvevan sends brownie points to @mynameisurl :sparkles: :thumbsup: :sparkles:
:warning: esvevan already gave mynameisurl points
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:38
your code would work though…its the way they are writing the code behind the scenes that scans for the right answer….it is probably just looking for those works and not actually testing the code I am guessing
Khaleel Syed
@khaleelsyed
Jul 10 2016 04:38
@Dinar717 I'm using Chromium on Arch Linux, I mean it should work. I tried running a browser test on https://html5test.com/ and my browser fully passes the the "Geolocation part" of the test.
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:40
@esvevan Your way isn’t wrong…it technically would work. However, as a best practice…you wouldn’t want to create that extra variable like you said…because it will create another location in memory in the computer to save that additional variable.
computers are blazing fast now a days so it doesn;t matter much…but techincally the computer is having to add another item to memory and then delete it once the function ends
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:46
alright, I’m out guys. Good luck!
Olly Sholotan
@Ollysho
Jul 10 2016 04:47
Oh god we're nothing without you
This is about to be painful, bye mate!
Brice Ayres
@MyNameIsURL
Jul 10 2016 04:47
@Ollysho You got this! You are on a roll.
Khaleel Syed
@khaleelsyed
Jul 10 2016 04:50
@Dinar717 I just updated my kernel and done a reboot, and EVERYTHING WORKS! No idea what the issue was, maybe everything just needed a reboot. Thanks
CamperBot
@camperbot
Jul 10 2016 04:50
khaleelsyed sends brownie points to @dinar717 :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @dinar717 |http://www.freecodecamp.com/dinar717
Sam Nave
@shrapnel2012
Jul 10 2016 04:50
Hi all. I am having an issue with with the accessing-nested objects challenge. I have the maps part done but unsure how to go about finding the dot/bracket notation. Any help would be appreciated
Mustafijur rahman
@Dinar717
Jul 10 2016 04:50
@khaleelsyed :+1:
Norvin Burrus
@ndburrus
Jul 10 2016 04:51
@shrapnel2012
can you post your code so far?
also, you may find this useful:
Sam Nave
@shrapnel2012
Jul 10 2016 04:52
var gloveBoxContents = "maps"; // Change this line

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

// Only change code below this line

var gloveBoxContents = "maps"; // Change this line

@ndburrus thanks. I will take a look at that. :)
CamperBot
@camperbot
Jul 10 2016 04:53
shrapnel2012 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 913 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 10 2016 04:54
@shrapnel2012
your'e welcome... :sparkles:
ok, take a closer look at the example code lines (2).
ourStorage.cabinet["top drawer"].folder2; // "secrets" and ourStorage.desk.drawer; // "stapler"
see how they "point" the code to the desired value/information?
in this line, you are identifying what you're looking for directly, you are not using the object! the lesson name (accessing nested objects) indicates what our approach should be, right?
basically, the object path to the information desired is like a ladder, we use word to ouline the path to the value... clear as mud?
Sam Nave
@shrapnel2012
Jul 10 2016 04:57
@ndburrus yes...so would I write something like: myStorage.car["inside"].glovebox; // "maps"
Norvin Burrus
@ndburrus
Jul 10 2016 04:58
@shrapnel2012
aaah... careful here, inside is a variable..
think of it this way - is it outside of a { ? in a similar thought pattern, glove box is inside a {
so, how would the code/line look?
and, once we have that, what would the assignment look like?
Francisco Franco
@frenktico
Jul 10 2016 05:02
Thanks @renelis @abhisekp @Rafase282 for your help with Algorithm: Falsy Bouncer
CamperBot
@camperbot
Jul 10 2016 05:02
frenktico sends brownie points to @renelis and @abhisekp and @rafase282 :sparkles: :thumbsup: :sparkles:
:cookie: 395 | @renelis |http://www.freecodecamp.com/renelis
:star2: 2686 | @abhisekp |http://www.freecodecamp.com/abhisekp
:star2: 1321 | @rafase282 |http://www.freecodecamp.com/rafase282
Sam Nave
@shrapnel2012
Jul 10 2016 05:05
@ndburrus Hmm do you mean something like the second part of the example: myStorage.car.glovebox;// "maps"
Norvin Burrus
@ndburrus
Jul 10 2016 05:06
@shrapnel2012
closer... are we missing a piece?
the code needs to know exactly (exact path) how to get to the desired value... that code makes a leap from car to glove box!
is there a step (sub-property) in between?
hint: inside, maybe?
Sam Nave
@shrapnel2012
Jul 10 2016 05:10
@ndburrus Ohhh so in my second example I used ["inside"] as part of the expression. So I need to figure out how to intragrate it knowing its a variable...
Norvin Burrus
@ndburrus
Jul 10 2016 05:12
@shrapnel2012 i think i understand... and i think you're right... so, write the code including all the steps to the desired value...
@shrapnel2012 actually, here is the guidance: Use bracket notation for properties with a space in their name.
so, after this we need to: assign the contents of the glove box property to the gloveBoxContents variable.
then you run tests :sparkles:
Indhu
@Indhusethu
Jul 10 2016 05:17

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {
var gear;
Bike.getGear();
Bike.setGear();

// Only change code below this line.

};

var myCar = new Car();
hii everyone,help me in finding out my mistakes

jltx113
@jltx113
Jul 10 2016 05:17
whast wrong with my code?
Screenshot 2016-07-09 22.15.46.png
Puvendran Pillay
@puven12
Jul 10 2016 05:17
hello guys. Had anyone tried "how-to-npm" cli workshop?
@jltx113 you can't access myVar
your console.log at line 12 doesn't work
jltx113
@jltx113
Jul 10 2016 05:20
Screenshot 2016-07-09 22.19.44.png
i try both way it didnt work
Puvendran Pillay
@puven12
Jul 10 2016 05:20
@jltx113 delete the line all together
jltx113
@jltx113
Jul 10 2016 05:21
which line>
?
tylerprosper
@removed~tylerprosper
Jul 10 2016 05:21
Hey guys, I was hoping someone might be able to answer my question regarding the
Accessing Objects Properties with Variables exercise...
this is the code:

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

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[playerNumber];   // Change this Line
Sam Nave
@shrapnel2012
Jul 10 2016 05:22
@ndburrus I am not getting this...var {gloveBoxContents = "maps"}; // Change this line
myStorage.car.glovebox; // "maps"
Puvendran Pillay
@puven12
Jul 10 2016 05:22
@jltx113 line 5 delete the console.log....
Sam Nave
@shrapnel2012
Jul 10 2016 05:22
:/
tylerprosper
@removed~tylerprosper
Jul 10 2016 05:22
Can anybody tell me what the point of accessing something inside of the object with a global variable is?
Why not just access the property directly?
Norvin Burrus
@ndburrus
Jul 10 2016 05:22
@jltx113 here: "Declare a local variable myVar inside myLocalScope." note that myLocalScope is the function name!
jltx113
@jltx113
Jul 10 2016 05:23
Screenshot 2016-07-09 22.22.45.png
tylerprosper
@removed~tylerprosper
Jul 10 2016 05:23

And also why isn't

var playerNumber = 16;

just 16? how does it access anything inside the object?

jltx113
@jltx113
Jul 10 2016 05:26
im confuse
Screenshot 2016-07-09 22.25.59.png
i try couple way and still didnt work
Norvin Burrus
@ndburrus
Jul 10 2016 05:27
@shrapnel2012 alright, let's go back to here: myStorage.car["inside"].glovebox
  1. inside can be referenced with dot notation
  2. glove box (note the space) can be referenced with bracket notation :point_up: July 10, 2016 1:12 AM
  3. this entire entity/value needs to be assigned to the var/iable gloveBoxContents
Indhu
@Indhusethu
Jul 10 2016 05:27
is there anyone to guide me??
Mustafijur rahman
@Dinar717
Jul 10 2016 05:27
@Indhusethu about what?
Indhu
@Indhusethu
Jul 10 2016 05:28
in finding out the mistakes

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {
var gear;
Bike.getGear();
Bike.setGear();

// Only change code below this line.

};

var myCar = new Car();

i'm getting an error in this
@Dinar717
Mustafijur rahman
@Dinar717
Jul 10 2016 05:30
@Indhusethu what error do u get
Sam Nave
@shrapnel2012
Jul 10 2016 05:33
@ndburrus so if inside is a dot notation then no brackets are needed but glove box should have bracks and be assigned inside. I am def. misreading this part: var gloveBoxContents = "maps"; // Change this line
myStorage.car.inside.["glovebox"]
Olly Sholotan
@Ollysho
Jul 10 2016 05:34
Hey really quick, could anyone tell me why this isn't returning anything in the console?
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop) === true) {
        return contacts[i].prop;
      }
    }
  }
// Only change code above this line
}
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:35
hi
need Help in java script algo challenge
Caesars Ciphar
Norvin Burrus
@ndburrus
Jul 10 2016 05:36
@shrapnel2012
  1. here: myStorage.car.inside.["glovebox"] - add the space in glove box
  2. here: gloveBoxContents = "maps"; - delete "maps"& add var to gloveBoxContents
  3. complete the assignment
Mustafijur rahman
@Dinar717
Jul 10 2016 05:36
I need to learn regex! can anyone help me with something?
clintonjohn
@clintonjohn
Jul 10 2016 05:36
☝🏼What does this and the time stamp mean @ndburrus
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:37
@Dinar717
Norvin Burrus
@ndburrus
Jul 10 2016 05:37
@clintonjohn not sure what you mean...
kirbyedy
@kirbyedy
Jul 10 2016 05:38
@clintonjohn its the link to a certain point in the chat, referring to some text most probably
clintonjohn
@clintonjohn
Jul 10 2016 05:38
Sorry to interrupt. I just notice sometimes that hand icon with a time stamp comes up on your answer, but then it disappears
@kirbyedy @ndburrus thanks
CamperBot
@camperbot
Jul 10 2016 05:39
clintonjohn sends brownie points to @kirbyedy and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 914 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 1207 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:40
is any one there how help me in Caesars Cipher . i almost done but i got this result FREE-CODE-CAMP instead of FREE CODE CAMP
Mustafijur rahman
@Dinar717
Jul 10 2016 05:41
@abhishekdevinfo I asked for regular expression.
clintonjohn
@clintonjohn
Jul 10 2016 05:41
@abhishekdevinfo @Dinar717 asked about Regex not redux they are vastly different things
Norvin Burrus
@ndburrus
Jul 10 2016 05:41
@clintonjohn you mean like this? :point_up: July 10, 2016 1:27 AM
it is a pointer...
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:42
@Dinar717 sorry i thought some thing differt
clintonjohn
@clintonjohn
Jul 10 2016 05:42
@ndburrus exactly
Sam Nave
@shrapnel2012
Jul 10 2016 05:42
@ndburrus delete maps? I came up with the following without maps: myStorage.car.inside.["glove box"]
var gloveBoxContents;
Norvin Burrus
@ndburrus
Jul 10 2016 05:42
@clintonjohn it points to an item (it's a link) :+1:
Mustafijur rahman
@Dinar717
Jul 10 2016 05:42
@abhishekdevinfo you can show us your code!
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:43

function rot13(str) {
  var strLen = str.length; //Str length
  var newStr = []; //for taking the decoded string
  var strNum; //for string number
  var AValue = "A".charCodeAt(0); //string number of A
  var ZValue = "Z".charCodeAt(0); //string number of B
  var calculation; //use in inner else
  for(var i = 0; i < strLen; i++) { //loop less than str length
    if(Boolean(str[i])) { 
      //check string str elements one by one wheather they are alphabetic character or not      
      strNum = str.charCodeAt(i) - 13; //get the number of string and then subtract by 13
      if(strNum >= AValue) { // check wheather the number is less than the number of A 
        newStr.push(String.fromCharCode(strNum));
        //get the character from the number and store in newStr array
      }
      else {
        //newStr value is less than AValue so subtract it by Avlue and then the result will 
        //subtract by Zvalue and than + 1 to get the desire character.
        calculation = AValue - strNum; 
        calculation = (( ZValue - calculation ) + 1 ); 
        newStr.push(String.fromCharCode(calculation));
      }
    }
    else { //push the non-alphabetic character in newStr
      newStr.push(str[i]);
    }
  }
  str = newStr.join('');
  return str;
}


rot13("SERR PBQR PNZC");
clintonjohn
@clintonjohn
Jul 10 2016 05:43
@ndburrus got it thanks for letting me know🙂
CamperBot
@camperbot
Jul 10 2016 05:43
clintonjohn sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: clintonjohn already gave ndburrus points
Norvin Burrus
@ndburrus
Jul 10 2016 05:43
@clintonjohn anytime! :palm_tree:
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:44
FREE-CODE-CAMP
clintonjohn
@clintonjohn
Jul 10 2016 05:44
@Dinar717 what's your question about regex?
Mustafijur rahman
@Dinar717
Jul 10 2016 05:44
@abhishekdevinfo you should use regex to skip whitespace
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:44
instead of this
@Dinar717 but whats wrong with my last else
Mustafijur rahman
@Dinar717
Jul 10 2016 05:45
@clintonjohn I want to learn it. I don't have any specific question.
clintonjohn
@clintonjohn
Jul 10 2016 05:45
@Dinar717 have you taken a look at MDN documentation?
kirbyedy
@kirbyedy
Jul 10 2016 05:45
Mustafijur rahman
@Dinar717
Jul 10 2016 05:46
@clintonjohn yes, but don't understand clearly.
Olly Sholotan
@Ollysho
Jul 10 2016 05:46
Hey, anyone mind helping me with Profile Lookup?
clintonjohn
@clintonjohn
Jul 10 2016 05:47
@Dinar717 Free Code Camp has a forum and a wiki, have you checked out those on the site?
there's a link to a forum discussion of your question where you can interact
Norvin Burrus
@ndburrus
Jul 10 2016 05:48
@tylerprosper
the point of accessing an object with a variable is flexibility. by using a variable (in this example - playerNumber), code input can change (ie from 16, to 99, to 76, etc.).
the code can get the input, use the variable, and access the object to retrieve information.
clear as mud? :panda_face:
Mustafijur rahman
@Dinar717
Jul 10 2016 05:50
@abhishekdevinfo Boolean(' ') would return true
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:51
@Dinar717 no it will return false in console
clintonjohn
@clintonjohn
Jul 10 2016 05:51
@Dinar717 here's a link to Regex learning resources curated by a code camp organizer in the forum section of FCC
Sam Nave
@shrapnel2012
Jul 10 2016 05:52
@ndburrus thanks for everything! Have a great night.
CamperBot
@camperbot
Jul 10 2016 05:52
shrapnel2012 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: shrapnel2012 already gave ndburrus points
Mustafijur rahman
@Dinar717
Jul 10 2016 05:52
@abhishekdevinfo I just checked that Boolean with a space would return true.
Norvin Burrus
@ndburrus
Jul 10 2016 05:52
@shrapnel2012
you're welcome :)
did you get it?
clintonjohn
@clintonjohn
Jul 10 2016 05:52
Mustafijur rahman
@Dinar717
Jul 10 2016 05:52
@clintonjohn thanks. I didn't check that.
CamperBot
@camperbot
Jul 10 2016 05:52
dinar717 sends brownie points to @clintonjohn :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @clintonjohn |http://www.freecodecamp.com/clintonjohn
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:52
Screenshot from 2016-07-10 11-21-49.png
Sam Nave
@shrapnel2012
Jul 10 2016 05:53
@ndburrus No...I was just going to sleep on it for now and try it again in the morning haha
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:53
@Dinar717 see in pic in right side in console
Norvin Burrus
@ndburrus
Jul 10 2016 05:53
@shrapnel2012 no worries... let me know if you have any questions... happy to assist... :palm_tree: have a great evening!
clintonjohn
@clintonjohn
Jul 10 2016 05:55
@Dinar717 @Rafase282 is a code camp coordinator. Here's his profile on the forum. He's curated and written resources for campers
@Rafase282 thanks
CamperBot
@camperbot
Jul 10 2016 05:55
clintonjohn sends brownie points to @rafase282 :sparkles: :thumbsup: :sparkles:
:star2: 1322 | @rafase282 |http://www.freecodecamp.com/rafase282
clintonjohn
@clintonjohn
Jul 10 2016 05:56
Mustafijur rahman
@Dinar717
Jul 10 2016 05:56
@abhishekdevinfo I saw. but here I found true.
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:57
@Dinar717 where give me link please
Mustafijur rahman
@Dinar717
Jul 10 2016 05:58
@abhishekdevinfo
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 05:58

function bouncer(arr) {
  arr = arr.filter(Boolean);


  return arr;
}

bouncer([7, "ate", "", false, 9]);
@Dinar717 see this will only give u [7,"ate",9]
Mustafijur rahman
@Dinar717
Jul 10 2016 05:59
@abhishekdevinfo hey there is nothing inside . "" is empty string
and you are giving a space. got it?
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 06:00
@Dinar717 ok
clintonjohn
@clintonjohn
Jul 10 2016 06:00
@abhishekdevinfo have you done much work in redux yourself? I'm interested in learning about it, too
Mustafijur rahman
@Dinar717
Jul 10 2016 06:00
Capture.JPG
Capture.JPG
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 06:01
@Dinar717 ya i got it i pass the empty string instead of space
Mustafijur rahman
@Dinar717
Jul 10 2016 06:01
@abhishekdevinfo use this condition : if(str[i]!=' ') . I think using regex would be good
Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 06:02
@clintonjohn no i have the links if some one want to learn REDUX
@Dinar717 ok i will use regex
@Dinar717 thanks for the help
CamperBot
@camperbot
Jul 10 2016 06:03
abhishekdevinfo sends brownie points to @dinar717 :sparkles: :thumbsup: :sparkles:
:cookie: 390 | @dinar717 |http://www.freecodecamp.com/dinar717
Mustafijur rahman
@Dinar717
Jul 10 2016 06:03
@abhishekdevinfo :+1: np
clintonjohn
@clintonjohn
Jul 10 2016 06:04
@abhishekdevinfo thanks. but you aren't interested for yourself? Do you prefer another way of doing backend?
CamperBot
@camperbot
Jul 10 2016 06:04
clintonjohn sends brownie points to @abhishekdevinfo :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @abhishekdevinfo |http://www.freecodecamp.com/abhishekdevinfo
musicsmithnz
@musicsmithnz
Jul 10 2016 06:04
help reduce
CamperBot
@camperbot
Jul 10 2016 06:04

:point_right: challenge condense arrays with reduce [wiki]

Challenge Condense Arrays with Reduce

Reduce can be useful for condensing an array of numbers into one value.

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;

});

:pencil: read more about challenge condense arrays with reduce on the FCC Wiki

Taro
@TaroWong
Jul 10 2016 06:05
help record collection
CamperBot
@camperbot
Jul 10 2016 06:05

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

:pencil: read more about challenge record collection on the FCC Wiki

musicsmithnz
@musicsmithnz
Jul 10 2016 06:05
help sorted union
CamperBot
@camperbot
Jul 10 2016 06:05

:point_right: algorithm sorted union [wiki]

Algorithm Sorted Union

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and there shouldn't be any duplicates.

Relevant Links

:pencil: read more about algorithm sorted union on the FCC Wiki

Abhishek Baliyan
@abhishekdevinfo
Jul 10 2016 06:06
@clintonjohn actually i didnt complete the front end and i also not started to learn redux
and now i dont about how many ways to learn backend
if u know then please let me know
clintonjohn
@clintonjohn
Jul 10 2016 06:10
@abhishekdevinfo I aLao haven't finished front end 🙂
I also haven't finished it yet
Mustafijur rahman
@Dinar717
Jul 10 2016 06:10
about @clintonjohn
CamperBot
@camperbot
Jul 10 2016 06:10
:cookie: 281 | @clintonjohn |http://www.freecodecamp.com/clintonjohn
Taro
@TaroWong
Jul 10 2016 06:11
Does anyone need help?
Mustafijur rahman
@Dinar717
Jul 10 2016 06:11
@clintonjohn did you start advance algorithm scripting?
chaitanya ashtekar
@chaitanyaashtekar
Jul 10 2016 06:12
@abhishekdevinfo wjats redux
Akshay Vasant Nayak
@akshaynayak
Jul 10 2016 06:13

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.sort();
  for(var i=0;i<num;i++){
    if(arr[i]>=num)
        return i;
  }
  return arr.length;
}

getIndexToIns([40, 60], 50);
The above code is failing for getIndexToIns([5, 3, 20, 3], 5) should return 2.
Can someone help me out?
clintonjohn
@clintonjohn
Jul 10 2016 06:13
@Dinar717 I'm on the beginning algorithms
Mustafijur rahman
@Dinar717
Jul 10 2016 06:15