These are chat archives for FreeCodeCamp/HelpJavaScript

25th
Jan 2016
GM-Connor
@GM-Connor
Jan 25 2016 00:00
@nf15 for real, trying to do php or something lol?
Bon
@OriBon
Jan 25 2016 00:00
@GM-Connor He already has an else clause.
Aleksander Gębicki
@Takumar
Jan 25 2016 00:00
@senthuran82 you can see also such JS miracle that you first use variable and then declare it and it also works ;-)
a = 10;
var a;
Bon
@OriBon
Jan 25 2016 00:01
all hail hoisting
Spencer Kuzara
@kodaxx
Jan 25 2016 00:01
function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    return myObj[checkProp];
  }
    else {
      return "Not Found!";
    }
}
GM-Connor
@GM-Connor
Jan 25 2016 00:01
@OriBon yeah but sounds like he wanted to know how to do else statements so I told him that
Spencer Kuzara
@kodaxx
Jan 25 2016 00:01
That is not working for me still, @GM-Connor
Bon
@OriBon
Jan 25 2016 00:02
@kodaxx which challenge is it
Spencer Kuzara
@kodaxx
Jan 25 2016 00:02
Testing objects for properties
GM-Connor
@GM-Connor
Jan 25 2016 00:02
@kodaxx Looks like it wasnt you to modify the value on the input property
Kevin Myrick
@aphextwin234
Jan 25 2016 00:02
```
```
GM-Connor
@GM-Connor
Jan 25 2016 00:02
wait nvm
Kevin Myrick
@aphextwin234
Jan 25 2016 00:02
return alert(total);
nf15
@nf15
Jan 25 2016 00:02
@rphares @GM-Connor no no, I am practising how to put the JS format here:) I never used that in my coding:) :)
Aleksander Gębicki
@Takumar
Jan 25 2016 00:02
@kodaxx you don't need exclamation mark in your returned string.
rphares
@rphares
Jan 25 2016 00:03
oooh, lol, i was confused, sorry! :)
Kevin Myrick
@aphextwin234
Jan 25 2016 00:03
@GM-Connor then I get [objectHtmlInputElement] in the alert box..
instead of the output calc
Spencer Kuzara
@kodaxx
Jan 25 2016 00:03
@Takumar Oh my! Of course!
GM-Connor
@GM-Connor
Jan 25 2016 00:03
@kodaxx when you run it with girft as the input paramater, what result do you get?
Spencer Kuzara
@kodaxx
Jan 25 2016 00:04
So the code is fine, it didn't like my string because it isn't what it asked for
GM-Connor
@GM-Connor
Jan 25 2016 00:04
@aphextwin234 post the js snippet
Spencer Kuzara
@kodaxx
Jan 25 2016 00:04
Thanks @GM-Connor and @Takumar
CamperBot
@camperbot
Jan 25 2016 00:04
kodaxx sends brownie points to @gm-connor and @takumar :sparkles: :thumbsup: :sparkles:
:star: 1878 | @takumar | http://www.freecodecamp.com/takumar
:star: 126 | @gm-connor | http://www.freecodecamp.com/gm-connor
Bon
@OriBon
Jan 25 2016 00:04
@kodaxx Technically the string is part of the code, but you get the point
nf15
@nf15
Jan 25 2016 00:04
I am glad,it worked for me today
Spencer Kuzara
@kodaxx
Jan 25 2016 00:05
Right, if it were me choosing to program this, it would have functioned fine
But because it was being tested, it needed to be exact
Kevin Myrick
@aphextwin234
Jan 25 2016 00:07
<script type="text/javascript">
  function calcship() {
    var price = document.getElementById('text1').value;
    console.log(price);
    var shipping;
      if (price <= 25)
          shipping = 1.5;
      else
          shipping = Number(price) / 10;
      var final = Number(price) + shipping;
      document.getElementById('total').value = final;
      return alert(total);
  }
</script>
I think i need some kind of inner HTML then set to output variable total or something
Then I got to go run grab food and I'll be back!
or do i need some kind of div tag or something
GM-Connor
@GM-Connor
Jan 25 2016 00:10
alert(final) not total :P
also you can remove that console.log on line 4
Kevin Myrick
@aphextwin234
Jan 25 2016 00:11
I thought about that! thANK!
console.log(price) get rid off?
GM-Connor
@GM-Connor
Jan 25 2016 00:12
yeah
Kevin Myrick
@aphextwin234
Jan 25 2016 00:12
ya that looks cleaner i see now @GM-Connor
tseamus
@tseamus
Jan 25 2016 00:25
Hey folks, I'm having some trouble with the 'Card Counting' challenge. I think the problem is in defining the count variable, but I don't know how to represent it so that it will count the answer for each card value entered. Can anyone help?

var count = 0;

function cc(card) {
 // Only change code below this line
  var answer = "";

  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
     answer = +1;
      break;

    case 7:
    case 8:
    case 9:
      answer = 0;
      break;

    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      answer = -1;
      break;
  }

  var count = (answer + answer + answer + answer + answer);

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

  else if (count > 0) {
   return (count + " " + "Bet");
  }
  //return answer;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(3); cc(2); cc('A'); cc(10); cc('K');
Darryl Pargeter
@darrylpargeter
Jan 25 2016 00:27
your not using count in you switch @tseamus change answer for count
Aleksander Gębicki
@Takumar
Jan 25 2016 00:27
@tseamus I think you misunderstood instruction a little.
You shouldn't set count( in your solution answer) variable, but increment or decrement its value.
Also you don't have to return result of all five cards at once:
var count = (answer + answer + answer + answer + answer);
tseamus
@tseamus
Jan 25 2016 00:28
@Takumar I got the instructions. But I don't know how to represent it in code.
Aleksander Gębicki
@Takumar
Jan 25 2016 00:29
@tseamus you should return result for only one card, and you call your function cc() five times
cc(3); cc(2); cc('A'); cc(10); cc('K');
That's why you see 5 different values
tseamus
@tseamus
Jan 25 2016 00:29
@Takumar I basically put the that as filler for the moment, as I don't know how to represent what I want.
@Takumar I understand that's why I see 5 different values. But the last value is the only one counted.
Aleksander Gębicki
@Takumar
Jan 25 2016 00:31
@tseamus count is global variable, so you modify this value 5 times.
but in your switch() statement you should modify this variable: count as @darrylpargeter already told you.
@tseamus for cards: 2, 3, 4, 5, 6 you increase value of count variable: count++; :-)
Your if statement returning resulting strings is good.
tseamus
@tseamus
Jan 25 2016 00:33
@darrylpargeter thanks for that.
CamperBot
@camperbot
Jan 25 2016 00:33
tseamus sends brownie points to @darrylpargeter :sparkles: :thumbsup: :sparkles:
:star: 596 | @darrylpargeter | http://www.freecodecamp.com/darrylpargeter
sciand6
@sciand6
Jan 25 2016 00:33
Not sure what to do
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this lin

  if (contacts.hasOwnProperty(firstName) && contacts.hasOwnProperty(prop)) // Checking for true first name and property
  {
    return contacts[prop];
  }
  else if (firstName !== contacts.hasOwnProperty(firstName) && prop !== contacts.hasOwnProperty(prop)) // Checking to see if first name does not correspond
  {
    return "No such contact";
  }
  else // Prop doesn't correspond to any valid properties
  {
    return "No such property";
  }  
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Darryl Pargeter
@darrylpargeter
Jan 25 2016 00:34
and if you wish you can drop case 7,8,9. if you want to refactor the code @tseamus
tseamus
@tseamus
Jan 25 2016 00:35
@Takumar thanks for your help.
CamperBot
@camperbot
Jan 25 2016 00:35
tseamus sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 1879 | @takumar | http://www.freecodecamp.com/takumar
Thequadehunter
@Thequadehunter
Jan 25 2016 00:36
Dude I'm dying here. My code clearly works correctly but I can't progress past the "Title Case a Sentence" bonfire. I've restarted the browser, my computer, and even reset the code. Nothing's working. Is the last resort here to contact the admins or something?
Aleksander Gębicki
@Takumar
Jan 25 2016 00:36
@tseamus you are welcome :-)
@Thequadehunter show your code.
GM-Connor
@GM-Connor
Jan 25 2016 00:37
@sciand6 this is what you are wanting to solve man
function ----(firstname, property) {
    cycle through each item in contacts {
        if item's firstname is equal to firstname {
            if item has property {
                return the property value;
            }
           //If we reached this point, it means we found the name, but property doesn't exit. 
           return "property not found"
        }
    }
    //If we reached this point, it means we didn't find a name 
    return "contact not found"
}
@sciand6 you have to use a for loop to cycle thourgh each object in the array contacts
Thequadehunter
@Thequadehunter
Jan 25 2016 00:39
function titleCase(str) {
  str = str.split(' ');
  var i = 0;
  var newSentence = '';

  for (i in str){
    str[i] = str[i].toLowerCase();
    str[i] = str[i].charAt(0).toUpperCase() + str[i].substr(1);
    newSentence += str[i].concat(' ');
  }
  return newSentence;
}

titleCase("I'm a little tea pot");
I took a screenshot too
http://imgur.com/IZ9bbo9
@Takumar whoops forgot to mention you
GM-Connor
@GM-Connor
Jan 25 2016 00:40
@Thequadehunter your code puts a space at the end of the string
Aleksander Gębicki
@Takumar
Jan 25 2016 00:40
@Thequadehunter yes, that's right you concat strings and have space at the end. It looks good, but it's too long :-)
Thequadehunter
@Thequadehunter
Jan 25 2016 00:40
Oh wow lol
Alright thanks guys I guess I got it from here
@GM-Connor Thank you!
Thank you! @GM-Connor @Takumar
CamperBot
@camperbot
Jan 25 2016 00:41
thequadehunter sends brownie points to @gm-connor and @takumar :sparkles: :thumbsup: :sparkles:
:star: 135 | @gm-connor | http://www.freecodecamp.com/gm-connor
:star: 1880 | @takumar | http://www.freecodecamp.com/takumar
Aleksander Gębicki
@Takumar
Jan 25 2016 00:41
@Thequadehunter you're welcome.
Bharatian
@bharatian
Jan 25 2016 00:49
don’t understand this challenge

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

// Only change code below this line
function update(id, prop, value) {

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

return collection;
}
// Alter values below to test your code
update(5439, "artist", "ABBA");

anyone else having issues with it
Jonathan Thompson
@Jon-thomps
Jan 25 2016 00:52
you should be referencing collection, not collection copy
collectionCopy
GM-Connor
@GM-Connor
Jan 25 2016 00:54
^
emran26
@emran26
Jan 25 2016 00:59
Hey guys, I have a question. This code is correct, but it doesn't make sense to me:

'''
// Example
var ourArray = [1,2,3];
var ourData = ourArray[0]; // equals 1

// Setup
var myArray = [1,2,3];

// Only change code below this line.

var myData = [1];
'''

CamperBot
@camperbot
Jan 25 2016 00:59
:bulb: to format code use backticks! ``` more info
emran26
@emran26
Jan 25 2016 00:59
// Example
var ourArray = [1,2,3];
var ourData = ourArray[0]; // equals 1

// Setup
var myArray = [1,2,3];

// Only change code below this line.

var myData = [1];
"Create a variable called myData and set it to equal the first value of myArray." Shouldn't the first value be 0 and not 1?
Kevin Myrick
@aphextwin234
Jan 25 2016 01:01
Feel alot better!
Had to eat. I might start a new JS excerise in a moment.. its a Target heart rate program
Chris Crook
@chrisisacrook
Jan 25 2016 01:03
@emran26 the first index value of myArray is 1.
the index number is 0 though
Spencer Kuzara
@kodaxx
Jan 25 2016 01:04
I don't uderstand what this instruction means: If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop
I have the beginning of my if statement, but I don't know what they want me to do
To be specific "update or set the value for the prop" this is the part I do no understand
Kevin Myrick
@aphextwin234
Jan 25 2016 01:05
alright im gonna get constructing a text box for a user to enter an age
emran26
@emran26
Jan 25 2016 01:06
@aphextwin234 So the first value of the example is 1 with an index of zero. In my code, the first value is 1 but the index is not, right? Because I am so confused
John Barbagallo
@john-barbagallo
Jan 25 2016 01:06
@kodaxx which challenge?
Spencer Kuzara
@kodaxx
Jan 25 2016 01:06
Record Collection
It may be my English
John Barbagallo
@john-barbagallo
Jan 25 2016 01:07
have u attempted to write the code yet? if so, can you post?
Chris Crook
@chrisisacrook
Jan 25 2016 01:08
@emran26 in your code you are creating an array named myData and inputing 1 as the first index. You're not setting myData equal to the first value of myArray.
Aleksander Gębicki
@Takumar
Jan 25 2016 01:08
@emran26 you have to grab value from your array: myArray at index 0 (because you were asked to get first value from your array).
Kevin Myrick
@aphextwin234
Jan 25 2016 01:08
@emran26 which statement are you talking about?
the first element in array always
0
Chris Crook
@chrisisacrook
Jan 25 2016 01:08
notice the relationship between ourArray and ourData in the example lines of code
Spencer Kuzara
@kodaxx
Jan 25 2016 01:09
@john-barbagallo her eis my code
 if (value ==! "" && prop !== "tracks")
    value = prop;
emran26
@emran26
Jan 25 2016 01:09
Hmm...yeah I think I'm just confused, thanks guys the explanation helped!
Spencer Kuzara
@kodaxx
Jan 25 2016 01:10
I've moved the !
John Barbagallo
@john-barbagallo
Jan 25 2016 01:10
@kodaxx so lets work on the first part of instruction : If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.
GM-Connor
@GM-Connor
Jan 25 2016 01:11
@emran26 Just remember, and array is a list of ordered things. If you want to get one of the things in the list, you have to know the position of it in the list. The position is the index and starts at 0.
Spencer Kuzara
@kodaxx
Jan 25 2016 01:11
Right, so inside the function I've written that code^
Haroon Ghawsi
@HaroonGhawsi
Jan 25 2016 01:11
Hi, How to make a full page background image in the body?
in bootstrap or css
GM-Connor
@GM-Connor
Jan 25 2016 01:12
just put body{ background-image: url("image location"); }
emran26
@emran26
Jan 25 2016 01:12
@GM-Connor cool, thanks a lot!
CamperBot
@camperbot
Jan 25 2016 01:12
emran26 sends brownie points to @gm-connor :sparkles: :thumbsup: :sparkles:
:star: 145 | @gm-connor | http://www.freecodecamp.com/gm-connor
emran26
@emran26
Jan 25 2016 01:13
I think I am just getting "value" and "index" confused
GM-Connor
@GM-Connor
Jan 25 2016 01:13
the Value is the thing in the list, the index is just its position in the list
emran26
@emran26
Jan 25 2016 01:14
because 0 = 1 in the example which is the first value in "ourArray", but when the directions ask for the first value in "myArray" I had to put 1 which is the correct answer but I figured 1 = 2 which isn't the first value in "myArray".
Jonathan Thompson
@Jon-thomps
Jan 25 2016 01:14
@GM-Connor Holy crap I just solved the Profile Lookup with your excellent advice from earlier, thanks again!
CamperBot
@camperbot
Jan 25 2016 01:14
jon-thomps sends brownie points to @gm-connor :sparkles: :thumbsup: :sparkles:
:star: 146 | @gm-connor | http://www.freecodecamp.com/gm-connor
GM-Connor
@GM-Connor
Jan 25 2016 01:15
:)
Aleksander Gębicki
@Takumar
Jan 25 2016 01:15
@emran26 check this example:
var arr = [8, 9, 7];
arr[0]; // this is first element and has value 8
arr[1]; // this is second element with value 9
arr[2]; // this is 7
Devon Brown
@Token95
Jan 25 2016 01:19

@GM-Connor can you see if i need more? here is my code

for (var i = 0; i < arr.lenght; i++){
for (var j = 0; j < arr[i].lenght; j++){
product *= arr[i][j];}}

DJ
@qualitymanifest
Jan 25 2016 01:19
@Token95 you have lenght instead of length in the second loop
Devon Brown
@Token95
Jan 25 2016 01:20
@qualitymanifest oo snap, i cant believe i didnt see that
@qualitymanifest thank you man
CamperBot
@camperbot
Jan 25 2016 01:20
token95 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 834 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Jan 25 2016 01:21
no problem. it seems to be a really common typo around here haha
Kevin Myrick
@aphextwin234
Jan 25 2016 01:23
@GM-Connor would you like me to type up what I am about to constuct?
GM-Connor
@GM-Connor
Jan 25 2016 01:24
sure
Spencer Kuzara
@kodaxx
Jan 25 2016 01:29
Thanks @john-barbagallo
CamperBot
@camperbot
Jan 25 2016 01:29
kodaxx sends brownie points to @john-barbagallo :sparkles: :thumbsup: :sparkles:
:star: 238 | @john-barbagallo | http://www.freecodecamp.com/john-barbagallo
Kevin Myrick
@aphextwin234
Jan 25 2016 01:31
.The American Heart Association recommends that you stay within 50-85 percent of your maximum hear rate while excersising. This range is called your target heart rate. One common formula for calculating maximum heart rate is to subtract your age from 220. Create a web page that you can use to calculate your target heart rate. Use a form that contains a text box in which user can enter their age, and a command button that use an onclick event handler to call a function named calcHeartRate(). Within calcHearRate(), include a statement that calculates the maximum heart rate and assigns the result to a variable. Use two other statements that calculate the minimum (50%) and maximum (85%) target heart rates. To calculate the minimum target heart rate, you use the formula maximum_heart_rate5; to calculate the maximum target heart rate, use the formula maximum_heart_rate85. After you calculate the minimum and maximum target heart rates, display the result in another text box in the form. For example, a 35-year-old person should have minimum and maximum target rates of 92 to 157 beats per minute.
Emerson Silva
@Emerson093
Jan 25 2016 01:33
hello guys i need help with waypoint Escape Sequences in Strings
I create a code
var myStr = " \ \t \t \r \n" ;
Starstuff03
@Starstuff03
Jan 25 2016 01:34
function myFunction(a, b) {
  console.log(a + b);
}
ourFunction(7,9);
Could anyone tell me why this is giving me a -2?
Paul
@PJonestown
Jan 25 2016 01:35
You'tre calling the wrong function
DJ
@qualitymanifest
Jan 25 2016 01:35
@Emerson093 you have a space before your \\
Paul
@PJonestown
Jan 25 2016 01:35
You want myFunction not ourFunction
Starstuff03
@Starstuff03
Jan 25 2016 01:35
function myFunction(a, b) {
  console.log(a + b);
}
ourFunction(7,9);
ohhhh
duh
thank you very much
Luciano Britis
@LucianoBritis
Jan 25 2016 01:35
is corret @Starstuff03
Paul
@PJonestown
Jan 25 2016 01:36
No problem :)
Emerson Silva
@Emerson093
Jan 25 2016 01:36
@qualitymanifest thank you man
CamperBot
@camperbot
Jan 25 2016 01:36
emerson093 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 835 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Paul
@PJonestown
Jan 25 2016 01:36
Hey guys I'm coming from a ruby background and just learned about js scope. So you can access a variable defined outside a function? This just feels really wrong
DJ
@qualitymanifest
Jan 25 2016 01:36
@Emerson093 np :+1:
Paul
@PJonestown
Jan 25 2016 01:36
I mean everything defined outside of functions is a global
Can anyone help me reconcile this?
It just seems dirty
Kevin Myrick
@aphextwin234
Jan 25 2016 01:38
I'm going to make this form right now. @GM-Connor
Secil
@senuka
Jan 25 2016 01:38
Hello, I am supposed to convert celcius to fahrenheit and I can't seem to make this code work for some reason. Whatever input i give to convert, the result does not change. What am I doing wrong?
function convert(celsius) {
  // Only change code below this line

  var fahrenheit = ((celcius * 9) / 5) + 32;

  // Only change code above this line
  if ( typeof fahrenheit !== 'undefined' ) {
    return fahrenheit;
  } else {
    return 'fahrenheit not defined';
  }
}

// Change the inputs below to test your code
convert(0);
GM-Connor
@GM-Connor
Jan 25 2016 01:39
@aphextwin234 sounds cool. First you need to outline the steps in the project. I left the last few blank to fill in. It's important to layout steps before you even start coding.
These are the steps I see:
  1. Create html form
  2. Give input element (age) unique IDs so they can be accessed with JS
  3. Create button that will execute JS function
  4. targetHeartRate = ?
  5. minRate = ?
  6. maxRate = ?
Fahar Jatoi
@digitaleye
Jan 25 2016 01:40
 collection[id].artist.push(value);
Kevin Myrick
@aphextwin234
Jan 25 2016 01:40
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 2</title>
<script type="text/javascript">

function calcHeartRate(){

}



</script>

</head>

<body>
<form name="totalheart">
Age<input type="text" onchange="calcHeartRate()" id="text1"/>
</form>

</body>

</html>
Paul
@PJonestown
Jan 25 2016 01:40
You spelled celsius wrong
Kevin Myrick
@aphextwin234
Jan 25 2016 01:40
this is thus far
Fahar Jatoi
@digitaleye
Jan 25 2016 01:40
Record collection
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

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



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

  }


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
please help
Secil
@senuka
Jan 25 2016 01:41
@PJonestown I am dumb. I have been looking at this code for 20 minutes now. Time for a break obviously. Thanks a bunch!
CamperBot
@camperbot
Jan 25 2016 01:41
senuka sends brownie points to @pjonestown :sparkles: :thumbsup: :sparkles:
:star: 188 | @pjonestown | http://www.freecodecamp.com/pjonestown
GM-Connor
@GM-Connor
Jan 25 2016 01:41
@aphextwin234 Nice. It's good practice to give things relevant names though. So the id "text1" could be "age" instead
Kevin Myrick
@aphextwin234
Jan 25 2016 01:41
okay let me do that, I will think of that procedure moving forward.
@GM-Connor
Paul
@PJonestown
Jan 25 2016 01:42
@senuka Happens to everyone :) Sometimes you just need fresh eyes
Johnny Cornyn
@JMIHC
Jan 25 2016 01:43
@digitaleye try [prop] instead of artisit
*artist
using dot notation is for looking for a specific string, in this case we're looking for whatever prop is, so the use of bracket notation
Kevin Myrick
@aphextwin234
Jan 25 2016 01:46
so include the variables in the statements right before the execution no need to declare a list up top
GM-Connor
@GM-Connor
Jan 25 2016 01:48
@aphextwin234 correct
Johnny Cornyn
@JMIHC
Jan 25 2016 01:50
question here, what could possibly be going wrong in Profile Lookup?
function lookUp(firstName, prop){
// Only change code below this line
if(firstName.hasOwnProperty(prop)) {
  return firstName[prop];
} else if(firstName === " " ) {
  return "No such contact";
} else if(prop === " ") {
  return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
GM-Connor
@GM-Connor
Jan 25 2016 01:50
You are supposed to search the contacts list above
Johnny Cornyn
@JMIHC
Jan 25 2016 01:51
aren't I doing that with hasOwnProperty?
Kevin Myrick
@aphextwin234
Jan 25 2016 01:51
<script type="text/javascript">

function calcHeartRate()

{

var targetH = maximum_heart_rate*5;

}



</script>
GM-Connor
@GM-Connor
Jan 25 2016 01:52
Nope, you are calling hasOwnProperty on the firstName input, which is Akira
Johnny Cornyn
@JMIHC
Jan 25 2016 01:52
oh!!
GM-Connor
@GM-Connor
Jan 25 2016 01:52
You want to cycle through the contacts list and compare the names until and if you find a match
Kevin Myrick
@aphextwin234
Jan 25 2016 01:52
wait hold up , i neeed one for min and max
Johnny Cornyn
@JMIHC
Jan 25 2016 01:52
yeah totally! I'm on the right path now thank you @GM-Connor
CamperBot
@camperbot
Jan 25 2016 01:52
jmihc sends brownie points to @gm-connor :sparkles: :thumbsup: :sparkles:
:star: 147 | @gm-connor | http://www.freecodecamp.com/gm-connor
Kevin Myrick
@aphextwin234
Jan 25 2016 01:55
@GM-Connor is this just one function that i need calcHeartRate() then one statement that calculates the max hear rate and assigns result to a variable. Then it says use two other statements that calculate the minimum target heart rate, you use the formula maximum_heart_rate5; to calculate the maximum target heart rate, use the formula maximum_heart_rate85.
GM-Connor
@GM-Connor
Jan 25 2016 01:56
@aphextwin234 Yeah, I don't believe you need to know the target heart rate actually
You just need max and min
and max = 220 - age
wait a sec
Kevin Myrick
@aphextwin234
Jan 25 2016 01:57
so you can throw all that jazz into one variable
that calc
Vik
@vvang044
Jan 25 2016 01:57
anyone completed "stand in line"
GM-Connor
@GM-Connor
Jan 25 2016 01:58
@aphextwin234 Ok there was typo in instructions. Target heartrate = 220 - age
max = th * .85
@aphextwin234 Yeah create 3 variables: target, max, min
Kevin Myrick
@aphextwin234
Jan 25 2016 01:59
@GM-Connor what do I do with those two bits of info.
kk
GM-Connor
@GM-Connor
Jan 25 2016 01:59
and post when you have all 3 and their values
Luciano Britis
@LucianoBritis
Jan 25 2016 02:05
@senuka solve it ?
Kevin Myrick
@aphextwin234
Jan 25 2016 02:07
<script type="text/javascript">

function calcHeartRate()

{

var targetmax = maximum_heart_rate*5;
var targetmin = maximum_heart_rate*8;
var targetH = age * 

}

</script>

</head>
Adam
@Blakemilton6
Jan 25 2016 02:07
Hi guys I'm stuck on the assignment with a returned value lesson I have to :Call the process function with an argument of 7 and assign its return value to the variable processed. this is what I have // Setup
var processed = 0;
function process(num) {
return (num + 3) / 5;
}
// Only change code below this line
function process(num) {
return (5 + 2);
}
var processed= process;
pointers? thanks
Kevin Myrick
@aphextwin234
Jan 25 2016 02:08
ah, I think I'm getting off the right track.
need to use this @GM-Connor
@aphextwin234 Ok there was typo in instructions. Target heartrate = 220 - age
max = th * .85
forgot
Benjamin Corry
@becorry
Jan 25 2016 02:14
Help please I took a break from coding and have no idea what to do now on this mad lib exercise.
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
CamperBot
@camperbot
Jan 25 2016 02:14
no wiki entry for: please i took a break from coding and have no idea what to do now on this mad lib exercise function wordblanksmynoun myadjective myverb myadverb var result your code below this line your code above this line return result change the words here to test your functionwordblanksdog big ran quickly
Vik
@vvang044
Jan 25 2016 02:17
has anyone completed" STand in line"??
Secil
@senuka
Jan 25 2016 02:17
@LucianoBritis yes the problem's solved
jpg8127
@jpg8127
Jan 25 2016 02:18
@becorry what is the name of it?
Vik
@vvang044
Jan 25 2016 02:18

function queue(arr, item) {
// Your code here

return item; // Change this line
}

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

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

Benjamin Corry
@becorry
Jan 25 2016 02:19
@jpg8127 its called "Word Blanks"
jpg8127
@jpg8127
Jan 25 2016 02:19
@vvang044 i have finished stand in line I think
@becorry that one confused me about what to do but I think you just have to put a string between each parameter
Vik
@vvang044
Jan 25 2016 02:20
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array.... function(arr, item, int) is that right??
1ety
@1ety
Jan 25 2016 02:20

Where I am wrong? // 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
phoneticLookup("Adams");

Adam
@Blakemilton6
Jan 25 2016 02:21
@becorry I just did that one was on it for weeks
1ety
@1ety
Jan 25 2016 02:21
and?
Kevin Myrick
@aphextwin234
Jan 25 2016 02:21
<script type="text/javascript">

function calcHeartRate()

{

var Target heartrate = 220 - age
var max = th * .85
}

</script>
something like this @GM-Connor then it needs to be put into an equation?
jpg8127
@jpg8127
Jan 25 2016 02:22
@1ety what is the name of the lesson?
Kevin Myrick
@aphextwin234
Jan 25 2016 02:22
sorry suffering lots of lack of sleep lots of stuff going on!
1ety
@1ety
Jan 25 2016 02:23
201
Adam
@Blakemilton6
Jan 25 2016 02:23
you have to : " " + myNoun + " " + myAdjective... space between string/commas
GM-Connor
@GM-Connor
Jan 25 2016 02:23
@aphextwin234 yeah except variables cant have spaces. You can replace with _ or just change to target. Also do the min now
jpg8127
@jpg8127
Jan 25 2016 02:24
@1ety I do not know how to find lesson by number
1ety
@1ety
Jan 25 2016 02:24
Using Objects for Lookups
Kevin Myrick
@aphextwin234
Jan 25 2016 02:25
```
<script type="text/javascript">

function calcHeartRate()

{

var Target_heartrate = 220 - age
var max = th * .85;
var min = th *.5;
}

</script>
Vik
@vvang044
Jan 25 2016 02:25
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed................... how can i do this?
Kevin Myrick
@aphextwin234
Jan 25 2016 02:25
?
jpg8127
@jpg8127
Jan 25 2016 02:25
@1ety the first part like alpha needs quotes also "alpha": "Adams",
GM-Connor
@GM-Connor
Jan 25 2016 02:25
@aphextwin234 yeah th needs to be replaced with Target_heartrate
Adam
@Blakemilton6
Jan 25 2016 02:26
result= " " + myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb + " "; that's how I did it dude
Jon
@jcmockbee
Jan 25 2016 02:26
Hi doing the new word blanks challenge in Java I am not sure what they are looking for?

We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to provide additional strings, which will not change, in between the provided words.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Run tests (ctrl + enter)
Reset Help Bug

SyntaxError: Unexpected string

wordBlanks("","","","") should return a string.
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).

jpg8127
@jpg8127
Jan 25 2016 02:26
@vvang044 push and shift is all I used
Jon
@jcmockbee
Jan 25 2016 02:26

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

function wordBlanks("dog", "big", "ran", "quickly")

wordBlanks("cat", "little", "hit", "slowly")
// Your code above this line
return result;
}

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

GM-Connor
@GM-Connor
Jan 25 2016 02:26
@jcmockbee link to challenge?
Kevin Myrick
@aphextwin234
Jan 25 2016 02:28
```
<script type="text/javascript">

function calcHeartRate()

{

var Target_heartrate = 220 - age
var max = Target_heartrate * .85;
var min = Target_heartrate *.5;
}

</script>
jpg8127
@jpg8127
Jan 25 2016 02:29
@jcmockbee put all the parameters into one string with a string between them
1ety
@1ety
Jan 25 2016 02:29

I // 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
phoneticLookup("Adams");

jpg8127
@jpg8127
Jan 25 2016 02:30
@jpg8127 myNoun +" asdf " + myAdjective << that would be the start
Jon
@jcmockbee
Jan 25 2016 02:30
1 string for both then got it thankyou
GM-Connor
@GM-Connor
Jan 25 2016 02:30
@aphextwin234 awesome, now lets test the button. put an alert in the function and click the button to see if it comes up
jpg8127
@jpg8127
Jan 25 2016 02:31
@1ety lookup not Lookup
Kevin Myrick
@aphextwin234
Jan 25 2016 02:31
return alert(calcHeartRate);
?
jpg8127
@jpg8127
Jan 25 2016 02:32
@aphextwin234 what is the lesson name?
GM-Connor
@GM-Connor
Jan 25 2016 02:32
no just put alert(max); below the max variable;
Jas
@Manwithmojo
Jan 25 2016 02:32
anyone do the stand in line challenge? Keep gettting a call stack size exceeded
GM-Connor
@GM-Connor
Jan 25 2016 02:33
@Manwithmojo post your code
Kevin Myrick
@aphextwin234
Jan 25 2016 02:33
@jpg8127 I have put a Target Heart Rate program instructions further up
Jas
@Manwithmojo
Jan 25 2016 02:33

function queue(arr, item) {
// Your code here
arr.push(item);
return arr.shift(); // Change this line
}

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

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

1ety
@1ety
Jan 25 2016 02:33
Thank you. I have to take a break now. will try later.
GM-Connor
@GM-Connor
Jan 25 2016 02:34
@aphextwin234 This is just so we know that the calculate button is working
Kevin Myrick
@aphextwin234
Jan 25 2016 02:34
```
jpg8127
@jpg8127
Jan 25 2016 02:34
@1ety did you get it working? I think you just needed to make the L lowercase
Kevin Myrick
@aphextwin234
Jan 25 2016 02:34
<script type="text/javascript">

function calcHeartRate()

{

var Target_heartrate = 220 - age
var max = Target_heartrate * .85;
 alert(max);
var min = Target_heartrate *.5;
}

</script>
it's return a NaN still not sure what that means it does that sometimes.
Jas
@Manwithmojo
Jan 25 2016 02:34

@GM-Connor function queue(arr, item) {
// Your code here
arr.push(item);
return arr.shift(); // Change this line
}

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

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

jpg8127
@jpg8127
Jan 25 2016 02:34
@Manwithmojo that looks like my code..
Kevin Myrick
@aphextwin234
Jan 25 2016 02:35
do i put target heart rate in there
Marie
@Marie79
Jan 25 2016 02:35

Hey there! JavaScript newbie needing help with Access MultiDimensional Arrays With Indexes
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];

GM-Connor
@GM-Connor
Jan 25 2016 02:35
@aphextwin234 nono, it ran, there was just an error. You can remove the alert statement
Jas
@Manwithmojo
Jan 25 2016 02:35
@jpg8127 but the error is still there
GM-Connor
@GM-Connor
Jan 25 2016 02:35
We referenced age before we defined it, so let's do that now
jpg8127
@jpg8127
Jan 25 2016 02:35
@Manwithmojo hmm....... I think I just ran your code and it worked......?
@Manwithmojo do you have a typo above that part?
Kevin Myrick
@aphextwin234
Jan 25 2016 02:36
you mean enter age within the alert? alert(age); <--- instead of max?
GM-Connor
@GM-Connor
Jan 25 2016 02:36
@aphextwin234 You need to get the value, or whats in the age text field and store in a variable called age
Jas
@Manwithmojo
Jan 25 2016 02:36
@jpg8127 keep getting RangeError
GM-Connor
@GM-Connor
Jan 25 2016 02:36
@aphextwin234 No, just remove the alert part
so its just the 3 variables
jpg8127
@jpg8127
Jan 25 2016 02:37
@Manwithmojo I dunno.. try copying the two lines you added then press reset and paste them back?
GM-Connor
@GM-Connor
Jan 25 2016 02:38
@aphextwin234 Now you need to get the value, or whats in the age text field and store in a variable called age
Jas
@Manwithmojo
Jan 25 2016 02:38
i tired that it didnt work only the first check works but the next 3 and still red Xs
@jpg8127 arr.push(item);
return arr.shift();
Kevin Myrick
@aphextwin234
Jan 25 2016 02:40
<script type="text/javascript">

function calcHeartRate()

{

var Target_heartrate = 220 - age
var max = Target_heartrate * .85;
 alert(age);
var min = Target_heartrate *.5;
}

</script>
jpg8127
@jpg8127
Jan 25 2016 02:40
@Manwithmojo that is exactly what I have..
Kevin Myrick
@aphextwin234
Jan 25 2016 02:40
okay i need a document.formname.age i think right something to return that becuase I'm getting the innerhtml text in the alert box
Jas
@Manwithmojo
Jan 25 2016 02:40
@jpg8127 are you changing anything for line 12?
jpg8127
@jpg8127
Jan 25 2016 02:41
@Manwithmojo no
Jas
@Manwithmojo
Jan 25 2016 02:41
@jpg8127 guess i should report as a bug
jpg8127
@jpg8127
Jan 25 2016 02:42

@Manwithmojo function queue(arr, item) {
arr.push(item);
return arr.shift();
}

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

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

@Manwithmojo try deleting everything then copy and pasting that?
Adam
@Blakemilton6
Jan 25 2016 02:43
@Marie79 it's a value of 8? right I just did that one it's [2][1]
GM-Connor
@GM-Connor
Jan 25 2016 02:43
@aphextwin234 not sure, but one way is to use document.document.getElementById("").value
Adam
@Blakemilton6
Jan 25 2016 02:44
var myData = myArray2;
GM-Connor
@GM-Connor
Jan 25 2016 02:44
1 too many documents
Adam
@Blakemilton6
Jan 25 2016 02:44
var myData = myArray2;
Kevin Myrick
@aphextwin234
Jan 25 2016 02:44
<script type="text/javascript">

function calcHeartRate()

{
ocument.document.getElementById("calcHeartRate").value
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;
 alert(age);
var min = Target_heartrate *.5;
}

</script>
Jas
@Manwithmojo
Jan 25 2016 02:44
@jpg8127 i copied and pasted it didnt work
GM-Connor
@GM-Connor
Jan 25 2016 02:44
just document.getElementById("").value;
Kevin Myrick
@aphextwin234
Jan 25 2016 02:44
what goes in the prathenaese
Jas
@Manwithmojo
Jan 25 2016 02:44
@jpg8127 so strange
jpg8127
@jpg8127
Jan 25 2016 02:44
@Manwithmojo refresh page maybe?
GM-Connor
@GM-Connor
Jan 25 2016 02:44
the id of the form element that user puts age in
Adam
@Blakemilton6
Jan 25 2016 02:45
var myData= myArray2;
Vik
@vvang044
Jan 25 2016 02:45

@jpg is this correct?
var queue= ["arr","item"];
queue.push(num);
queue.shift(arr);

return arr;

Kevin Myrick
@aphextwin234
Jan 25 2016 02:45
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 2</title>
<script type="text/javascript">

function calcHeartRate()

{
document.getElementById("").value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;
 alert(age);
var min = Target_heartrate *.5;
}

</script>

</head>

<body>
<form name="totalheart">
Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>

</body>

</html>
Adam
@Blakemilton6
Jan 25 2016 02:45
sorry for the repeats
GM-Connor
@GM-Connor
Jan 25 2016 02:46
@aphextwin234 k put the id of the input field user puts age in. (the form <input> id)
jpg8127
@jpg8127
Jan 25 2016 02:46
@vvang044 did you change the function..? it should not look like that
Jas
@Manwithmojo
Jan 25 2016 02:46
@jpg8127 page refresh did the trick lol. who knew.... THANK YOU KIND STRANGER!
CamperBot
@camperbot
Jan 25 2016 02:46
manwithmojo sends brownie points to @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 260 | @jpg8127 | http://www.freecodecamp.com/jpg8127
jpg8127
@jpg8127
Jan 25 2016 02:46
@Manwithmojo nice lol
@vvang044 that looks like you changed more than you were supposed to
@vvang044 you just need to push the array then return it shifted
Vik
@vvang044
Jan 25 2016 02:47
it says to add a number....so i added queue.push(num)
jpg8127
@jpg8127
Jan 25 2016 02:47
@vvang044 the array is arr the function name is queue
@jpg8127 function queue(arr, item) <<< that means queue is what you call outside of the function, arr is the first parameter, item is the second parameter
Kevin Myrick
@aphextwin234
Jan 25 2016 02:49
id=""/>
?
GM-Connor
@GM-Connor
Jan 25 2016 02:50
<form name="totalheart">
    Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
The id you gave the form input element
Vik
@vvang044
Jan 25 2016 02:51
what confuses me is add a number
jpg8127
@jpg8127
Jan 25 2016 02:51
@vvang044 .push(item); is the adding number part
@vvang044 you had that part right.. the wrong part is the part before that
GM-Connor
@GM-Connor
Jan 25 2016 02:51
@aphextwin234 "age"
jpg8127
@jpg8127
Jan 25 2016 02:52
@vvang044 you do not push queue you push arr
Vik
@vvang044
Jan 25 2016 02:52
oh
that makes sence
Juan Martin Marco
@jmmarco
Jan 25 2016 02:52
Hi guys, I’m a bit stuck with the “Profile Lookup” challenge. I need an extra set of eyes, just to make sure I’m on the right path..
```
jpg8127
@jpg8127
Jan 25 2016 02:52
@vvang044 I am terrible at explaining things :/
Juan Martin Marco
@jmmarco
Jan 25 2016 02:52
function lookUp(firstName, prop) {
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    console.log(contacts[i].firstName == firstName);
    console.log(contacts[i].hasOwnProperty(prop));
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop) ) {
      return contacts[i][prop];
    }

  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "address”);
Kevin Myrick
@aphextwin234
Jan 25 2016 02:52
yes it gives me [objectHTMLInputElement]
in the alert
when i put age in
Jon
@jcmockbee
Jan 25 2016 02:53
Hi ,
Vik
@vvang044
Jan 25 2016 02:53
im worst at asking things.....lol
Juan Martin Marco
@jmmarco
Jan 25 2016 02:53
Any suggestions are appreciated.
jpg8127
@jpg8127
Jan 25 2016 02:53
@vvang044 did you get it right now though?
Bharatian
@bharatian
Jan 25 2016 02:53
@jmmarco - i am on the same challenge
GM-Connor
@GM-Connor
Jan 25 2016 02:54
@aphextwin234 thats because the variable age is still undefinded. make age = to the document.getElementById("age").value;
Kevin Myrick
@aphextwin234
Jan 25 2016 02:54
<script type="text/javascript">

function calcHeartRate()

{
document.getElementById("age").value
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;
 alert(age);
var min = Target_heartrate *.5;
}

</script>

</head>

<body>
<form name="totalheart">
 Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>

</body>

</html>
my apologies
Vik
@vvang044
Jan 25 2016 02:54
@jpg let me try
Bharatian
@bharatian
Jan 25 2016 02:54
@jmmarco - i am having hard time getting the logics.
Kevin Myrick
@aphextwin234
Jan 25 2016 02:54
yes I have document.getElementById("age").value right now
Juan Martin Marco
@jmmarco
Jan 25 2016 02:54
@bharatian Cool, are you also using a loop to iterate through the contacts object?
Bharatian
@bharatian
Jan 25 2016 02:55
@jmmarco - no i am not even sure
jpg8127
@jpg8127
Jan 25 2016 02:55
profile lookup took me a while I used a loop
GM-Connor
@GM-Connor
Jan 25 2016 02:55
@bharatian @jmmarco This is the logic behind it
function ----(firstname, property) {
    cycle through each item in contacts {
        if item's firstname is equal to firstname {
            if item has property {
                return the property value;
            }
           //If we reached this point, it means we found the name, but property doesn't exit. 
           return "property not found"
        }
    }
    //If we reached this point, it means we didn't find a name 
    return "contact not found"
}
Vik
@vvang044
Jan 25 2016 02:55
@jpg8127 is stays maximum stack exceeded.....
Juan Martin Marco
@jmmarco
Jan 25 2016 02:55
@jpg8127 I’ve been at it for a couple of hours! I can’t seem to get the conditionals right...
Vik
@vvang044
Jan 25 2016 02:56
says
jpg8127
@jpg8127
Jan 25 2016 02:56
@vvang044 copy and paste your new code

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

wordblank ("dog", "big", "ran", "quickly")+("cat", "little", "hit", "slowly");
// Your code above this line
return result;
}

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

GM-Connor
@GM-Connor
Jan 25 2016 02:57
@jcmockbee You combine strings like addition: string1 + string2
Jon
@jcmockbee
Jan 25 2016 02:57
wordblank ("dog", "big", "ran", "quickly")+("cat", "little", "hit", "slowly"); as such?????
Vik
@vvang044
Jan 25 2016 02:58

function queue(arr, item) {
// Your code here

arr.push(item);
arr.push(arr);

cannelflow
@cannelflow
Jan 25 2016 02:58
@jcmockbee you have to make a sentence using input myNoun, myAdjective, myVerb, myAdverb
jpg8127
@jpg8127
Jan 25 2016 02:58
@jcmockbee str = myNoun +" asdf " + myAdjective
Juan Martin Marco
@jmmarco
Jan 25 2016 02:58
@GM-Connor, So a for in loop seems to be the right approach.. And the nested if… Ah, let try that approach.. :+1:
GM-Connor
@GM-Connor
Jan 25 2016 02:58
@jcmockbee so if you are inputting "dog", "big", "ran", "quickly" into the function you will be adding their variables myNoun, myAdjective, myVerb, myAdverb
Juan Martin Marco
@jmmarco
Jan 25 2016 02:58
*let me try
jpg8127
@jpg8127
Jan 25 2016 02:58
@vvang044 arr.push(item) is right but then you have to return the first thing with shift
GM-Connor
@GM-Connor
Jan 25 2016 02:59
@jcmockbee also take the wordblank ("dog", "big", "ran", "quickly")+("cat", "little", "hit", "slowly"); line out completely
Vik
@vvang044
Jan 25 2016 02:59
isnt the first item or the parameter is "arr" ??
Jon
@jcmockbee
Jan 25 2016 02:59
out comes the line
GM-Connor
@GM-Connor
Jan 25 2016 02:59
@jcmockbee start with result =
jpg8127
@jpg8127
Jan 25 2016 02:59
@vvang044 not sure what you mean..? arr.push(item) adds item to the array arr
GM-Connor
@GM-Connor
Jan 25 2016 02:59
because result is what will be returned
Bharatian
@bharatian
Jan 25 2016 02:59
@jmmarco for and in ? or for and if?
Jon
@jcmockbee
Jan 25 2016 03:00
ok I will try result thanks
cannelflow
@cannelflow
Jan 25 2016 03:00
@jmmarco make that sentence = result
jpg8127
@jpg8127
Jan 25 2016 03:00
@vvang044 var arr = [2]; <<< if you use arr.push(5); then arr becomes... arr = [2, 5];
E
@1Emre-K
Jan 25 2016 03:00
Hey guys could someone help me with the "Record Collection" project please
GM-Connor
@GM-Connor
Jan 25 2016 03:00
@jcmockbee you now set result to the addition of the strings(variables)
E
@1Emre-K
Jan 25 2016 03:01
Here's my code:
Juan Martin Marco
@jmmarco
Jan 25 2016 03:01
@bharatian Yup, check out this reference
E
@1Emre-K
Jan 25 2016 03:01
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}

// Alter values below to test your code
update(5439, "artist", "ABBA");
update(1245, "tracks", "Addicted to Love");
update(2548, "tracks", "");
Andrew Bales
@agbales
Jan 25 2016 03:01
This message was deleted
Juan Martin Marco
@jmmarco
Jan 25 2016 03:01
@cannelflow , I’ll give that a try too
jpg8127
@jpg8127
Jan 25 2016 03:01
@agbales I think you msged the wrong person..?
Bharatian
@bharatian
Jan 25 2016 03:01
@jmmarco glad i didn’t just try to solve it for hours, i had no idea about that.
Andrew Bales
@agbales
Jan 25 2016 03:01
@jpg8127 I did, then hung my head in shame by deleting it :)
jpg8127
@jpg8127
Jan 25 2016 03:02
lol
Vik
@vvang044
Jan 25 2016 03:02
now if i want to remove it arr.shift(2) will remove the first parameter
Andrew Bales
@agbales
Jan 25 2016 03:02
I believe I was telling @1Emre-K to post some code, but it looks that already happened. :)
GM-Connor
@GM-Connor
Jan 25 2016 03:02
@jmmarco @bharatian a for in isn't necessary and can be done with regular for loop. for in is just a simple version
E
@1Emre-K
Jan 25 2016 03:02

the

delete collection[id][prop];

seems to be working, but the rest isn't! :worried:

cannelflow
@cannelflow
Jan 25 2016 03:02
@jmmarco let me konw if you need anything
jpg8127
@jpg8127
Jan 25 2016 03:03
@vvang044 arr.shift(); <<< that will remove the first element by it self and returns it
chipymunk
@chipymunk
Jan 25 2016 03:03
How do I insert a code block again?
E
@1Emre-K
Jan 25 2016 03:03
```
```
oops
lol
Eina
@thelittleblacksmith
Jan 25 2016 03:03
wiki format
CamperBot
@camperbot
Jan 25 2016 03:03

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

jpg8127
@jpg8127
Jan 25 2016 03:03
var test = 5;
GM-Connor
@GM-Connor
Jan 25 2016 03:03
@aphextwin234 you have to create the variable age now and set it equal to that (document.getElementById("age"))
Bharatian
@bharatian
Jan 25 2016 03:04
@jmmarco your initial code looks logical what was wrong with it sorry to ask you
Vik
@vvang044
Jan 25 2016 03:04
onsole.log(queue(testArr, 6)); // Modify this line to test.......what do i do with this part?
Bharatian
@bharatian
Jan 25 2016 03:04
@GM-Connor - thanks for your guidance.
CamperBot
@camperbot
Jan 25 2016 03:04
bharatian sends brownie points to @gm-connor :sparkles: :thumbsup: :sparkles:
:star: 150 | @gm-connor | http://www.freecodecamp.com/gm-connor
Kevin Myrick
@aphextwin234
Jan 25 2016 03:04
<script type="text/javascript">

function calcHeartRate()

{
var document.getElementById("age").value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;
 alert(age);
var min = Target_heartrate *.5;
}

</script>
jpg8127
@jpg8127
Jan 25 2016 03:04
@vvang044 that is just for testing not for the answer
chipymunk
@chipymunk
Jan 25 2016 03:04

```function factorialize(num) {
if (num === 0) {return 1;} else {
return num * factorialize(num - 1);
}
}

factorialize(5);```

jpg8127
@jpg8127
Jan 25 2016 03:05

`function factorialize(num) {
if (num === 0) {return 1;} else {
return num * factorialize(num - 1);
}
}

factorialize(5);`

GM-Connor
@GM-Connor
Jan 25 2016 03:05
@aphextwin234 var document... to var age = document...
Juan Martin Marco
@jmmarco
Jan 25 2016 03:05
@bharatian Well, that initial code works out fine, but to get the rest of the items in the problem to check out you have to nest another if statement inside the first one. See @GM-Connor , example..
Kevin Myrick
@aphextwin234
Jan 25 2016 03:06
oh i see
how come it is just giving me the age though I enter not the calculated target heart rate or whatever
E
@1Emre-K
Jan 25 2016 03:06
No one..?
Vik
@vvang044
Jan 25 2016 03:06
this is getting really frustrating
cannelflow
@cannelflow
Jan 25 2016 03:07
@jmmarco worked ?
GM-Connor
@GM-Connor
Jan 25 2016 03:07
@aphextwin234 because the alert has the age variable in it, you can replace with something else
jpg8127
@jpg8127
Jan 25 2016 03:07
@vvang044 lol copy and paste your full code. Its just two lines I think you are making it harder than it is.
Juan Martin Marco
@jmmarco
Jan 25 2016 03:07
@cannelflow , not yet.. Still at it.. Thanks for the follow up
CamperBot
@camperbot
Jan 25 2016 03:07
jmmarco sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
cannelflow
@cannelflow
Jan 25 2016 03:07
@vvang044 which exercise can you paste your whole code ?
CamperBot
@camperbot
Jan 25 2016 03:07
:star: 528 | @cannelflow | http://www.freecodecamp.com/cannelflow
chipymunk
@chipymunk
Jan 25 2016 03:07
Greetings all.. I have a question.. How does this code know to loop back to the begining? This is the factorialize code. I understand how we get the initial iteration of the num * num-1 but how does it know to go back and do it again and again until it reaches zero.
function factorialize(num) {
  if (num === 0) {return 1;} else {
    return num * factorialize(num - 1);
  }
}

factorialize(5);
Vik
@vvang044
Jan 25 2016 03:07
function queue(arr, item) {
  // Your code here

  arr.push(item);
  arr.shift();

  return arr;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr))
GM-Connor
@GM-Connor
Jan 25 2016 03:08
@GM-Connor like "Your target heart range is " + min + "-" + max + "beats a minute"
jpg8127
@jpg8127
Jan 25 2016 03:08
@vvang044 you are returning the array rather than the shift
Andrew Bales
@agbales
Jan 25 2016 03:08
Anyone able to take a look at Sum All Primes? I've gotten fairly close, but stuck now.
Kevin Myrick
@aphextwin234
Jan 25 2016 03:08
yea it's supposed to calculate the minumum and max target heart rates and siplay in another text box in the form actually this time
Vik
@vvang044
Jan 25 2016 03:09
iisnt that the first item which needs to be returned?
Kevin Myrick
@aphextwin234
Jan 25 2016 03:09
a 35 year old person should have a minumum and max target heart rate of 92 to 157 hmm
cannelflow
@cannelflow
Jan 25 2016 03:09
@chipymunk first num=5 and then it come here *factorialize(num - 1) this is calling function itself
Vik
@vvang044
Jan 25 2016 03:09
the element that was removed
GM-Connor
@GM-Connor
Jan 25 2016 03:09
@chipymunk That is because each time you call it you are using num - 1 whi means each time you call it you are using 1 less that you used last time. Eventually it will reach 0
jpg8127
@jpg8127
Jan 25 2016 03:09
@vvang044 return arr.shift(); <<< that returns the first item and return arr; would return the rest of the array
cannelflow
@cannelflow
Jan 25 2016 03:10
@vvang044 you need to return arr.shift
jpg8127
@jpg8127
Jan 25 2016 03:10
@vvang044 you want to return the element that is removed not the rest of the array
GM-Connor
@GM-Connor
Jan 25 2016 03:10
@GM-Connor A function like this is called a recursive function. It calls itself
within itself
Vik
@vvang044
Jan 25 2016 03:10
hmmmm
chipymunk
@chipymunk
Jan 25 2016 03:10
OIC now.. So instead of a "loop" like we would normally think, this way it just calls back on itself.. tricky.. tks!
Bharatian
@bharatian
Jan 25 2016 03:10
@jmmarco - I read the logic of @GM-Connor but I guess I need help with learning more about this array style data extraction. the exercises are not cutting it for me. any suggestions?
jpg8127
@jpg8127
Jan 25 2016 03:10
@chipymunk it first checks if num equals zero if it is then the thing returns ending everything
oh you already understand
Vik
@vvang044
Jan 25 2016 03:11
function queue(arr, item) {
  // Your code here

  arr.push(item);
  arr.shift();

  return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
jpg8127
@jpg8127
Jan 25 2016 03:11
@vvang044 remove the other arr.shift();
Vik
@vvang044
Jan 25 2016 03:11
like that?
cannelflow
@cannelflow
Jan 25 2016 03:11
@vvang044 remove forst arr.shift()
chipymunk
@chipymunk
Jan 25 2016 03:12
Yeah I was expecintg to have to come up with a for loop to iterate thourhg. And I suppose I could do that but this way seems more elegant..
cannelflow
@cannelflow
Jan 25 2016 03:12
@chipymunk got it ?
GM-Connor
@GM-Connor
Jan 25 2016 03:13
@chipymunk Yep so when you call factorilze(5), it calls factorize(4) in it self and repeats until it reaches what is called a base case. In this case the base case is when num = 0 and return 1. A recursive function always has to have a base case
Vik
@vvang044
Jan 25 2016 03:13
this is crazy.....lol....i still dont get it
GM-Connor
@GM-Connor
Jan 25 2016 03:13
@chipymunk Also recursion is elegant, but is slower (processing-wise) than iteration
Vik
@vvang044
Jan 25 2016 03:14
even after removing arr.shift()
Bharatian
@bharatian
Jan 25 2016 03:14
@jmmarco and @GM-Connor this is my brain

function lookUp(firstName, prop){
// Only change code below this line
for (i=0; i<=contacts.length; i++)
{
if (contacts[i].firstName==="firstName")
{
if (contacts[i].hasOwnProperty(prop))
{
return contacts[i].prop;
}
return "No such property";
}
return "No such proeprty";
}

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");

jpg8127
@jpg8127
Jan 25 2016 03:14
@vvang044 you should have the code right if you removed the first arr.shift();
Kevin Myrick
@aphextwin234
Jan 25 2016 03:14
@gm so I am removing the alert box for this excersise and need the output in the form
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 2</title>
<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById("age").value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;
}

</script>

</head>

<body>
<form name="totalheart">
 Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>
<br/>
Target Heart Rate <input type="text" onclick="calcHeartRate()"/>

</body>

</html>
GM-Connor
@GM-Connor
Jan 25 2016 03:15
@aphextwin234 change to alert to alert("Your target heart range is " + min + "-" + max + "beats a minute");
Kevin Myrick
@aphextwin234
Jan 25 2016 03:15
This is my HTML
sorry for the switch up
Vik
@vvang044
Jan 25 2016 03:15
function queue(arr, item) {
  // Your code here

  arr.push(item);


  return arr.shift();  // Change this line
}
jpg8127
@jpg8127
Jan 25 2016 03:15
@vvang044 yes
Vik
@vvang044
Jan 25 2016 03:15
nope it doesnt work
jpg8127
@jpg8127
Jan 25 2016 03:16
@vvang044 try refreshing the page
GM-Connor
@GM-Connor
Jan 25 2016 03:16
Its fine @aphextwin234 where do you want the result to go? in the last input box?
Kevin Myrick
@aphextwin234
Jan 25 2016 03:16
yes the text box that says 'target heart rate ' or something like that
parapharaing
jpg8127
@jpg8127
Jan 25 2016 03:16
@vvang044 that code is right
Vik
@vvang044
Jan 25 2016 03:17
lol..... you are f....ing great....it worked.....
GM-Connor
@GM-Connor
Jan 25 2016 03:17
ok, first you ned to remove the onclick from that text box. And you will need to give it a unique id so we can reference with js to put it there
Kevin Myrick
@aphextwin234
Jan 25 2016 03:17
and if I could work on this form because ya there is one text box then a button and then a huge white space and the other text box indented over
jpg8127
@jpg8127
Jan 25 2016 03:17
@vvang044 lol do you understand what it is doing though?
Vik
@vvang044
Jan 25 2016 03:17
and i need a f......ing break.....my brain is going to explore
now i do
jpg8127
@jpg8127
Jan 25 2016 03:17
@vvang044 k
Vik
@vvang044
Jan 25 2016 03:18
we just added and we returned the element
Juan Martin Marco
@jmmarco
Jan 25 2016 03:18
@bharatian Tip: Use ``` to display code, it makes it easier to read. :+1:
jpg8127
@jpg8127
Jan 25 2016 03:18
@vvang044 yes
Vik
@vvang044
Jan 25 2016 03:19
instead i was doing this var queue=["arr","item","num"] (( because it said to add))
it should take an array
Bharatian
@bharatian
Jan 25 2016 03:19
ok
I solved some part of it though, still not all the way through
Vik
@vvang044
Jan 25 2016 03:20
@jpg8127
jpg8127
@jpg8127
Jan 25 2016 03:20
@vvang044 ?
Vik
@vvang044
Jan 25 2016 03:20
@jpg8127
no brownie points for you......lol
jpg8127
@jpg8127
Jan 25 2016 03:20
lol
Vik
@vvang044
Jan 25 2016 03:20
its not working.....lol
Kevin Myrick
@aphextwin234
Jan 25 2016 03:20
document.avgForm.text6.value = result; do i need something like this but replace this text id
Vik
@vvang044
Jan 25 2016 03:21
but thank you
jpg8127
@jpg8127
Jan 25 2016 03:21
np
Andrew Bales
@agbales
Jan 25 2016 03:21
Has anyone worked on Sum All Primes yet?
xgumball
@xgumball
Jan 25 2016 03:21
i need help
jpg8127
@jpg8127
Jan 25 2016 03:21
@xgumball with?
Kevin Myrick
@aphextwin234
Jan 25 2016 03:21

<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById("age").value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;

document.totalheart.age.value = result;
}

</script>
GM-Connor
@GM-Connor
Jan 25 2016 03:22
@aphextwin234 document.getElementById("text6").value = min + "-" + max;
xgumball
@xgumball
Jan 25 2016 03:22
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh" };

function checkObj(checkProp) {
// Your Code Here

if (myObj.hasOwnProperty("checkProp")=== true);

{return myObj[checkProp];}

return "Not Found"; }

// Test your code by modifying these values
checkObj("house");
Kevin Myrick
@aphextwin234
Jan 25 2016 03:22
ah that isadding the two min and max and giving you those values thanks
Bharatian
@bharatian
Jan 25 2016 03:22
@jmmarco code works for me but only for Akira
Kevin Myrick
@aphextwin234
Jan 25 2016 03:22
amazing this is making sense right now
Bharatian
@bharatian
Jan 25 2016 03:22
now
jpg8127
@jpg8127
Jan 25 2016 03:22
@xgumball what lesson is that?
Kevin Myrick
@aphextwin234
Jan 25 2016 03:22
im like exhausted
Adam
@Blakemilton6
Jan 25 2016 03:22
I'm stuck at the assignment with a returned value lesson anyone can help?
xgumball
@xgumball
Jan 25 2016 03:22
testing object for properties
Adam
@Blakemilton6
Jan 25 2016 03:23

var processed = 0;

function process(num) {
return (num + 3) / 5;
}

// Only change code below this line

GM-Connor
@GM-Connor
Jan 25 2016 03:23
@bharatian The second return statement if if the firstname was found. Where you have the second return statement should be someonewhere else
Bharatian
@bharatian
Jan 25 2016 03:23
```function lookUp(firstName, prop){
// Only change code below this line
for (i=0; i<=contacts.length; i++)
{
if (firstName==contacts[i].firstName)
{
if (contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
else return "No such property";
}
return "No such proeprty";
}````
Kevin Myrick
@aphextwin234
Jan 25 2016 03:23
shoot it returns both NaN
in the first text box
GM-Connor
@GM-Connor
Jan 25 2016 03:23
@aphextwin234 yeah it puts the 2 values with a hyphen between them
Bharatian
@bharatian
Jan 25 2016 03:23
@GM-Connor check my new code i just posted please, thank you
CamperBot
@camperbot
Jan 25 2016 03:23
bharatian sends brownie points to @gm-connor :sparkles: :thumbsup: :sparkles:
:warning: bharatian already gave gm-connor points
Adam
@Blakemilton6
Jan 25 2016 03:24
Call the process function with an argument of 7 and assign its return value to the variable processed.
Kevin Myrick
@aphextwin234
Jan 25 2016 03:24

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 2</title>
<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById("age").value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;

document.getElementById("age").value = min + "-" + max;
}

</script>

</head>

<body>
<form name="totalheart">
 Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>
<br/>
Target Heart Rate <input type="text" onclick="calcHeartRate()"/>
<br/>

</body>

</html>
GM-Connor
@GM-Connor
Jan 25 2016 03:24
@bharatian do three ticks so a can see it formatted
xgumball
@xgumball
Jan 25 2016 03:24
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh" };

function checkObj(checkProp) {
// Your Code Here

if (myObj.hasOwnProperty("checkProp")=== true);

{return myObj[checkProp];}

return "Not Found"; }

// Test your code by modifying these values
checkObj("house");
what am i doing wrong
GM-Connor
@GM-Connor
Jan 25 2016 03:25
@aphextwin234 Well since you want the result to go to Target Heart Rate <input type="text" onclick="calcHeartRate()"/>, you will need to give this an id and change the "age" in document.getElementById("age").value = min + "-" + max; to new id
Bharatian
@bharatian
Jan 25 2016 03:25
@GM-Connor not sure what that is
Johnny Cornyn
@JMIHC
Jan 25 2016 03:25
@xgumball try taking off the "" from checkProp
GM-Connor
@GM-Connor
Jan 25 2016 03:26
```
code here
```
it will format pretty-like
Andrew Bales
@agbales
Jan 25 2016 03:26
@xgumball take a look at the ; after your if statement parentheses
jpg8127
@jpg8127
Jan 25 2016 03:26
@xgumball you are using a string instead of a parameter
Bharatian
@bharatian
Jan 25 2016 03:26
function lookUp(firstName, prop){
// Only change code below this line
  for (i=0; i<=contacts.length; i++)
  {
   if (firstName==contacts[i].firstName)
   {
     if (contacts[i].hasOwnProperty(prop))
       {
         return contacts[i][prop];
        }
     else return "No such property";
   }
  return "No such proeprty";
  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Harry", "lastName");
jpg8127
@jpg8127
Jan 25 2016 03:27
@xgumball myObj.hasOwnProperty(checkProp) not myObj.hasOwnProperty("checkProp")
Bharatian
@bharatian
Jan 25 2016 03:27
ah
@GM-Connor this code is only returning for Akira
GM-Connor
@GM-Connor
Jan 25 2016 03:27
shouldn't the second return statement be "no such contract"?
@bharatian or something?
nik
@nikrb
Jan 25 2016 03:28
@xgumball remove the quotes around checkProp. As it is you are check for a property called checkProp
Bharatian
@bharatian
Jan 25 2016 03:28
lol yes
xgumball
@xgumball
Jan 25 2016 03:28
still not working
jpg8127
@jpg8127
Jan 25 2016 03:28
@xgumball post new code
GM-Connor
@GM-Connor
Jan 25 2016 03:28
Function-wise looks good. Just make sure the return strings match exactly what is expected.
Kevin Myrick
@aphextwin234
Jan 25 2016 03:28
what should my id be called in that unique textbox
jpg8127
@jpg8127
Jan 25 2016 03:28
@xgumball did you remove the ; after the if also?
GM-Connor
@GM-Connor
Jan 25 2016 03:28
@aphextwin234 doesn't matter, call it "result"
Kevin Myrick
@aphextwin234
Jan 25 2016 03:28
<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById(= min + "-" + max).value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;

document.getElementById("age").value = min + "-" + max;
}

</script>

</head>

<body>
<form name="totalheart">
 Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>
<br/>
Target Heart Rate <input type="text" onclick="calcHeartRate() "/>
<br/>

</body>
nik
@nikrb
Jan 25 2016 03:29
@xgumball there is no house property
GM-Connor
@GM-Connor
Jan 25 2016 03:29
@aphextwin234 also remove the onClick part of Target Heart Rate <input type="text" onclick="calcHeartRate() "/>
Kevin Myrick
@aphextwin234
Jan 25 2016 03:30
?
GM-Connor
@GM-Connor
Jan 25 2016 03:30
@aphextwin234 Only the Get Heart Rate button should be calling the function
Kevin Myrick
@aphextwin234
Jan 25 2016 03:30
remove all this <input type="text" onclick="calcHeartRate() "/>
Bharatian
@bharatian
Jan 25 2016 03:30
@GM-Connor its returning for two cases now. Bob and Akira but not for Harry Kristian and Sherlock
GM-Connor
@GM-Connor
Jan 25 2016 03:30
@aphextwin234 replace Target Heart Rate <input type="text" onclick="calcHeartRate() "/> with Target Heart Rate <input type="text"/>
@aphextwin234 The <button> has the onclick event and calls the button when pressed. You don't want the function to run when someone clicks on the input box at the bottom
Kevin Myrick
@aphextwin234
Jan 25 2016 03:31
alright. well I have to scrap this.. looksl ike i have a different one to do using a loop shoot
are you still gonna be going at this?
GM-Connor
@GM-Connor
Jan 25 2016 03:31
@aphextwin234 why do you have to scrap it?
nf15
@nf15
Jan 25 2016 03:32
any hint on this? Return Early Pattern for Functions
Kevin Myrick
@aphextwin234
Jan 25 2016 03:32
apparently I am doing the wrong excersise but I am saving this.
ahh
nf15
@nf15
Jan 25 2016 03:32
// Setup
function abTest(a, b) {
  // Only change code below this line


  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
GM-Connor
@GM-Connor
Jan 25 2016 03:32
@aphextwin234 Go ahead and finish it
we are 2 steps away
Kevin Myrick
@aphextwin234
Jan 25 2016 03:32
yea
xgumball
@xgumball
Jan 25 2016 03:32
Testing Objects for Properties
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh" };

function checkObj(checkProp) {
// Your Code Here

if ( myObj.hasOwnProperty(checkProp)=== true);

{return myObj[checkProp];}

return "Not Found"; }

// Test your code by modifying these values
checkObj("house");
not working
GM-Connor
@GM-Connor
Jan 25 2016 03:33
@bharatian k checking
@bharatian past your entire code block including the lookup array
Kevin Myrick
@aphextwin234
Jan 25 2016 03:34
Target Heart Rate <input type="text" onclick="calcHeartRate() "/> ok i need to do the ID in here
Bharatian
@bharatian
Jan 25 2016 03:34
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
  for (i=0; i<=contacts.length; i++)
  {
   if (firstName==contacts[i].firstName)
   {
     if (contacts[i].hasOwnProperty(prop))
       {
         return contacts[i][prop];
        }
     else return "No such property";
   }
  else return "No such contact";
  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Kevin Myrick
@aphextwin234
Jan 25 2016 03:34
whatever i want to return @GM-Connor
GM-Connor
@GM-Connor
Jan 25 2016 03:34
@aphextwin234 yep make an id name called "result". And remove the THE onclick="calcHeartRate() PART LOL!!
nf15
@nf15
Jan 25 2016 03:35
any one?
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.
Kevin Myrick
@aphextwin234
Jan 25 2016 03:35
```
```
<body>
<form name="totalheart">
 Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>
<br/>
Target Heart Rate <input type="text"/>
<br/>

</body>

</html>
GM-Connor
@GM-Connor
Jan 25 2016 03:36
@aphextwin234 yep now add the id
nf15
@nf15
Jan 25 2016 03:36
// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
GM-Connor
@GM-Connor
Jan 25 2016 03:37
@bharatian Found your problem. You are supposed to return "No such contact" in the event that the name was not found in the list. Your return statement is in the wrong place
Kevin Myrick
@aphextwin234
Jan 25 2016 03:37
<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById(= min + "-" + max).value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;

document.getElementById("age").value = min + "-" + max;
return result;
}

</script>

</head>

<body>
<form name="totalheart">
 Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>
<br/>
Target Heart Rate <input type="text" id="result"/>
<br/>

</body>

</html>
GM-Connor
@GM-Connor
Jan 25 2016 03:37
@GM-Connor also remove the else part
Kevin Myrick
@aphextwin234
Jan 25 2016 03:37
couple errors but then i think thats done
Juan Martin Marco
@jmmarco
Jan 25 2016 03:37
@GM-Connor Sucesss! Thanks for that logic tip! :+1:
CamperBot
@camperbot
Jan 25 2016 03:37
jmmarco sends brownie points to @gm-connor :sparkles: :thumbsup: :sparkles:
:star: 151 | @gm-connor | http://www.freecodecamp.com/gm-connor
GM-Connor
@GM-Connor
Jan 25 2016 03:37
@aphextwin234 1 more thing. update the id in document.getElementById("age").value = min + "-" + max; to the new id
Juan Martin Marco
@jmmarco
Jan 25 2016 03:39
@bharatian Keep at it, your code needs a little refactor. Use the example logic that @GM-Connor suggested.
Kevin Myrick
@aphextwin234
Jan 25 2016 03:39
```
Juan Martin Marco
@jmmarco
Jan 25 2016 03:39
Needs a little *refactoring
Kevin Myrick
@aphextwin234
Jan 25 2016 03:39
<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById(= min + "-" + max).value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;

document.getElementById("= min + "-" + max").value = min + "-" + max;
return result;
}

</script>
ah messed that up
GM-Connor
@GM-Connor
Jan 25 2016 03:39
@bharatian If other-words, we know if the name isn't in the lookup if we reach the end of the for loop without any other return statements triggering
*if other-words, we know that the name isn't in the lookup if we reach the end of the for loop without any other return statements triggering
Bharatian
@bharatian
Jan 25 2016 03:41
ok
I am still blind
GM-Connor
@GM-Connor
Jan 25 2016 03:41
@aphextwin234 na, make the document.getElementById("= min + "-" + max").value = min + "-" + max; part document.getElementById("result").value = min + "-" + max;
it has to be set to result because that is the name of the element whose value we want to change
@bharatian it's ok, the second return needs to be after the for loop
not in it
jpg8127
@jpg8127
Jan 25 2016 03:42
.
GM-Connor
@GM-Connor
Jan 25 2016 03:42
@GM-Connor because reaching the end of the for loop mean the name wasn't found
Kevin Myrick
@aphextwin234
Jan 25 2016 03:43
<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById(= min + "-" + max).value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;

document.getElementById("result").value = min + "-" + max;

}

</script>
GM-Connor
@GM-Connor
Jan 25 2016 03:43
@aphextwin234 Try that!
wait
You changed your first var age = document.getElementById(= min + "-" + max).value;
the id needs to still be "age"
Kevin Myrick
@aphextwin234
Jan 25 2016 03:44
93-158.1
schwing
Bharatian
@bharatian
Jan 25 2016 03:44
@GM-Connor you are right, i am not sure why the retun statement has to be outside…also now it is not returning no such contact but works otherwise for all others
GM-Connor
@GM-Connor
Jan 25 2016 03:45
@bharatian ok ill try to explain
Kevin Myrick
@aphextwin234
Jan 25 2016 03:45
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 2</title>
<script type="text/javascript">

function calcHeartRate()

{
var age = document.getElementById("age").value;
var Target_heartrate = 220 - age
var max = Target_heartrate * .85;

var min = Target_heartrate *.5;

document.getElementById("result").value = min + "-" + max;
return result;
}

</script>

</head>

<body>
<form name="totalheart">
 Age<input type="text" onchange="calcHeartRate()" id="age"/>
</form>
<br/>
<button type="button" onclick="calcHeartRate()">Get Heart Rate</button>
<br/>
Target Heart Rate <input type="text" id="result"/>
<br/>

</body>

</html>
@GM-Connor ;_)
sweet @GM-Connor ;)
GM-Connor
@GM-Connor
Jan 25 2016 03:47
@bharatian
There is a for loop in the code that goes through each item in the lookup and sees if the items name is equal to the firstname given. If a name is never match the for loop will raech the last item and end.
*reach
So any code after the for loop will only execute if no nmaes were matched
Bharatian
@bharatian
Jan 25 2016 03:47
yes but its not giving that output anymore. i get the loop part now, thanks
GM-Connor
@GM-Connor
Jan 25 2016 03:48
@aphextwin234 You're welcome. That should be it. It works?
@bharatian So does the code run fine?
pass the challenge?
Kevin Myrick
@aphextwin234
Jan 25 2016 03:48
Yea it gives you the min and max target heart rage.
range
brilliant
Bharatian
@bharatian
Jan 25 2016 03:49
@GM-Connor it does run fine for the loop but if i put a value that does not match for example Bob for the challenge, the output is not No such contact.
it is TypeError: contacts[i] is undefined
Kevin Myrick
@aphextwin234
Jan 25 2016 03:49
kudos @GM-Connor
GM-Connor
@GM-Connor
Jan 25 2016 03:49
@bharatian post your code again
@aphextwin234 :+1:
Bharatian
@bharatian
Jan 25 2016 03:50
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
  for (i=0; i<=contacts.length; i++)
  {
   if (firstName==contacts[i].firstName)
   {
     if (contacts[i].hasOwnProperty(prop))
       {
         return contacts[i][prop];
        }
      return "No such property";
   }
  }

 return "No such contact";



// Only change code above this line
}

// Change these values to test your function
lookUp("bob", "last");
GM-Connor
@GM-Connor
Jan 25 2016 03:50
take out the <= and replace with <
Kevin Myrick
@aphextwin234
Jan 25 2016 03:50
@GM-Connor this next one has a prime number program with a nested if statement and some looping conditional statements
oyyy
GM-Connor
@GM-Connor
Jan 25 2016 03:50
@aphextwin234 haha i got to go to bed
Kevin Myrick
@aphextwin234
Jan 25 2016 03:50
Ya
I am gonna crash out
Thanks for all the help
Bharatian
@bharatian
Jan 25 2016 03:50
@GM-Connor dang!!!!!!
can’t believe it! thanks so much lol
Kevin Myrick
@aphextwin234
Jan 25 2016 03:50
@GM-Connor um maybe send me an email let me know your allocated openings!
Learned alot today!
Bharatian
@bharatian
Jan 25 2016 03:51
@aphextwin234 - you are not aphextwin just saying.
happy coding.
John Soukas
@redsoukas
Jan 25 2016 03:51
hello i am stuck in challenge "Stand in Line" in javascript, here is my code, it returns the correct values for the tests but it keeps displaying the red X , can anyone spot a problem?
function queue(arr, item) {
  // Your code here
  arr.push(item);

  return arr.splice(0,1);  // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
GM-Connor
@GM-Connor
Jan 25 2016 03:51
@aphextwin234 Anytime, lol
jpg8127
@jpg8127
Jan 25 2016 03:52
@redsoukas remove the 0,1 from splice
Bharatian
@bharatian
Jan 25 2016 03:52
@GM-Connor - thank you so much!!! I am taking it all in that i passed this challenge.
CamperBot
@camperbot
Jan 25 2016 03:52
bharatian sends brownie points to @gm-connor :sparkles: :thumbsup: :sparkles:
:warning: bharatian already gave gm-connor points
jpg8127
@jpg8127
Jan 25 2016 03:52
@redsoukas oh wiat.. use shift
Kevin Myrick
@aphextwin234
Jan 25 2016 03:53
@bharatian obvi
lol
Alwan Mortada
@TheeGrassHopper
Jan 25 2016 03:53
Can AnyOne help me, add 5 more numbers to my array using a loop
var genericNumberArray = [1, 2, 3, 4, 5]; for(var i = 6; i <= 10 ; i++ ){ genericNumberArray.push([i]); }
GM-Connor
@GM-Connor
Jan 25 2016 03:53
@bharatian Yeah, when you get erros, try to make sense of them. I was able to figure out what problem was just at the sight of TypeError: contacts[i] is undefined. That means there is a case in your for loop when i refers to an index not in the array
John Soukas
@redsoukas
Jan 25 2016 03:53
@jpg8127 use shift? what do you mean exactly?
jpg8127
@jpg8127
Jan 25 2016 03:53
@redsoukas shift will remove the first element and for you to return which is what you want to do
John Soukas
@redsoukas
Jan 25 2016 03:54
but splice(0,1) does the exact same thing
jpg8127
@jpg8127
Jan 25 2016 03:54
@redsoukas return arr.shift(); instead of return arr.splice(0,1);
Bharatian
@bharatian
Jan 25 2016 03:54
@GM-Connor i am so new to this language stuff
learning by making mistakes is not bad
GM-Connor
@GM-Connor
Jan 25 2016 03:54
nope, you will get used to the sytax and formatting etc
John Soukas
@redsoukas
Jan 25 2016 03:54
@jpg8127 you answer worked , but still i dont get it why it wont accept splice(0,1) since it does the same thing
jpg8127
@jpg8127
Jan 25 2016 03:54
@redsoukas it does not work when you try to run it though lol I believe they should do the same thing but it wont be right
@redsoukas I do not know either..
GM-Connor
@GM-Connor
Jan 25 2016 03:55
I still need to get out of this bootstrap stuff here
John Soukas
@redsoukas
Jan 25 2016 03:55
@jpg8127 thanks anyway!
CamperBot
@camperbot
Jan 25 2016 03:55
redsoukas sends brownie points to @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 261 | @jpg8127 | http://www.freecodecamp.com/jpg8127
GM-Connor
@GM-Connor
Jan 25 2016 03:55
Annnnnyyyywayyy, I'm going to bed> L8r all!
Alwan Mortada
@TheeGrassHopper
Jan 25 2016 03:56
var genericNumberArray = [1, 2, 3, 4, 5]; for(var i = 6; i <= 10 ; i++ ){ genericNumberArray.push([i]); }
Can AnyOne help me, add 5 more numbers to my array using a loop
jpg8127
@jpg8127
Jan 25 2016 03:56
@TheeGrassHopper what lesson is that?
Chris Moore
@dooglus
Jan 25 2016 03:56
@TheeGrassHopper push individual elements, not arrays
@TheeGrassHopper .push(2), not .push([2])
jpg8127
@jpg8127
Jan 25 2016 03:56
@TheeGrassHopper i think you have to remove the brackets
Bharatian
@bharatian
Jan 25 2016 03:57
Good night @GM-Connor
Alwan Mortada
@TheeGrassHopper
Jan 25 2016 03:57
Fantastic
Kevin Myrick
@aphextwin234
Jan 25 2016 03:57
@GM-Connor will you be around tomorrow?
Alwan Mortada
@TheeGrassHopper
Jan 25 2016 03:57
Thank you guys
Kevin Myrick
@aphextwin234
Jan 25 2016 03:57
@bharatian @GM-Connor night peeps
Chris Moore
@dooglus
Jan 25 2016 03:58
no problem
Alwan Mortada
@TheeGrassHopper
Jan 25 2016 03:58
@jpg8127 Its this right here https://github.com/devleague/array-methods
@dooglus thank you dooglus
CamperBot
@camperbot
Jan 25 2016 03:58
theegrasshopper sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 344 | @dooglus | http://www.freecodecamp.com/dooglus
Kevin Myrick
@aphextwin234
Jan 25 2016 03:59
p
e
a
c
e
@GM-Connor
Thanks for everything!
Srikar Samudrala
@srikarsams
Jan 25 2016 04:00
what's the problem with this code?
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr(i).length; j++){
      product = product * arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}
jpg8127
@jpg8127
Jan 25 2016 04:01
@srikarsams lesson name?
jpg8127
@jpg8127
Jan 25 2016 04:07
@srikarsams j < arr(i).length
Chris Moore
@dooglus
Jan 25 2016 04:08
@srikarsams use [] to access array elements, not ()
Eric McKinney
@mckinney99
Jan 25 2016 04:14
#174 Global scope and functions. I don't see what I'm doing wrong here. Says: "oopsGlobal should have a value of 5"
jpg8127
@jpg8127
Jan 25 2016 04:15
@mckinney99 paste your code
Elliott-69
@Elliott-69
Jan 25 2016 04:15
how do I link the waypoint I am working on?
jpg8127
@jpg8127
Jan 25 2016 04:16
you could say the name its easy to find
Renee Matthews
@rym465
Jan 25 2016 04:16
HELP! Im having problems with the local variable exercise. I think there's something amiss... Here's my code
CamperBot
@camperbot
Jan 25 2016 04:16
no wiki entry for: im having problems with the local variable exercise i think theres something amiss heres my code
Renee Matthews
@rym465
Jan 25 2016 04:16

function myFunction() {
'use strict';
var myVar = "Renee";

console.log(myVar);
}
myFunction();

// run and check the console
// myVar is not defined outside of myFunction
console.log(myVar);

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

Chris Moore
@dooglus
Jan 25 2016 04:16
@Elliott-69 you can paste its URL, but omit all the solution=... noise
Renee Matthews
@rym465
Jan 25 2016 04:16
It's telling me that myVar is not defined. But it is, and it's a local variable...
WHAT am I doing wrong???
rphares
@rphares
Jan 25 2016 04:17
@rym465 , have you removed the last console.log, like the comments say?
(hi, @dooglus ! :) )
Eric McKinney
@mckinney99
Jan 25 2016 04:17

// Declare your variable here
var myGlobal = 10;

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

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

how to paste code so it looks good?
rphares
@rphares
Jan 25 2016 04:17
explain format
CamperBot
@camperbot
Jan 25 2016 04:17

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Eric McKinney
@mckinney99
Jan 25 2016 04:17
Thank youuuu
rphares
@rphares
Jan 25 2016 04:18
@mckinney99 :point_up: or 'copy as pretty code' :)
anytime~
Elliott-69
@Elliott-69
Jan 25 2016 04:19
fair enough, I'm working on 'Using objects for Lookups'
and to be honest I don't know where to start or continue
http://www.freecodecamp.com/challenges/using-objects-for-lookups
 var lookup = {
    'alpha':'Adams',
    'bravo':'Boston',
    'charlie':'Chicago',
    'delta':'Denver',
    'echo':'Easy',
    'foxtrot':'Frank'
  };
is as much as I've gotten
rphares
@rphares
Jan 25 2016 04:19
hi, @Elliott-69 , thats a good start!
Renee Matthews
@rym465
Jan 25 2016 04:19
@mckinney99 - the instruction is to declare a local variable inside myFunction so I put it inside myFunction and it didnt work.
rphares
@rphares
Jan 25 2016 04:19
you have a few things left to do...
nf15
@nf15
Jan 25 2016 04:19
@rym465 cancel console.log(myVar); per the instruction
Renee Matthews
@rym465
Jan 25 2016 04:19
I tried that and it's still not working
Elliott-69
@Elliott-69
Jan 25 2016 04:20
I'm just lost as to what they are, I know I have to connect to val and result, but not how
rphares
@rphares
Jan 25 2016 04:20
now you are probably getting an error, right @rym465 ?
refresh the page and run tests again :)
good--
Eric McKinney
@mckinney99
Jan 25 2016 04:20

'<// Declare your variable here
var myGlobal = 10;

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

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

rphares
@rphares
Jan 25 2016 04:20
okay, @Elliott-69 , we need to make our lookup
check out the example, its alpha[2], right @Elliott-69 ?
Jorden Kreps
@jakereps
Jan 25 2016 04:20
Make Unique Objects by Passing Parameters to our Constructor
Elliott-69
@Elliott-69
Jan 25 2016 04:21
right @rphares
rphares
@rphares
Jan 25 2016 04:21
so, alpha is the name of their table-- what is your var name? @Elliott-69
Dante Kelly
@dantekelly
Jan 25 2016 04:21
var count = 0;

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

  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count += 1;
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count -= 1;
      break;
  }

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

  return count;
  // 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');
How do I make count global?
Jorden Kreps
@jakereps
Jan 25 2016 04:21
Whoops, meant to say I'm receiving "TypeError: Attempted to assign to readonly property" for the Make Unique Objects by Passing Parameters to our Constructor challenge.
Elliott-69
@Elliott-69
Jan 25 2016 04:22
I suppose I made it lookup
rphares
@rphares
Jan 25 2016 04:22
yep :) then-- they are looking for 2, what are you looking for, @Elliott-69 ?
jpg8127
@jpg8127
Jan 25 2016 04:22
@dantekelly count is already global I think....
Elliott-69
@Elliott-69
Jan 25 2016 04:23
I am looking for val I think
rphares
@rphares
Jan 25 2016 04:23
yep-- so that would go in the [], so now, we just need to figure out how to return it,
Dante Kelly
@dantekelly
Jan 25 2016 04:23
@jpg8127 It's not being edited by function cc
Jorden Kreps
@jakereps
Jan 25 2016 04:23
Any idea why this isn't working in Chrome, Firefox, or Safari?
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};

//Try it out here
var myCar = Car(6, 3, 1);
Chris Moore
@dooglus
Jan 25 2016 04:23
@dantekelly your count is global. where you're going wrong is contaminating your count number by appending strings to it
jpg8127
@jpg8127
Jan 25 2016 04:24
@dantekelly you are trying to make count a string when you just need to return a string with count
rphares
@rphares
Jan 25 2016 04:24
at the moment, you are returning... i think it was result, right? @Elliott-69 . But, that is just a " " atm
Chris Moore
@dooglus
Jan 25 2016 04:24
@dantekelly you can return "string" + count without changing count itself
Dante Kelly
@dantekelly
Jan 25 2016 04:24
OHHHHH, Thankyou!
rphares
@rphares
Jan 25 2016 04:24
so, we need to assign our lookup to what we want to return (i think it was called result been awhile)? @Elliott-69
Elliott-69
@Elliott-69
Jan 25 2016 04:25
@rphares ok I'm with you so far..
Chris Moore
@dooglus
Jan 25 2016 04:25
@dantekelly see what I mean? you want count to always just be a number, so you can add or subtract 1 from it when you see the next card
rphares
@rphares
Jan 25 2016 04:25
okay-- i think you may be okay, try running tests, and if they fail, paste what we have just gone through so i can see what we forgot , please :blush: @Elliott-69
Chris Crook
@chrisisacrook
Jan 25 2016 04:26
question on Nesting For Loops. I am getting a type error: Cannot read property 'length' of undefined. Can anyone see what's causing my problem?
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (i = 0; i < multiplyAll.length; i++){
    for (j = 0; j < multiplyAll[i].length; j++){
     product *= multiplyAll[i][j];
   }
 }

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
rphares
@rphares
Jan 25 2016 04:26
@mckinney99 , did you solve it already? If not,... why do you have two function fun1() {?
Chris Moore
@dooglus
Jan 25 2016 04:26
@jakereps you need to use new to make a new car
Dante Kelly
@dantekelly
Jan 25 2016 04:27
@dooglus, I understand and I took out the bit of code that turns it into a string but I am confused onto why variable count is not highlighted in function and count returns as 0.
Elliott-69
@Elliott-69
Jan 25 2016 04:27
well, where I'm stuck so far is lookup[val] is giving me an error
jpg8127
@jpg8127
Jan 25 2016 04:27
@chrisisacrook you need to use the arr parameter not the function name
Chris Moore
@dooglus
Jan 25 2016 04:27
@chrisisacrook multiplyAll is the name of the function. it doesn't have a .length. it is arr which has the length...
rphares
@rphares
Jan 25 2016 04:28
@Elliott-69 -- it shouldn't be if you assigned it to result, could you please paste what you are trying now? :)
Chris Moore
@dooglus
Jan 25 2016 04:28
@dantekelly what do you mean, 'not highlighted'?
Jorden Kreps
@jakereps
Jan 25 2016 04:28
@dooglus Wow, duh... Thank you! Used to Swift and Python where that isn't needed.
CamperBot
@camperbot
Jan 25 2016 04:28
jakereps sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 345 | @dooglus | http://www.freecodecamp.com/dooglus
Chris Crook
@chrisisacrook
Jan 25 2016 04:28
well shoot. thanks @dooglus @jpg8127 I have been staring at it so long I am missing the obvious
CamperBot
@camperbot
Jan 25 2016 04:28
chrisisacrook sends brownie points to @dooglus and @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 346 | @dooglus | http://www.freecodecamp.com/dooglus
:star: 263 | @jpg8127 | http://www.freecodecamp.com/jpg8127
jpg8127
@jpg8127
Jan 25 2016 04:28
lol
Elliott-69
@Elliott-69
Jan 25 2016 04:29
@rphares
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'
  };

    lookup[val];






  // Only change code above this line
  return result;
}
Chris Moore
@dooglus
Jan 25 2016 04:29
@dantekelly maybe re-paste your current code after you changed it
Dante Kelly
@dantekelly
Jan 25 2016 04:29
@dooglus, nevermind I passed the challenge. The problem I was having is actually supposed to be like that.
rphares
@rphares
Jan 25 2016 04:29
ah-- okay, to assign the lookup, we need to use our = @Elliott-69 ,
we want result = our nice lookup[val] that we just built,
Chris Moore
@dooglus
Jan 25 2016 04:30
@Elliott-69 you need to set result to the thing you want to return, because that last line is doing return result...
rphares
@rphares
Jan 25 2016 04:30
so that when we return result, we have what we need
Renee Matthews
@rym465
Jan 25 2016 04:30
So... the solution for #176 was that I declared my variable before the line that said 'use strict'. And it worked... <still scratching my head, but thanks guys!>
Chris Moore
@dooglus
Jan 25 2016 04:30
I gotta go for a few minutes. Sorry to walk out on you all.
rphares
@rphares
Jan 25 2016 04:30
have a good one, @dooglus !
@rym465 , for which one?
Elliott-69
@Elliott-69
Jan 25 2016 04:31
Bullseye! Thank you (once again) @rphares !!
CamperBot
@camperbot
Jan 25 2016 04:31
elliott-69 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1960 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 25 2016 04:31
(the numbers are your points, not the challenge number, @rym465 :) )
anytime!
Elliott-69
@Elliott-69
Jan 25 2016 04:32
:smile:
Chris Moore
@dooglus
Jan 25 2016 04:48
I'm back. Does anyone still need help?
nf15
@nf15
Jan 25 2016 04:51
where am wrong, falks?
rphares
@rphares
Jan 25 2016 04:53
on what, @nf15 ?
nf15
@nf15
Jan 25 2016 04:57
@r4phares will post
@rphares
rphares
@rphares
Jan 25 2016 04:57
k :)
nf15
@nf15
Jan 25 2016 04:58
yes, locked me couldnt post:)
am working on Counting Cards
@rphares here is my work

switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
return "5 Bet";

case 7:
case 8:
case 9:
  return "0 Hold";
case 10:
case "J":
case "Q":
case "K":
case "A":
  return "-5 Hold";  
case 3:
case 2:
case A:
case 10:
case K:
  return "-1 Hold";
  break;

}

rphares
@rphares
Jan 25 2016 05:00
ooooh, you did it the switch way,
paging @dooglus , would you like to field this one? :)
nf15
@nf15
Jan 25 2016 05:01
oops, here comes part of my work:)
rphares
@rphares
Jan 25 2016 05:01
lol
nf15
@nf15
Jan 25 2016 05:01
where is my mistak?
rphares
@rphares
Jan 25 2016 05:02
i can see it well enough... but i used 'ifs', I've only used switch in the required 'switch' lessons, I'm not great at deciphering them, but i presume the same logic would semi-apply,
you want to increment the var count,
jpg8127
@jpg8127
Jan 25 2016 05:02
@nf15 I think the problem is you are not using count
rphares
@rphares
Jan 25 2016 05:02
right now, you are returning every case, not using count
jpg8127
@jpg8127
Jan 25 2016 05:04
@nf15 instead of returns you should have count changing in your swift, you also need breaks
switch*
rphares
@rphares
Jan 25 2016 05:04
(phew glad someone else can talk about this one, and also glad I'm not completely off :) thanks, @jpg8127 !)
CamperBot
@camperbot
Jan 25 2016 05:04
rphares sends brownie points to @jpg8127 :sparkles: :thumbsup: :sparkles:
:star: 266 | @jpg8127 | http://www.freecodecamp.com/jpg8127
jpg8127
@jpg8127
Jan 25 2016 05:05
@nf15 and.... I am not sure where the -5 came from that should be -1 I think......
rphares
@rphares
Jan 25 2016 05:05
ditto
nf15
@nf15
Jan 25 2016 05:05
@jpg8127 I have used breaks before. where I use count. in all?
rphares @rphares sneaks out to sleep. Night, all!
jpg8127
@jpg8127
Jan 25 2016 05:06
cya
Redvibe
@Redvibe
Jan 25 2016 05:06
@yonichanowitz @michaelsmith Hi Just wondering if you could share michael's answer to the Profile Lookup problem. I don't see it in the chat.
jpg8127
@jpg8127
Jan 25 2016 05:06
@nf15 your returns should be count
nf15
@nf15
Jan 25 2016 05:06
@jpg8127 I have got all except this....Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
A
@a-d-collins
Jan 25 2016 05:07
Trying to complete "Truncate a String." The so-called 'tests' seemingly do not test the proper requirements.
jpg8127
@jpg8127
Jan 25 2016 05:07
@nf15 at the end of the switch then you do an if to return a string but in the switch you should be using the global variable count
A
@a-d-collins
Jan 25 2016 05:07
Any advice?
jpg8127
@jpg8127
Jan 25 2016 05:07
@a-d-collins paste your code
A
@a-d-collins
Jan 25 2016 05:07
function truncate(str, num) {
// Clear out that junk in your trunk
var extraCutOff = 3;
if (str.length > num) {
str = str.substr(0, num);
if (num > 3) {
str = str.substr(0,str.length - extraCutOff)+"...";
}
}
return str;
}
The test: truncate("A-", 1) should NOT return "A..." according to the rules
But that's what the test expects
The rules claim that a num = 1 should return a truncated string without the ...
Markus Kiili
@Masd925
Jan 25 2016 05:09
@a-d-collins Test is correct. You understood it wrong.
A
@a-d-collins
Jan 25 2016 05:09
ohhhh
I get it now
jpg8127
@jpg8127
Jan 25 2016 05:09
yeah that confused me also at first
I had to read that multiple times
A
@a-d-collins
Jan 25 2016 05:10
less than or equal to 3 is not added to the TRUNCATED string length...
Got it
Markus Kiili
@Masd925
Jan 25 2016 05:10
@a-d-collins It confuses most people, I think.
jpg8127
@jpg8127
Jan 25 2016 05:10
@nf15 did you get it working?
Calvoxel
@Calvoxel
Jan 25 2016 05:11
Hey everyone, I'm trying to use filter in Javascript to filter elements from oldArray that are greater than five. For some reason, the code I have does not do this. This is the code:
var Car =