These are chat archives for FreeCodeCamp/HelpJavaScript

19th
May 2016
Abby
@s0uth
May 19 2016 00:00
Question about my code in the Chunky Monkey challenge 269, why can't I pass? I seem to get the correct output.
var resultsArray = [];

function chunkArrayInGroups(arr, size) {
  // Break it up.
    for (var i = 0; i < arr.length; i += size) {
        resultsArray.push(arr.slice(i, i + size));
    }
  return resultsArray;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Aryan
@aryandua
May 19 2016 00:02
@s0uth refresh your page
if all of your outputs are rigth
Abby
@s0uth
May 19 2016 00:02
I did. But I'll try again and close my browser and do a hard refresh
@aryandua ^^
shaylynnd
@shaylynnd
May 19 2016 00:03
@subhsamal does hasOwnProperty() search each of the properties or do i have to write another loop to do that?
Coy Sanders
@coymeetsworld
May 19 2016 00:03
@s0uth you want to move the resultsArray inside the function
the challenges dont like global variables
Aryan
@aryandua
May 19 2016 00:03
yes
move your declaration to inside the function
@coymeetsworld I just finished the twitch tv project :0
Greg Duncan
@GregatGit
May 19 2016 00:04
@WotanTGH I'm glad that worked - my advice would be to learn how to use the chomes dev tools - I'm not that good at them yet, but often it helps me find the problem quickly (even if I don't know how to fix it). Viel Spass
Aryan
@aryandua
May 19 2016 00:04
Onto intermidiate algorithmic scripting now
Dan Couper
@DanCouper
May 19 2016 00:04

@DouglasDunn look at Array.from (for turning the arguments into an array), filter and indexOf.

You know that the first argument is always going to be there - it’s the array. And you know that the rest of the arguments are the items you want to remove, but you don’t know how many there will be in advance (look at array.slice() as well). You want to filter the array, removing the values

Coy Sanders
@coymeetsworld
May 19 2016 00:05
cool @aryandua :thumbsup: dont go too fast on these things though
seems like you're strugging w/ some of the basic things, take your time and learn
Subh Samal
@subhsamal
May 19 2016 00:05
@shaylynnd I am trying to execute your code
Aryan
@aryandua
May 19 2016 00:05
@coymeetsworld yes
Abby
@s0uth
May 19 2016 00:05
ohhhh...that worked. Thanks @coymeetsworld
CamperBot
@camperbot
May 19 2016 00:05
s0uth sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 902 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Abby
@s0uth
May 19 2016 00:05
Thanks for the reply as well @aryandua
CamperBot
@camperbot
May 19 2016 00:05
s0uth sends brownie points to @aryandua :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @aryandua |http://www.freecodecamp.com/aryandua
Coy Sanders
@coymeetsworld
May 19 2016 00:06
np @s0uth, yeah just keep in mind to avoid global variables unless the code they give you has them
shaylynnd
@shaylynnd
May 19 2016 00:06
@subhsamal thanks
CamperBot
@camperbot
May 19 2016 00:06
shaylynnd sends brownie points to @subhsamal :sparkles: :thumbsup: :sparkles:
:cookie: 234 | @subhsamal |http://www.freecodecamp.com/subhsamal
Coy Sanders
@coymeetsworld
May 19 2016 00:06
they're generally bad practice when writing your own code too
Abby
@s0uth
May 19 2016 00:06
ok, that is actually very useful advice going through this. Thank You, @coymeetsworld
CamperBot
@camperbot
May 19 2016 00:06
s0uth sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: s0uth already gave coymeetsworld points
Coy Sanders
@coymeetsworld
May 19 2016 00:06
you're welcome
Jeff
@ObieMD5
May 19 2016 00:08
Any advice on how to remember functions? is it it just repetitive use? I have been programming desktop applications for 7 years and can do that, but I feel like I am looking up the syntax for everything on here.
Vick
@vbouloute07
May 19 2016 00:08
hey yall
Subh Samal
@subhsamal
May 19 2016 00:09
@shaylynnd try removing else above the line return "No such contact";
EODjugornot
@EODjugornot
May 19 2016 00:09
@ObieMD5 the way i remember stuff is i keep an entire folder to notes for myself. then, for functions, id just create a txt file and make notes for myself to remember them
@ObieMD5 there are way too many to remember (and created) to try to remember all that myself lol
Wiktor
@Wkredz1
May 19 2016 00:10
where can i run javascript code ?
Coy Sanders
@coymeetsworld
May 19 2016 00:10
@Wkredz1 you can run it in jsfiddle or codepen
or locally in your own browser
Vick
@vbouloute07
May 19 2016 00:10
a should be assigned to b with =
what does this mean
its not a = b
EODjugornot
@EODjugornot
May 19 2016 00:11
var a = b
@vbouloute07 but it depends on the rest of the script
@vbouloute07 or rather, if youre assigning a to b, it would be var b = a
Wiktor
@Wkredz1
May 19 2016 00:12
@coymeetsworld how do you run it? I know i can type it but how do i test ?
Coy Sanders
@coymeetsworld
May 19 2016 00:12
best way is to utilize console.log functions, and view the console window
on codepen theres a button that will give you the console, or you can hit f12 on most browser and it will give you development tools, one of which is the console
EODjugornot
@EODjugornot
May 19 2016 00:14
@coymeetsworld you can also right click on pages with most browsers. firefox and chrome are your best choice. you can see the console and even interact with it
Coy Sanders
@coymeetsworld
May 19 2016 00:14
f12 faster @EODjugornot :ok_hand:
click, console :)
EODjugornot
@EODjugornot
May 19 2016 00:15
haha yes youre right it definitely is!
my hand is almost always on my mouse when im browsing the interwebs though. creature of horrible habit
shaylynnd
@shaylynnd
May 19 2016 00:16
@subhsamal i think it is only checking the first object in the array but im not sure where to put i++ to make the counter
Jeff
@ObieMD5
May 19 2016 00:17
@coymeetsworld you can press F12 and then esc and it brings the console up right away
Coy Sanders
@coymeetsworld
May 19 2016 00:18
yeah but that opens 2 tabs @ObieMD5, kind of messy
looks like for Chrome CTRL+SHIFT+J gets you straight to console
Jeff
@ObieMD5
May 19 2016 00:18
nice
Yolixtly
@yolixtly
May 19 2016 00:19
hi guys I cant figure out how to solve the Profile Lookup exercise this is my attempt but it doesnt look right, do you have anysuggestions for it?

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

if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
  return contacts[i][prop];
} else if(contacts[i].firstName !== firstName) {
  return "No such contact";
} else if(contacts[i].hasOwnProperty(prop) === false) {
  return "No such property";
}
i++;

}
// Only change code above this line
}

Coy Sanders
@coymeetsworld
May 19 2016 00:19
yeah not bad, hope i remember that lol
@yolixtly the problem is that you're not going through the entire contacts array before declaring no such contact exists
also just a suggestion your loop is fine but i would recommend using a for loop instead
your code would look a little better w/ it
Yolixtly
@yolixtly
May 19 2016 00:21
yeap I see that because in the first Iteration it will stop the process. Ok let me change that ;)
shaylynnd
@shaylynnd
May 19 2016 00:21
@coymeetsworld i used a while loop too but i dont understand why mine isnt working
Coy Sanders
@coymeetsworld
May 19 2016 00:22
the while loop isn't necessarily a problem @shaylynnd, just with a for loop its just a better option
what do you have so far?
shaylynnd
@shaylynnd
May 19 2016 00:22
function lookUpProfile(firstName, prop) {
// Only change code below this line
var i = 0;
  while (i < contacts.length) {
    if (contacts[i].firstName == firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop]; 
      } else {
        return "No such property";
      }
    } else {
      return "No such contact";
    }
  } i++;
// Only change code above this line
}
Yolixtly
@yolixtly
May 19 2016 00:22
I see but still, the iteration stops in the first round
Coy Sanders
@coymeetsworld
May 19 2016 00:22
yeah same thing with @yolixtly, @shaylynnd
basically you're only checking the first contact
Subh Samal
@subhsamal
May 19 2016 00:23
@shaylynnd In while loop it is been difficult to increment value of i , since return statement taking it out of the loop.
Coy Sanders
@coymeetsworld
May 19 2016 00:23
but for No such contact to be true, you need to determine none of the contacts have the first name you're looking for, not just the first
@subhsamal is right too, @shaylynnd
although your code won't infinite loop because based on the logic it will only run one time
it will always reach a return statement
shaylynnd
@shaylynnd
May 19 2016 00:24
im still not understanding why it only runs once
Coy Sanders
@coymeetsworld
May 19 2016 00:24
because a return statement exits out of the function
shaylynnd
@shaylynnd
May 19 2016 00:24
the first return statement ends the loop?
Coy Sanders
@coymeetsworld
May 19 2016 00:24
any return statement that the code reaches
Subh Samal
@subhsamal
May 19 2016 00:24
return key word breaks ur loop. so i++ never executes. in case of a for loop i++ executes inside of it. @shaylynnd
Coy Sanders
@coymeetsworld
May 19 2016 00:24
its basically saying ok i'm done with this code, don't need to run the function anymore
1ety
@1ety
May 19 2016 00:25
str = str.charAt(0).toApperCase();
Joseph
@revisualize
May 19 2016 00:25
@1ety ApperCase?
Coy Sanders
@coymeetsworld
May 19 2016 00:25
@yolixtly what do you have now?
1ety
@1ety
May 19 2016 00:25
Why do I get "str.charAt is not a function"?
Yolixtly
@yolixtly
May 19 2016 00:25
I change the while for the for loop
Coy Sanders
@coymeetsworld
May 19 2016 00:25
don't believe it has a charAt function
shaylynnd
@shaylynnd
May 19 2016 00:25
goooootcha @subhsamal
Joseph
@revisualize
May 19 2016 00:25
@yolixtly What's the code?
Subh Samal
@subhsamal
May 19 2016 00:26
try doing same in a for loop. ur code is correct otherwise @shaylynnd
Coy Sanders
@coymeetsworld
May 19 2016 00:26
ok but there's also the main problem @yolixtly, you're only checking the first contact w/ your code
Wiktor
@Wkredz1
May 19 2016 00:26
how do i make a string uppercase? or why does this not work? str[1-10].toUpperCase()
shaylynnd
@shaylynnd
May 19 2016 00:26
so you do need a for loop for this one then @coymeetsworld @subhsamal
Subh Samal
@subhsamal
May 19 2016 00:26
ri8
Yolixtly
@yolixtly
May 19 2016 00:26
but again i cant see how to go to the next step. so my thinking is eliminating the return statement
Coy Sanders
@coymeetsworld
May 19 2016 00:26
no you don't @shaylynnd, although its better written that way
Yolixtly
@yolixtly
May 19 2016 00:26
and place it at the end
mostlind
@mostlind
May 19 2016 00:26
Hey, I'm doing the friendly date ranges challenge, and it keeps giving me a syntax error saying that SyntaxError {message: "Octal literals are not allowed in strict mode."} any idea?
Jeff
@ObieMD5
May 19 2016 00:26
@shaylynnd also watch out for your loop. You start a 0 and are counting to something that doesn't start at 0.
Coy Sanders
@coymeetsworld
May 19 2016 00:26
you want to do the "No such contact" outside of the function yeah @yolixtly
Joseph
@revisualize
May 19 2016 00:26
@shaylynnd You do need some sort of a loop to iterate through the items in the object.
Coy Sanders
@coymeetsworld
May 19 2016 00:26
i mean outside the for loop
because you can only determine no such contact exists after you've gone through all contacts
your for loop will go through all contacts, and if it finds something with the firstName, it will either return the property if it has one, or "no such property" if not
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:27
haha I was just about to jump in here and ask about the exact same challenge
Wiktor
@Wkredz1
May 19 2016 00:28
how do i make a string uppercase? or why does this not work? str[1-10].toUpperCase
Coy Sanders
@coymeetsworld
May 19 2016 00:28
@ObieMD5 arrays start at 0-index so what @shaylynnd starts with is fine
mostlind
@mostlind
May 19 2016 00:28
@shaylynnd the Array.prototype.every()function is super handy
Coy Sanders
@coymeetsworld
May 19 2016 00:28
it may be @mostlind but it's not needed for that problem
functional programming not introduced till later in curriculum, have to learn basics first
eeflores
@eeflores
May 19 2016 00:29
@Wkredz1 toUpperCase() is a function that returns the upper case value
mostlind
@mostlind
May 19 2016 00:29
@coymeetsworld makes sense
Wiktor
@Wkredz1
May 19 2016 00:29
@eeflores it doesnt work on fcc
Jeff
@ObieMD5
May 19 2016 00:29
@coymeetsworld isn't contacts.length going to break the bounds? the length is going to return 4 and the counter will make it to 4 also in the array but in reality it should of stopped at 3?
Coy Sanders
@coymeetsworld
May 19 2016 00:30
but yeah fair point, wouldn't be a bad way to improve on the solution once you get more experience @mostlind
eeflores
@eeflores
May 19 2016 00:30
@Wkredz1 var blah = str[0].toUpperCase();
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:30
sounds like someone else is also on the Profile Lookup challenge, so hope I'm not getting in the way of anyone's progress here, but I'm stuck. Each of the if statements work on their own if the other 2 are deleted, why can't I chain them together to work? I tried if/else but that doesn't work either. Can someone give some advice?

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

  for (i = 0; i < contacts.length; i += 1 ) {

      if (contacts[i].firstName == firstName && prop !== undefined) {
      return contacts[i][prop];
    } 

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

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

  }

}

lookUpProfile("Akira", "adress");
Coy Sanders
@coymeetsworld
May 19 2016 00:30
it will be @ObieMD5, i < contacts.length
@no-stack-dub-sack you have the same problem as the others
shaylynnd
@shaylynnd
May 19 2016 00:30
@coymeetsworld is there a way to do this with the while loop? i know im really close but im still not sure where to put i++ in order to go through the whole array
Joseph
@revisualize
May 19 2016 00:31
@no-stack-dub-sack We do NOT need the object.
Coy Sanders
@coymeetsworld
May 19 2016 00:31
yes you can do it with while loop @shaylynnd its no big deal
Joseph
@revisualize
May 19 2016 00:31
@no-stack-dub-sack Your loop isn't looping. Please test your code through http://www.pythontutor.com/javascript.html#mode=edit
eeflores
@eeflores
May 19 2016 00:31
@Wkredz1 toUpperCase() does not do an in place upper case substitution
Coy Sanders
@coymeetsworld
May 19 2016 00:31
for a for loop this is what the syntax would be though: for (var i = 0; i < contacts.length; i++)
the reason that's better than the while loop is because you don't have to initialize or increment the variable i on different lines, you can do it all in one place
Wiktor
@Wkredz1
May 19 2016 00:32
@eeflores what do you mean?
Coy Sanders
@coymeetsworld
May 19 2016 00:32
but the logic you had for the while loop is fine, whatever is easier for you to do, no big deal @shaylynnd
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:32
@revisualize I don't get what that is? The for loop is set up correctly, right?
Yolixtly
@yolixtly
May 19 2016 00:32
@coymeetsworld im still working on it ;) ill be back shortly
shaylynnd
@shaylynnd
May 19 2016 00:33
yeah ive had the solution for a bit i just want to figure out how to use the while loop because i stubborn lol but its still not working for me no matter where i put i++
Coy Sanders
@coymeetsworld
May 19 2016 00:33
ok, gl @yolixtly :)
eeflores
@eeflores
May 19 2016 00:33
@Wkredz1 calling str[0].toUpperCase() does not modify str[0] - the call to str[0].toUpperCase()returns the upper case value for str[0]
Coy Sanders
@coymeetsworld
May 19 2016 00:33
well you had other problems too @shaylynnd, basically you don't want to return "No such contact" inside the loop at all
that part should be moved outside
eeflores
@eeflores
May 19 2016 00:33
you would assign the returned value to a var
Joseph
@revisualize
May 19 2016 00:33
@no-stack-dub-sack Your for statement looks okay. The if evaluations don't look correct. But, no matter.. Your loop isn't looping.
Coy Sanders
@coymeetsworld
May 19 2016 00:34
and make sure i++ is inside the while loop, or else you'll have an infinite loop
i.e.
var i = 0;
while (i < contacts.length) {

i++;
}
make sure you have that at least
are you sure its not looping @revisualize?
1ety
@1ety
May 19 2016 00:35
Why? var str = "a";
str = str.charAt(0).toUppercase();
"str.charAt(...).toUppercase is not a function"
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:35
@revisualize but why is the loop not looping if the for statement is correct? And why do all of the ifs work individually?
Coy Sanders
@coymeetsworld
May 19 2016 00:35
i += 1 is fine I think, although better to write i++
Joseph
@revisualize
May 19 2016 00:35
What happens when you return something from a function or a loop?
EVERYTHING HALTS.
1ety
@1ety
May 19 2016 00:36
var str = "a";
str = str.charAt(0).toUppercase();
"str.charAt(...).toUppercase is not a function"
Why?
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:36
@revisualize right, so everything after the 1st return is never hapening
eeflores
@eeflores
May 19 2016 00:36
@1ety its toUpperCase() capital c
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:36
@revisualize is that what you're saying?
shaylynnd
@shaylynnd
May 19 2016 00:36
ugh this is the worst
Joseph
@revisualize
May 19 2016 00:36
If you write...
for (var i = 0; i < 5; i++) {
   if (i == 4) {
      return "FOUR!!!!";
  }
  else {
      return "Not looping";
  }
}
It will only run once.
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:37
so my other statements need to be outside the fully closed for loop then?
Joseph
@revisualize
May 19 2016 00:38
Bingo.
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:38
@revisualize ok, lemme try that. I'll be back. Thanks.
CamperBot
@camperbot
May 19 2016 00:38
no-stack-dub-sack sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1120 | @revisualize |http://www.freecodecamp.com/revisualize
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:40
@revisualize but wait - wouldnt that mean I need a second loop altogether? I still need to iterate through the array to determine whether or not the arguments that are calling the function exist or not...
Yolixtly
@yolixtly
May 19 2016 00:41
@no-stack-dub-sack same question!
Ben Daniels
@benjamindaniels21
May 19 2016 00:41
I'm also working through this challenge...so confused!
Subh Samal
@subhsamal
May 19 2016 00:41
Can anyone explain why we are writing like /\d+/g, what is the need of / before \d+\g . topic: Find Numbers with Regular Expressions
1ety
@1ety
May 19 2016 00:41
Why?
var str = ['a','b';
str = str.charAt(0).toUpperCase();
"Unexpected token ;"
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:42
I tried running concurrent loops earlier, and it said illegal for after return or something
eeflores
@eeflores
May 19 2016 00:43
@subhsamal backslash denotes escape sequence - the char following it then has a special meaning
as opposed to just meaning the char 'd'
Tien
@TienDo1011
May 19 2016 00:44
I'm doing Record Collection, and it always give me TypeError: Cannot set property 'artist' of undefined.
eeflores
@eeflores
May 19 2016 00:44
@subhsamal /d+/g matches one or more 'd' chars
Vick
@vbouloute07
May 19 2016 00:45
@EODjugornot thanks
CamperBot
@camperbot
May 19 2016 00:45
vbouloute07 sends brownie points to @eodjugornot :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @eodjugornot |http://www.freecodecamp.com/eodjugornot
1ety
@1ety
May 19 2016 00:45
var str = ['a','b'];
str = str.charAt(0).toUpperCase();
"Unexpected token ;"
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:45
@TienDo1011 I'm not necessarily the best person to help you, but show some code so we can see why you're getting that error
Wiktor
@Wkredz1
May 19 2016 00:45
someone help 1ety, same question
1ety
@1ety
May 19 2016 00:45
var str = ['a'];
str = str.toUpperCase();
"str.toUpperCase is not a function"
Why?
eeflores
@eeflores
May 19 2016 00:45
@1ety dunno if charAt() will work with array
Tien
@TienDo1011
May 19 2016 00:45
This message was deleted
Vick
@vbouloute07
May 19 2016 00:46
var a = 6;
var b = 15;
Tien
@TienDo1011
May 19 2016 00:46
sr i didn't know how to put it into code
Coy Sanders
@coymeetsworld
May 19 2016 00:46
@TienDo1011 please delete it though
Vick
@vbouloute07
May 19 2016 00:46
whats wrong with this
Subh Samal
@subhsamal
May 19 2016 00:46
I think I am not wise enough to get your point :( @eeflores
eeflores
@eeflores
May 19 2016 00:46
@1ety :
var str = "a";
str = str.charAt(0).toUpperCase();
Tien
@TienDo1011
May 19 2016 00:46
@coymeetsworld : how do i put it into code
Coy Sanders
@coymeetsworld
May 19 2016 00:46
don't just give code out away, try to help people through issues
help format
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:46
@TienDo1011 Also, helpful to paste code in between 3 backticks, which will show it as code like this code
CamperBot
@camperbot
May 19 2016 00:46

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Coy Sanders
@coymeetsworld
May 19 2016 00:47
but as I said @TienDo1011 if someone wants help don't just give them the answer
Tien
@TienDo1011
May 19 2016 00:47
@coymeetsworld : I did try, and search google for the answer but it didn't work
eeflores
@eeflores
May 19 2016 00:47
@subhsamal goto https://regex101.com/ and try the regexp /d+/g and /\d+/g on the string "abcdddd123413"
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:48
@coymeetsworld I think he's asking for help on his code
Tien
@TienDo1011
May 19 2016 00:48
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  var property = prop;
  if(prop !== "tracks" && value !== "") {
    collection.id[property] = "";
    collection.id[property] = value;
  } else if (prop === "tracks" && value !== "") {
    collection.id[property].push(value);
  } else {
    delete collection.id[property];
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Coy Sanders
@coymeetsworld
May 19 2016 00:48
oh ok nvm, i just saw him at somebody who is working through an issue
Joseph
@revisualize
May 19 2016 00:48
@TienDo1011 WE don't need the object.
@TienDo1011 Also. You're using dot notation. when you should be accessing the id variable. Not id as a string.
Tien
@TienDo1011
May 19 2016 00:49
@revisualize : sorry, i'm new here. Anything i can do
Joseph
@revisualize
May 19 2016 00:50
@no-stack-dub-sack Just one loop completes that task.
@TienDo1011 collection.id[property] = ""; is not correct.
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:50
@revisualize then I might be a little lost here, let me play around a bit more and try to figure out more specifically where I am going wrong...
Tien
@TienDo1011
May 19 2016 00:51
@revisualize : i just add it, because it didn't work before
Joseph
@revisualize
May 19 2016 00:51
@TienDo1011 That's because of the aforementioned issue of dot notation.
Tien
@TienDo1011
May 19 2016 00:52
@revisualize : ok, i changed from dot notation to braket notation and it worked, i don't understand?
Yolixtly
@yolixtly
May 19 2016 00:52
@coymeetsworld thank you ;) I got it
CamperBot
@camperbot
May 19 2016 00:52
yolixtly sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 904 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Tien
@TienDo1011
May 19 2016 00:53
@revisualize : for object, dot and braket notation should work equally, right?
Jeff
@ObieMD5
May 19 2016 00:53
@TienDo1011 just curious is that for a specific reason? Because when I use bracket notation on the tests, it says I should use dot notation instead
Coy Sanders
@coymeetsworld
May 19 2016 00:53
nice @yolixtly :thumbsup:
Joseph
@revisualize
May 19 2016 00:53
@TienDo1011 Dot notation is string literals. Example.
myObj.nameis the same as myObj["name"]
and doesn't work if you want to use myObj[name] where name is a variable.
Tien
@TienDo1011
May 19 2016 00:53
@ObieMD5 : i have no idea, man.
waynelouie
@waynelouie
May 19 2016 00:54

var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = 1;
       case 7:
    case 8:
    case 9:
      count = count+0;

    case 10:  
    case "J":  
    case "Q":    
    case "K":
    case "A":
      count = count -1;


     if (count >0){
       return card +" Bet";
     }
       if (count <= 0 ){
         return card + " Hold";

     }



      break;
  }

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
oh sorry
i wasn't trying to figure out how to work this
Coy Sanders
@coymeetsworld
May 19 2016 00:54
sometimes you can interchange them @TienDo1011 @ObieMD5 but look what @revisualize is saying
waynelouie
@waynelouie
May 19 2016 00:54
am i on the right track for this?
Coy Sanders
@coymeetsworld
May 19 2016 00:55
@waynelouie few issues. First you're not incrementing count, you keep setting it to 1, you need more break statements in the switch, also your if statement should not be inside the switch statement
Joseph
@revisualize
May 19 2016 00:55
@waynelouie count = 1; is incorrect. You should be increment the global variable of count.
Tien
@TienDo1011
May 19 2016 00:55
@coymeetsworld , @revisualize : so i should use bracket notation only, right?
NegrilloC
@NegrilloC
May 19 2016 00:55
@waynelouie i think you need to have break; after each count = (something)
Susheel Palakurthi
@ush19
May 19 2016 00:55

So, I'm working on the Basic Algorithm Scripting on the factorializing a number and I'm running into a bit of trouble.


var product = 1;

function factorialize(num) {

  for (var i = 1; i <= num; i++)
    {


      product *= i;
    }

  return product;
}

factorialize(10);

I'm getting the right results but FCC isn't letting me through

Joseph
@revisualize
May 19 2016 00:55
@TienDo1011 Depends.
@TienDo1011 For this assessment .. yes. because you're trying to access a variable.
Tien
@TienDo1011
May 19 2016 00:56
@revisualize: when should i use dot notation?
Joseph
@revisualize
May 19 2016 00:56
@TienDo1011 For other stuff later.. Depends on what you're doing.
Coy Sanders
@coymeetsworld
May 19 2016 00:56
no absolutes @TienDo1011
NegrilloC
@NegrilloC
May 19 2016 00:56
@ush19 you should put product declaration within the function
Coy Sanders
@coymeetsworld
May 19 2016 00:56
dot notation if you know the property name already
Joseph
@revisualize
May 19 2016 00:56
@TienDo1011 Let me repaste this.
Coy Sanders
@coymeetsworld
May 19 2016 00:57
if its in a variable, you need bracket notation
can't do collection.id because id is a variable
Joseph
@revisualize
May 19 2016 00:57
@TienDo1011
Dot notation is string literals. Example.
myObj.name is the same as myObj["name"]
and doesn't work if you want to use myObj[name]
where name is a variable.
Susheel Palakurthi
@ush19
May 19 2016 00:57
@NegrilloC woah, thanks! but how was that a problem?
CamperBot
@camperbot
May 19 2016 00:57
ush19 sends brownie points to @negrilloc :sparkles: :thumbsup: :sparkles:
:cookie: 262 | @negrilloc |http://www.freecodecamp.com/negrilloc
Tien
@TienDo1011
May 19 2016 00:58
@coymeetsworld, @revisualize: i see, thank you guys!!!
CamperBot
@camperbot
May 19 2016 00:58
tiendo1011 sends brownie points to @coymeetsworld and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 905 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
:star2: 1121 | @revisualize |http://www.freecodecamp.com/revisualize
Coy Sanders
@coymeetsworld
May 19 2016 00:58
np @TienDo1011
Joseph
@revisualize
May 19 2016 00:58
:v:
Peter Weinberg
@no-stack-dub-sack
May 19 2016 00:59
@revisualize so now I have the for Loop, which stops running when it's iterated through the array and returns the contact's prop value if it is found. Then as a seperate statement, the other 2 ifs - again I deleted everything inside the function, including the loop, and both if statements work on their own - why am I unable to get these statements to run after the loop?
function lookUpProfile(firstName, prop){

  for (i = 0; i < contacts.length; i += 1 ) {

      if (contacts[i].firstName == firstName && prop !== undefined) {
      return contacts[i][prop];
    } 
  }

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


}
Joseph
@revisualize
May 19 2016 00:59
MEH!
function lookUpProfile(firstName, prop){
// Only change code below this line
   for (var i = 0; i < contacts.length; i++) {
        if (firstName === contacts[i].firstName) {
            return contacts[i].hasOwnProperty(prop) ? contacts[i][prop] : "No such property";
        }
    }
    return "No such contact";
// Only change code above this line
}
eeflores
@eeflores
May 19 2016 01:00
har har
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:01
OMG
Joseph
@revisualize
May 19 2016 01:01
First iterate through the loop.. If the loop returns .. It exits the function.
If the loop doesn't return .. It returns.
You're over thinking it.
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:02
quite clearly
NegrilloC
@NegrilloC
May 19 2016 01:02
@ush19 I think its that since product wasnt declared, it doesnt know what to multiply the value 1 with for the first iteration of the loop
Joseph
@revisualize
May 19 2016 01:02
Normally, I don't give people answers. But, In this case.. I think you needed to see it to understand it.
Kennon Houck
@kennh
May 19 2016 01:03
anyone here
mathpharaoh
@mathpharaoh
May 19 2016 01:03
I'm having the same problem, I cannot get a return contacts[i][prop];
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:04
@revisualize Yes, thank you. I think if we were in person, I probably could've worked through it with verbal guidance. I appreciate it though - I've been at it for wayyyyyy to long.
CamperBot
@camperbot
May 19 2016 01:04
no-stack-dub-sack sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: no-stack-dub-sack already gave revisualize points
Manisha Reddy
@myeramareddy
May 19 2016 01:04
Function to title case a sentence - seems right, but not getting through, what did I miss?
function titleCase(str) {
  var arr = str.split(" ");
  var ret = "";

  for(var i=0; i<arr.length; i++) {
    var word = arr[i].charAt(0).toUpperCase() + arr[i].slice(1).toLowerCase();
    ret = ret + word + " ";
  }

  return ret;
}
mathpharaoh
@mathpharaoh
May 19 2016 01:04
to return anything. It's extremely frustrating,
Stephen James
@sjames1958gm
May 19 2016 01:05
@myeramareddy Extra space at end of string?
eeflores
@eeflores
May 19 2016 01:05
yep
Joseph
@revisualize
May 19 2016 01:05
@no-stack-dub-sack Just wait until you get to Seek and Destroy.
Let's just say.. I do NOT assist people with Seek and Destroy.
Manisha Reddy
@myeramareddy
May 19 2016 01:06
@sjames1958gm Ahhhh, silly me, thank you!
CamperBot
@camperbot
May 19 2016 01:06
myeramareddy sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1161 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 19 2016 01:06
@myeramareddy You can push the values onto an array and join
Subh Samal
@subhsamal
May 19 2016 01:06
@eeflores I executed var expression = /\s/g; & var expression = /\s+/g; both cases result is 7 !!!
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:06
@revisualize Ha - can't wait!
mathpharaoh
@mathpharaoh
May 19 2016 01:07

for(i=0; i<4; i++){
if(contacts[i].firstName !== firstName){
return "No such contact";
}

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

}

return contacts[i][prop];

}

Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:07
I still think there are some fundamental things I was missing on this one - maybe suggesting the hasOwnProperty, which I didn't even think to incorporate, might have helped me get a little closer.
It's tough doing all this through a chat I guess
eeflores
@eeflores
May 19 2016 01:08
@subhsamal what's the input string, and what function are you passing the regex to?
mathpharaoh
@mathpharaoh
May 19 2016 01:10
@revisualize Thank you so much! can't return from an if!
CamperBot
@camperbot
May 19 2016 01:10
mathpharaoh sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1122 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
May 19 2016 01:11
@mathpharaoh You can.
Kennon Houck
@kennh
May 19 2016 01:12
Hello, I am needing a little help on Factorilize a Number. anyone want to help me on it quickly
Joseph
@revisualize
May 19 2016 01:12
@mathpharaoh
for (var i = 0; i < 5; i++) {
   if (i == 4) {
      return "FOUR!!!!";
  }
  else {
      return "Not looping";
  }
}
@kennh "Talk is cheap. Show me the code." - Linus Torvalds (2000-08-25).
Kennon Houck
@kennh
May 19 2016 01:14
i didnt want to blast code on here with out asking first

var factorial = 1;

for(var i = 2; i <= num; i++) {
factorial = factorial *= i;
}

return factorial;

Joseph
@revisualize
May 19 2016 01:14
@kennh Ummm.
factorial = factorial *= i;
That isn't really how variable assignment works.
Carlos Vigil
@carlosvigil
May 19 2016 01:15

Can someone help with "next in line". I've occasionally seen this question around and feel super nooby for adding to this trend.

Here's my code, it won't pass the "returns '2'" test:

function nextInLine(arr, item) {
  // Your code here
  arr.shift();
  arr.push(item);
  return arr.unshift();  // Change this line
}
Joseph
@revisualize
May 19 2016 01:15
@carlosvigil Incorrect order of operations.
Kennon Houck
@kennh
May 19 2016 01:15
sorry, wrong code. reworked it
var answer = 1;
for (var i = 1; i <= num; i++) {
answer = answer * 1;
}
return answer;
}
Subh Samal
@subhsamal
May 19 2016 01:16

// Setup
var testString = "How many spaces are there in this sentence?";

// Only change code below this line.

var expression = /\s/g; // Change this line

// Only change code above this line

// This code counts the matches of expression in testString
var spaceCount = testString.match(expression).length;

Joseph
@revisualize
May 19 2016 01:16
@kennh change var i = 1; to 2 and answer * 1 toanswer * i`
Carlos Vigil
@carlosvigil
May 19 2016 01:17
If i switched the places of shift and push @revisualize it would work?
Joseph
@revisualize
May 19 2016 01:17
@carlosvigil
// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // Add the number to the end of the array,
    // then remove the first element of array.
    // The nextInLine function should 
    // then return the element that was removed.

    return item; // Change this line
}
Subh Samal
@subhsamal
May 19 2016 01:17
@eeflores above is my code
Joseph
@revisualize
May 19 2016 01:17
@carlosvigil Why are you unshifting?
Subh Samal
@subhsamal
May 19 2016 01:17
I am not able to format the code here.
eeflores
@eeflores
May 19 2016 01:17
@subhsamal you may get a different result if you have 2 or more consecutive spaces
Joseph
@revisualize
May 19 2016 01:17
help format
CamperBot
@camperbot
May 19 2016 01:17

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Kennon Houck
@kennh
May 19 2016 01:18
why 2. I understand the answer to i.
Joseph
@revisualize
May 19 2016 01:18
ummm.
What is 1 * 1?
Jason Keenan
@raavin
May 19 2016 01:18
@kennh what are you trying to achieve? This sort of does nothing 😟
eeflores
@eeflores
May 19 2016 01:18
/\s+/g - the plus is a modifier to the previous value by stating "1 or more"
Carlos Vigil
@carlosvigil
May 19 2016 01:18
@revisualize to return the removed value
Walter Augustine
@Walter-0
May 19 2016 01:19
help spinal tap case
CamperBot
@camperbot
May 19 2016 01:19

:point_right: algorithm spinal tap case [wiki]

Algorithm Spinal Tap Case

Problem Explanation:

  • Convert the given string to an all lowercase sentence joined by dashes.
:pencil: read more about algorithm spinal tap case on the FCC Wiki
eeflores
@eeflores
May 19 2016 01:19
@subhsamal you may get a different result with the string
"one          two three"
Kennon Houck
@kennh
May 19 2016 01:19
@revisualize okay I understand that.
Blake Harris
@bharris62
May 19 2016 01:19
i got a question regarding twitch app, anyone got a second to help?
Joseph
@revisualize
May 19 2016 01:19
@carlosvigil The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.
Kennon Houck
@kennh
May 19 2016 01:20
@raavin I was trying to figure out the Factorilize A Number.
Joseph
@revisualize
May 19 2016 01:20
@carlosvigil Unshift is ...
var arr = [1, 2];

arr.unshift(0); // result of call is 3, the new array length
// arr is [0, 1, 2]
Kennon Houck
@kennh
May 19 2016 01:20
thank you for the help
Jason Keenan
@raavin
May 19 2016 01:21
@kennh you're returning the same number
Subh Samal
@subhsamal
May 19 2016 01:21

@eeflores // Setup
var testString = "How many spaces are there in this sentence?";

// Only change code below this line.

var expression = /\s+/g; // Change this line

// Only change code above this line

// This code counts the matches of expression in testString
var spaceCount = testString.match(expression).length;

this gives the same result as of single space
Joseph
@revisualize
May 19 2016 01:21
@carlosvigil I don't believe that is what you are intending to do.
Carlos Vigil
@carlosvigil
May 19 2016 01:21
@revisualize oh wow, yeah hah, no
Subh Samal
@subhsamal
May 19 2016 01:21
// Setup
var testString = "How many spaces are there in this sentence?";
// Setup
var testString = "How many      spaces are     there in this sentence?";
Carlos Vigil
@carlosvigil
May 19 2016 01:22
@revisualize i'll reorder the operations and think on a new return solution
eeflores
@eeflores
May 19 2016 01:22
@subhsamal uh ... that's what I have in my solution ... is there a problem?
Joseph
@revisualize
May 19 2016 01:22
@carlosvigil You have what you need to return in your code already.
Jason Keenan
@raavin
May 19 2016 01:23
@kennh I'm on my phone. Can you paste the requirements?
Subh Samal
@subhsamal
May 19 2016 01:23
@eeflores js // Setup var testString = "How many spaces are there in this sentence?";
Joseph
@revisualize
May 19 2016 01:23
@carlosvigil Re-read everything I posted about your issue.
Subh Samal
@subhsamal
May 19 2016 01:23
both sentences produce result 7
mathpharaoh
@mathpharaoh
May 19 2016 01:23
@revisualize thanks, my brain is fried i've been moving if and for statements all over
CamperBot
@camperbot
May 19 2016 01:23
mathpharaoh sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: mathpharaoh already gave revisualize points
eeflores
@eeflores
May 19 2016 01:24
@subhsamal does the exercise pass?
Subh Samal
@subhsamal
May 19 2016 01:24
yup :( @eeflores
Carlos Vigil
@carlosvigil
May 19 2016 01:24
@revisualize ok, thanks
CamperBot
@camperbot
May 19 2016 01:24
carlosvigil sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1123 | @revisualize |http://www.freecodecamp.com/revisualize
Subh Samal
@subhsamal
May 19 2016 01:24
try on yours
Joseph
@revisualize
May 19 2016 01:24
@mathpharaoh Let me try to help.
Jaison D. Vieira
@jaisonv
May 19 2016 01:25
hello guys
eeflores
@eeflores
May 19 2016 01:25
@subhsamal so are you trying to find the difference between \s and \s+? try it at https://regex101.com/
Jaison D. Vieira
@jaisonv
May 19 2016 01:25
i'm stuck in the seek and destroy task
i have it returning the expected values
eeflores
@eeflores
May 19 2016 01:26
@subhsamal I tried it there and there is a difference
Jaison D. Vieira
@jaisonv
May 19 2016 01:26
but it says it's not passing
Subh Samal
@subhsamal
May 19 2016 01:26
really !!
you tried without + ? @eeflores
eeflores
@eeflores
May 19 2016 01:27
@subhsamal yeah, without the + it counts each space char individually, whereas with the + it counts consecutive space chars as one
Joseph
@revisualize
May 19 2016 01:28
@mathpharaoh
function checkFour(arr) {
   // first we iterate through the arr
   for (var i = 0; i < arr.length; i++) {
     if (arr[i] === 4) {
          return "FOUR!!!!!!!!";
     }
   }
   // if 4 is not found in the arr.
   // return text.
   return "You can't four here. Play golf elsewhere.";
}

var myArr = [1,3,5,6,7,12,33]
checkFour(myArr);
Subh Samal
@subhsamal
May 19 2016 01:28
aahh.. here is the key :smile: got it..bugging you since log time.. thank you @eeflores
CamperBot
@camperbot
May 19 2016 01:28
subhsamal sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 723 | @eeflores |http://www.freecodecamp.com/eeflores
Jaison D. Vieira
@jaisonv
May 19 2016 01:29
function destroyer(arr) {
  // Remove all the values

  var cleaned = arguments[0];

  for (var i = 1; i < arguments.length; i++) {
    cleaned = cleaned.filter(different, arguments[i]);
  }

  return cleaned;
}

function different(value) {
  return value !== this;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
any guess?
mathpharaoh
@mathpharaoh
May 19 2016 01:29
My loops run ok, but I cannot get contacts[i].prop; to produce
Stephen James
@sjames1958gm
May 19 2016 01:30
@mathpharaoh If your property is in a variable you must use [] id is a variable and so is prop
mathpharaoh
@mathpharaoh
May 19 2016 01:30
return arr[]i.prop;
Joseph
@revisualize
May 19 2016 01:30
"Talk is cheap. Show me the code." - Linus Torvalds (2000-08-25).
mathpharaoh
@mathpharaoh
May 19 2016 01:31
so return arr[i][prop]; ? I've tried that also to no avail. I know I hit inside the loop because I put a simple output in to check it.
Stephen James
@sjames1958gm
May 19 2016 01:31
@mathpharaoh contacts[i][prop]
Jason Keenan
@raavin
May 19 2016 01:32
@jaisonv looks like you're only getting the first argument
Joseph
@revisualize
May 19 2016 01:32
@mathpharaoh Where's the rest of the code?
Vick
@vbouloute07
May 19 2016 01:32
myVar = myVar++;
whats wrong with this?
mrcsscco
@marcussacco
May 19 2016 01:32
When I run npm start to fire up a server, I can no longer run any more commands. I just get a blinking cursor without a prompt. Do i need to open another terminal?
Stephen James
@sjames1958gm
May 19 2016 01:32
@vbouloute07 myVar++ changes the variable, no need for myVar =
rphares
@rphares
May 19 2016 01:32
@vbouloute07 , you dont need myVar =
Vick
@vbouloute07
May 19 2016 01:33
ohhh thanks guys
mathpharaoh
@mathpharaoh
May 19 2016 01:33
@sjames1958gm Thanks.
CamperBot
@camperbot
May 19 2016 01:33
mathpharaoh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1162 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jaison D. Vieira
@jaisonv
May 19 2016 01:33
@raavin I put the first argument in a var because that is the array to be filtered
Joseph
@revisualize
May 19 2016 01:33

@vbouloute07

var myVar = 2;
myVar = myVar + 1;
myVar += 1;
myVar++

These all do the same thing. Add one to the value.

Stephen James
@sjames1958gm
May 19 2016 01:33
@jaisonv I don't think this is different is a number strictly, so it is always !==
waynelouie
@waynelouie
May 19 2016 01:33

var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = count ++;
      break;

    case 7:
    case 8:
    case 9:
      card = count;
      break;

    case 10:  
    case "J":  
    case "Q":    
    case "K":
    case "A":
      card = count --;
      break;
  }


  if (count >0){
       return card +" Bet";
     }
       if (count <= 0 ){
         return card + " Hold";

     }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2);
i still can't get this count to work
Vick
@vbouloute07
May 19 2016 01:33
@sjames1958gm @revisualize thanks
CamperBot
@camperbot
May 19 2016 01:33
vbouloute07 sends brownie points to @sjames1958gm and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1163 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1124 | @revisualize |http://www.freecodecamp.com/revisualize
waynelouie
@waynelouie
May 19 2016 01:34
im still working on the first set 7-a im not even worried about yet
Vick
@vbouloute07
May 19 2016 01:34
@rphares thanks
CamperBot
@camperbot
May 19 2016 01:34
vbouloute07 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star2: 4705 | @rphares |http://www.freecodecamp.com/rphares
Joseph
@revisualize
May 19 2016 01:34
@waynelouie :point_up: May 18, 2016 6:33 PM
mrcsscco
@marcussacco
May 19 2016 01:34
When I run npm start to fire up a server, I can no longer run any more commands. I just get a blinking cursor without a prompt. Do i need to open another terminal?
Joseph
@revisualize
May 19 2016 01:35
Stephen James
@sjames1958gm
May 19 2016 01:35
@waynelouie If using ++ or -- you don't need count =
anthonyjl92
@anthonyjl92
May 19 2016 01:35
hey guys, I'm trying to write to the body of an iframe element without using .write()
waynelouie
@waynelouie
May 19 2016 01:35
yeah i just realized
mrcsscco
@marcussacco
May 19 2016 01:35
@revisualize thanks
CamperBot
@camperbot
May 19 2016 01:35
marcussacco sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1125 | @revisualize |http://www.freecodecamp.com/revisualize
waynelouie
@waynelouie
May 19 2016 01:36
i still can't get the count right though. even if i only use one card it registers at two it seems like
Jaison D. Vieira
@jaisonv
May 19 2016 01:36
@sjames1958gm it is working.. the value in the example >>>> destroyer([3, 5, 1, 2, 2], 2, 3, 5); returns "[1]"
anthonyjl92
@anthonyjl92
May 19 2016 01:36
<script type="text/javascript">
(function(d) {
var ttx_iframe = d.createElement('iframe');
ttx_iframe.style = "margin: 0px; padding: 0px; border: 0px none; width: 160px; height: 600px; overflow: hidden;";
var doc = ttx_iframe.contentDocument ? ttx_iframe.contentDocument : ttx_iframe.contentWindow.document;
var script = "<scr"+"ipt type='text/javascript' src='cdn.angular'</scr"+"ipt>";
doc.open();
doc.write(script);
doc.close();
})(document);</script>
How would I rewrite this using appendChild or innerHTML? Do i replace doc.write(script) with doc.body.appendChild(script) or doc.innerHTML(script)?
Joseph
@revisualize
May 19 2016 01:36
@waynelouie Why are you reassigning card?
waynelouie
@waynelouie
May 19 2016 01:37
i was just messing around with that
Joseph
@revisualize
May 19 2016 01:37
@waynelouie You're doing 2 through 6 correctly (almost) at the end. But, then your code complete changes for the other sets.
waynelouie
@waynelouie
May 19 2016 01:37
i was using card 2 so i figured the bottom half wouldn't even matter
i was going to change that later once i figured out how to even do it
Jason Keenan
@raavin
May 19 2016 01:38
@jaisonv do you need a sort()
Joseph
@revisualize
May 19 2016 01:38
@waynelouie
count++
count = count + 0; // not really needed
count--
Jaison D. Vieira
@jaisonv
May 19 2016 01:38
@raavin how? if an array with only one value does not pass the test
@raavin i can't understand =/
Jason Keenan
@raavin
May 19 2016 01:39
@jaisonv sorry. I'm on my phone so hard to check... No I mean the result
Joseph
@revisualize
May 19 2016 01:39
@waynelouie Also, you're messing with count a lot.. But, returning card?
heymark
@heymark
May 19 2016 01:39

Hey, ES6 wizards. Can I destructure a nested array in a map function?
I'm doing:

myArray.map(subArray => subArray[0] + subArray[1])

and I'd like to do something like:

myArray.map([elementA, elementB] => elementA + elementB)

Is there syntax for this?

waynelouie
@waynelouie
May 19 2016 01:39
@revisualize I WAS DESPERATE! i just got it.
Joseph
@revisualize
May 19 2016 01:40
@waynelouie Grats.
waynelouie
@waynelouie
May 19 2016 01:40
i didn't realize it was returning the card number
i thought it was counting wrong
Jason Keenan
@raavin
May 19 2016 01:41
@jaisonv is it removing the correct arguments but returning the result in incorrect order?
mathpharaoh
@mathpharaoh
May 19 2016 01:41
I can't get the screen to paste code into, defeated :(
Joseph
@revisualize
May 19 2016 01:41
?
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:41
@revisualize Ok, after looking at your solution, I still felt the need to come up with my own since I didn't fully understand yours:
function lookUpProfile(firstName, prop){

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

  return "No such contact";
}


lookUpProfile("Kristian", "lastName");
mathpharaoh
@mathpharaoh
May 19 2016 01:42
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
 var statement = "No such contact";

 for(i=0; i<4; i++){



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

     if(contacts[i].hasOwnProperty(prop) === true){

       return contacts[i][prop];
      }
     statement = "No such property";
   }

   return statement;

 }




// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");
```
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:42
@revisualize What I didnt understand about yours was how the ? accounted for No Such Property piece - can you explain that?
Joseph
@revisualize
May 19 2016 01:43
@no-stack-dub-sack It is a simple..
Stephen James
@sjames1958gm
May 19 2016 01:43
I you return no such contact inside your for loop you will never get to i = 1
eeflores
@eeflores
May 19 2016 01:43
@mathpharaoh you'll return without iterating through the whole for loop
@mathpharaoh you're only testing the first array element
Joseph
@revisualize
May 19 2016 01:43
@no-stack-dub-sack
(evaluation) ? true : false;
if (evaluation) {
   true stuff
}
else {
   false stuff
}
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:43
I tried looking it up but couldnt find what it meant
eeflores
@eeflores
May 19 2016 01:44
ternary operator
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:44
Ok, gotcha, the curriculum hadn't taught that yet so I was lost on that part
mathpharaoh
@mathpharaoh
May 19 2016 01:44
I think I found it
thanks for your help
Jaison D. Vieira
@jaisonv
May 19 2016 01:45
@raavin it returns in the same order as expected in the side bar.
mathpharaoh
@mathpharaoh
May 19 2016 01:45
@eeflores thanks
CamperBot
@camperbot
May 19 2016 01:45
mathpharaoh sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 724 | @eeflores |http://www.freecodecamp.com/eeflores
eeflores
@eeflores
May 19 2016 01:45
@mathpharaoh you're welcome
Stephen James
@sjames1958gm
May 19 2016 01:45
@mathpharaoh Also, you should not have the value 4 in your loop, while it works for this data, if you added another contact, you would have to change the code.
Peter Weinberg
@no-stack-dub-sack
May 19 2016 01:46
@revisualize so you're giving it an option for both true and false... I get it
Matt
@mattstates
May 19 2016 01:46
Has anyone here worked on the Game of Life react.js project?
Jason Keenan
@raavin
May 19 2016 01:46
@jaisonv yeah just looked and you're right.
Jaison D. Vieira
@jaisonv
May 19 2016 01:47
@raavin i think i found a bug... i will report it. how lucky lol
Joseph
@revisualize
May 19 2016 01:47
@no-stack-dub-sack It's just shorter code.
@no-stack-dub-sack It's good for short code like I posted.

@no-stack-dub-sack

return contacts[i].hasOwnProperty(prop) ? contacts[i][prop] : "No such property";

is the same as..

if (contacts[i].hasOwnProperty(prop)) {
   return contacts[i][prop];
}
else {
   return "No such property";
}
I'm lazy sometimes.
mathpharaoh
@mathpharaoh
May 19 2016 01:50
@sjames1958gm thanks, I changed it from .length as I tried to debug the problems
CamperBot
@camperbot
May 19 2016 01:50
mathpharaoh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: mathpharaoh already gave sjames1958gm points
Joseph
@revisualize
May 19 2016 01:50
You could do a ternary operator inside of a ternary operator inside of a ternary operator inside of a ternary operator inside of a ternary operator with a branching ternary operator inside of a ternary operator inside of a ternary operator... But, that crap gets confusing. So... Don't do it.
Jason Keenan
@raavin
May 19 2016 01:51
@jaisonv oooh
mathpharaoh
@mathpharaoh
May 19 2016 01:51
I'm mot sure of the ? in your code @revisualize
Joseph
@revisualize
May 19 2016 01:52
@mathpharaoh I just explained it.
mathpharaoh
@mathpharaoh
May 19 2016 01:52
@revisualize I see it now, thanks
CamperBot
@camperbot
May 19 2016 01:52
mathpharaoh sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: mathpharaoh already gave revisualize points
Jason Keenan
@raavin
May 19 2016 01:53
@jaisonv have you checked the format/result of each returned array to make sure ?
Joseph
@revisualize
May 19 2016 01:53
@mathpharaoh It isn't needed to complete any of the challenges.
Jaison D. Vieira
@jaisonv
May 19 2016 01:54
@raavin yes.. i tried all
Austin Searle
@Speedclip
May 19 2016 01:54
this isn't really related to freecodecamp but it is with Java in general. is anyone familier with Eclipse IDE? need help if so let me know so you can help with my problem in coding
Jaison D. Vieira
@jaisonv
May 19 2016 01:54
@raavin all of them show the expected values in the expected order
Jason Keenan
@raavin
May 19 2016 01:55
@jaisonv weird 😟
Jaison D. Vieira
@jaisonv
May 19 2016 01:56
@raavin even this one is right
screen shot 2016-05-18 at 10 55 30 pm
1ety
@1ety
May 19 2016 01:56

Thank you
@eeflores

Is someone explain to me how is the following code know to make the second or the third word first letter upper case.

CamperBot
@camperbot
May 19 2016 01:56
1ety sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 725 | @eeflores |http://www.freecodecamp.com/eeflores
1ety
@1ety
May 19 2016 01:57

function titleCase(str) {
return str.replace(/\w\S*/g, function(w) {
return w.charAt(0).toUpperCase() + w.substr(1).toLowerCase();
});
}

titleCase("I'm a little tea pot");

Joseph
@revisualize
May 19 2016 01:58
Has anyone been trying to use www.pythontutor.com/javascript.html#mode=edit
Stephen James
@sjames1958gm
May 19 2016 02:00
@1ety The \W\S* \ selects a word, the g then makes is select them all in turn. The function is called for each one with w equal to the matching string. w is then replaced in the original string with the reconstructed string.
Jason Keenan
@raavin
May 19 2016 02:01
@jaisonv I'm on a phone app so I can't blow up the image 😟
Can you post a zoomed image of the resilt
Stephen James
@sjames1958gm
May 19 2016 02:02
@jaisonv I thought you said it was working?
Jason Keenan
@raavin
May 19 2016 02:03
@sjames1958gm not passing tests though
Jaison D. Vieira
@jaisonv
May 19 2016 02:04
@sjames1958gm it is working... but not passing the tests. i mean the results are the ones expected. but they don't pass the tests for unknown reason
@raavin can you see this?
Joe
@joemanriquez
May 19 2016 02:04
This message was deleted
Jason Keenan
@raavin
May 19 2016 02:06
@jaisonv yeah what about the empty array
Joe
@joemanriquez
May 19 2016 02:07
Hey guys. I'm a newbie. I'm working on javascript bonfires and starting to feel a bit lost. I was wondering if anyone could help with the "Stand in Line" bonfire? The instructions say "Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of the array. The nextInLine function should then return the element that was removed." Having the hard time grasping the concept right now.
function nextInLine(arr, item) {
  // Your code here
  function queue (arr, item) {
    arr.push(item);
    arr.shift();
  }
  return item;  // Change this line

// Test Setup
var testArr = [1,2,3,4,5];
CamperBot
@camperbot
May 19 2016 02:07
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Jason Keenan
@raavin
May 19 2016 02:08
@jaisonv do a console.log for the results and paste all of them at the bottom so you
Stephen James
@sjames1958gm
May 19 2016 02:08
@joemanriquez Don't create a new function, just use the existing one. Then return the result from shift
1ety
@1ety
May 19 2016 02:08
Thank you @sjames1958gm
CamperBot
@camperbot
May 19 2016 02:08
1ety sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1164 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jaison D. Vieira
@jaisonv
May 19 2016 02:09
@raavin how to use console.log?
@raavin i found out.. let me do it
Walter Augustine
@Walter-0
May 19 2016 02:11
help sum all odd fibonacci numbers
CamperBot
@camperbot
May 19 2016 02:11

:point_right: algorithm sum all odd fibonacci numbers [wiki]

Algorithm Sum All Odd Fibonacci Numbers

Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

:pencil: read more about algorithm sum all odd fibonacci numbers on the FCC Wiki

Jason Keenan
@raavin
May 19 2016 02:11
@jaisonv maybe try returning arr
it might need you
Joe
@joemanriquez
May 19 2016 02:12
@sjames1958gm Okay. still struggling conceptually with javascript. I've removed the function and just put the js code. But not sure what you mean by return the result from shift? ```
Stephen James
@sjames1958gm
May 19 2016 02:12
return arr.shift()
Wiktor
@Wkredz1
May 19 2016 02:13
@sjames1958gm IS FUNCTION W A BUILT IN FUNCTION ??
Stephen James
@sjames1958gm
May 19 2016 02:13
I DON"T KNOW WHAT IS W?
:)
Wiktor
@Wkredz1
May 19 2016 02:14
@sjames1958gm
you said
The \W\S* \ selects a word, the g then makes is select them all in turn. The function is called for each one with w equal to the matching string. w is then replaced in the original string with the reconstructed string.
for that question
Stephen James
@sjames1958gm
May 19 2016 02:15
@Wkredz1 /\w\S*/ is a regular expression that matches a word character followed by non-space characters. I would have used \w+
Joe
@joemanriquez
May 19 2016 02:15
@sjames1958gm Wow! thanks so much! I got it. Still not sure I understand it, but thanks for the help!
CamperBot
@camperbot
May 19 2016 02:15
joemanriquez sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1165 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 19 2016 02:16
@joemanriquez Along with removing the element from the array it returns the removed value and so you just passed it on in your return.
Wiktor
@Wkredz1
May 19 2016 02:18
I understand thanks
Stephen James
@sjames1958gm
May 19 2016 02:18
@Wkredz1 :+1:
Jaison D. Vieira
@jaisonv
May 19 2016 02:19
Joseph
@revisualize
May 19 2016 02:23
Vick
@vbouloute07
May 19 2016 02:23
what would give me a quotient of 2.2
Joseph
@revisualize
May 19 2016 02:24
1.1 * 2
Jason Keenan
@raavin
May 19 2016 02:24
@jaisonv my only thought is that y
Joseph
@revisualize
May 19 2016 02:24
4.4 / 2
goodm0urning
@goodm0urning
May 19 2016 02:24
Can someone explain why this works giving me a factorial for (of?) 5?

function factorialize(num) {
  if (num === 0) {
    return 1;
  }


  return num * factorialize(num - 1);
}

factorialize(5);
shouldn't that give me 20?
Chris Hoenack
@ChrisHoenack
May 19 2016 02:25
const newCell = oldCell.set('checkbox', !oldCell.get('checkbox'));
Can anyone tell me what !oldCell means?
or !whateverVar for that matter
Is that somehow like a mini if statement or something?
Jaison D. Vieira
@jaisonv
May 19 2016 02:27
@revisualize it is running everything right
Vick
@vbouloute07
May 19 2016 02:27
@revisualize thats what i did didnt let me pass
@revisualize gotchua thanks
CamperBot
@camperbot
May 19 2016 02:28
vbouloute07 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: vbouloute07 already gave revisualize points
mrcsscco
@marcussacco
May 19 2016 02:29
So, I have a pretty peculiar problem with 'Return Largest Nimbers in Arrays'
Moisés Man
@moigithub
May 19 2016 02:29
mrcsscco
@marcussacco
May 19 2016 02:30
Take a look at the console response to this script: https://jsfiddle.net/29omxam7/
Freinet Brutus
@freinet12
May 19 2016 02:30

can someone help me out with this ? function convertToF(celsius) {
// Only change code below this line

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

// Change the inputs below to test your code
convertToF(30);

Jason Keenan
@raavin
May 19 2016 02:30
@jaisonv sorry, didn't finish. Just wondering if it is checking for arr to be returned?? I checked my version but looks like mines been deleted 😟
@jaisonv I have run out of ideas 😞
Moisés Man
@moigithub
May 19 2016 02:31
@marcussacco winners[i] = largest; should be outside the inner loop
var winners = []; should be inside the function
Jaison D. Vieira
@jaisonv
May 19 2016 02:32
@raavin you mean using the same var "arr" that is given as a parameter?
Jason Keenan
@raavin
May 19 2016 02:33
@jaisonv I'd move on and check back in 5 or so hours. That's when the guns are online 😊
@jaisonv only thing I can think of...yes
deebsFCC
@deebsFCC
May 19 2016 02:34
Hey, I have a working answer for the "Return Largest Numbers in Arrays" bonfire. I'm curious if there is a better way to do this or something that can be refactored to improve it. If anyone has any suggestions hit me up :)
function largestOfFour(arr) {

  var largestNum = []; 
  //Loop through array
  for(var i = 0; i < arr.length; i++) {
    //Assign sub array to variable
    var subArray = arr[i];
    //Check for largest number in each sub array and push to largestNum array
    largestNum.push(Math.max.apply(null, subArray));
  }
  return largestNum;
}
mrcsscco
@marcussacco
May 19 2016 02:35
@moigithub thanks, i'm still not sure why it didn't work. the script passes with 2 of the 3 test cases.
CamperBot
@camperbot
May 19 2016 02:35
marcussacco sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1183 | @moigithub |http://www.freecodecamp.com/moigithub
Jaison D. Vieira
@jaisonv
May 19 2016 02:35
@raavin I tried here and had the same result... =/
@raavin are you from the team? you develop the fcc website?
Jason Keenan
@raavin
May 19 2016 02:37
@jaisonv oh no... From memory o used map to iterate through and modify the original array. That's why I thought it might be the key
Joseph
@revisualize
May 19 2016 02:38
@jaisonv I don't understand how or why you're using this
@deebsFCC Let me see if that works and if so.. I'll give you my answer
Jaison D. Vieira
@jaisonv
May 19 2016 02:41
@revisualize ahhahaha "this" takes the second value passed as argument in the filter() function
Joseph
@revisualize
May 19 2016 02:41
@deebsFCC I pm'd you my solution.
Jason Keenan
@raavin
May 19 2016 02:41
@jaisonv I also cheated a bit and only accounted for 3 arguments rather than iterating through them
Joseph
@revisualize
May 19 2016 02:41
I did this:
function destroyer(arr) { 
    // get the values after our initial array, these will be removed.
    // the .slice 1. removes arguments[0] from the new Array
    // arguments[0] is arr and we don't want to remove arr elements.
    var removeThese = Array.prototype.slice.call(arguments, 1);

    // Filter through our array, remove our unwanted values
    // this basically iterates through "arr" and challenges them against
    // our filter function
    return arr.filter(function (v) { 
        // if remove_these does not contain value
        if (removeThese.indexOf(v) === -1) { 
            // return true, since we will be letting this value stay in "arr"
            return true;
        }
    });
}
@jaisonv
@jaisonv It took me 2 hours a day over 4 days... Then I asked for help.. And came to that solution.
Jaison D. Vieira
@jaisonv
May 19 2016 02:44
@raavin ahahah. shhhh. don't tell anyone
Jason Keenan
@raavin
May 19 2016 02:44
;)
Joseph
@revisualize
May 19 2016 02:45
@joemanriquez Did you fix your issue?
Jason Keenan
@raavin
May 19 2016 02:46
@jaisonv try modifying to mutate the original array. I think that is the problem
Jaison D. Vieira
@jaisonv
May 19 2016 02:46
@revisualize wooow. you did a great job!! very simple. i just realised i could use callback with filter and i googled some pages then i found out i could use "this" to access a value passed with the function as filter's parameter.
Joseph
@revisualize
May 19 2016 02:48
I want people to know that it took me about 12 hours of work on JUST that Algo Challenge. To come up with that solution.
It sucked. I don't like it.
Jason Keenan
@raavin
May 19 2016 02:48
@jaisonv see how @revisualize mutates arr
at least I think it does????
Jaison D. Vieira
@jaisonv
May 19 2016 02:49
@raavin well.. actually the filter function doesn't mutate the array. what he did was to return the arr.filter
Jason Keenan
@raavin
May 19 2016 02:50
No idea then 😜
Jaison D. Vieira
@jaisonv
May 19 2016 02:51
@raavin @revisualize i did this and nothing changes
function destroyer(arr) {
  // Remove all the values

  for (var i = 1; i < arguments.length; i++) {
    arr = arr.filter(different, arguments[i]);
  }

  return arr;
}

function different(value) {
  return value !== this;
}
@raavin i saw other people's answer and i can finish this task with their answer. the point is.. my answer is right hahaha
Jason Keenan
@raavin
May 19 2016 02:54
@jaisonv seems to be. Maybe copy your code, reset the challenge and retype it in.
Jaison D. Vieira
@jaisonv
May 19 2016 02:55
i already tried in another browser hehe. i will open an issue on github. let's see what they say
Jason Keenan
@raavin
May 19 2016 02:55
@jaisonv good luck. A couple of hours we won't get back 😩
Jaison D. Vieira
@jaisonv
May 19 2016 02:57
@raavin ahahhaha. thank you very much guy!!! i will let you know when they answer me. you too @revisualize
CamperBot
@camperbot
May 19 2016 02:57
jaisonv sends brownie points to @raavin and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @raavin |http://www.freecodecamp.com/raavin
:star2: 1126 | @revisualize |http://www.freecodecamp.com/revisualize
Jason Keenan
@raavin
May 19 2016 02:57
@jaisonv np, wish I could have helped more
Lusako Njwaba
@lunjwaba1
May 19 2016 03:00
Hello there peeps
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 03:03
@lunjwaba1 hello. welcome
@ChrisHoenack lol
Lusako Njwaba
@lunjwaba1
May 19 2016 03:06
@kakalak-lumberJack thanks
CamperBot
@camperbot
May 19 2016 03:06
lunjwaba1 sends brownie points to @kakalak-lumberjack :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @kakalak-lumberjack |http://www.freecodecamp.com/kakalak-lumberjack
Lusako Njwaba
@lunjwaba1
May 19 2016 03:09
  for(i=0;card<=6;i++) {

    return count + 5 + " Bet";
  }

  for(i=0;card>6 && card <=9;i++) {

    return count + " Hold";
  }

  for(i=0;card==10 || card=="J" || card=="Q" || card=="K" || card=="A";i++) {

    return count -5 + " Hold";
  }
I am stuck at counting cards challenge (basic Javascript section). Anyone got any ideas how to tackle it?
Chris Lacaille
@ChrisL108
May 19 2016 03:11
@lunjwaba1 A 'switch' statement would probably be easier to read/work with
Gabriel
@gdiaz1410
May 19 2016 03:14

Hello everyone. I'm still stuck on this problem (Local Scope and Functions

#181)

Anyone able to help?
KhaiNQ
@nguyenkhai1203
May 19 2016 03:15
hello. i have a problem, can anyone help me?
a declare oppGlobal have value of 5 like that:
oppGlobal=5;
.
but it does not accept.
cannelflow
@cannelflow
May 19 2016 03:18
i guess it is oopsGlobal @nguyenkhai1203
Lusako Njwaba
@lunjwaba1
May 19 2016 03:18
@ChrisHoenack Ok. let me try that. I tried it with a slew of <em>If </em> statements and they were getting long and going nowhere really.
KhaiNQ
@nguyenkhai1203
May 19 2016 03:20
@cannelflow yes. tks pro.
Peter Weinberg
@no-stack-dub-sack
May 19 2016 03:23
I'm sure this is a silly question that will become apparent later on, but why go through the trouble of creating a constructor function when it is simpler to just create the object outright? Unless you are using variables and thus could create several objects at once?
var MotorBike = function() {
  this.wheels = 2;
  this.engines = 1;
  this.seats= 2;

};
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 03:23
@gdiaz1410 where are you stuck exactly?
Gabriel
@gdiaz1410
May 19 2016 03:24
@kakalak-lumberJack just with the whole problem. I can't get out of this problem.

This is what I have function myLocalScope() {
var myLocalScope = //"use strict";

function myVar() {
var myVar = "B";

} ;
console.log(loc);
}
myLocalScope(); //"use strict";
console.log(loc);// "undefined";

// Run and check the console
// myVar is not defined outside of myLocalScope

// Now remove the console log line to pass the test

kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 03:24
@gdiaz1410 did you read the commented out lines in the code? they tell you how to get out
Peter Weinberg
@no-stack-dub-sack
May 19 2016 03:25
@gdiaz1410 help format
Robert Richey
@0x0936
May 19 2016 03:25
@no-stack-dub-sack constructors allow you to create several, similar copies of an object with independent state - their variables can hold different values.
Peter Weinberg
@no-stack-dub-sack
May 19 2016 03:25
help format
CamperBot
@camperbot
May 19 2016 03:25

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Gabriel
@gdiaz1410
May 19 2016 03:25
@kakalak-lumberJack I did but not getting it
Peter Weinberg
@no-stack-dub-sack
May 19 2016 03:26
@0x0936 Thanks, was looking for a brief, simple explanation. Nailed it.
CamperBot
@camperbot
May 19 2016 03:26
no-stack-dub-sack sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1318 | @0x0936 |http://www.freecodecamp.com/0x0936
venkyafhs
@venkyafhs
May 19 2016 03:28
@VultureBetrayer Hi, How did you finish "Selecting from many options with Switch Statements" challenge?
I am not getting this can you help me plz
what value we need to assign val answer=???
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 03:29
@gdiaz1410 make sure you are removing the correct console.log line (the one outside of the function
Gabriel
@gdiaz1410
May 19 2016 03:31
@kakalak-lumberJack wow finally thanks!
CamperBot
@camperbot
May 19 2016 03:31
gdiaz1410 sends brownie points to @kakalak-lumberjack :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @kakalak-lumberjack |http://www.freecodecamp.com/kakalak-lumberjack
Gabriel
@gdiaz1410
May 19 2016 03:32
I'm pretty confused with javascript because I can't really see the effects it is having on a web page.
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 03:32
@gdiaz1410 the console.log is trying to call myVar but can't find it because it is local to the function. thats why it was stuck :)
@gdiaz1410 you might like khan academy's javascript program that focusing on drawing and animation
Gabriel
@gdiaz1410
May 19 2016 03:33
sweet. I'll check it out. Thanks again
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 03:33
no problem
Anteli
@Anteli
May 19 2016 03:36
Hello! I'm having problems to get my calculator keyboard input work on Firefox. With Safari, Chrome and Vivaldi it works as expected. You should be able to use 1234567890 on the keyboard to give numbers to the calculator. https://jsfiddle.net/0uy7rjca/
Any ideas? Thanks for help!
Victor
@abeledovictor
May 19 2016 03:39

Hi guys !! need help with Make Unique Objects by Passing Parameters to our Constructor


var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(2,6,3);

instructions: Alter the Car constructor to use parameters to assign values to the wheels, seats, and engines properties.

Then call your new constructor with three number arguments and assign it to myCar to see it in action.

William Coleman
@wcski
May 19 2016 03:40
Do you need double quotes around each string in a js object?
I'm used to seeing the object written as
var myObj {
"example": "number one";
}
but in the setup for the 'Testing Objects for Property' exercise the object is as follows
Matthew Hand
@mmhand123
May 19 2016 03:42
the key doesn't need quotes, but the value does
so you can do var my obj { example: 'number one' };
William Coleman
@wcski
May 19 2016 03:42
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
gotcha
is there a best practice?
or just whatever the style is for the project you're working on (say, for a company or whatever)
Diego Mayer
@Chrono79
May 19 2016 03:43

@jaisonv

function destroyer(arr) {
  // Remove all the values

  for (var i = 1; i < arguments.length; i++) {
      arr = arr.filter(different, { key: arguments[i] });
  }

  return arr;
}

function different(value) {
  return value !== this.key;
}  

destroyer([1,2,3,4,5],2,3);

Afaik, the optional parameter of Array.filter should be an object, when you used a number it converted it to an empty object

Vick
@vbouloute07
May 19 2016 03:44
what does the instructions means:
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Matthew Hand
@mmhand123
May 19 2016 03:44
@Anteli try using jquery for the key handlner
Diego Mayer
@Chrono79
May 19 2016 03:49
@vbouloute07 you have to translate that using the table in the challenge description
tab tab is \t \t
Vick
@vbouloute07
May 19 2016 03:50
@Chrono79 oh ok thanks
CamperBot
@camperbot
May 19 2016 03:50
vbouloute07 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 768 | @chrono79 |http://www.freecodecamp.com/chrono79
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 03:54
@abeledovictor I just finished that one. did you figure it out?
Tien
@TienDo1011
May 19 2016 03:55
i'm doing check for palindromes, but it didn't work, can anybody give me a hand:
function palindrome(str) {
  // Good luck!
  var newStr = str.toLowerCase();
  var newStr2 = newStr.replace(/\W+_/g,"");
  var newStr3 = newStr2.split("");
  var newStr4 = newStr3.reverse();
  var newStr5 = newStr4.join("");
  return newStr5 === str;
}


palindrome("eye");
Marvellous Ubani
@MarvellousUbani
May 19 2016 03:55

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i<contacts.length; i++){
    if(contacts[i][prop]&&contacts[i]["firstName"]===firstName){
     return contacts[i][prop];  
    }

    else if(firstName!== contacts[i]["firstName"]){
    return "Never";
    }

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




  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
HELP PLEASE!!! I feel under the hood the loop checks each object one after the other and the first
result is likely being used to judge others, how do I fix this please....
eeflores
@eeflores
May 19 2016 03:56
@TienDo1011 regexp /[\W_]+/g
Tien
@TienDo1011
May 19 2016 03:56
@eeflores : why so?
and it still didn't work :(
eeflores
@eeflores
May 19 2016 03:57
@TienDo1011 actually it can probably be /[\W_]/g
@TienDo1011 you don't want the final comparison to be with str
@TienDo1011 probably compare newStr2 === newStr5
Victor
@abeledovictor
May 19 2016 03:58
@kakalak-lumberJack yes! thanks, Im with the motorbike one now
CamperBot
@camperbot
May 19 2016 03:58
abeledovictor sends brownie points to @kakalak-lumberjack :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @kakalak-lumberjack |http://www.freecodecamp.com/kakalak-lumberjack
Tien
@TienDo1011
May 19 2016 03:59
@eeflores : amazing! thank you
CamperBot
@camperbot
May 19 2016 03:59
tiendo1011 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 729 | @eeflores |http://www.freecodecamp.com/eeflores
Victor
@abeledovictor
May 19 2016 03:59
you passed that one?
eeflores
@eeflores
May 19 2016 03:59
you're welcome
Tien
@TienDo1011
May 19 2016 04:00
@eeflores : can u tell me why i have to use [] in regex?
eeflores
@eeflores
May 19 2016 04:01
@TienDo1011 the brackets define a set ...
@TienDo1011 if you had /[ab]/g and /ab/g, the second one will match specifically to "ab" whereas the first will match to either "a" or "b"
Marvellous Ubani
@MarvellousUbani
May 19 2016 04:02

//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][prop]&&contacts[i]["firstName"]===firstName){
     return contacts[i][prop];  
    }


  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Harry", "likes");
HELP ME FIGURE THIS OUT PLEASE
Tien
@TienDo1011
May 19 2016 04:03
@eeflores : i see, thank you!
CamperBot
@camperbot
May 19 2016 04:03
tiendo1011 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:warning: tiendo1011 already gave eeflores points
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 04:04
@MarvellousUbani you need to access the array after the === you only need the variable before
eeflores
@eeflores
May 19 2016 04:04
This message was deleted
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 04:05
*object not array
Victor
@abeledovictor
May 19 2016 04:06

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 = 0;
  // Only change code below this line.
  this.getGear = function() {
    return gear;
  };
  this.setGear = function(change) {
    gear+= change;
  };
};

var myCar = new Car();

var myBike = new Bike();

myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).

what im missing???

Matthew Hand
@mmhand123
May 19 2016 04:08
using += is going to keep incrementing the value
Anteli
@Anteli
May 19 2016 04:09

@mmhand123 Do you mean like this?

       document.keypress(function(event) {
         // switch statement
        });
      });

It doesn't seem to work neither :/

Matthew Hand
@mmhand123
May 19 2016 04:11
@Anteli try $(document).on('keypress', function(event) {
Victor
@abeledovictor
May 19 2016 04:14
@mmhand123 what should i change it for? just = ???
Anteli
@Anteli
May 19 2016 04:17
@mmhand123 $(document).on('keypress', function(event) {
works fine on other browsers, but still not on Firefox.
Matthew Hand
@mmhand123
May 19 2016 04:18
what event method are you using to determine the keypress?
@abeledovictor yea try that!
Zach
@Moose1551
May 19 2016 04:20
In the bonfire challenge "Mutations," I can pass everything except for the first test. Can someone guide me a bit?

function mutation(arr) {
  var element0 = arr[0].toLowerCase();
  var element1 = arr[1].toLowerCase();

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


    if (element0.indexOf(element1[i]) != -1) {
      return true;
    } else {
      return false;
    }  
  }                    
}

mutation(["hello", "hey"]);
Victor
@abeledovictor
May 19 2016 04:21
@mmhand123 thanks!
CamperBot
@camperbot
May 19 2016 04:21
abeledovictor sends brownie points to @mmhand123 :sparkles: :thumbsup: :sparkles:
:cookie: 117 | @mmhand123 |http://www.freecodecamp.com/mmhand123
bitgrower
@bitgrower
May 19 2016 04:24
arr length is wrong in your loop .. you want to do it the length of element1 ...
Zach
@Moose1551
May 19 2016 04:25
Thanks, @bitgrower !
CamperBot
@camperbot
May 19 2016 04:25
moose1551 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1056 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 19 2016 04:27
This message was deleted
Anteli
@Anteli
May 19 2016 04:28
what event method are you using to determine the keypress? @mmhand123 I have tried .keypress() and .keydown() if that's what you mean.
Zach
@Moose1551
May 19 2016 04:32
@bitgrower , I applied your changes and got the same result:(
lol
David Shavers
@frontEndDevv
May 19 2016 04:33
hey guys i'm trying to generate a random number but the system isn't accepting my code. what ami doing wrong?? function () { return Math.random(); }
Anteli
@Anteli
May 19 2016 04:36

@mmhand123 I think it works now, using

$(document).keydown(function (event) {

Thanks for help!

CamperBot
@camperbot
May 19 2016 04:36
anteli sends brownie points to @mmhand123 :sparkles: :thumbsup: :sparkles:
:cookie: 118 | @mmhand123 |http://www.freecodecamp.com/mmhand123
Vick
@vbouloute07
May 19 2016 04:41
how it this wrong:
var myStr = "This is the first sentence. " += "This is the second sentence.";
Victor
@abeledovictor
May 19 2016 04:44

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var plusThree = oldArray.map(function(val){
  return val + 3;
});
var newArray = oldArray;
how can i add 3 to each value on the array and not just to one?
DJ
@qualitymanifest
May 19 2016 04:48
@abeledovictor you already are. plusThree is the array you want
oldArray is never actually changing
Victor
@abeledovictor
May 19 2016 04:49
fcc tells me that "You should add three to each value in the array."
DJ
@qualitymanifest
May 19 2016 04:50
@abeledovictor what challenge is this
Victor
@abeledovictor
May 19 2016 04:50
with the code i showed
Iterate over Arrays with map
DJ
@qualitymanifest
May 19 2016 04:50
alright let me look. i'm guessing you're just not returning the array name they want

@abeledovictor yeah:

Use the map function to add 3 to every value in the variable oldArray, and save the results into variable newArray. oldArray should not change.

so rather than var plusThree = oldArray.map...etc you need to do var newArray = oldArray.map...etc
Victor
@abeledovictor
May 19 2016 04:53
@qualitymanifest

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var newArray = oldArray.map(function(val){
  return val + 3;
});
var newArray = oldArray;
DJ
@qualitymanifest
May 19 2016 04:54
@abeledovictor don't reassign newArray to oldArray
Victor
@abeledovictor
May 19 2016 04:54
@qualitymanifest that was it thank you!
CamperBot
@camperbot
May 19 2016 04:54
abeledovictor sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1169 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
May 19 2016 04:54
np
OceanMountains
@OceanMountains
May 19 2016 04:59

Still figuring this one out, been stuck on it for a couple days. I know I am getting closer, but right now my output of "artist" : "ABBA" is appearing in a blank section at the end of my object. I need to be able to check if that "id" already exists then append the "value" and "prop" to it if it exists. I am trying to use the obj.hasOwnProperty() method to do this but still can't quite get it. I try appending to the collections object but nothing comes out in my output. Any hints or ideas?

Instruction:
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 !== "") and prop is not "tracks" then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Note
Don't forget to use bracket notation when accessing object properties with variables.

CamperBot
@camperbot
May 19 2016 04:59
:bulb: to format code use backticks! ``` more info
OceanMountains
@OceanMountains
May 19 2016 05:00
This message was deleted


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

// Only change code below this line
function updateRecords(id, prop, value) {
  for (id in collection)  {

    if (collection.hasOwnProperty(id)){
     // some more code here //
    }


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

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

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

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Jaison D. Vieira
@jaisonv
May 19 2016 05:05
@Chrono79 it doesn't work here
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 05:06
@OceanMountains its a beast :) a couple things i see. in your if conditions the first part left of the === is referencing the var in the function so you don't need call the object collection,etc.
OceanMountains
@OceanMountains
May 19 2016 05:08
ok cool, that is good to know. thank you @kakalak-lumberJack.
CamperBot
@camperbot
May 19 2016 05:08
:cookie: 257 | @kakalak-lumberjack |http://www.freecodecamp.com/kakalak-lumberjack
oceanmountains sends brownie points to @kakalak-lumberjack :sparkles: :thumbsup: :sparkles:
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 05:08
@OceanMountains also make sure you include the [id] index when you are accessing the objects after collections and before prop
OceanMountains
@OceanMountains
May 19 2016 05:12
I'm not sure I understand what you mean. So something like if (collection[1][prop] == "tracks")?
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 05:13
for example...
if (value !== "" && prop !=="tracks") {
   collection[id][prop] = value;
 }
OceanMountains
@OceanMountains
May 19 2016 05:14
ahhhhhhhhh ok, now I see.
Kevin Holmes
@codersc
May 19 2016 05:14

http://codepen.io/sc_developer/pen/QNXwRr?editors=0001

$(document).ready( function() {

  var baseURL = "https://api.twitch.tv/kraken";

  var channels = ["freecodecamp", "storbeck", "terakilobyte", "habathcx","RobotCaleb","thomasballinger","noobs2ninjas","beohoff","callofduty"];

  var APICall;

  var activeAccts = [];

  channels.forEach(function(channel) {

    APICall = baseURL + "/streams/" + channel;        

    $.getJSON( APICall, function( data ) {      

      //console.log(data);

      if (data.stream === null) {               

        $("#content").append("<h1><a href='https://www.twitch.tv/" + channel + "' target='_blank'>" + channel + "</a></h1><h2>Offline</h2>"); 

        activeAccts.push(channel);

      }

      else {

        $("#content").append("<h1>" + channel + "</h1><h2>Streaming Now</h2><h3>" + data.stream.game + " Viewers: " + data.stream.viewers + "</h3>");

        activeAccts.push(channel);

      }

    } );

  } );  

  console.log(activeAccts);

} );

please help why cant i simply push a string into an array in my code? when i log the value it says the array is empty but i don't see how thats posible because it is adding content to the page

OceanMountains
@OceanMountains
May 19 2016 05:16
You're awesome @kakalak-lumberJack
Marvellous Ubani
@MarvellousUbani
May 19 2016 05:19

var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
     count++;
      break;

    case 7:
    case 8:
    case 9:
     count+=0;
      break;

    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
     count--;
      break;


  }

  if(card>0){
    return count + " Bet";
  }
  else{
   return count + " Hold"; 
  }


  return "Change Me";

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2);
cc(3);
cc(7);
cc("K"); 
cc("A");
NEED HELP FIXING THIS
Cards Sequence 7, 8, 9 should return --but it doesnt
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 05:19
@OceanMountains it was me asking the same questions a couple days ago...just passing the knowledge along :)
Marvellous Ubani
@MarvellousUbani
May 19 2016 05:19
it should return "0 Hold"
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 05:22
@OceanMountains count += 0 is the same as saying count = count + 0. so you don't need to change count
Ankur sharma
@ankur1163
May 19 2016 05:25
I have a question
reduce function basically return one value and works on array
But I am working on code
function sym() {
  var args = Array.prototype.slice.call(arguments);

  // Return the symmetric difference of 2 arrays
  var getDiff = function(arr1, arr2) {

    // Returns items in arr1 that don't exist in arr2
    function filterFunction(arr1, arr2) {
      return arr1.filter(function(item) {
        return arr2.indexOf(item) === -1;
      });
    }

    // Run filter function on each array against the other then get unique values
    return filterFunction(arr1, arr2)
      .concat(filterFunction(arr2, arr1))
      .filter(function(item, idx, arr) {
        // Keep any items that are unique - the index of the current item === index of the first occurrence in the array
        return arr.indexOf(item) === idx;
      });
  };

  // Reduce all arguments getting the difference of them
  return args.reduce(getDiff, []);
}

sym([1, 2, 3], [5, 2, 1, 4]);
when reduce is applied here
it returns array
why it is so?
Markus Kiili
@Masd925
May 19 2016 05:29
@ankur1163 The reduce method can return a value of any type. You specify the initial running value to be [] and the later running values to be arrays too. Also the last running value (reduce return value) is therefore also an array.
Joseph
@revisualize
May 19 2016 05:33
@OceanMountains
// Write a function which takes:
//  an id, a property (prop), and a value.
function updateRecords(id, prop, value) {
// If value is non-blank (value !== "") 
// and prop is not "tracks" 
// then update or set the value for the prop.
    // Your code here

// If the prop is "tracks" and value is non-blank,
// push the value onto the end of the tracks array.
    // Your code here

// If value is blank, 
// delete that prop.
    // Your code here

// Always return the entire collection object.
  return collection;
}
Ankur sharma
@ankur1163
May 19 2016 05:33
oh sorry I pasted wrong code. This solution also works. But, here's the code I want to understand @Masd925

function sym() {
 var args = [];
    for (var i = 0; i < arguments.length; i++) {
        args.push(arguments[i]);
    }

    function symDiff(arrayOne, arrayTwo) {
        var result = [];

        arrayOne.forEach(function(item) {
            if (arrayTwo.indexOf(item) < 0 && result.indexOf(item) < 0) {
                result.push(item);
            }
        });

        arrayTwo.forEach(function(item) {
            if (arrayOne.indexOf(item) < 0 && result.indexOf(item) < 0) {
                result.push(item);
            }
        });

        return result;
    }

    return args.reduce(symDiff);    
}

sym([1, 2, 5], [2, 3, 5], [3, 4, 5]);
Joseph
@revisualize
May 19 2016 05:33
@OceanMountains Read the text. It writes the function for you.
Ankur sharma
@ankur1163
May 19 2016 05:34
when we use args.reduce(symdiff)
does it take any initial value? like we usually have total in other reduce examples?
we are applying reduce method to every element of args and passing symdiff function
now in this case , by every element it means 3 arrays
OceanMountains
@OceanMountains
May 19 2016 05:35
Thanks Joseph Tracy, but I've already tried that a few times. If I can figure it out by reading it then I don't come to the help forum.
Ankur sharma
@ankur1163
May 19 2016 05:35
so, it picks first array , apply symdiff and put result in new array
Joseph
@revisualize
May 19 2016 05:35
@OceanMountains What is your current code?
@OceanMountains Just the function.
I don't need to see the object.
Ankur sharma
@ankur1163
May 19 2016 05:36
then again it picks second array apply symdiff and put result in same total array
Markus Kiili
@Masd925
May 19 2016 05:36
@ankur1163 If you don't specify an initial value, the first element becomes the running value and the second element the first current element being iterated.
OceanMountains
@OceanMountains
May 19 2016 05:36
function updateRecords(id, prop, value) {
  for (id in collection)  {

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

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

    if (value === "") {
    delete collection[prop];
    }
  }  
  return collection;
}
Joseph
@revisualize
May 19 2016 05:36
@OceanMountains That isn't correct.
Markus Kiili
@Masd925
May 19 2016 05:37
@OceanMountains You don't need a loop.
@OceanMountains Just 2 or 3 if's that test value and prop and then you access collection on if blocks.
Joseph
@revisualize
May 19 2016 05:37
// If value is non-blank (value !== "") 
// and prop is not "tracks" 
// then update or set the value for the prop.
    // Your code here
if (value !== "" && props !== "tracks")
The collection has nothing to do with it for the evaluation.
Also.. Remove the for loop.

@OceanMountains Also..

// If the prop is "tracks" and value is non-blank,
// push the value onto the end of the tracks array.
    // Your code here

... remove the collection from that code too.. It isn't what is being evaluated.

OceanMountains
@OceanMountains
May 19 2016 05:39
All right, thank you, well I guess I misinterpreted "For the given id in collection:" when I read it @revisualize.
CamperBot
@camperbot
May 19 2016 05:39
oceanmountains sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1127 | @revisualize |http://www.freecodecamp.com/revisualize
Ankur sharma
@ankur1163
May 19 2016 05:40
i got it now
thanks @Masd925
CamperBot
@camperbot
May 19 2016 05:40
ankur1163 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1535 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
May 19 2016 05:40
@OceanMountains Also, you're missing the ID in your second if truth.
Markus Kiili
@Masd925
May 19 2016 05:41
@ankur1163 The parameters of reduce callback are the running value and the element being iterated. The return value is the next running value.
OceanMountains
@OceanMountains
May 19 2016 05:44
Ok @revisualize I edited out the collections.
Joseph
@revisualize
May 19 2016 05:47
@OceanMountains What's your current code?
Please tell me that you didn't remove ALL of the collections.
OceanMountains
@OceanMountains
May 19 2016 05:50
When I try to run it I'm still getting a type error with the push method so I need to look over that syntax again.
function updateRecords(id, prop, value) {

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

    if ((prop == "tracks") && (value !== "")) {
      id.tracks.push.value;
    }

    if (value === "") {
    delete collection[prop];
    }
  return collection;
}
Markus Kiili
@Masd925
May 19 2016 05:51
@OceanMountains You are not accessing collection when you push.
revisualize @revisualize exits stage left.
Joseph
@revisualize
May 19 2016 05:51
Yeah..
It's my bed ... time.
How do you push an item to an object or an array??
OceanMountains
@OceanMountains
May 19 2016 05:52
Well thank you for the help @revisualize .
CamperBot
@camperbot
May 19 2016 05:52
oceanmountains sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: oceanmountains already gave revisualize points
Joseph
@revisualize
May 19 2016 05:52

Why is this correct

collection[id][prop] = value;

But... Then.. you do this...

id.tracks.push.value;
buiphuking
@buiphuking
May 19 2016 05:52
@Masd925
i fixed my calculator, thanks!
CamperBot
@camperbot
May 19 2016 05:52
buiphuking sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1536 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
May 19 2016 05:53
@OceanMountains You're also missing the id in your delete.
OceanMountains
@OceanMountains
May 19 2016 05:53
I'm guessing it's because I'm misreading it.
misreading the instructions*.
Joseph
@revisualize
May 19 2016 05:54

@OceanMountains

var myArr = [0,2,4];

How do I push 6 to the end of that array?

myArr.push(6);
Douglas Dunn
@DouglasDunn
May 19 2016 05:59

function rot13(str) {
var newStr = "";
var counter = 0;
/
for (var i = 0; i < str.length - 1; i++)
{
newStr = newStr + str.charCodeAt(i) + ", ";
counter++;
}
newStr += str.charCodeAt(counter);
/
var array = [];

for (var i = 0; i < str.length; i++)
{
if (str.charCodeAt(i) < 65 || str.charCodeAt(i) > 90)
{
array.push(str.charCodeAt(i));
/*
if (str.charCodeAt(i) > 90)
{

    }
    */
  }
  else
  {
      var num;
      //array.push(str.charCodeAt(i) + 13);
      num = str.charCodeAt(i) + 13;
      if (num > 90)
       {
           num = num - 90 + 65;
       }
    array.push(num);
  }

}
array = array.join(", ");
return String.fromCharCode(array);
}

// Change the inputs below to test
rot13("SERR YBIR?");

sorry ignore that
Kyle W Pilkinton
@tadake
May 19 2016 06:00
hey guys on code pen when ever i click a button that i have on my document it reloads th page? why is this?
Douglas Dunn
@DouglasDunn
May 19 2016 06:00
i was wondering how to copy and paste my code on here
Kyle W Pilkinton
@tadake
May 19 2016 06:01
put ``` before and after @DouglasDunn
shift + enter to make a newline
Markus Kiili
@Masd925
May 19 2016 06:01
explain format
CamperBot
@camperbot
May 19 2016 06:01

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 06:01
@tadake are the buttons to links to outside pages?
OceanMountains
@OceanMountains
May 19 2016 06:02

@revisualize the instructions I am really getting lost with is this 'If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.'

The reason this confuses me is that every time I try to push to the tracks array I get a ReferenceError telling me that tracks isn't defined, even though I can see it above in the collection object.

Kyle W Pilkinton
@tadake
May 19 2016 06:03
no its a button on a search bar
  <form id="form">
                <div class="input-group input-group-lg featurette featurette-inner text-center ">
                    <span class="input-group-btn">
                        <button class="btn btn-danger input-group input-group-lg featurette featurette-inner text-center" >Search</button>
                    </span>
                    <input type="text" name="id" id="searchbar" class="form-control" placeholder="Search....." />
                </div>
</form>
OceanMountains
@OceanMountains
May 19 2016 06:04
function updateRecords(id, prop, value) {

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

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

    if (value === "") {
    delete collection[id][prop];
    }
  return collection;
}
Joseph
@revisualize
May 19 2016 06:04
// Write a function which takes:
//  an id, a property (prop), and a value.
function updateRecords(id, prop, value) {
// If value is non-blank (value !== "") 
// and prop is not "tracks" 
// then update or set the value for the prop.
    // Your code here

// If the prop is "tracks" and value is non-blank,
// push the value onto the end of the tracks array.
    // Your code here

// If value is blank, 
// delete that prop.
    // Your code here

// Always return the entire collection object.
  return collection;
}
@OceanMountains Read the text ... your second if truth isn't correct.
You're not pushing anything.
OceanMountains
@OceanMountains
May 19 2016 06:05
Every time I try to push something I get an error.
Let me try again.
Joseph
@revisualize
May 19 2016 06:06
@OceanMountains collection[id][prop].push(value); ... This gives you an error??????????????
I do NOT believe you.
collection[id][tracks] = value;
I mean.. tracks isn't a variable. But.. Whatev's.
OceanMountains
@OceanMountains
May 19 2016 06:08
I appreciate your help, but if you look above the first example of all of these contained: "if ((collection[prop] == "tracks") && (collection[value] !== "")) {
collection.tracks.push(value);
}
"
Joseph
@revisualize
May 19 2016 06:08
collection[id][prop] = value;
vs
collection[id][tracks] = value;
to...
delete collection[id][prop];
...
...
where you got tracks.. No idea. But, Okay.
Kyle W Pilkinton
@tadake
May 19 2016 06:09
This is the link to the code pen. I cant figure out why my page keeps reloading.
http://codepen.io/tadake/pen/regOgK?editors=1010
Joseph
@revisualize
May 19 2016 06:09
@OceanMountains
// Only change code below this line
function updateRecords(id, prop, value) {
  // If value is non-blank (value !== "") and 
  // prop is not "tracks" 
  // then update or set the value for the prop.
  if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  }
  // If the prop is "tracks" and value is non-blank, 
  // push the value onto the end of the tracks array.
  else if (prop === "tracks" && value !== "") {
    collection[id][prop].push(value);
  }
  // If value is blank, 
  // delete that prop.
  else if (value === "") {
    delete collection[id][prop];
  }
  // Always return the entire collection object.
  return collection;
}

...

@OceanMountains
I appreciate your help, but if you look above the first example of all of these contained: "if ((collection[prop] == > "tracks") && (collection[value] !== "")) {
collection.tracks.push(value);
}
"
And I told you that was wrong.

OceanMountains
@OceanMountains
May 19 2016 06:10
And yes, you were correct. That finally did the trick. You were right. I guess this all really came down to the fact that all examples separate a lot of push notation and dot notation so I guess I'm just no good at combining the two notations together so far.
separate a lot of bracket* notation and dot notation
Joseph
@revisualize
May 19 2016 06:11
@OceanMountains Where is dot notation used in this assessment?
Keone Martin
@Athaman
May 19 2016 06:11
don't worry about it @OceanMountains a lot of people struggle with the different notations
Joseph
@revisualize
May 19 2016 06:12
Dot Notation VS Bracket Notation is EASY.
Keone Martin
@Athaman
May 19 2016 06:12
bro, that's not helpful
Joseph
@revisualize
May 19 2016 06:12
myObj.this; is the same as myObj["this"];
If you need to use a variable.
OceanMountains
@OceanMountains
May 19 2016 06:12
collection[id][prop].push(value);
Markus Kiili
@Masd925
May 19 2016 06:13
@OceanMountains The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
Joseph
@revisualize
May 19 2016 06:13
var that = "Frank";
myObj[that];
OceanMountains
@OceanMountains
May 19 2016 06:13
that's where.
Joseph
@revisualize
May 19 2016 06:13
@OceanMountains That isn't dot notation. That is a method call.
The push() method adds one or more elements to the end of an array and returns the new length of the array.
Ajith
@ajithvallabai
May 19 2016 06:14
algoritm :Dna pairing .. iam getting paired but in a single array what to do to make it in multiple arrays

function pairElement(str) {
  var tim=[];
  var stm=[],stm1=[],stm2=[],stm3=[];
  var yhn=[];
  tim=str.split("");
  for(i=0;i<str.length;i++)
    {
      if(str[i]=='G')
        {
          stm.push(str[i]+','+'C');
        }
      else if(str[i]=='C')
        {
           stm.push(str[i]+','+'G');
        }
      else if(str[i]=='A')
        {
          stm.push(str[i]+','+'T');
        }
      else if(str[i]=='T')
        {
          stm.push(str[i]+','+'A');
        }
    }


  return stm;
}

pairElement("ATCGA");
Joseph
@revisualize
May 19 2016 06:14
Object Push methods are the same as array push methods.
because.. arrays are objects.
Marvellous Ubani
@MarvellousUbani
May 19 2016 06:14

var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
     count++;
      break;

    case 7:
    case 8:
    case 9:
     count+=0;
      break;

    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
     count--;
      break;


  }

  if(card>=0){
    return count + " Bet";
  }
  else{
   return count + " Hold"; 
  }


  return "Change Me";

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2);
cc(3);
cc(7);
cc("K"); 
cc("A");
this is really frustrating and worse still no one has helped me out with the answer to this so far..
Joseph
@revisualize
May 19 2016 06:15
@MarvellousUbani You're almost done.
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 06:15
@MarvellousUbani i sent you an answer...sorry if you missed it
Joseph
@revisualize
May 19 2016 06:16
@MarvellousUbani Why are you modifying count but your if evaluation is against card.
@MarvellousUbani change card to count in your if statement and.. done.
OceanMountains
@OceanMountains
May 19 2016 06:16
yes, again you're right. Proving for the 15th time tonight that you know more about this than I do. Again, I appreciate the help. I'm going to bed now, good night.
Joseph
@revisualize
May 19 2016 06:17
What the fuck? Did I do something wrong?
Markus Kiili
@Masd925
May 19 2016 06:17
@revisualize What is "Object Push method" ?
Ujjwal Sharma
@ryzokuken
May 19 2016 06:17
@revisualize try keeping the chatroom f-word free
Joseph
@revisualize
May 19 2016 06:18
@Masd925 .push()
Markus Kiili
@Masd925
May 19 2016 06:18
@revisualize Objects don't have .push() method. Only arrays have (Objects that inherit from Array.prototype).
Joseph
@revisualize
May 19 2016 06:19
@Masd925 What is an array?
What is the typeOf an array?
(object)
Ajith
@ajithvallabai
May 19 2016 06:20
could any one help me i dont know how to make array with in array

function pairElement(str) {
  var tim=[];
  var stm=[],stm1=[],stm2=[],stm3=[];
  var yhn=[];
  tim=str.split("");
  for(i=0;i<str.length;i++)
    {
      if(str[i]=='G')
        {
          stm.push(str[i]+','+'C');
        }
      else if(str[i]=='C')
        {
           stm.push(str[i]+','+'G');
        }
      else if(str[i]=='A')
        {
          stm.push(str[i]+','+'T');
        }
      else if(str[i]=='T')
        {
          stm.push(str[i]+','+'A');
        }
    }
  for(i=0;i<stm.length;i++)
    {
      yhn.push(stm[i]);
    }


  return yhn;
}

pairElement("ATCGA");
Joseph
@revisualize
May 19 2016 06:21

@Masd925

@revisualize
Object Push methods are the same as array push methods.
because.. arrays are objects.

Markus Kiili
@Masd925
May 19 2016 06:22
@revisualize That is because there are only primitive types and object type in JS. All objects inherit from Object prototype but only arrays inherit from Array.prototype (where push is).
Joseph
@revisualize
May 19 2016 06:22
var myArr = [1,2];
typeof(myArr);
Markus Kiili
@Masd925
May 19 2016 06:23
var obj = {};
obj.push(5); // TypeError: obj.push is not a function
sumit sinha
@sumitsinha91
May 19 2016 06:24
hello
i need help omn js and css
Joseph
@revisualize
May 19 2016 06:24
@Masd925 Ok.
@Masd925 Technically, I guess you're correct because with this lesson you're supposed to push the value into the array within the object.
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  // If value is non-blank (value !== "") and 
  // prop is not "tracks" 
  // then update or set the value for the prop.
  if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  }
  // If the prop is "tracks" and value is non-blank, 
  // push the value onto the end of the tracks array.
  else if (prop === "tracks" && value !== "") {
    collection[id][prop].push(value);
  }
  // If value is blank, 
  // delete that prop.
  else if (value === "") {
    delete collection[id][prop];
  }
  // Always return the entire collection object.
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

/*
The fucntion could also be written like this:

function updateRecords(id, prop, value) {
  if (value !== '') {
      if (prop === 'tracks') {
          collection[id][prop].push(value);
      } else {
          collection[id][prop] = value;
      }
  } else {
    delete collection[id][prop];
  }
  return collection;
}

*/
Markus Kiili
@Masd925
May 19 2016 06:27
@revisualize Yes, there you find the array and push to it.
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 06:27
@MarvellousUbani the problem in in your if statement it should be if (count >0) instead of if (count>=0)
Ajith
@ajithvallabai
May 19 2016 06:29
guys could anyone help me with DNA pairing
Joseph
@revisualize
May 19 2016 06:30
@ajithvallabai I just did it the easy way.
function pairElement(str) {
  var result = [];
  for (var i = 0; i < str.length; i += 1) {
    if (str[i] === "A") {
      result.push(["A", "T"]);
    } else if (str[i] === "T") {
      result.push(["T", "A"]);
    } else if (str[i] === "C") {
      result.push(["C", "G"]);
    } else if (str[i] === "G") {
      result.push(["G", "C"]);
    }
  }
  return result;
}
Ajith
@ajithvallabai
May 19 2016 06:31
thas cool :clap:
is there any way to go with my method @revisualize
Joseph
@revisualize
May 19 2016 06:32
Not that giving you the answer really helps you learn anything.
@ajithvallabai No idea.
Markus Kiili
@Masd925
May 19 2016 06:32
@revisualize This shows the prototype chain of an array. That is why arrays have all the object methods and array methods:
var obj = [];

var proto1 = Object.getPrototypeOf(obj); 
var proto2 = Object.getPrototypeOf(proto1); 
var proto3 = Object.getPrototypeOf(proto2);

proto1 === Array.prototype;  // true
proto2 === Object.prototype; // true
proto3 === null;             // true
Jevaughn Vance
@jvans7
May 19 2016 06:32
just a random question! as any of you uploaded your portfolio as a real website and if yes what did you use? thank
Greg
@GregJacoby
May 19 2016 06:32
hi everyone
im using this api http://quotes.stormconsultancy.co.uk/random.json for a random quote machine
Ajith
@ajithvallabai
May 19 2016 06:33
thanks @revisualize
CamperBot
@camperbot
May 19 2016 06:33
ajithvallabai sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1128 | @revisualize |http://www.freecodecamp.com/revisualize
Greg
@GregJacoby
May 19 2016 06:33
how come var.quote isn't giving me the quote from that?
it works when i console log it, but codepen generates nothing
Joseph
@revisualize
May 19 2016 06:33
@Masd925 You're still going on about that?
Yuval
@unc0mm0n
May 19 2016 06:34
I misread the question about Fibonacci numbers and tried to sum up to the 4 millionth fibonacci number. Oops..
Joseph
@revisualize
May 19 2016 06:34
@unc0mm0n How long did that take to run?
Yuval
@unc0mm0n
May 19 2016 06:35
@revisualize My browser crashed long before it could finish. No idea how long it survived
Joseph
@revisualize
May 19 2016 06:36
@jvans7 I used my own webhost that I pay for each month.
Yuval
@unc0mm0n
May 19 2016 06:37
@GregJacoby You are missing the http:// part of the url. After that you need to deal with the CORS problem, which I'm not certain about myself.
Jevaughn Vance
@jvans7
May 19 2016 06:38
@revisualize ok i'm trying to get the free stuff lol
Joseph
@revisualize
May 19 2016 06:38
@jvans7 Github Pages?
Greg
@GregJacoby
May 19 2016 06:38
@unc0mm0n yeah I just removed the http to test if it would work that way. what do you mean the CORS problem? what's that? the last api i tried was working great but it wasn't a free API so it wouldn't give me more than one quote
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 06:40
@GregJacoby I haven't gotten to that project yet so take this for what it worth...just an idea...but wouldn't there need to be some sort of html element to render quote at text on the page?
Yuval
@unc0mm0n
May 19 2016 06:40

@GregJacoby When you get the error message:

XMLHttpRequest cannot load http://quotes.stormconsultancy.co.uk/random.json?jsonp. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.

it's because Cross Origin Resource Sharing (CORS) requests are blocked by the server. https://en.wikipedia.org/wiki/Cross-origin_resource_sharing has more info. Usually you can get around it by setting the data type to JSONP but it doesn't seem to work with this server so I'm note sure

Greg
@GregJacoby
May 19 2016 06:41
@unc0mm0n how did you get that message? clearly my debugging approach is behind the times in terms of APIs
@kakalak-lumberJack that's really important - that's why I have the simple empty <div> to test if it works!
Yuval
@unc0mm0n
May 19 2016 06:42
@GregJacoby Go to the console (ctrl+shift+i on chorme, not sure on firefox). It's an important tool, as you can put any information there by using console.log(anything).
Greg
@GregJacoby
May 19 2016 06:43
@unc0mm0n excellent, thank you
CamperBot
@camperbot
May 19 2016 06:43
:cookie: 298 | @unc0mm0n |http://www.freecodecamp.com/unc0mm0n
gregjacoby sends brownie points to @unc0mm0n :sparkles: :thumbsup: :sparkles:
kakalak-lumberJack
@kakalak-lumberJack
May 19 2016 06:44
also @GregJacoby "<p" + response.quote + "</p>") you are missing a >
Greg
@GregJacoby
May 19 2016 06:44
@kakalak-lumberJack thanks :) i was playing around with it so i think it updating as i was editing and it was lagging behind my fixes
CamperBot
@camperbot
May 19 2016 06:44
gregjacoby sends brownie points to @kakalak-lumberjack :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @kakalak-lumberjack |http://www.freecodecamp.com/kakalak-lumberjack
yedlahs
@yedlahs
May 19 2016 06:45
How do you read property value?
var myObj = { gift: "pony"};
How can I read "pony"?
myObj.gift is not working
Markus Kiili
@Masd925
May 19 2016 06:47
@yedlahs It works. myObj["gift"] would work too.
Greg
@GregJacoby
May 19 2016 06:49
wow, i wish they would give you a free quote api
i can't find any at all
sigh
Markus Kiili
@Masd925
May 19 2016 06:49
@GregJacoby Can't find api's or quotes?
yedlahs
@yedlahs
May 19 2016 06:50
Thanks @Masd925. myObj["gift"] worked. For some reason '.' notation didn't work.
CamperBot
@camperbot
May 19 2016 06:50
yedlahs sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1538 | @masd925 |http://www.freecodecamp.com/masd925
Greg
@GregJacoby
May 19 2016 06:50
@Masd925 not at all, i've tried a number of them and it's all bust. found a couple that looked promising but there's the access control problem. i've read about fixes for that online but i'm reluctant to use something that i have absolutely no idea how it works when i'm doing a project that's about learning =P
Markus Kiili
@Masd925
May 19 2016 06:52
@GregJacoby I believe an option is just to make an array of quotes and use it. Haven't done the project myself, so not sure about that.
EricOber
@EricOber
May 19 2016 06:52
hey can someone tell me the difference between parameters and arguments?
Greg
@GregJacoby
May 19 2016 06:52
@Masd925 it is, but the project is about utilizing APIs! :( i guess i'll have to do that though
Markus Kiili
@Masd925
May 19 2016 06:53
@Am3ricanPaladin Parameter is a part of function declaration. Argument is passed into the function on invocation.
EricOber
@EricOber
May 19 2016 06:53
like how though?
Markus Kiili
@Masd925
May 19 2016 06:54
function double (x) {
    return 2*x;
}

double (5); // returns 10

// x is a parameter. 
// 5 is an argument.
EricOber
@EricOber
May 19 2016 06:54
function question(this is argument?) { or this is arguments}
oooh so the argument is what you get back
no... wait, its what the user puts into the console
you can put in any number for the argument... but for the function double to work, it has to use the number 2. ook thanks @Masd925
CamperBot
@camperbot
May 19 2016 06:56
am3ricanpaladin sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1539 | @masd925 |http://www.freecodecamp.com/masd925
Yan Kozlovskiy
@YanKozlovskiy
May 19 2016 07:04
Make sure that you don't have spaces before the parentheses
double(5);
:)
Markus Kiili
@Masd925
May 19 2016 07:08
@YanKozlovskiy Are you sure that can be a problem somewhere? Seems to run fine on repl.it and normal html/js.
Yan Kozlovskiy
@YanKozlovskiy
May 19 2016 07:09
No, just convention :)
@Masd925
Arun Balaji
@arun-aji-balaji
May 19 2016 07:23
// Declare your variable here
var myGlobal = 10;
function fun1(oopsGlobal) {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5;
}
fun1(5);
// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}
fun2(5);
What is wrong in my code??
I have no idea :worried: .
RakeshNerkar
@Rakesh18754
May 19 2016 07:29

Uncaught TypeError: path.data is not a function

Any D3 expert who can help me on this issue???

Chris Cullen
@123xylem
May 19 2016 07:52
$("#output") (function() {
  document.write(data)
});
how can i make this a function?
XiaoWeiHuang
@xiaoweihuang
May 19 2016 07:53
@123xylem are you using jquery ?
Chris Cullen
@123xylem
May 19 2016 07:53
Yes
I know it needs .click or something but
Nothing is being clicked for it to work. the data is loaded
Markus Kiili
@Masd925
May 19 2016 07:55
@123xylem The syntax should be $(selector).action() where action is some jquery method.
@123xylem Or if you just wan't to run a function that manipulates DOM:
$(document).ready(function(){
    // code here
});
Chris Cullen
@123xylem
May 19 2016 08:01
ahh nice
@Masd925 il try it it sounds good... thanks
CamperBot
@camperbot
May 19 2016 08:01
:star2: 1540 | @masd925 |http://www.freecodecamp.com/masd925
123xylem sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Islam Ibakaev
@dagman
May 19 2016 08:02
does anyone know what is this and how to fix
Merge branch 'master' of https://github.com/dagman/dagman.github.io
https://github.com/dagman/dagman.github.io
Paresh Shrivastava
@Paresh18
May 19 2016 08:03
does anyone know how to access maps value in this object
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
Chris Cullen
@123xylem
May 19 2016 08:05
OMG the code stoped console.logging AGAIN! Any idea why it sometimes does and doesnt work overnight?
Dan Couper
@DanCouper
May 19 2016 08:08
@Paresh18 you get to it via dot notation for valid keys (myObject.key), if the key isn’t a valid identifier (eg ‘other key with spaces’), you need to use bracket notation, eg myObject.key.childkey['child of childkey’]
kirbyedy
@kirbyedy
May 19 2016 08:10
@123xylem Uncaught ReferenceError: data is not defined
this line: document.write(data)
your data is not accessible
deeprols
@deeprols
May 19 2016 08:16
@deeprols
Hi all! :)
i am planing to create an extension where my need is to as soon as file downloaded i want to save it to my google drive
in chrome.download api any way to push file to drive?
pls some one help me on this
Chris Cullen
@123xylem
May 19 2016 08:23
@kirbyedy Yea I will try $output above my data funciton
Harun
@harooooo1
May 19 2016 08:34
can anyone help me with Java script? i am doing the Golf Code task, in the course
what does it mean "Expected an assignment or function call and instead saw an expression"?
Keone Martin
@Athaman
May 19 2016 08:37
it sounds like you edited the section of the prewritten code that calls the function
Harun
@harooooo1
May 19 2016 08:40
function golfScore(par, strokes) {
// Only change code below this line
if ( strokes = 1) {return "Hole-in-one!";}
else if ( strokes <= par - 2 ) {return "Eagle";}
else if (strokes = par - 1) {return "Birdie" ;}
else if (strokes = par) {return "Par";}
else if (strokes = par + 1) {return "Bogey";}
else if (strokes = par + 2) {return "Double Bogey";}
else (strokes >= par + 3) {return "Go Home!";}
// Only change code above this line
}
this is the whole function, and i cant seem to notice where did i do wrong
Keone Martin
@Athaman
May 19 2016 08:40
did you change the code under the end brace of the function?
Blauelf
@Blauelf
May 19 2016 08:40
@harooooo1 = (assignment operator) is not the same as == (equals operator)
Keone Martin
@Athaman
May 19 2016 08:40
oh, also that yeah >.<
Harun
@harooooo1
May 19 2016 08:40
Aaaah
Blauelf
@Blauelf
May 19 2016 08:41
@harooooo1 The error message is probably caused by that (strokes >= par + 3). Remove that.
Harun
@harooooo1
May 19 2016 08:41
what will i do instead of it? just type else {return "Go Home!";} ?
Blauelf
@Blauelf
May 19 2016 08:42
Sure. You want that to trigger in any case that's not covered by the others, so just else {...}.
Matteo
@matteo78
May 19 2016 08:49

Hi Guys, been stuck since yesterday on the profile lookup, anybody got a clue what I.m doing wrong? If i stop my code before the else ifs it always gives me the correct properties back but once I add the else ifs it only gives me the "no such property "or "no such content" results...
```function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if ((contacts[i]["firstName"] === firstName) && (contacts[i].hasOwnProperty(prop))) {
return (contacts[i][prop]);
} // end of first if
else if (contacts[i].hasOwnProperty(prop) === false) {
return ("No such property");
} // ens of first else if
else return ("No such contact");
} // end of for loop
// Only change code above this line
} // end of functin

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

function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if ((contacts[i]["firstName"] === firstName) && (contacts[i].hasOwnProperty(prop))) {
      return (contacts[i][prop]);  
    } // end of first if
    else if (contacts[i].hasOwnProperty(prop) === false) {
      return ("No such property");
    } // ens of first else if
    else return ("No such contact");
  } // end of for loop
// Only change code above this line
} // end of functin

// Change these values to test your function
lookUpProfile("Harry", "likes");
Markus Kiili
@Masd925
May 19 2016 08:51
@matteo78 No such contact should be returned after the loop block.
Matteo
@matteo78
May 19 2016 08:52
@Masd925 Thanks a lot! You’re a Star!! I’ve been trying since yesterday, rewritten the code a doen times!
CamperBot
@camperbot
May 19 2016 08:52
matteo78 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1541 | @masd925 |http://www.freecodecamp.com/masd925
Mike Ekkel
@Murkrage
May 19 2016 08:58
@matteo78 Do you also know why it should be returned after the loop?
@matteo78 The reason I am asking is because it's important to know WHEN to return your values :). I want to make sure you understand what's happening
Matteo
@matteo78
May 19 2016 09:00
@Murkrage I think because the “no such content” is not a real check, I ve already done my check with the first2 if, if they are both false the only reasonable answer is the contact doesn’t exist, i don’t need to know the value of [i] anymore, is it correct?
Mike Ekkel
@Murkrage
May 19 2016 09:01
@matteo78 Correct :). No such contact will be the only answer left when the loop finishes (i.e. no other answers were matched). So you let the loop do it's thing and only when it's finished without any results, you return your final answer
Matteo
@matteo78
May 19 2016 09:03
@Murkrage Thanks Mike, I thought I understood the reason but it’s good to have somebody to confirm your theories! :smile:
CamperBot
@camperbot
May 19 2016 09:03
matteo78 sends brownie points to @murkrage :sparkles: :thumbsup: :sparkles:
:cookie: 321 | @murkrage |http://www.freecodecamp.com/murkrage
Mike Ekkel
@Murkrage
May 19 2016 09:03
@matteo78 If you put the "No such contact" inside the loop, it will return that when [i] doesn't match the contact. So if [0] isn't the matched contact, but 1 is then it will return "no such contact" even tho the next part of the loop IS the actual contact
No problem :)
You'll run into more loops like this later on. So it's valuable to understand why :)
Jide
@JideLambo
May 19 2016 09:05
This message was deleted
Ghost
@ghost~56a552d0e610378809be0124
May 19 2016 09:06
check for palindromes i did it this way..

function palindrome(str) {
  str = str.toLowerCase();
  var strArray = str.split("");

  var j = 0;

  var strArray2 = [];

  for (var i = 0; i < strArray.length; i++) {
    if (strArray[i].match(/[a-z]/i) || strArray[i].match(/[0-9]/)) {
      strArray2[j] = strArray[i];
      j++;
    }
  }

  var str2 = strArray2.join("");

  var reverseStrArray2 = strArray2.reverse();
  var reverseStr2 = reverseStrArray2.join("");

  if (reverseStr2 == str2) {
    return true;
  }

  return false;
}



palindrome("eye123_*hk");
Markus Kiili
@Masd925
May 19 2016 09:07
@matteo78 Because contacts is an array, you could also solve the challenge with an array iterator instead of loop.
Blauelf
@Blauelf
May 19 2016 09:08
@ShashiDwivedi You could combine those two regexes to /[a-z0-9]/i (matches a character of any of those ranges). Also, the last if (reverseStr2 == str2) { return true; } return false; is the same as return reverseStr2 == str2;.
Matteo
@matteo78
May 19 2016 09:08
@Masd925 I don’t think I’ve come across them yet in freecodecamp, do you mean with something like “for var Key in contacts”?
Markus Kiili
@Masd925
May 19 2016 09:08
@matteo78 I mean using an iterator like .reduce().
Mike Ekkel
@Murkrage
May 19 2016 09:09
@Masd925 @Masd925 .reduce() will come into play later on. These challenges are meant to become a little better at using loops
Ghost
@ghost~56a552d0e610378809be0124
May 19 2016 09:09
@Blauelf thanks and is this a good way to do this problem of palindromes?
CamperBot
@camperbot
May 19 2016 09:09
shashidwivedi sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1838 | @blauelf |http://www.freecodecamp.com/blauelf
Matteo
@matteo78
May 19 2016 09:09
@Masd925 No idea what they are, do you think it’s a better way of solving the problem in javascript (I supposee the way I am doing it at the moment is more “language independent” as for loops exist everywhere
Mike Ekkel
@Murkrage
May 19 2016 09:10
@matteo78 Don't worry about .reduce() for now. You'll get that later on. Your current challenges are focused at making you better at using loops
Jide