These are chat archives for FreeCodeCamp/HelpJavaScript

12th
May 2016
Alex
@Alex-HL780
May 12 2016 00:00
@PattyCreates get rid of the switch statement val and create a lookup named lookup
Ken Haduch
@khaduch
May 12 2016 00:01
@PattyCreates - you already have the proper transformation of the switch statement to an object - you just need to do the lookup...
nostrahistoria
@nostrahistoria
May 12 2016 00:02
Hi. Can someone help me with Return Early Pattern for Functions?
Instructions: Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined. Code: function abTest(a, b) {
PattyCreates
@PattyCreates
May 12 2016 00:02
@khaduch I have
var val = lookup["Charlie"];
Greg Duncan
@GregatGit
May 12 2016 00:02
@Antiphilous your welcome and thanks for Do you want ants!?! because that's how you get ants!
-Mallory Archer ! best quote I've read in a long time
CamperBot
@camperbot
May 12 2016 00:02
gregatgit sends brownie points to @antiphilous :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @antiphilous |http://www.freecodecamp.com/antiphilous
PattyCreates
@PattyCreates
May 12 2016 00:02
And it's saying lookup is undefined.
Stephane
@overmelo
May 12 2016 00:02
@tuliodnw nice one, i see your point. i wanted to finish all functionalities before designing
Alex
@Alex-HL780
May 12 2016 00:03
@PattyCreates the switch statement has the information you need lookup={ };
nostrahistoria
@nostrahistoria
May 12 2016 00:04
No one wants to help/
?
James Bond
@Dman89
May 12 2016 00:05
whats up
Christina
@cgraham74
May 12 2016 00:05
help steamroller
CamperBot
@camperbot
May 12 2016 00:05

:point_right: algorithm steamroller [wiki]

Explanation:

This problem seems simple but you need to make sure to flatten any array, regardless of the level which is what adds a bit of difficulty to the problem.

:pencil: read more about algorithm steamroller on the FCC Wiki

James Bond
@Dman89
May 12 2016 00:05
nostra
Coy Sanders
@coymeetsworld
May 12 2016 00:05
what do you have so far @nostrahistoria
PattyCreates
@PattyCreates
May 12 2016 00:05

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

  // Only change code below this line
  var lookup = {
    "alpha" : "Adams",
    "bravo" : "Boston",
    "charlie" : "Chicago",
    "delta" : "Denver",
    "echo" : "Easy",
    "foxtrot" : "Frank"
  };

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

// Change this value to test
var phoneticLookup = lookup.val;
nostrahistoria
@nostrahistoria
May 12 2016 00:05
I have no Daniel and Coy. Can you help me?
*nothing
Coy Sanders
@coymeetsworld
May 12 2016 00:06
sure what part you having trouble with?
PattyCreates
@PattyCreates
May 12 2016 00:06
@Alex-HL780 i think i have the switch statement in place.
James Bond
@Dman89
May 12 2016 00:06
@nostrahistoria yeah what do you need?
nostrahistoria
@nostrahistoria
May 12 2016 00:06
I do not even know where to start. It is difficult because I cannot just use cases in a switch. I have a value: a or b is less than 0
Alex
@Alex-HL780
May 12 2016 00:06
yes
nostrahistoria
@nostrahistoria
May 12 2016 00:06
Can you either give me the code or give me a line of code to start
James Bond
@Dman89
May 12 2016 00:06
send me link i dont see your original post
Ken Haduch
@khaduch
May 12 2016 00:06
@PattyCreates - don't get confused... you do not want to have one of the actual property names in the brackets. The call of the function - the phoneticLookup("charlie"); translates to having the value "Charlie" contained in the function argument val - that's the way that function calls work. So there is an implicit val = "charlie"; happening as the function is called. WIthin the function, you use the variable val to access the object... see my previous post (maybe a couple posts back) about accessing either lookup.val or lookup[val]. You want to use val and the proper syntax to access the lookup object...
James Bond
@Dman89
May 12 2016 00:07
@nostrahistoria sending a link?
nostrahistoria
@nostrahistoria
May 12 2016 00:07
How do you do that?
Greg Duncan
@GregatGit
May 12 2016 00:07
@PattyCreates You don't need a switch
James Bond
@Dman89
May 12 2016 00:07
copy and paste it in here
Coy Sanders
@coymeetsworld
May 12 2016 00:07
@nostrahistoria you basically need to write an if statement checking the values of a and b
Alex
@Alex-HL780
May 12 2016 00:07
the function is going to call the val
nostrahistoria
@nostrahistoria
May 12 2016 00:07
Oh!
Ok. I will try it out. Thanks!
Coy Sanders
@coymeetsworld
May 12 2016 00:07
thats all you need for it yeah
nostrahistoria
@nostrahistoria
May 12 2016 00:08
Thank you guys.
Coy Sanders
@coymeetsworld
May 12 2016 00:08
if either a is less than 0, or b is less than 0 you return undefined
thats all
yeah good luck
Ken Haduch
@khaduch
May 12 2016 00:08
@PattyCreates - restore that bottom line of the editor to what it was before, I think it was phoneticLookup("charlie"); ?
nostrahistoria
@nostrahistoria
May 12 2016 00:08
Thanks. Have a nice night.
James Bond
@Dman89
May 12 2016 00:08
@nostrahistoria type thanks @coymeetsworld to send him points
CamperBot
@camperbot
May 12 2016 00:08
dman89 sends brownie points to @nostrahistoria and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @nostrahistoria |http://www.freecodecamp.com/nostrahistoria
:cookie: 813 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 12 2016 00:09
lol thanks @Dman89
CamperBot
@camperbot
May 12 2016 00:09
coymeetsworld sends brownie points to @dman89 :sparkles: :thumbsup: :sparkles:
:cookie: 377 | @dman89 |http://www.freecodecamp.com/dman89
Ken Haduch
@khaduch
May 12 2016 00:09
@PattyCreates - you only have to add a line of code after your lookup object's closing semicolon, to set result to a value...
Sage Searwar
@Acer12
May 12 2016 00:10
Would someone please help explain the formula : Math.floor(Math.random() * (max - min + 1)) + min
Alex
@Alex-HL780
May 12 2016 00:10
@PattyCreates, assign the lookup value to the result variable
Aryan
@aryandua
May 12 2016 00:10
whoof!
James Bond
@Dman89
May 12 2016 00:10
@coymeetsworld haha no problem
Aryan
@aryandua
May 12 2016 00:11
worked for soo long and i think i finally got it!
This message was deleted
Sage Searwar
@Acer12
May 12 2016 00:11
It's from "Generate Random Whole Numbers within a Range".
Aryan
@aryandua
May 12 2016 00:11
function rot13(str) { 

  var val;
  var myString = "";

  for (var i = 0; i < str.length; i++) {
    val = str.charCodeAt(i);

    if (val < 65 || val > 90) {
      // Do nothing
    }
    else if (val <= 90 - 13) { 
      val += 13;
    }
    else {
      val = val + 13 - 26;
    }
    myString += String.fromCharCode(val);
  }
  return myString;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
now
PattyCreates
@PattyCreates
May 12 2016 00:11

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

  // Only change code below this line
  var lookup = {
    "alpha" : "Adams",
    "bravo" : "Boston",
    "charlie" : "Chicago",
    "delta" : "Denver",
    "echo" : "Easy",
    "foxtrot" : "Frank"
  };

  var result = lookup.val;

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

// Change this value to test
phoneticLookup("charlie");
Aryan
@aryandua
May 12 2016 00:11
boom!
I got it!
eeflores
@eeflores
May 12 2016 00:12
@PattyCreates use bracket notation instead of dot notation
Coy Sanders
@coymeetsworld
May 12 2016 00:12
that works @aryandua ?
oh wait nvm yeah it does
Ken Haduch
@khaduch
May 12 2016 00:12
@PattyCreates :point_up: May 11, 2016 8:06 PM - check that post. You're close...
Alex
@Alex-HL780
May 12 2016 00:12
@PattyCreates , lookup[]
Coy Sanders
@coymeetsworld
May 12 2016 00:12
was wondering where you skip non alphabet characters
misread it
PattyCreates
@PattyCreates
May 12 2016 00:14
@khaduch @Alex-HL780 okay that works. thanks. That was so confusing.
CamperBot
@camperbot
May 12 2016 00:14
:cookie: 217 | @alex-hl780 |http://www.freecodecamp.com/alex-hl780
pattycreates sends brownie points to @khaduch and @alex-hl780 :sparkles: :thumbsup: :sparkles:
:star2: 1100 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
May 12 2016 00:16
@PattyCreates - great! The thing to do now is go back and look at the lesson "Accessing Objects Properties with Variables" - this is a tricky concept that will keep popping up over and over and over and over... try to get it clearly understood!
PattyCreates
@PattyCreates
May 12 2016 00:17
Thanks @khaduch I generally feel like I get it when its micro, but sometimes when it's combining multiple aspects all at once not knowing what to do is confusing.
CamperBot
@camperbot
May 12 2016 00:17
pattycreates sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: pattycreates already gave khaduch points
Ken Haduch
@khaduch
May 12 2016 00:18
@PattyCreates - that is normal - the simple lessons are sometimes (seemingly) too simple... application in a slightly different context seems to throw a lot of people (myself included!) off the track... This object access will be used in a few coming exercises that definitely throw people for a loop quite often! Good luck!
Coy Sanders
@coymeetsworld
May 12 2016 00:21
yeah it was tricky for me to know when to use bracket notation or dot notation @khaduch @PattyCreates, still get mixed up with it a bit sometimes
I just think if the property I'm looking for is in a variable I use bracket notation, or if I need to access a nested property use bracket notation. If i know the property ahead of time I can use dot notation
Ken Haduch
@khaduch
May 12 2016 00:24
@coymeetsworld - it took me a while to get that whole concept straight - I even had to go and look at explanations of it on other websites! But after helping people umpteen times with some of those problems - i hope that I never forget it... :) But I wouldn't put a bet on it...
nostrahistoria
@nostrahistoria
May 12 2016 00:28
Hi. Can someone help with Counting Cards. Instructions: You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Chin Seah
@seahchin
May 12 2016 00:29

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

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Can anyone tell me why my updateRecords doesn't work? Help!

Greg Duncan
@GregatGit
May 12 2016 00:29
@devopsec sorry - didn't quite read your question properly - just declare var apiKey = text; outside the function
PattyCreates
@PattyCreates
May 12 2016 00:30
@nostrahistoria I was stuck on that question yesterday. Feel free to give it a shot and paste your code in here.
nostrahistoria
@nostrahistoria
May 12 2016 00:30
@PattyCreates I do not know where to even start. Can you help?
Tyler Moore
@devopsec
May 12 2016 00:31
@GregatGit I got some help with it but thanks for the reply!
CamperBot
@camperbot
May 12 2016 00:31
devopsec sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 471 | @gregatgit |http://www.freecodecamp.com/gregatgit
PattyCreates
@PattyCreates
May 12 2016 00:31
So, I haz a question again. Reading through the bracket notations to find key value pairs. There's only been instruction to find specific values or specific properties.

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

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    return checkProp; //
  }
  else {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
Coy Sanders
@coymeetsworld
May 12 2016 00:32
yeah you want to return the property value there @PattyCreates, not the key (checkProp)
Sage Searwar
@Acer12
May 12 2016 00:32
@nostrahistoria Use a switch statement.
PattyCreates
@PattyCreates
May 12 2016 00:32
The return with the checkprop section is what I'm not sure on. how can i return it's respectful prop value.
Ken Haduch
@khaduch
May 12 2016 00:32
@seahchin - prop is a variable, one of the function arguments. You have to be careful about whether you have to use "dot" notation or "bracket" notation to use prop to lookup an object property...
Coy Sanders
@coymeetsworld
May 12 2016 00:32
so you need to access myObj again and return the value associated with whatever is in checkProp
nostrahistoria
@nostrahistoria
May 12 2016 00:32
@Acer12 Can you give any other hints?
Coy Sanders
@coymeetsworld
May 12 2016 00:33
similar to what you did in lookup
babooon
@babooon
May 12 2016 00:33
@nostrahistoria make a switch on "card" and increase your count variable according to the table
PattyCreates
@PattyCreates
May 12 2016 00:33
do i need tod efine val?
define*
nostrahistoria
@nostrahistoria
May 12 2016 00:33
Thanks guys. I will try again.
Coy Sanders
@coymeetsworld
May 12 2016 00:33
nope, no need to define anything its all there for you
val in the previous example was a parameter for phoneticLookup function
now your parameter is not named val, its checkProp, for the function checkObj()
so instead of using val use checkProp in its place
Sage Searwar
@Acer12
May 12 2016 00:34
@nostrahistoria break between each of the sets
Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K', 'A' and after the switch statement use an if statement and return count + answer.
PattyCreates
@PattyCreates
May 12 2016 00:35
@coymeetsworld so, isn't checkProp checking for properties and not property values?
nostrahistoria
@nostrahistoria
May 12 2016 00:35
Thanks @Acer12 I will try it out. I need to rest a little right now.
CamperBot
@camperbot
May 12 2016 00:35
nostrahistoria sends brownie points to @acer12 :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @acer12 |http://www.freecodecamp.com/acer12
Coy Sanders
@coymeetsworld
May 12 2016 00:36
checkProp is the property name (key) you're supposed to check for in myObj
if it has that key, you want to return its value
Sage Searwar
@Acer12
May 12 2016 00:36
@nostrahistoria okay cool, hope you figure it out.
Coy Sanders
@coymeetsworld
May 12 2016 00:37
so if checkProp is "gift", you want to see if myObj has a "gift" property, which it does, so you want to return its value which is "pony"
Justin Scoggin
@jscogg
May 12 2016 00:37
Hello people of Gitter... I have a JavaScript conundrum for ya. I'm not sure how to go about using JS to test whether an HTML element's attribute is equal to something or not. Here's a codepen to illustrate: http://codepen.io/anon/pen/JXzmWy
Coy Sanders
@coymeetsworld
May 12 2016 00:37
if checkProp was something like idk "chair", testObj doesn't have a property named "chair" so you would return "Not found"
PattyCreates
@PattyCreates
May 12 2016 00:38
Yeah @coymeetsworld currently, it's returning gift.
Which makes sense to what you're saying.
Coy Sanders
@coymeetsworld
May 12 2016 00:38
yeah because you just return the checkProp value back
Ken Haduch
@khaduch
May 12 2016 00:38
@jscogg - are you planning to use jQuery?
Coy Sanders
@coymeetsworld
May 12 2016 00:39
but what you want is to return something from myObj, similar to what you did in the PhoneticLookup challenge
you created a lookup object that the function got data from
Justin Scoggin
@jscogg
May 12 2016 00:39
@khaduch Nope. Vanilla JS.
Coy Sanders
@coymeetsworld
May 12 2016 00:39
in this case the object is already created for you, just need to pull the data from it
Ken Haduch
@khaduch
May 12 2016 00:39
@jscogg - OK.
Chin Seah
@seahchin
May 12 2016 00:40
@khaduch Thanks! It works with collection[id][prop].
CamperBot
@camperbot
May 12 2016 00:40
seahchin sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1101 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
May 12 2016 00:41
@seahchin - great! I was going to point out that you were doing the right thing with the id / [id] value... but I figured that since you had that right, just mentioning it would lead you in the right direction. An important concept to get straight! You're welcome, and good luck!
PattyCreates
@PattyCreates
May 12 2016 00:42

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

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    var val = checkObj[val];
    return val;
  }
  else {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
Coy Sanders
@coymeetsworld
May 12 2016 00:42
ya looks good
or wait
one mistake
you need to check for checkProp inside checkObj
PattyCreates
@PattyCreates
May 12 2016 00:43
which checkObj?
inside my variable?
Coy Sanders
@coymeetsworld
May 12 2016 00:43
oh lol whoops another thing
checkObj should be just the function name
myObj is your object you need to check
you're trying to pull data from this:
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
so val should reference something from myObj, not from checkObj, which is just the name of the function
Ken Haduch
@khaduch
May 12 2016 00:46

@jscogg - document.getElementsByClassName("box"); will get you a list of elements with the class. Since there is only one, you can access it by doing this:

var element = document.getElementsByClassName("box")[0];
if (element.getAttribute('data-toggle') === "change") {
    element.style.background = "tomato";
}

At least I think that will work...

Oops. not quite... just trying it. And the update works...

PattyCreates
@PattyCreates
May 12 2016 00:47
@coymeetsworld "you need to check for checkProp inside checkObj" what do you mean by this?
I updated the myobj mishap.
Coy Sanders
@coymeetsworld
May 12 2016 00:47
oh thats my mistake @PattyCreates sorry, i misspoke
you need to check for checkProp inside myObj
sorry, got the names mixed around :(
can you show what you have now?
Tiffany White
@twhite96
May 12 2016 00:48
Having some trouble with Record Collection waypoint.
Here is my code:
// 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 !== "" && prop == "tracks") {
    collection[id] = value;
    array.push(tracks);
  } else if (value === "") {
    delete collection[prop];
  }
   return collection;
}




// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
PattyCreates
@PattyCreates
May 12 2016 00:49

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

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    var val = myObj[val];
    return val;
  }
  else {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");
Coy Sanders
@coymeetsworld
May 12 2016 00:49
ok better @PattyCreates, just need to change what you're looking for in myObj
don't check for val, check for checkProp
Tiffany White
@twhite96
May 12 2016 00:50
Not sure where to go from here.
PattyCreates
@PattyCreates
May 12 2016 00:50
hmm
Coy Sanders
@coymeetsworld
May 12 2016 00:50
var val = myObj[checkProp]; like that
because thats what you're checking for right?
val at that point is undefined
so it wouldn't return you anything
PattyCreates
@PattyCreates
May 12 2016 00:51
ohh.
Coy Sanders
@coymeetsworld
May 12 2016 00:51
in fact, you don't even need to create a val variable, you can just return myObj[checkProp]
PattyCreates
@PattyCreates
May 12 2016 00:51
wait. still confused. I thought checkProp was looking for a key. Not the value.
Coy Sanders
@coymeetsworld
May 12 2016 00:51
it is
Aparna
@Aparna-S
May 12 2016 00:52
@darkSkiesUniverse @Chrono79 Hii, i just started working on the record challenge again
now i get the first one correct
rest 3 not able to update
After updateRecords(2548, "artist", ""), artist should not be set
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2548, "tracks", ""), tracks should not be set
Coy Sanders
@coymeetsworld
May 12 2016 00:52
ugh
another typo i had sorry
Justin Scoggin
@jscogg
May 12 2016 00:52
@khaduch Well that at least gives me a starting point! Thanks!
CamperBot
@camperbot
May 12 2016 00:52
jscogg sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1102 | @khaduch |http://www.freecodecamp.com/khaduch
Coy Sanders
@coymeetsworld
May 12 2016 00:53
I meant return myObj[checkProp]; not return myObj[val]
Ken Haduch
@khaduch
May 12 2016 00:53
@jscogg - updated code in my example - it works... :point_up: May 11, 2016 8:46 PM
Coy Sanders
@coymeetsworld
May 12 2016 00:53
but anyways checkProp is your key, and to find the value of checkProp inside myObj, you would run myObj[checkProp]
like myObj["gift"] would return "pony"
myObj["bed"] would return "sleigh"

in prev example

var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"
  };

lookup["alpha"] would return "Adams"
lookup["delta"] would return "Denver"

PattyCreates
@PattyCreates
May 12 2016 00:57
ah i get it.
so what is checkProp? is it a parameter?
Coy Sanders
@coymeetsworld
May 12 2016 00:58
correct
parameter is a variable specified in the function
in phoneticLookup it had a parameter variable named val
Sage Searwar
@Acer12
May 12 2016 00:59
@twhite96 you have a couple small problems your missing at least one exclamtion point.
Coy Sanders
@coymeetsworld
May 12 2016 00:59
in this function the parameter variable name is checkProp
PattyCreates
@PattyCreates
May 12 2016 00:59
and when you call the function the specific parameter entry will run it with that entry. What is the parameter entry name?
Coy Sanders
@coymeetsworld
May 12 2016 00:59
what do mean by entry name?
Tiffany White
@twhite96
May 12 2016 00:59
What are the other small problems, @Acer12?
PattyCreates
@PattyCreates
May 12 2016 00:59
like "gift" was the parameter when it was called.
Coy Sanders
@coymeetsworld
May 12 2016 01:00
gift was the value of the parameter checkProp in that instance yeah
if you ran checkObj("bed"), the checkProp in that instance would be "bed"
Sage Searwar
@Acer12
May 12 2016 01:01
@twhite96 you also need another if statement.
PattyCreates
@PattyCreates
May 12 2016 01:01
oh, so its just called the value of a parameter?
i guess i'm wondering the terminology of it.
Coy Sanders
@coymeetsworld
May 12 2016 01:01
pretty much yeah
we call it arguments
PattyCreates
@PattyCreates
May 12 2016 01:01
Oh. that makes sense!
Coy Sanders
@coymeetsworld
May 12 2016 01:02
like the checkObj function takes in one argument
here's a SO post describing difference between argument and parameter if that helps http://stackoverflow.com/questions/1788923/parameter-vs-argument
PattyCreates
@PattyCreates
May 12 2016 01:02
sweet. thanks a ton @coymeetsworld
CamperBot
@camperbot
May 12 2016 01:02
pattycreates sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 815 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 12 2016 01:02
its basically just how you're referring to the value you're passing into a function
yeah no problem, sorry bout confusion earlier must be tired right now lol
PattyCreates
@PattyCreates
May 12 2016 01:03
what time zone are you in?
Coy Sanders
@coymeetsworld
May 12 2016 01:03
Pacific lol
PattyCreates
@PattyCreates
May 12 2016 01:05
lol.
i'm sleepy as well but staying up to watch warriors game at 730. so late yet obviously so early.
Coy Sanders
@coymeetsworld
May 12 2016 01:06
yes me too! Huge game 2 days ago
Sage Searwar
@Acer12
May 12 2016 01:09
@twhite96 little hard for me to explain without telling.
Aparna
@Aparna-S
May 12 2016 01:10
doing "Record" challenge
"After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element." is in red
my code is below

// 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 !== "" && prop!= "tracks")
{
collection[id][prop]=value;
}

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

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
updateRecords(2548, "artist", "");
updateRecords(1245, "tracks", "Addicted to Love");
updateRecords(2548, "tracks", "");

resulkt is below

learn to code javascript at Free Code Camp logo
Map
Chat
Wiki
About
Shop
[ 224 ]

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

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

For the given id in collection:

If value is non-blank (value !== "") 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.

Run tests (ctrl + enter)
Reset Help Bug

collection =
{
"1245": {
"artist": "Robert Palmer",
"tracks": "Addicted to Love"
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"2548": {
"album": "Slippery When Wet"
},
"5439": {
"album": "ABBA Gold",
"artist": "ABBA"
}
}

After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
After updateRecords(2548, "artist", ""), artist should not be set
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2548, "tracks", ""), tracks should not be set

-
1

2
// Setup
3
var collection = {
4
2548: {
5
album: "Slippery When Wet",
6
artist: "Bon Jovi",
7
tracks: [
8
"Let It Rock",
9
"You Give Love a Bad Name"
10
]
11
},
12
2468: {
13
album: "1999",
14
artist: "Prince",
15
tracks: [
16
"1999",
17
"Little Red Corvette"
18
]
19
},
20
1245: {
21
artist: "Robert Palmer",
22
tracks: [ ]
23
},
24
5439: {
25
album: "ABBA Gold"
26
}
27
};
28
// Keep a copy of the collection for tests
29
var collectionCopy = JSON.parse(JSON.stringify(collection));
30

31
// Only change code below this line
32
function updateRecords(id, prop, value) {
33
if (value !== "" && prop!= "tracks")
34
{
35
collection[id][prop]=value;
36
}
37

38
if (value!== "" && prop== "tracks")
39
{
40
collection[id][prop]= value;
41
}
42
if (value==="")
43
{
44
delete collection[id][prop];
45
}
46
return collectionCopy;
47
}
48

49
// Alter values below to test your code
50
updateRecords(5439, "artist", "ABBA");
51
updateRecords(2548, "artist", "");
52
updateRecords(1245, "tracks", "Addicted to Love");
53
updateRecords(2548, "tracks", "");
54

Help JavaScript

any help??
Coy Sanders
@coymeetsworld
May 12 2016 01:13
@Aparna-S when the value is not null and prop is tracks, you don't want to replace what is in tracks you want to add to it
Thomas G.
@CaptainMurphey
May 12 2016 01:13
hey guys im having a bit of a problem im doing the Falsy Bouncer challenge, and the NaN is giving me trouble. I know how to test if something is NotANumber i.e. a string but I cant find any info on how to test if somesthing is the actual constant NaN without tripping up all the items that are actually just a string, ive tried isNaN(variable) and tried just setting equal to NaN which just returns false, and also !NaN which isint allowed, so what do i do here?
Jamie
@kesjam
May 12 2016 01:14
How do I add code to comments on here?
Coy Sanders
@coymeetsworld
May 12 2016 01:15
help format
CamperBot
@camperbot
May 12 2016 01:15

: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 the code.

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

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

Jamie
@kesjam
May 12 2016 01:19

function testSize(num) {
  // Only change code below this line
  If (num < 5) { 
    return "Tiny";
  } else if (num < 10) {
    return "Small";
  } else if (num < 15) {
    return "Medium";
  } else if (num < 20) {
    return "Large";
  } else (num >= 20) {
    return "Huge";
  }

  return "Change Me";
  // Only change code above this line
}

// Change this value to test
testSize(7);
I am stuck on 199, everything looks correct to me
Coy Sanders
@coymeetsworld
May 12 2016 01:19
if is not capitalized @kesjam
Jamie
@kesjam
May 12 2016 01:19
aaaaah @coymeetsworld thanks! ;)
CamperBot
@camperbot
May 12 2016 01:19
kesjam sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 816 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 12 2016 01:20
np, also you can remove return Change Me line
since your code can never get there
also for reference that number 199 is your brownie points, not the challenge name
Jamie
@kesjam
May 12 2016 01:21
I am still getting an unexpected token error
Coy Sanders
@coymeetsworld
May 12 2016 01:21
what does code look like now?
Jamie
@kesjam
May 12 2016 01:22

function testSize(num) {
  // Only change code below this line
  if (num < 5) { 
    return "Tiny";
  } else if (num < 10) {
    return "Small";
  } else if (num < 15) {
    return "Medium";
  } else if (num < 20) {
    return "Large";
  } else (num >= 20) {
    return "Huge";
  }

}

// Change this value to test
testSize(7);
Coy Sanders
@coymeetsworld
May 12 2016 01:22
whats challenge name?
Thomas Nguyen
@thomasnguyen
May 12 2016 01:22
hey I need help on the falsy bouncer project
Jamie
@kesjam
May 12 2016 01:22
Chaining If Else Statements
Thomas Nguyen
@thomasnguyen
May 12 2016 01:22
don't know where to look, thanks
Coy Sanders
@coymeetsworld
May 12 2016 01:23
oh your else statement
should just say else, doesn't take in anything
with your logic, basically else is guaranteed to be 20 or greater
so you don't need to specify it anyways
Greg Duncan
@GregatGit
May 12 2016 01:24
@devopsec for your quotes background
body {
  background: url("yourImg.jpg")no-repeat center fixed;
  background-size: cover;
  text-align: center;
}
Thomas G.
@CaptainMurphey
May 12 2016 01:25
@toshiru having trouble with the NaN?
Nate
@nateReiners
May 12 2016 01:25
Anyone willing to help me with the Title Case a Sentence challenge?
Greg Duncan
@GregatGit
May 12 2016 01:25
@kesjam the final else should have no condition statement
Jamie
@kesjam
May 12 2016 01:25
Thanks got it :)
Rachel Melville
@rjmelville
May 12 2016 01:26
Would someone mind checking my solution for 'Reverse a String' and let me know if there's a more efficient approach?
function reverseString(str) {
  var myArr = str.split("");
  var myReversedArr = myArr.reverse();
  return myReversedArr.join([separator = ""]);
}

reverseString("hello");
Nate
@nateReiners
May 12 2016 01:27
My code works, kind of. The problem is it returns "I'mALittleTeaPot" with no spaces since I'm adding letters to newArr one by one. I can't figure out how to capitalize the first letter and then add the whole word to newArr as a whole. Any tips would be greatly appreciated! :smile:
function titleCase(str) {
var x = str.toLowerCase().split(" ");
var newArr = [];
for(i = 0; i < x.length; i++) {
  for(j = 0; j < x[i].length; j++) {
    if(j === 0) {
      newArr.push(x[i][j].toUpperCase());
    } else if (j > 0) {
      newArr.push(x[i][j]);
    }
}
}
return newArr.join("").replace(/,/g, "");
}

titleCase("I'm a little tea pot");
Greg Duncan
@GregatGit
May 12 2016 01:27
@rjmelville you can keep using str instead of new varibles
@rjmelville so str = str.split("");
Aparna
@Aparna-S
May 12 2016 01:28
@coymeetsworld is it this way?

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

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

Rachel Melville
@rjmelville
May 12 2016 01:28
@GregatGit Oh! Right. Thank you. I had a feeling I didn't need the variables.
CamperBot
@camperbot
May 12 2016 01:28
rjmelville sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
MVM1969
@MVM1969
May 12 2016 01:28
Aparna, change your line 40 from "collection[id][prop]= value;" to collection[id].tracks.push(value);
CamperBot
@camperbot
May 12 2016 01:28
:cookie: 472 | @gregatgit |http://www.freecodecamp.com/gregatgit
Ken Haduch
@khaduch
May 12 2016 01:28
@nateReiners - if you just use a space ' ' as the argument to .join() - does that work?
Greg Duncan
@GregatGit
May 12 2016 01:29
@rjmelville try linking the functions one after another so str = str.function1().function2;
Nate
@nateReiners
May 12 2016 01:29
@khaduch My code returns I ' m A L i t t l e T e a P o t if I do that
MVM1969
@MVM1969
May 12 2016 01:29
@Aparna-S Here's my updateRecords(): function updateRecords(id, prop, value) {
if (value!== '' && prop!='tracks')
collection[id][prop]=value;
if (value!=='' && prop==='tracks')
collection[id].tracks.push(value);
if (value==='')
delete collection[id][prop];
return collection;
}
Ken Haduch
@khaduch
May 12 2016 01:30
@nateReiners - sorry, I misread your code... I see what you're doing. You should put the words in the output array as separate words, instead of just stringing them into one big word...
Coy Sanders
@coymeetsworld
May 12 2016 01:30
@MVM1969 in future try not to give out the code when helping someone
try to help them out with the issue, doesn't help when trying to learn something if you're just given the answers
Nate
@nateReiners
May 12 2016 01:30
@khaduch how can I keep them separate while singling out the first letter of each?
Coy Sanders
@coymeetsworld
May 12 2016 01:31
having said that yeah what @MVM1969 said about how to put the value into tracks is right @Aparna-S
Ken Haduch
@khaduch
May 12 2016 01:31
@nateReiners - you have separate words in your x array. You can form each new uppercased word separately, and then just push that new word into your output array, and the join (with spaces)... does that make sense?
Nate
@nateReiners
May 12 2016 01:32
@khaduch Ok I'll give it a try. Thanks a million!!
CamperBot
@camperbot
May 12 2016 01:32
natereiners sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1103 | @khaduch |http://www.freecodecamp.com/khaduch
Aparna
@Aparna-S
May 12 2016 01:32
@MVM1969 @coymeetsworld thanks for the help! :) so it is alays a foramte where we go in order, like here it is id, then prop and value, whether you push pop or replace the value?
CamperBot
@camperbot
May 12 2016 01:32
aparna-s sends brownie points to @mvm1969 and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 817 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
:cookie: 88 | @mvm1969 |http://www.freecodecamp.com/mvm1969
Thomas G.
@CaptainMurphey
May 12 2016 01:33
@toshiru Thomas did you still need help?
Rachel Melville
@rjmelville
May 12 2016 01:33
@GregatGit Cool. Got it.
function reverseString(str) {
  str = str.split("").reverse().join([separator = ""]);
  return str;
}

reverseString("hello");
Suren VB
@surenz298
May 12 2016 01:34

HI - I am sure I am missing a obvious - but only a third is eye is what gonna help me - as I have been fidling with a while

Everything works well - but when I re-size my text does not fit the container and overflows

Have tried overflow:hidden - but no use

http://codepen.io/surenz298/pen/YqRjzq

Lizzy
@DevElisabeth
May 12 2016 01:34
Hi all! Kind of frustrated with the Local Scope and Function challenge in basic Java Script. I have no global variables, and yet it says I do. myVar is defined, and yet it says it isn't. Am I missing something?
function myLocalScope() {
var myVar = 'strict use';
console.log(myVar);
}
myLocalScope();
console.log(myVar);
Greg Duncan
@GregatGit
May 12 2016 01:35
@rjmelville cool - you could try return instead of str = , im not sure if that would work
Puvendran Pillay
@puven12
May 12 2016 01:35
Where can I find help for my personal projects?
Thomas G.
@CaptainMurphey
May 12 2016 01:36
@surenz298 I dont see what text isint fitting?
Suren VB
@surenz298
May 12 2016 01:36
@CaptainMurphey - when you resize to mobile view port - you can see my quotes going off the container
Rachel Melville
@rjmelville
May 12 2016 01:36
@GregatGit It did! Nice. Thanks again.
CamperBot
@camperbot
May 12 2016 01:36
rjmelville sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:warning: rjmelville already gave gregatgit points
Lizzy
@DevElisabeth
May 12 2016 01:36
I even removed the last two lines and it says all tasks are completed and yet it won't let me continue. o_o
Thomas G.
@CaptainMurphey
May 12 2016 01:37
@surenz298 ohh ok , i believe there is a way to fix that with font size, setting to a percentage, or using text wrap
Greg Duncan
@GregatGit
May 12 2016 01:37
@rjmelville cool - you can always cut and past code at https://repl.it/ to play around with the challenges. I always use this when i'm playing with objects
Lizzy
@DevElisabeth
May 12 2016 01:39
:rainbow: Nevermind, it finally worked! :sparkles:
Thomas G.
@CaptainMurphey
May 12 2016 01:39
Justin Woodward
@jwoo92
May 12 2016 01:40
question on using the .html() function for jQuery: i want to create an array in javascript with the hmtl tags and text i want to cycle through using that jQuery function. how would i list my tags and html text in an array in javascript? here is part of what i have as an example of what i am currently working with.
quotes = [
  <blockquote>The best preparation for tomorrow is doing your best today.<footer><cite title="source-title">H. Jackson Brown, Jr.</cite></footer></blockquote>,...
Nate
@nateReiners
May 12 2016 01:40
@khaduch I did it! thank you thank you haha. Got those good coding feels going. :)
CamperBot
@camperbot
May 12 2016 01:40
natereiners sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: natereiners already gave khaduch points
Lizzy
@DevElisabeth
May 12 2016 01:40
This message was deleted
Travis Stevenson
@travisxcode
May 12 2016 01:41

I'm having a bit of trouble on the "Counting Cards" bonfire. Can anyone please help me understand where my logic is incorrect?

Source Code:

var count = 0;

function cc(card) {
// Only change code below this line

switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
return count += 1;
case 7:
case 8:
case 9:
return count;
case 10:
case "J":
case "Q":
case "K":
case "A":
return count -= 1;
}

if (count > 0) {

return count + " Hold";

} else {
return count + " Bet";

}

// 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');

Nate
@nateReiners
May 12 2016 01:43
what happens when you run it as is?
also, you can type ```` before and after your code to make it go in a black box
Travis Stevenson
@travisxcode
May 12 2016 01:45
var count = 0;

function cc(card) {
  // Only change code below this line

  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      return count += 1;
    case 7:
    case 8:
    case 9:
      return count;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      return count -= 1;
  }

  if (count > 0) {

   return count + " Hold";

  } else {
    return count + " Bet";

  }


  // 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');
Wow, thanks for that markup tip!
@nateReiners , When I run the test I get the output "0".
Ken Haduch
@khaduch
May 12 2016 01:47
@nateReiners oh, great! Sometimes you just have to have a little push (no pun intended) to do something different, you'll get more experienced as you go along and will instinctively learn how to do some things...
@travisxcode - I think it's your global variable...
coderCarlitos
@coderCarlitos
May 12 2016 01:49
Please, help, I'm stuck, I'm getting the right answer... sort of? I'm not sure if its the format, but my answer is an actual array, tested with Array.isArray(arr). Is it supposed to be an array-like object.
function doesNotContain(val) {
  return val !== this;

}

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

  //returns [1,5,1] "destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1]."
}


destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Travis Stevenson
@travisxcode
May 12 2016 01:51
@khaduch What do you mean it is my global variable? doesn't my function have access to the count variable?
@ken Then again, judging by the syntax highlighting I would suppose not...
@khaduch
Ken Haduch
@khaduch
May 12 2016 02:01
@travisxcode - sorry, I was wrong... there are some problems like this where the testing fails if there is a global variable... this is a different problem that you are having.
MVM1969
@MVM1969
May 12 2016 02:01
@coymeetsworld Apologies - I am brand-new to FreeCodeCamp! I will refrain from posting answers in the future.
Jamie
@kesjam
May 12 2016 02:02
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  case "a":
    return "apple";
    break;
  case "b":
    return "bird";
    break;
  case "c":
    return "cat";
    break;
  default:
    answer = "stuff";

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

// Change this value to test
switchOfStuff(1);
Having trouble getting this to work:
Instructions
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
PattyCreates
@PattyCreates
May 12 2016 02:05
@kesjam it's not return statements.
Jamie
@kesjam
May 12 2016 02:06
@PattyCreates should I be assigning the apple variable to a?
Ken Haduch
@khaduch
May 12 2016 02:06
@travisxcode - you have the wrong approach to doing this problem. With each card that you get, you are supposed to increment or decrement the global count variable. You do not want to return the count, but as the problem states: "The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space." So you should be adjusting the count variable according to the card you receive, and then returning the count with the "Bet" or "Hold" attached.
PattyCreates
@PattyCreates
May 12 2016 02:07
@kesjam so, you're default answer is closest to how you should be attributing values for all of your cases.
Jamie
@kesjam
May 12 2016 02:07
@PattyCreates ok thanks
CamperBot
@camperbot
May 12 2016 02:07
kesjam sends brownie points to @pattycreates :sparkles: :thumbsup: :sparkles:
:cookie: 106 | @pattycreates |http://www.freecodecamp.com/pattycreates
Jamie
@kesjam
May 12 2016 02:10

@PattyCreates did this but still no go ```js

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
case "a":
answer = "apple";
break;
case "b":
answer = "bird";
break;
case "c":
answer = "cat";
break;
default:
answer = "stuff";

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

// Change this value to test
switchOfStuff(1);

Thomas G.
@CaptainMurphey
May 12 2016 02:10
Hey guys im working on seek and destroy and im using a for loop to check the arguments with arguments[i] and it keeps returning the parts of the array instead of the actual arguments I need to use ie destroyer([1, 2, 3, 1, 2, 3], 2, 3); is returning 123123 instead of 2,3 ..... so am i supposed to separate these first or something? I think the array is an argument as well right so why is it only passing the array instead of the array and other arguments as well
@kesjam you forgot to ad the actual switch statement
刘增辉
@liuzenghui2007
May 12 2016 02:13
I am solving a problem at https://www.freecodecamp.com/challenges/validate-us-telephone-numbers. Can some one tell me that how to match a pattern like "(555)555-5555" and "555555-5555"? I don't know how to deal with the brackets pair.
I write this expression 1?[\s-]?(d{3})|((\d{3}))[\s-]?\d{3}[\s-]?\d{4}, but it does not work well.
Thomas G.
@CaptainMurphey
May 12 2016 02:14
@kesjam before your cases add switch (val) gotta think of it as a loop it still needs something to compare all of the cases to
PattyCreates
@PattyCreates
May 12 2016 02:18
yeah @kesjam the final value to test should be updated?
Suren VB
@surenz298
May 12 2016 02:21

@CaptainMurphey - Hi Greg - Fixed the issue

Way I constructed my html from json was the issue

But Thnx for the article - a new thing learnt

CamperBot
@camperbot
May 12 2016 02:21
surenz298 sends brownie points to @captainmurphey :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @captainmurphey |http://www.freecodecamp.com/captainmurphey
bitgrower
@bitgrower
May 12 2016 02:23

@liuzenghui2007 -- if you haven't gone thru the tutorials on regexone.com -- I highly recommend them ...

and one of the ways of dealing with matching braces or parentheses is to make it a complete "phrase" or "chunk" you are looking for, and use the alternation operator in your regex ...

Dominic Lobban
@alkapwn3d
May 12 2016 02:24
can someone help me with a js question?
bitgrower
@bitgrower
May 12 2016 02:24
sure ...
what's up ?
Dominic Lobban
@alkapwn3d
May 12 2016 02:24
"Testing Objects for Properties"
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (checkObj()) {
  myObj.hasOwnProperty("gift"); 
  myObj.hasOwnProperty("pet");
} else
  return "Not Found";
}
myObj.hasOwnProperty(""); 
// Test your code by modifying these values
checkObj("gift");
Jamie
@kesjam
May 12 2016 02:25
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
  case "a":
    answer = "apple";
    break;
  case "b":
    answer = "bird";
    break;
  case "c":
    answer = "cat";
    break;
  default:
    answer = "stuff";

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

// Change this value to test
switchOfStuff(4);
switchOfStuff("a");
switchOfStuff("b");
switchOfStuff("c");
@PattyCreates @CaptainMurphey Did this but the a b c still not receiving the values
Ken Haduch
@khaduch
May 12 2016 02:25
@liuzenghui2007 - you need to have some literal parentheses in your expression \( and \). I don't see those.
bitgrower
@bitgrower
May 12 2016 02:26
@alkapwn3d -- you need to be using the parameter passed to the checkObj function ... not the literal values in myObj
Dominic Lobban
@alkapwn3d
May 12 2016 02:27
1st thing i did and it didnt work
Jamie
@kesjam
May 12 2016 02:27
@PattyCreates @CaptainMurphey Got it, it was the } after return answer thanks!
CamperBot
@camperbot
May 12 2016 02:27
kesjam sends brownie points to @pattycreates and @captainmurphey :sparkles: :thumbsup: :sparkles:
:warning: kesjam already gave pattycreates points
:cookie: 279 | @captainmurphey |http://www.freecodecamp.com/captainmurphey
Dominic Lobban
@alkapwn3d
May 12 2016 02:27
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty(checkProp); 
  return "Not Found";
}
myObj.hasOwnProperty(""); 
// Test your code by modifying these values
checkObj("gift");
bitgrower
@bitgrower
May 12 2016 02:28
well, @alkapwn3d -- you need to make it a conditional, yeah ? what .hasOwnProperty returns is not captured in any way ...
so you are not checking whether it is true or false ..
Dominic Lobban
@alkapwn3d
May 12 2016 02:29
use if statements you then
?
bitgrower
@bitgrower
May 12 2016 02:30
I thought I saw one in your first post ... yes ... you have do check the value that .hasOwnProperty returns ... then use a conditional to see whether to return the value or to return "Not Found" ...
the very last .hasOwnProperty in your post does nothing... it's not needed ... and it's outside of your function ...

so ...

if (myObj.hasOwnProperty(checkObj) === true) {
return myObj.hasOwnProperty(checkObj)
...etc ...

oops ... sorry ... you would return myObj[checkObj] if true -- sorry, long and busy day ...
Dominic Lobban
@alkapwn3d
May 12 2016 02:35
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkObj) === true) {
return myObj.hasOwnProperty(checkObj);
} else return "Not Found";
}
myObj.hasOwnProperty(""); 
// Test your code by modifying these values
checkObj("gift");
Aaron
@amfische
May 12 2016 02:35
I'm have a basic js issue with a global variable returning undefined and I'm not sure why
Dominic Lobban
@alkapwn3d
May 12 2016 02:36
??
Aaron
@amfische
May 12 2016 02:36
how do you upload a picture like that?
Dominic Lobban
@alkapwn3d
May 12 2016 02:37

```js
bitgrower
@bitgrower
May 12 2016 02:37

@amfische ...

^```js

<paste your code in here>
^```

(put in the last 3 backticks onlly if they haven't been added for you ...

Dominic Lobban
@alkapwn3d
May 12 2016 02:37
shift + enter
```
bitgrower
@bitgrower
May 12 2016 02:37
or .. put another way
help formatting
CamperBot
@camperbot
May 12 2016 02:37

: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 the code.

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

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

Dominic Lobban
@alkapwn3d
May 12 2016 02:38
@bitgrower is my code right
i know its not right. wats wrong with it
Aaron
@amfische
May 12 2016 02:38

```var weather;

navigator.geolocation.getCurrentPosition(function(position) {
document.getElementById("data").innerHTML = position.coords.latitude + ", " + position.coords.longitude;
});

$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=51f61b5f031e34a4e3c790f126690615", gotData);

function gotData(data) {
weather = data;
}
document.getElementById("weatherAPI").innerHTML = weather.wind.speed;

```var weather;

navigator.geolocation.getCurrentPosition(function(position) {
document.getElementById("data").innerHTML = position.coords.latitude + ", " + position.coords.longitude;
});

$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=51f61b5f031e34a4e3c790f126690615", gotData);

function gotData(data) {
weather = data;
}
document.getElementById("weatherAPI").innerHTML = weather.wind.speed;

```

bitgrower
@bitgrower
May 12 2016 02:40
@alkapwn3d -- I gave you the wrong code -- see my correction .. it should be return myObj[checkObj] .. my bad -- I misposted
Dominic Lobban
@alkapwn3d
May 12 2016 02:41
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkObj) === true) {
return  myObj[checkObj];
} else return "Not Found";
}
myObj.hasOwnProperty(""); 
// Test your code by modifying these values
checkObj("gift");
??
isa that it?
bitgrower
@bitgrower
May 12 2016 02:42
does it pass ?!?!?!
Dominic Lobban
@alkapwn3d
May 12 2016 02:42
nope
wrong link
Gianni de Luca
@giannidluca
May 12 2016 02:43
i cant understadn very well javascript lessons
bitgrower
@bitgrower
May 12 2016 02:43
that's cuz you are missing an ending bracket for your function, @alkapwn3d --
Dominic Lobban
@alkapwn3d
May 12 2016 02:44
could you paste what you think is the right answer?
bitgrower
@bitgrower
May 12 2016 02:44
actually -- wait -- I thought I saw an if statement in there before --
NO!! sorry ...
you won't learn anything that way ...
you want answers -- they are in the wiki ...
Dominic Lobban
@alkapwn3d
May 12 2016 02:44
im not learning anything now
please dont assume you know whats the best way for me to learn
everyone learns differently
Aaron
@amfische
May 12 2016 02:45
var x = 0;
Johnny K Juarez
@Reapnsow
May 12 2016 02:45

Hey guys! So i'm on "Accessing Objects Properties with Variables" and I passed it, but I just wanted to make sure that my code is actually correct. Thanks.

```

bitgrower
@bitgrower
May 12 2016 02:45
like I said, @alkapwn3d -- if you want answers, they are in the wiki ...
Johnny K Juarez
@Reapnsow
May 12 2016 02:45

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

// Only change code below this line;

var playerNumber = 16;// Change this Line
var player = testObj[playerNumber];   // Change this Line
Aaron
@amfische
May 12 2016 02:45
var weather;

navigator.geolocation.getCurrentPosition(function(position) {
  document.getElementById("data").innerHTML = position.coords.latitude + ", " + position.coords.longitude;
});


$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=51f61b5f031e34a4e3c790f126690615", gotData);

function gotData(data) {
    weather = data;
}
document.getElementById("weatherAPI").innerHTML = weather.wind.speed;
finally, my weather variable returns undefined in my last line of code. why is that??
Dominic Lobban
@alkapwn3d
May 12 2016 02:46
it would be one thing if we were in person but when ever i ask for help people give me answers that I dont understand and im really tired of it
i am very close to quitting because of it
Aaron
@amfische
May 12 2016 02:46
:(
Gianni de Luca
@giannidluca
May 12 2016 02:46
i’m really stuck with javascript
you should google answers
Aaron
@amfische
May 12 2016 02:47
maybe just take a couple days off from coding, then come back with a fresh and clear head
Gianni de Luca
@giannidluca
May 12 2016 02:47
with explanation
bitgrower
@bitgrower
May 12 2016 02:47
sorry -- ain't gonna be guilt tripped ... coding is TOUGH ... and it's not for everyone ...
Chris Lacaille
@ChrisL108
May 12 2016 02:47
@amfische I'm not sure if anything's wrong with your code or not but I know in Chrome you can't use Geolocation because of a security update.. unless your getting JSON through HTTPS instead of HTTP
Gianni de Luca
@giannidluca
May 12 2016 02:47
hey guys i’m stuck with JSON
Dominic Lobban
@alkapwn3d
May 12 2016 02:47
no shit its touch but like i said everyone learns differently
bitgrower
@bitgrower
May 12 2016 02:48
I would suggest going back and reviewing the challenges you've already done and passed ... because you are probably mssing a few things ...
Gianni de Luca
@giannidluca
May 12 2016 02:48
i pass the lesson but i can’t really understand what i’m doing
Dominic Lobban
@alkapwn3d
May 12 2016 02:48
when i ask someone on the street for directions i dont expect them to tell me to go figure it out by myself
tough*
bitgrower
@bitgrower
May 12 2016 02:48
that's a bit different, @alkapwn3d
Dominic Lobban
@alkapwn3d
May 12 2016 02:48
is it?
ive been staring at this question for 5 hours
i ask for help as a last resort
Johnny K Juarez
@Reapnsow
May 12 2016 02:49
@giannidluca I'd recommend googling what they're asking you to do and read about what you're actually doing, I noticed in alot of FCC lessons it's mostly just examples. but some articles online will breakdown what you're trying to do.
bitgrower
@bitgrower
May 12 2016 02:49
go back to what I said -- go thru the past challenges you completed and review them ...
Justin Seiter
@justinseiter
May 12 2016 02:49
@alkapwn3d see if this helps: http://jsbin.com/dupayejuzo/edit?js,console
bitgrower
@bitgrower
May 12 2016 02:49
make sure you understand them...if you don't understand them ... that's where you should start ...
Chris Lacaille
@ChrisL108
May 12 2016 02:50
@amfische and I think you need to pass the data object gotData(data) in the getJSON? maybe
Dominic Lobban
@alkapwn3d
May 12 2016 02:50
@bitgrower thank you for you help. have a good day
CamperBot
@camperbot
May 12 2016 02:50
alkapwn3d sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1040 | @bitgrower |http://www.freecodecamp.com/bitgrower
Norvin Burrus
@ndburrus
May 12 2016 02:50
@alkapwn3d what did you have a question on?
Aaron
@amfische
May 12 2016 02:51
@ChrisL108 I'm using firefox because chrome crashes my os for some reason, let me try passing the gotData function directly into the getJSON
Chris Lacaille
@ChrisL108
May 12 2016 02:52
No i mean keep it like you have it but pass the data parameter into the function call... I might be wrong but try that
Norvin Burrus
@ndburrus
May 12 2016 02:53
@Reapnsow it looks good...
Chris Lacaille
@ChrisL108
May 12 2016 02:53
@amfische Oh nvm I see what u mean :thumbsup:
Justin Woodward
@jwoo92
May 12 2016 02:54
@alkapwn3d reviewing your latest code post, i noticed you did not put your else in brackets.
Norvin Burrus
@ndburrus
May 12 2016 02:56
@amfische the code creates this error: "TypeError: Cannot read property 'getCurrentPosition' of undefined" ...is that the entire code?
Aaron
@amfische
May 12 2016 02:58
@ndburrus @ChrisL108 the error I'm getting in the console only says : "TypeError: weather is undefined"
Norvin Burrus
@ndburrus
May 12 2016 02:59
@amfische is this the entire code? it looks like you're retrieving information from the DOM...
Chris Lacaille
@ChrisL108
May 12 2016 02:59
@amfische Is there anything by the icon bar saying your location was blocked
url bar *
Aaron
@amfische
May 12 2016 03:00
@ndburrus if I open up that coded error it says: "<anonymous> app:js.13" line 13 is referring to where I try to add weather.wind.speed to my html
MVM1969
@MVM1969
May 12 2016 03:01
Question re:Expressions: Why do I use \s+ to find all white spaces but \S (no +!!) to find all non-white spaces?
Aaron
@amfische
May 12 2016 03:02
@ChrisL108 no I don't think so. the first part of the code with the geolocation works and asks permission for my location. but the part of my code with the weather variable is separate so I don't think it should affect it
Chris Lacaille
@ChrisL108
May 12 2016 03:02
Oh alright, think it's just a chrome thing
Aaron
@amfische
May 12 2016 03:02
but I'm in firefox
oh i gotcha
Chris Lacaille
@ChrisL108
May 12 2016 03:03
Hm well idk man lol I just remembered that security issue giving me trouble.. I'm still new to AJAX and JSON
bitgrower
@bitgrower
May 12 2016 03:04

@amfische - some times error messages can be hard to understand ... LOL -- but when you see one, and you finally realize what the problem was -- then go back and see how the error message was trying to tell you what you now understand ...

...the error messages may not be the best ...but this is a good way of dealing with them now & in the future ... Over time, I've found it works for me ...

they DO tend to be VERY VERY literal...
Aaron
@amfische
May 12 2016 03:06
ya I don't get it, especially because I'm trying to do something very simple just make a global variable
if i type typeof weather in the console i get undefined, but if i type "weather" in window it returns true
bitgrower
@bitgrower
May 12 2016 03:06
maybe a global variable naming conflict ?
Aaron
@amfische
May 12 2016 03:07
maybe, let me try a different name
dont think its the name
Chris Lacaille
@ChrisL108
May 12 2016 03:09
Oh you know that
what*
bitgrower
@bitgrower
May 12 2016 03:09
wait ... you are using "data" in two different places ...
Chris Lacaille
@ChrisL108
May 12 2016 03:10
there was one other thing
weather[0].wind.speed; <-- something like that
because it was in a object
Aaron
@amfische
May 12 2016 03:11
i changed the code a bit, here is what i have
var weather;

navigator.geolocation.getCurrentPosition(function(position) {
  document.getElementById("data").innerHTML = position.coords.latitude + ", " + position.coords.longitude;
});


$.getJSON("api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=51f61b5f031e34a4e3c790f126690615", function(data) {
    weather = data;
});


document.getElementById("weatherAPI").innerHTML = weather.wind.speed;
Chris Lacaille
@ChrisL108
May 12 2016 03:11
@amfische try calling weather[0].wind.speed;
Ken Haduch
@khaduch
May 12 2016 03:12
@bitgrower - how are you doing? Looks like you're giving great help, I hope that everyone appreciates your efforts!
bitgrower
@bitgrower
May 12 2016 03:12
LOL I think @ChrisL108 is onto the correct answer ... I was about to post something like that ... like you are passing a json object to innerHTML and innerHTML doesn't like it ...
Chris Lacaille
@ChrisL108
May 12 2016 03:12
Yeah i forgot i 'luckily' noticed that on first glance
when i did it
bitgrower
@bitgrower
May 12 2016 03:13
hahahaha @khaduch -- kicking but a little...my usual cantakerous self ... probably exacerbated by a sort of bootcamp I just joined (not a coding bootcamp ... )
Ken Haduch
@khaduch
May 12 2016 03:14
@bitgrower - well, buts need to be kicked once in a while... keep up the great work! A little tough love is needed to build good coders... ;)
Aaron
@amfische
May 12 2016 03:14
adding the index didn't help, weather[0].wind.speed :(
Chris Lacaille
@ChrisL108
May 12 2016 03:14
aw
bitgrower
@bitgrower
May 12 2016 03:15
@amfische -- see if you can dump the json ... it might be more than an index you need ...
Chris Lacaille
@ChrisL108
May 12 2016 03:15
thought that was it.. have you tried typing the url in the browser to see the returbned JSON?
bitgrower
@bitgrower
May 12 2016 03:15
snap @ChrisL108
Chris Lacaille
@ChrisL108
May 12 2016 03:15
@bitgrower LOL was so happy with myself
Aaron
@amfische
May 12 2016 03:16
yes it returns the json code
hah
bitgrower
@bitgrower
May 12 2016 03:16
yeah -- think there might be something amiss with the JSON references ...
you're not addressing something properly ...
Aaron
@amfische
May 12 2016 03:16
well I gotta run guys, I will have to try this again tomorrow
thanks a lot of your input though!
Chris Lacaille
@ChrisL108
May 12 2016 03:16
good Luck @amfische
bitgrower
@bitgrower
May 12 2016 03:16
think back to Profile Lookup & Record Collection ...
Ken Haduch
@khaduch
May 12 2016 03:17
@amfische - looks like wind.speed might be what you need?
Islam Ibakaev
@dagman
May 12 2016 03:17
@amfische use http://ipinfo.io/ by making
$.getJSON('http://ipinfo.io', function(data){
  console.log(data)
})
bitgrower
@bitgrower
May 12 2016 03:19
oooh ... nice, @dagman ...
Islam Ibakaev
@dagman
May 12 2016 03:21
@bitgrower ...
:worried:
bitgrower
@bitgrower
May 12 2016 03:22
it's simple & clear ... :)
Islam Ibakaev
@dagman
May 12 2016 03:22
yep :smile:
Steve
@smr312
May 12 2016 03:22

So im trying to iterate through an array with a for loop whats wrong here : var myArr = [ 2, 3, 4, 5, 6];
var myTotal = 0;

for (var i = 2; i < myArr.length; i++) {
myTotal += myArr[i];
}

bitgrower
@bitgrower
May 12 2016 03:23
a nice building block ... :)
Steve
@smr312
May 12 2016 03:23
the var i=2 should be 0 i know
bitgrower
@bitgrower
May 12 2016 03:23
are you getting any error messages, @smr312 -- or just not passing tests ?
Steve
@smr312
May 12 2016 03:24
i got 2 of 4 error messages... Total should be declared and initialized to 0
bitgrower
@bitgrower
May 12 2016 03:24
what happens if you change the var i = 0
Steve
@smr312
May 12 2016 03:24
and total should equal 20
same thing
Islam Ibakaev
@dagman
May 12 2016 03:25
@smr312
var myArr = [ 2, 3, 4, 5, 6],
       myTotal = 0,
        i,
        len = myArr.length;
for ( i = 0; i < len; i += 1) {
       myTotal += myArr[i];
}
bitgrower
@bitgrower
May 12 2016 03:26
hmmm ... there's a piece missing for me ...
Steve
@smr312
May 12 2016 03:28
nope that didnt work
Islam Ibakaev
@dagman
May 12 2016 03:29
???
Norvin Burrus
@ndburrus
May 12 2016 03:29
@smr312 it works offering a value of 20...
Chris Lacaille
@ChrisL108
May 12 2016 03:29
Can anyone take a peek at this codePen - I can't figure out why my .on('click') isn't working correctly
for the life of me it's probably something simple lol
Steve
@smr312
May 12 2016 03:30
not for me
Islam Ibakaev
@dagman
May 12 2016 03:31
@ChrisL108 $("body").html(quote[0].title);??????
Norvin Burrus
@ndburrus
May 12 2016 03:31
@smr312 is this a challenge?
Chris Lacaille
@ChrisL108
May 12 2016 03:31
The Random Quote Generator
Ken Haduch
@khaduch
May 12 2016 03:31
@ChrisL108 - you're replacing the entire body?
Chris Lacaille
@ChrisL108
May 12 2016 03:31
no ignore that it's $("#quote") LOL
It didnt update when i posted?
Steve
@smr312
May 12 2016 03:31
yes
Norvin Burrus
@ndburrus
May 12 2016 03:31
@smr312 ok, im not there yet, but the code you posted works (with the adjustment of i = 0, not 2)
Steve
@smr312
May 12 2016 03:32
yeah I made that adjustment its not working so I was justinputing random numbers
rphares
@rphares
May 12 2016 03:33
@antiphilous-- very cool! :) thanks for the link~
CamperBot
@camperbot
May 12 2016 03:33
rphares sends brownie points to @antiphilous-- :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for antiphilous--
Norvin Burrus
@ndburrus
May 12 2016 03:33
@smr312 i dont see that challenge
Ken Haduch
@khaduch
May 12 2016 03:33
@ChrisL108 - yeah, it is still showing $("body")
Steve
@smr312
May 12 2016 03:33
challenge 233
Ken Haduch
@khaduch
May 12 2016 03:34
@ChrisL108 - it looks like it's working to fetch a quote and get the author? Or title? But just writing to the body...
Steve
@smr312
May 12 2016 03:34
Iterate Through an Array with a For Loop\
Norvin Burrus
@ndburrus
May 12 2016 03:34
@smr312 im not sure how to search by number, sorry
Chris Lacaille
@ChrisL108
May 12 2016 03:35
@khaduch No i have $('#quote') not $('body')
still not workin :/
It's so simple but a pain in the arse
I always get lost in CodePen for some unknown reason lol
Ken Haduch
@khaduch
May 12 2016 03:36
@ChrisL108 - have you ssaved your pen? I'm seeing this:
$("#newQuote").on('click', function(e) {
e.preventDefault();  

  $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=",function(quote) {
    $("body").html(quote[0].title);
    console.log(quote[0].title);
  });
 });  // on click
Chris Lacaille
@ChrisL108
May 12 2016 03:36
Oh wow lol there you go its saved
Norvin Burrus
@ndburrus
May 12 2016 03:36
@smr312 are you using the var/ables (total, myArr) given in the challenge?
Steve
@smr312
May 12 2016 03:37
yeah
Ken Haduch
@khaduch
May 12 2016 03:38
@ChrisL108 - it looks like it's working, at least for what you have implemented. I click the button and get "Johanna Drucker" posted to the screen. Is it that you think it should be changing?
Chris Lacaille
@ChrisL108
May 12 2016 03:38
What? really lol
are you using Chrome?
Chrome's security's update completely screw up JSON callbacks
Steve
@smr312
May 12 2016 03:38
figured go it
*got it
Norvin Burrus
@ndburrus
May 12 2016 03:39
@smr312 ok, good...
Chris Lacaille
@ChrisL108
May 12 2016 03:39
It's not updating the text at all for me @khaduch
Steve
@smr312
May 12 2016 03:39
thanks @ndburrus for the help
CamperBot
@camperbot
May 12 2016 03:39
smr312 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 12 2016 03:39
@smr312 what was it? i didn't do much... but, you're welcome, anytime :)
Islam Ibakaev
@dagman
May 12 2016 03:39

@ChrisL108

$("#newQuote").on('click', function(e) {
  e.preventDefault();

  $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(quote) {
    $("#quote")
      .html(quote[0].content)
      .siblings('#quote-src')
      .text(quote[0].title);
  });
});

but looks like you always gets the same quote from api :smile:

Steve
@smr312
May 12 2016 03:40
spelling
Ken Haduch
@khaduch
May 12 2016 03:40
@ChrisL108 - which browser are you using? I'm using Chrome and I see that "Johanna Drucker" posted in the grey box in the middle.
Chris Lacaille
@ChrisL108
May 12 2016 03:40
Hmm well thanks for helping me figure out it's my browser @dagman and it's not random lol
CamperBot
@camperbot
May 12 2016 03:40
chrisl108 sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:cookie: 534 | @dagman |http://www.freecodecamp.com/dagman
Steve
@smr312
May 12 2016 03:40
like an idiot
Chris Lacaille
@ChrisL108
May 12 2016 03:40
Chrome You?
wth?
Ken Haduch
@khaduch
May 12 2016 03:41
blob
Norvin Burrus
@ndburrus
May 12 2016 03:41
@smr312 aah.... ok... well, you spotted it & corrected it... excellent work!
Steve
@smr312
May 12 2016 03:41
thankyou thankyou
Chris Lacaille
@ChrisL108
May 12 2016 03:41
@khaduch Why do you think it wouldn't work for me? I'm on Chrome
Micah Bales
@micahbales
May 12 2016 03:41
Working on Smallest Common Multiple. Can anyone give me an idea of what is broken here?
function smallestCommons(arr) {
  // find high and low numbers
  var high = arr[1] > arr[0] ? arr[1] : arr[0];
  var low = arr[0] < arr[1] ? arr[0] : arr[1];
  var range = [];

  for (i = low; i <= high; i += 1) { // create a range of numbers between high and low
    range.push(i);
  }  
  range.reverse(); // make the highest number first

  var multiple = range[0];
  var counter = 0;

  while (counter < range.length) {

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

      if (range[j] % multiple === 0) { // check each number in range to see if lowest common multiple
        counter++;
      } else {
        break;
      }

    } // for loop

    if (counter === range.length) {
      return multiple;
    } else {
      multiple += multiple;
      counter = 0;
    }


  } // while

}


smallestCommons([1,5]);
Chris Lacaille
@ChrisL108
May 12 2016 03:43
@khaduch and thanks for the .siblings('#quote-src') .text(quote[0].title);
CamperBot
@camperbot
May 12 2016 03:43
chrisl108 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1104 | @khaduch |http://www.freecodecamp.com/khaduch
Islam Ibakaev
@dagman
May 12 2016 03:43
@micahbales you would better divide you solution into small functions
Ken Haduch
@khaduch
May 12 2016 03:43
@ChrisL108 - are you seeing anything in your console?
Chris Lacaille
@ChrisL108
May 12 2016 03:43
im still getting used to the 'jQuery' way of doing thinfs like chaining
Thomas G.
@CaptainMurphey
May 12 2016 03:43

function destroyer(arr) {

  var myArray = arr.slice(arguments[0]);
  console.log(myArray);
   function destroyer(value,index,array){
     console.log(arr[arr.length-1]);
     if (value===arr[arr.length-1] || value===arr[arr.length-2]){return false;}
     else{return true;}


   }

  var result = myArray.filter(destroyer);
  // Remove all the values
  return result;
}

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

ok guys im doing the seek and destroy, and i cant figure out a way to separate the parameter that is an array from the parameters that are just numbers, the way im doing it i know is hard coding the last two arguments to compare against the array, so anyone have any suggestions to how to get past this?

```

Chris Lacaille
@ChrisL108
May 12 2016 03:43
nah it doesn't work for me lol
im baffled
Micah Bales
@micahbales
May 12 2016 03:43
@dagman Can you say a bit more about that?
@dagman I'm getting an infinite loop warning and not quite understanding why
bitgrower
@bitgrower
May 12 2016 03:44
@CaptainMurphey -- if you look on the recommended MDN page for arguments object, they have a piece of code you can steal to create an array from the arguments object (hint, hint)
Chris Lacaille
@ChrisL108
May 12 2016 03:44
@khaduch I even added your implementation thinking maybe a typo or something but nothing...
Ken Haduch
@khaduch
May 12 2016 03:45
@ChrisL108 - I have to go, but I'll make one suggestion - try clearing your browser cache / temporary files, or move to firefox for a test? Sometimes javascript gets cached and you just don't get the new code? It's a long shot...
Thomas G.
@CaptainMurphey
May 12 2016 03:45
@bitgrower so would you create a seperate array of the two or three extra parameters that arent in the array argument?
Chris Lacaille
@ChrisL108
May 12 2016 03:46
@khaduch Ok I'lll give it a shot. Thx again!
CamperBot
@camperbot
May 12 2016 03:46
chrisl108 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: chrisl108 already gave khaduch points
bitgrower
@bitgrower
May 12 2016 03:46
@micahbales smallest common is a challenge which needs some specific algos -- have you searched the web for "least common denominator" algos -- I found a nice one (that I used) on the dummies.com site ...
Chris Lacaille
@ChrisL108
May 12 2016 03:46
maybe incognito mode
bitgrower
@bitgrower
May 12 2016 03:46
@CaptainMurphey -- try it and see !
Thomas G.
@CaptainMurphey
May 12 2016 03:46
@bitgrower ok cool thx
CamperBot
@camperbot
May 12 2016 03:46
captainmurphey sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1041 | @bitgrower |http://www.freecodecamp.com/bitgrower
Chris Lacaille
@ChrisL108
May 12 2016 03:47
Incognito Mode fixed it! it works woot
Islam Ibakaev
@dagman
May 12 2016 03:47
@micahbales
1) build a function that gets [1, 5] and returns [1,2,3,4,5]
2) build functions that find gcd for two numbers
3) build function that find scm for two numbers
Ken Haduch
@khaduch
May 12 2016 03:47
@ChrisL108 - I just ran it in firefox with your latest code, I'm getting the full quote and it changes with each click...
Chris Lacaille
@ChrisL108
May 12 2016 03:47
@khaduch It works in incognito mode
Yeah it must be some kinda cache issue or something like you said
Ken Haduch
@khaduch
May 12 2016 03:48
@ChrisL108 - ok... that's probably a sign of caching issues? But I"m only seeing one quote when I run in Chrome... Firefox was showing different quotes?
Chris Lacaille
@ChrisL108
May 12 2016 03:49
Oh okay that was the next thing I was about to figure out lol thx for the third time hah
that's weird
Guilherme Salomé
@Salompas
May 12 2016 03:49
Fellows I'm having problem with the challenge Inventory Update. I get the exact same solution that is asked for, but I don't get the points (some test cases appear as if I got something wrong. Here's my code:
Chris Lacaille
@ChrisL108
May 12 2016 03:50
@khaduch I only get the first one in Incog too
Ken Haduch
@khaduch
May 12 2016 03:50
@ChrisL108 - I cleared my Chrome temporary files, I got a new quote, but now it's "stuck" on that one... crazy!!!
Chris Lacaille
@ChrisL108
May 12 2016 03:51
@khaduch you showed me that i need to have firefox or another browser while debugging lol
download ff now
Guilherme Salomé
@Salompas
May 12 2016 03:51
This message was deleted
Ken Haduch
@khaduch
May 12 2016 03:51
@ChrisL108 - same thing again... maybe putting some "nocache" meta tag in there or something would work?
bitgrower
@bitgrower
May 12 2016 03:52

a bit of pontification here ... part of learning how to code is learning how to use the tools you have to check and inspect what is happening within your code ... this is why sites like jsbin & jsfiddle are cool ... the one I found and have been in love with ever since is http://pythontutor.com/javascript.html ...

if you run into problems ... you need more information -- you may have missed something in some of the earlier challenges ... sometimes you have to go what seems to be backward to actually move forward...

one of the reasons for folks to come out and help here is it beefs up our knowledge of even material we've already covered ... (and I highly recommend helping out ... it's a great way to learn .. and yeah, sometimes you'll make a mistake ... it happens...)

...if you get stuck -- pounding your head against the wall until you find a solution may not be the best alternative ... sometimes the BEST thing you can do is take a break -- get some exercise, get some food, meditate, take a nap ...

Chris Lacaille
@ChrisL108
May 12 2016 03:52
@khaduch I'll check the API doc's
Guilherme Salomé
@Salompas
May 12 2016 03:53
Fellows I'm having problem with the challenge Inventory Update. I get the exact same solution that is asked for, but I don't get the points (some test cases appear as if I got something wrong. Here's my code:
function updateInventory(arr1, arr2) {
    // All inventory must be accounted for or you're fired!
    arr2.forEach(function(item) {
      var name = item[1];
      var value = item[0];
      var found = false;
      for(var i = 0; i < arr1.length; i++) {
        if(arr1[i][1] === name) {
          arr1[i][0] += value;
          i = arr1.length + 1;
          found = true;
        }
      }
      if(!found) {
        arr1.push([value,name]);
      }      
    });

    return arr1.sort(function(item1,item2){return item1[1]>item2[1];});
}
Micah Bales
@micahbales
May 12 2016 03:53
@bitgrower if you could briefly pontificate in my direction: Do you think it's legit for me to just look up established algorithms on stackoverflow and use them as the basis for my solution? isn't that "cheating" (mostly myself, of the chance to use my brain and figure it out?)
@bitgrower I'm finding the answer to this problem on stackoverflow, but feel like I'm missing the point to use it.
Chris Lacaille
@ChrisL108
May 12 2016 03:54
@ChrisL108 maybe $('body).on('click', '#newQuote', function() {});?
@khaduch
Islam Ibakaev
@dagman
May 12 2016 03:54
@ChrisL108 you don't need delegation here
Chris Lacaille
@ChrisL108
May 12 2016 03:55
@dagman Yeah that didn't change anything
Islam Ibakaev
@dagman
May 12 2016 03:55
@ChrisL108 what the problem do u have for now?
Fatma Ali
@Fatmali
May 12 2016 03:55
hi guys how can I get over the CORS error, I have tried everything but still doesnt work, http://codepen.io/fatmali/pen/xVBLbK
Chris Lacaille
@ChrisL108
May 12 2016 03:55
well my Pen works on firefox but not Chrome lol
bitgrower
@bitgrower
May 12 2016 03:56

it really depends ... I had to look up the solution for seek and destroy here on the wiki -- but even after looking at it, I didn't understand it -- but I kept pursuing it ... if you've reallly tried, and you're really stuck to the point you're moving backwards ... go check out the hints on the wiki (go far enough, you'll get complete solutions...)

I had difficulty understanding S&D as I said -- but I just kept at it until I understood that thing backward and forward ... and I LOVE that challenge ever since ... :)

Chris Lacaille
@ChrisL108
May 12 2016 03:56
Only get's one quote in Chrome
bitgrower
@bitgrower
May 12 2016 03:56
are you using an api @ChrisL108 ?
some api sources have a limitation on the # of calls in a period of time ...
Justin Woodward
@jwoo92
May 12 2016 03:57
@bitgrower great advice :+1:
Chris Lacaille
@ChrisL108
May 12 2016 03:57
@bitgrower didn't even think of that
Islam Ibakaev
@dagman
May 12 2016 03:57
@ChrisL108 it works
khaduch @khaduch - turning into a pumpkin... good night all...
Islam Ibakaev
@dagman
May 12 2016 03:57
@ChrisL108 every time returns the same object
Chris Lacaille
@ChrisL108
May 12 2016 03:58
I think it's right but just like @bitgrower said
bitgrower
@bitgrower
May 12 2016 03:58
looking up answers to pass a challenge -- not good ... looking up answers because you've really tried, and then dedicating yourself to understanding them ... I had even asked someone else (not in FCC) to explain the S&D solution -- and I still didn't get it ... but I refused to stop until I understood (later, in reviewing the comments the other programmer made about how the code worked, some were actually incorrect...) ...
Islam Ibakaev
@dagman
May 12 2016 03:59
@ChrisL108 maybe something wrong with url???
Chris Lacaille
@ChrisL108
May 12 2016 03:59
URL gives random when searched in browser
@dagman IT MAKES NO SENSE MAN
LOL
bitgrower
@bitgrower
May 12 2016 03:59
...and don't be afraid to go out and augment your learning here .. .there are plenty of excellent resources out there -- even free resources -- to augment your learninig ...
help js resources
bitgrower
@bitgrower
May 12 2016 04:00
those are some -- several of us REALLY like Tony Alicea's stuff (that's the Udemy course mentioned)
me included ... one of the first things I accessed to augment my learning here ...
Chris Lacaille
@ChrisL108
May 12 2016 04:00
@dagman I think I'll leave it since it works just a weird caching or too many calls to API or something else weird
It has worked for people usng firefox apparently
Fatma Ali
@Fatmali
May 12 2016 04:02
@\all I could really use some help
I dont know what Im doing wrong http://codepen.io/fatmali/pen/xVBLbK
I keep getting cross-domain errors
bitgrower
@bitgrower
May 12 2016 04:03
yes -- that's a common problem -- I would recommend all you web projects people consider checking out the frontend room for help ... the people who hang out there are going to have, on average, a lot more experience with the web project challenges than people in this room ...
help rooms
CamperBot
@camperbot
May 12 2016 04:03

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap FreeCodeCamp/Help
JavaScript/Algorithms FreeCodeCamp/HelpJavaScript
Front End FreeCodeCamp/HelpFrontEnd
Data Visualization FreeCodeCamp/HelpDataViz
Back End FreeCodeCamp/HelpBackEnd

Choose the right room for your questions!

See also: :earth_asia: Language Specific | :satellite: Technology | :crystal_ball: Miscellaneous

back to top

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

bitgrower
@bitgrower
May 12 2016 04:04
@Fatmali -- google CORS ... cross domain errors and the like ...
Thomas G.
@CaptainMurphey
May 12 2016 04:04
@bitgrower ok bud so im trying to use var args = Array.prototype.slice.call(arguments); like var sliced = Array.prototype.slice.call( arr, arr[1] ); and its starts from the second number in the argument that is an array, instead of starting at the second actual argument --> so if : arguments([chesse, beer, fish] , tacos, beer ) it will start at beer instead of tacos
Chris Lacaille
@ChrisL108
May 12 2016 04:04
@bitgrower Are Firefox and Chrome 2 good browsers to have for debugging. Do you have more like Opera etc?
@bitgrower last question i promise lol
bitgrower
@bitgrower
May 12 2016 04:05
FF & Chrome are the best -- I don't use anything else, so I couldn't speak to others -- and my opinion about them is based a lot on having read the opinions of other people I respect (in some of that "augmentation reading" I mentioned ... )
Fatma Ali
@Fatmali
May 12 2016 04:07
I have practically tried almost every solution on google @bitgrower, however If i move the ajax api call out of the callback , the api call is successful
Chris Lacaille
@ChrisL108
May 12 2016 04:07
Thanks @bitgrower :thumbsup:
CamperBot
@camperbot
May 12 2016 04:07
chrisl108 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1042 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
May 12 2016 04:07

nice work, love you getting in there and kicking ... see what happens to your code when you throw it in here:

http://pythontutor.com/javascript.html ... you can actually step thru your code and watch your variables change (that's what I did when playing around with S&D ..

Fatma Ali
@Fatmali
May 12 2016 04:08
but it returns the wrong result because latitude and longitude are still undefined
bitgrower
@bitgrower
May 12 2016 04:08
:( ... again, @Fatmali -- I don't know what to tell you -- if it were me, I would go see if someone in the FrontEnd room could help ...
Fatma Ali
@Fatmali
May 12 2016 04:09
okay thanks @bitgrower
CamperBot
@camperbot
May 12 2016 04:09
fatmali sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1043 | @bitgrower |http://www.freecodecamp.com/bitgrower
EricOber
@EricOber
May 12 2016 04:09
hey u giys
bitgrower
@bitgrower
May 12 2016 04:11
okay ... about 30 minutes ago I realized I hadn't eaten anything today -- and it's been a longer & much busier day than expected ... so, like @khaduch -- I'm making like a pumpkin (I'm so tired now, i don't even know if that's the right expression ... :worried:
good luck to y'all and keep on swimming ...even when it seems like it's all uphill against a fast current ...
Iskya
@iskya
May 12 2016 04:13

hi.. any sugest in the largest of Four Arrays, i'm kinda confused... this is my code ```
function largestOfFour(arr) {

var largestArr = [];

for(i = 0; i< arr.length; i++){
var inArr= arr[i];
var num = 0;
for(j = 0; j<inArr.length; j++){ if(inArr[j] > num){
num = inArr[j];
}
largestArr.push(num);
}
return largestArr;
}

} ```

Islam Ibakaev
@dagman
May 12 2016 04:16
@ChrisL108 chuck norris jokes api works perfectly http://codepen.io/dagman/pen/NNJEYj?editors=0010
Chris Lacaille
@ChrisL108
May 12 2016 04:20
@dagman Yeah that doesn't work on my browser either? Weird...
@dagman Works in firefox though
Islam Ibakaev
@dagman
May 12 2016 04:21
@ChrisL108 even chuck norris?
Chris Lacaille
@ChrisL108
May 12 2016 04:21
@dagman even chuck... lol
works on firefox and not chrome for me
rphares
@rphares
May 12 2016 04:22
Works in safari
Islam Ibakaev
@dagman
May 12 2016 04:22
works in chrome for me
V Arun Kumar
@arunvkumr
May 12 2016 04:22
@iskya your are close.. there is mismatch of braces in the algo..
Islam Ibakaev
@dagman
May 12 2016 04:22
:worried:
Chris Lacaille
@ChrisL108
May 12 2016 04:23
@dagman I think it's my cache or something because it works when i run in a icognito windows in Chrom
Islam Ibakaev
@dagman
May 12 2016 04:23
@ChrisL108 maybe update browser?
Chris Lacaille
@ChrisL108
May 12 2016 04:23
You can see how this had me pulling my hair out though LOL
Iskya
@iskya
May 12 2016 04:27
ohhh i see it ... thanx @arunkumrv
CamperBot
@camperbot
May 12 2016 04:27
iskya sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:cookie: 541 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
Austin Searle
@Speedclip
May 12 2016 04:27
// Fix the variable declarations and assinments so their names use camelCase
var StUdLyCapVaR = 10;
var properCamelCase = "A String";
var TitleCaseOver = 9000;

// Fix the variable declarations and assinments so their names use camelCase
var STUDLYCAPVAR = 10;
var PRoperCAmelCAse = "A String";
var tITLEcASEoVER = 9000;
need help
Chris Lacaille
@ChrisL108
May 12 2016 04:27
@Speedclip What's the problem
Austin Searle
@Speedclip
May 12 2016 04:28
i put a comment on the code
Chris Lacaille
@ChrisL108
May 12 2016 04:28
Have you tried? lol
@Speedclip Make sure you ubnderstand what 'camelcase' is
understand
Austin Searle
@Speedclip
May 12 2016 04:29
@ChrisL108 What am i doing wrong? it wants me to set each one to the name camelCase
Chris Lacaille
@ChrisL108
May 12 2016 04:29
no camelcase is a way of naming variables
like thisIsCamelCase
instead of say this-is-not-camel-case
V Arun Kumar
@arunvkumr
May 12 2016 04:30
@iskya you're welcome.. remove the last } and add a } before the push call. that should do it.. :smile:
Chris Lacaille
@ChrisL108
May 12 2016 04:31
var studlyCapVaR = 10;
theres the first one
studlyCapVar*
Aryan
@aryandua
May 12 2016 04:34
Hey guys I have a question
I have a variable named randQuote in JS
Austin Searle
@Speedclip
May 12 2016 04:35
@ChrisL108
Aryan
@aryandua
May 12 2016 04:35
how do I pass it to html??
Austin Searle
@Speedclip
May 12 2016 04:35
// Declarations
var studlyCapVaR = 10;
var properCamelCase = "A String";
var titleCaseOver = 9000;

// Assignments
var studlyCAPVAR = 10;
var properCAmelCAse = "A String";
var titleCaseOver = 9000;
rphares
@rphares
May 12 2016 04:35
look at the ones on the bottom, @Speedclip , need to fix both sets
Bobby McDonald
@BobbyMcWho
May 12 2016 04:35
@aryandua are you familiar with jquery at all?
Chris Lacaille
@ChrisL108
May 12 2016 04:36
I think it just wants you to declare it at top then assign on bottom @Speedclip
rphares
@rphares
May 12 2016 04:36
and the first one-- the last r shouldn't be capitlized @Speedclip
Aryan
@aryandua
May 12 2016 04:36
@BobbyMcWho yes
but i just cant remember
rphares
@rphares
May 12 2016 04:36
also, you dont need those assignments up top, @ChrisL108 is correct @Speedclip
Bobby McDonald
@BobbyMcWho
May 12 2016 04:36
@aryandua if you want pure javascript look at this page: http://www.w3schools.com/jsref/prop_html_innerhtml.asp
Chris Lacaille
@ChrisL108
May 12 2016 04:37
And like @rphares said var studlyCapVaR is var studlyCapVar
Bobby McDonald
@BobbyMcWho
May 12 2016 04:37
@aryandua for jquery cjeck this out: http://www.w3schools.com/jquery/html_html.asp
Chris Lacaille
@ChrisL108
May 12 2016 04:37
that was a typo on my part earlier sorry
Aryan
@aryandua
May 12 2016 04:37
@BobbyMcWho which one is easier??
Bobby McDonald
@BobbyMcWho
May 12 2016 04:37
@aryandua I personally prefer jquery
Aryan
@aryandua
May 12 2016 04:38
ok ill try that
Austin Searle
@Speedclip
May 12 2016 04:38
// Declarations
var studlyCapVar;
var properCamelCase;
var titleCaseOver;

// Assignments
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;
Bobby McDonald
@BobbyMcWho
May 12 2016 04:38
$('#target').html(variable);
Chris Lacaille
@ChrisL108
May 12 2016 04:39
looks good @Speedclip did it work
Bobby McDonald
@BobbyMcWho
May 12 2016 04:39
@aryandua
Austin Searle
@Speedclip
May 12 2016 04:39
@ChrisL108 Thanks
CamperBot
@camperbot
May 12 2016 04:39
speedclip sends brownie points to @chrisl108 :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @chrisl108 |http://www.freecodecamp.com/chrisl108
Chris Lacaille
@ChrisL108
May 12 2016 04:39
:thumbsup:
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:47
help me plz
CamperBot
@camperbot
May 12 2016 04:47
no wiki entry for: me plz
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:48
Capture.JPG
plz some one tell me what to do ?
rphares
@rphares
May 12 2016 04:48
@YeasenHossainFarhad , the first one seems okay,
you need to assign the contents of a to b, right?
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:49
yes
rphares
@rphares
May 12 2016 04:49
var a = 2;
var b = 3;
var c = 4;

b = c;
in the above example, i assigned the contents of c to b
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:50
b != c in real time
rphares
@rphares
May 12 2016 04:50
you can just restate (not declare, you only need var the first time) a var's name,
Joseph
@revisualize
May 12 2016 04:50
a is 2, b is 4, c is 4
rphares
@rphares
May 12 2016 04:50
and reassign it
Joseph
@revisualize
May 12 2016 04:51
:P
Austin Searle
@Speedclip
May 12 2016 04:51
@YeasenHossainFarhad
var a = 2;
var = 3;
var c = 4;

b = c;
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:51
i didnt get you dear
Joseph
@revisualize
May 12 2016 04:52
Can I help anyone?
rphares
@rphares
May 12 2016 04:52
the first half of those examples, we declared and assigned some vars, right? @YeasenHossainFarhad
var a = 2;
var b = 3;
var c = 4;
 The above makes sense, right?
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:52
yes
rphares
@rphares
May 12 2016 04:53
the last line, we are *re-assigning` var b
we already declared it
so we dont need to use var in front anymore
Joseph
@revisualize
May 12 2016 04:53
= defines assignment
rphares
@rphares
May 12 2016 04:53
we can just say its name, in this case b
and, we use = to assign it something new
b = (whatever we say)
Tyler Moore
@devopsec
May 12 2016 04:53
hey everyone having some trouble with my JSON get requests and I had them verified on jsonlint and prettyjson, but firefox debugger is giving me these syntax errors:
syntax error quoteData.json:1:1
syntax error backgroundData.json:1:1
rphares
@rphares
May 12 2016 04:53
so, to assign the contents of var c to var b in our examples,
Joseph
@revisualize
May 12 2016 04:53
var defines variable declaration.
= allows assignment and reassignment
rphares
@rphares
May 12 2016 04:54
we write b = c
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:54
hmm
rphares
@rphares
May 12 2016 04:54
you need to assign the contents of var b to var a if i recall-- check the instructions,
but you write it in the same format :blush:
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:55
okk thank you rphares rphares
let me try now
rphares
@rphares
May 12 2016 04:56
anytime~
(and ty @revisualize , @Speedclip ~)
CamperBot
@camperbot
May 12 2016 04:56
rphares sends brownie points to @revisualize and @speedclip :sparkles: :thumbsup: :sparkles:
:cookie: 22 | @speedclip |http://www.freecodecamp.com/speedclip
:star2: 1105 | @revisualize |http://www.freecodecamp.com/revisualize
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:57
hmm ur genius :D
rphares
@rphares
May 12 2016 04:58
You got it? Yay!! congrats and happy coding, @YeasenHossainFarhad ~
YeasenHossainFarhad
@YeasenHossainFarhad
May 12 2016 04:58
(y)
:)
Chris Lacaille
@ChrisL108
May 12 2016 04:58
How would you select 2 separate elements in 1 jQuery selector?
Samuel Cupidon
@Zerazera
May 12 2016 04:59
@ChrisL108 Give them both the same class
Sean DiSanti
@badc0ded
May 12 2016 04:59
lots of ways
Samuel Cupidon
@Zerazera
May 12 2016 04:59
Then select the class
Sean DiSanti
@badc0ded
May 12 2016 04:59
$('#one, #theOther')
Chris Lacaille
@ChrisL108
May 12 2016 04:59
@Zerazera Thanks but what about in jquery?
CamperBot
@camperbot
May 12 2016 04:59
chrisl108 sends brownie points to @zerazera :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @zerazera |http://www.freecodecamp.com/zerazera
Chris Lacaille
@ChrisL108
May 12 2016 04:59
@badc0ded thanks lol
CamperBot
@camperbot
May 12 2016 04:59
chrisl108 sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 339 | @badc0ded |http://www.freecodecamp.com/badc0ded
Samuel Cupidon
@Zerazera
May 12 2016 04:59
@ChrisL108 Same in jquery
Sean DiSanti
@badc0ded
May 12 2016 05:00
class is best when possible, but selectors can be combined just like in css
Chris Lacaille
@ChrisL108
May 12 2016 05:00
probably more overhead with selectors right?
definetly lol
Samuel Cupidon
@Zerazera
May 12 2016 05:01
@ChrisL108 You can do either one, but I would generally use a class because it's more readable and you're probably grouping the elements in more than one way between your CSS/JS
Sean DiSanti
@badc0ded
May 12 2016 05:01
yeah, i only contributed the comma as an example of another way
CyrilSL
@CyrilSL
May 12 2016 05:02
Guys im using this function Object.values() It keeps returning "TypeError: Object.values is not a function"
Chris Lacaille
@ChrisL108
May 12 2016 05:02
No I know, @badc0ded that's what I was asking, hadn't even thought about CSS I'm trying to think jQuery to learn jQuery lol
@Zerazera true
Samuel Cupidon
@Zerazera
May 12 2016 05:05
@CyrilSL Object.values() is relatively new and not fully implemented. You should iterate through Object.keys() and then use map to get the values.
Like this Object.keys(obj).map(x => obj[x])
Islam Ibakaev
@dagman
May 12 2016 05:07
experimental api
andreyorlov33
@andreyorlov33
May 12 2016 05:08
Hey guys im working on the Twitchtv JSON API project. For some reason my JSON request is not working. I try to console log the data but nothing show... I would really appreciate it if some one could take a look at my code... any feedback would be appreciated!
var channels = ["freecodecamp", "storbeck", "terakilobyte", "habathcx","RobotCaleb","thomasballinger","noobs2ninjas","beohoff"];

function getChannelInfo() {

  channels.forEach(function(channel) {
    function makeURL(type, name) {
     return 'https://api.twitch.tv/kraken/' + type + '/' + name + '?callback=?';

    };


    $.getJSON(makeURL("streams", channel), function(data) {

      var game,
        status;
      if (data.stream === null) {
        game = "Offline";
        status = "Offline";
      } else if (data.stream === undefined) {
        game = "Account Closed";
        status = "Offline";
      } else {
        game = data.stream.game;
        status = "Online";
      }

    })
  });
};
Islam Ibakaev
@dagman
May 12 2016 05:09
@andreyorlov33 pen?
Sean DiSanti
@badc0ded
May 12 2016 05:10
the network tab in the inspector is great for troubleshooting ajax also
often times you'll have useful error messages being returned by the api in the console or network calls
CyrilSL
@CyrilSL
May 12 2016 05:11
@Zerazera Oh ok, thanks I'll try that.
CamperBot
@camperbot
May 12 2016 05:11
cyrilsl sends brownie points to @zerazera :sparkles: :thumbsup: :sparkles:
:cookie: 430 | @zerazera |http://www.freecodecamp.com/zerazera
Austin Searle
@Speedclip
May 12 2016 05:14
if anyone is looking to become apart of Speedclip which is a company for developing android games then let me know, we are looking for more coders who knows java programming
Bobby McDonald
@BobbyMcWho
May 12 2016 05:15
@Speedclip this is javascript not java
Austin Searle
@Speedclip
May 12 2016 05:15
anytype of java :)
dontchaknow
@dontchaknow
May 12 2016 05:17
function MyObject(name, message) {
    this.name = name.toString();
    this.message = message.toString();
}
(function() {
    this.getName = function() {
        return this.name;
    };
    this.getMessage = function() {
        return this.message;
    };
}).call(MyObject.prototype);
can someone explain what's going on here
Austin Searle
@Speedclip
May 12 2016 05:17
javascript is a (very) distant cousin of Java
looking for ones who know java in general, could be any language
Austin Searle
@Speedclip
May 12 2016 05:23
var myVar = 87;
// Only change code below this line
myVar = myVar + 1; i++;
@dontchaknow try flipping ")" around there at bottom you see it?
Markus Kiili
@Masd925
May 12 2016 05:25
@dontchaknow A constructor is declared and then methods are added to the prototype.
Sean DiSanti
@badc0ded
May 12 2016 05:25
@Speedclip they've got similarities but they're not actually related
Austin Searle
@Speedclip
May 12 2016 05:25
@dontchaknow or remove it that don't look correct to me
@badc0ded So how would i go about fixing this?
Sean DiSanti
@badc0ded
May 12 2016 05:27
fixing what? sorry i was just responding to the distant cousin comment
i'm bouncing back and forth in a few rooms
Austin Searle
@Speedclip
May 12 2016 05:28
@badc0ded haha no your fine! and i thought that javascript and java was both a OOP language, am i wrong?
Sean DiSanti
@badc0ded
May 12 2016 05:29
kind of
without going too crazy in depth, the 'objects' in js are functions
Austin Searle
@Speedclip
May 12 2016 05:30
@badc0ded well i know that Javascript was made by the people over at Netscape but thought that Java and Javascript is both a Object Oriented Programming language
Sean DiSanti
@badc0ded
May 12 2016 05:30
they're not
java is
Samuel Cupidon
@Zerazera
May 12 2016 05:31
@Speedclip JS OOP is way different than most other languages. Look up JS prototype vs class on google
Sean DiSanti
@badc0ded
May 12 2016 05:31
js implements prototypal objects by way of functions
dontchaknow
@dontchaknow
May 12 2016 05:31
how does call work in adding methods to a constructor?
Chris Lacaille
@ChrisL108
May 12 2016 05:32
Javascript just got called that to piggyback off of java's success back in the day. I've heard they are very different
I know I've read that in a book lol
Samuel Cupidon
@Zerazera
May 12 2016 05:33
Yup. Javascript's real name is ECMAScript. Netscape changed the name when they were bought by Oracle for marketing purposes because Java was way more popular.
Austin Searle
@Speedclip
May 12 2016 05:34
@Zerazera i thought Javascript use to be called Livescript
Samuel Cupidon
@Zerazera
May 12 2016 05:34
@Speedclip Yes. I meant now the real name is ECMAScript.
Austin Searle
@Speedclip
May 12 2016 05:35
oh okay never heard about that but that is nice to know
so if i am wanting to know java programming what is the best language to learn?
Markus Kiili
@Masd925
May 12 2016 05:36
@Zerazera More precisely, ECMAScript is the specification and Javascript is one implementation.
kwal0203
@kwal0203
May 12 2016 05:37
Anybody know how to do the Pomodoro clock challenge? I can make the seconds count down to zero but then how to get it back to "59" seconds for the next minute?
Samuel Cupidon
@Zerazera
May 12 2016 05:37
@kwal0203 Oh, don't do it that way, that's way too complicated.
@kwal0203 Track the total milliseconds, then break down the milliseconds for display purposes.
kwal0203
@kwal0203
May 12 2016 05:38
what's the best way to do it?
yeah i tried that
I think I did it wrong because the html would not update
@Zerazera so do you use a global variable that holds the milliseconds?
Markus Kiili
@Masd925
May 12 2016 05:39
@dontchaknow The call method argument is set as the value of this, so the methods get added to the prototype.
ereinertsen
@ereinertsen
May 12 2016 05:39
Can someone help me with my switch statement code?
Samuel Cupidon
@Zerazera
May 12 2016 05:39
@kwal0203 Here's my clock if you want to see it. I basically created a clock object and kept track of the variables within the object. http://codepen.io/Zeratul/full/aNKYZL/
ereinertsen
@ereinertsen
May 12 2016 05:40
I am doing this wrong but I feel like I'm on the right track
Coryphaeus
@cvdeby
May 12 2016 05:40
@kwal0203 I made it( actually I'm working with it right now ) with setInterval + setTimeout and inside the setInterval I checked does that enough of seconds passed. If not - clearInterval and recursion
Samuel Cupidon
@Zerazera
May 12 2016 05:40
I started out with global variables and refactored afterwards because Global Variables Are Bad (TM)
ereinertsen
@ereinertsen
May 12 2016 05:40
Screen Shot 2016-05-11 at 10.39.47 PM.png
Vaggelis Karlis
@VKRocks
May 12 2016 05:41
@ereinertsen try to use return and not console.log
Sean DiSanti
@badc0ded
May 12 2016 05:42
@ereinertsen you're not setting answer anywhere
just logging
ereinertsen
@ereinertsen
May 12 2016 05:42
@VKRocks thank you!
CamperBot
@camperbot
May 12 2016 05:42
ereinertsen sends brownie points to @vkrocks :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @vkrocks |http://www.freecodecamp.com/vkrocks
Coryphaeus
@cvdeby
May 12 2016 05:42
@kwal0203 I didn't made that challenge yet, because I'm learning how to work with events and plugins) and actually I found addEventListener helpful too)
Sean DiSanti
@badc0ded
May 12 2016 05:42
so all you're actually returning is empty string
ereinertsen
@ereinertsen
May 12 2016 05:43
@badc0ded yea that makes sense. thank you!
CamperBot
@camperbot
May 12 2016 05:43
ereinertsen sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
May 12 2016 05:43
no problem
Austin Searle
@Speedclip
May 12 2016 05:47
Please tell me what am i doing wrong?
var myVar = 87;

// Only change code below this line
myVar = myVar + 1; i++;
Sean DiSanti
@badc0ded
May 12 2016 05:47
@Speedclip it depends on what you're trying to do?
those are 3 valid statements
assuming i means something
Austin Searle
@Speedclip
May 12 2016 05:48
@badc0ded
Instructions
Change the code to use the ++ operator on myVar
Sean DiSanti
@badc0ded
May 12 2016 05:49
ah
you're not using it on myVar, you're using it on i
and with ++ you don't need to use the assignment operator (=)
like, to increment a variable 'example' it would be example++;
Jesús Antonio Zúñiga Arce
@jzunigarce
May 12 2016 05:50
someone used jwt with jQuery.?
Ivan Aganin
@criativ
May 12 2016 05:50
Good morning :) I need help with "Using Objects for Lookups" - I do not understand what is asked of me :( F1!
"Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable."
Chris Lacaille
@ChrisL108
May 12 2016 05:50
Why is the color animating going to white a bunch and sometimes not changing colors? Not sure if should be running the function randomColor() inside the getJSON()? I'm using jQuery UI so animate works on color..
https://codepen.io/chris1545/pen/bpQRKm?editors=1111
Austin Searle
@Speedclip
May 12 2016 05:51
so i put myVar++;
?
Sean DiSanti
@badc0ded
May 12 2016 05:51
yep
Chris Lacaille
@ChrisL108
May 12 2016 05:51
hm that doesn't work in the little codepen window in here
Sean DiSanti
@badc0ded
May 12 2016 05:51
looking now @ChrisL108
Austin Searle
@Speedclip
May 12 2016 05:52
didn't seem to work?
var myVar = 87;

// Only change code below this line
myVar = myVar + 1; myVar++;
Chris Lacaille
@ChrisL108
May 12 2016 05:52
You only need the myVar++;
unless I missed something? lol
Sean DiSanti
@badc0ded
May 12 2016 05:53
remove everythign before the myVar++
the way you have it there, you're incrementing it in each of the two statements
andreyorlov33
@andreyorlov33
May 12 2016 05:54
This message was deleted
Austin Searle
@Speedclip
May 12 2016 05:54
ok bit confusing but thanks it worked
Chris Lacaille
@ChrisL108
May 12 2016 05:54
Oh and idk about your browser @badc0ded but I had to allow that pen to access something lol
for it to work
Bobby McDonald
@BobbyMcWho
May 12 2016 05:54
@ChrisL108 this is how I did mine: http://codepen.io/BobbyMcWho/pen/MyBLMg
Vaggelis Karlis
@VKRocks
May 12 2016 05:54
is there any search button on chat in order to see if a problem is already discussed?
Sean DiSanti
@badc0ded
May 12 2016 05:54
i wasn't prompted for access
i forked it to play with it
@VKRocks it has almost definitely been discussed, but i'm nto sure if the search searches content or just room titles and people names
it's ok though, people are still happy to help with repeats
Steph
@tcapre01
May 12 2016 05:56
morning all
Sean DiSanti
@badc0ded
May 12 2016 05:56
@ChrisL108 if you add a console.log(color); you'll see that it's not selecting white every time the color goes to white
Vaggelis Karlis
@VKRocks
May 12 2016 05:57
@badc0ded i searched for something a minute ago but now i cant find how i did it !!!
Sean DiSanti
@badc0ded
May 12 2016 05:57
there's a search box in upper right corner
Steph
@tcapre01
May 12 2016 05:57
can someone help me with the seek and destroy waypoint? I got everything except the last bit..
Mateusz Szymański
@matszym
May 12 2016 05:58
@ChrisL108 Seems like jQuery cannot animate background-color property
Chris Lacaille
@ChrisL108
May 12 2016 05:58
@badc0ded Oh it doesn't support the darkorange etc
Sean DiSanti
@badc0ded
May 12 2016 05:58
exactly