These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Jan 2016
Micah Bales
@micahbales
Jan 24 2016 00:00

Quick question: In the code below, "arr" is returning "[1,3,1,3]". I want it to return "[1,1]".

Are the two "3"s remaining because executing arr.splice(i, 1) is ending the function? or what's going on?

```js
function destroyer(arr, arg1, arg2) {

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

    if (arr[i] === arg1) {
      arr.splice(i, 1);      
    } else if (arr[i] === arg2) {
      arr.splice(i, 1);  
    }

  }

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
rphares
@rphares
Jan 24 2016 00:00
because he is outside by himself, everything can access him. var that are inside functions are local :)
@kerianngannon
following so far?
Keri Gannon
@kerianngannon
Jan 24 2016 00:00
Here's what I have so far
  var myGlobal ="";
  oopsGlobal = 5;
}
rphares
@rphares
Jan 24 2016 00:01
myGlobal shloud be initialized to 10, not empty quotes :)
Keri Gannon
@kerianngannon
Jan 24 2016 00:01
I got it! Thanks @rphares
CamperBot
@camperbot
Jan 24 2016 00:01
kerianngannon sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1920 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 24 2016 00:01
anytime! :)
Vincent Yan
@envincebal
Jan 24 2016 00:01
@rphares That is what I did. My answer was: var myStr = \ \t \t \r \n; But it said it's incorrect
matthew3454
@matthew3454
Jan 24 2016 00:01
I'm having trouble on the waypoint:
Return Early Pattern for Functions These are the instructions I have yet to complete:abTest(-2,2) should return undefined
abTest(2,-2) should return undefined.
Here is my code:
Vincent Yan
@envincebal
Jan 24 2016 00:02
whoopes I meant: var myStr = \ \t \t \r \n;
matthew3454
@matthew3454
Jan 24 2016 00:02
// Setup
function abTest(a, b) {
  // Only change code below this line
  if a or b < 0
  return "undefined";


  // 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);
rphares
@rphares
Jan 24 2016 00:02
you forgot the quotes, @envincebal :)
(also, that is why we format-- bitter will eat some characters like \ :) but i know what you meant, the main problem is that your sequence should be in between "" @envincebal )
Micah Bales
@micahbales
Jan 24 2016 00:03
Quick question: In the code below, "arr" is returning "[1,3,1,3]". I want it to return "[1,1]".
Are the two "3"s remaining because executing arr.splice(i, 1) is ending the function? or what's going on?
function destroyer(arr, arg1, arg2) {

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

    if (arr[i] === arg1) {
      arr.splice(i, 1);      
    } else if (arr[i] === arg2) {
      arr.splice(i, 1);  
    }

  }

  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Vincent Yan
@envincebal
Jan 24 2016 00:04
@rphares Ooooohh. thanks!
CamperBot
@camperbot
Jan 24 2016 00:04
envincebal sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 1921 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Jan 24 2016 00:04
Anytime~
Micah Bales
@micahbales
Jan 24 2016 00:09
If anyone can look at my last question, I'd love some help. Thanks!
matthew3454
@matthew3454
Jan 24 2016 00:10
me too
rphares
@rphares
Jan 24 2016 00:11
@micahbales , I'm sorry, I'm not good enough to help on BFs,
@matthew3454 , whats up?
Micah Bales
@micahbales
Jan 24 2016 00:11
NP, @rphares
matthew3454
@matthew3454
Jan 24 2016 00:11
This is my code:
// Setup
function abTest(a, b) {
  // Only change code below this line
  if a or b < 0
  return "undefined";


  // 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);
rphares
@rphares
Jan 24 2016 00:11
ah, okay--
two things :)
so, we need to work on the conditional
it should be in () to start,
and it should say (if a is less than zero OR if b is less than zero)
using the ||
then, we need to fix the return...
matthew3454
@matthew3454
Jan 24 2016 00:12
okay
rphares
@rphares
Jan 24 2016 00:12
undefined is a special value,
"undefined" is just a string :)
matthew3454
@matthew3454
Jan 24 2016 00:13
oaky
I did the first part
rphares
@rphares
Jan 24 2016 00:14
do you see the difference between the two undefined sentences i wrote above?
that's the key on the return-- we don't want it to give us the word "undefined"
we want it to return the value undefined....
no quotes :)
matthew3454
@matthew3454
Jan 24 2016 00:14
okay
rphares
@rphares
Jan 24 2016 00:15
hmmm, still not working? if still stuck, paste again with the updates, please :)
d wilder
@alhazen1
Jan 24 2016 00:16
@micahbales I'm not 100% but it looks like since you are looping over an array that is getting shorter over time your index may be skipping elements
matthew3454
@matthew3454
Jan 24 2016 00:16
okay it solved these instructions :abTest(-2,2) should return undefined
abTest(2,-2) should return undefined ......but it unsolved these instructions: abTest(2,2) should return a number
abTest(2,2) should return 8
abTest(2,8) should return 18
abTest(3,3) should return 12
@rphares
rphares
@rphares
Jan 24 2016 00:17
mmm-- can you re-paste the code?
matthew3454
@matthew3454
Jan 24 2016 00:17
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0 || b < 0);
  return undefined;


  // 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);
@rphares
rphares
@rphares
Jan 24 2016 00:18
what's that semicolon hanging out at the end of the conditional for ? :blush:
matthew3454
@matthew3454
Jan 24 2016 00:19
i don't know
it removes an error x
It says I need the ;
Andrew Bales
@agbales
Jan 24 2016 00:20
@matthew3454 You'll want to have {} instead of the ;
Redvibe
@Redvibe
Jan 24 2016 00:20

Hi, I can't figure out why this doesn't work for the Testing Objects for Properties task. I'm getting errors on the 'else' line.

function checkObj(checkProp) {

If (myObj.hasOwnProperty(checkProp));

{return myObj[checkProp];

} else {return "Not Found"}

}

Andrew Bales
@agbales
Jan 24 2016 00:20
(what @rphares is pointing out)
Jason
@jimillett
Jan 24 2016 00:21
hey again, I am doing the record collection challenge. I have to update, set, or delete JSON object properties and values. what am I doing wrong here?
// Setup
var collection = {
    2548: {
        album: "Slippery When Wet",
        artist: "Bon Jovi",
        tracks: [
        "Let It Rock",
        "You Give Love a Bad Name"
      ]
    },
    2468: {
        album: "1999",
        artist: "Prince",
        tracks: [
        "1999",
        "Little Red Corvette"
      ]
    },
    1245: {
        artist: "Robert Palmer",
        tracks: []
    },
    5439: {
        album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));
// Only change code below this line
function update(id, prop, value) {
    if (collection[id].prop[value] !== "" && collection[id].prop !== "tracks") {
        collection[id].prop[value] = value;
    } else if (collection[id].prop[value] !== "" && collection[id].prop === "tracks") {
        collection[id].prop.push(value);
    } else if (collection[id].prop[value] === "") {
        delete collection[id].prop;
    }
    return collection;
}
rphares
@rphares
Jan 24 2016 00:21
@agbales -- thank you for stepping in... tired and getting unclear :)
CamperBot
@camperbot
Jan 24 2016 00:21
rphares sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 306 | @agbales | http://www.freecodecamp.com/agbales
matthew3454
@matthew3454
Jan 24 2016 00:21
You saved the day again @rphares . Thanks
CamperBot
@camperbot
Jan 24 2016 00:21
matthew3454 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:warning: matthew3454 already gave rphares points
rphares
@rphares
Jan 24 2016 00:21
time for me to grab some food and coffee-!
Jason
@jimillett
Jan 24 2016 00:21

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object.

rphares
@rphares
Jan 24 2016 00:21
Anytime-- @agbales said it clearly :)
cheers~
Andrew Bales
@agbales
Jan 24 2016 00:22
@Redvibe Looks like a similar issue to @matthew3454 -- you have a semicolon where you're wanting {
@Redvibe look after the if statement opening
@rphares Power up :+1:
Ken Haduch
@khaduch
Jan 24 2016 00:25
@jimillett - Hi Jason - one thing that you are doing wrong (as you said) is trying to use the function arguments such as prop directly to access the elements of the objects. That will not work.
Redvibe
@Redvibe
Jan 24 2016 00:26
@agbales when I take out the semi I get an error.. and I have the { on next line - in front of the return line.
Jason
@jimillett
Jan 24 2016 00:26
ok, so how do I do that then?
@khaduch
Andrew Bales
@agbales
Jan 24 2016 00:27
@Redvibe you don't want that first ; after the if, but you DO want one after your return "Not Found"
@jimillett If you want to access a value, you have to call that property. You can't look up Prince, for instance, but you could look up the record 2468 artist
Jason
@jimillett
Jan 24 2016 00:31
@agbales ok... not sure I understand...ill hack around a little more
Ken Haduch
@khaduch
Jan 24 2016 00:31
it is a very basic thing, @jimillett . If you have known strings that represent properties of an object, you can refer to items in the object using "dot notation", so for the record collection objects, you can do something like collection[id].artistbecause you know that 'artist' is a property of the collection. But if you have a variable that contains the property name, as we do here, prop, you have to use array notation to do that access. So you would need collection[id][prop] to get the property.
Jason
@jimillett
Jan 24 2016 00:32
@khaduch ok so I was doing collection[id].prop
which is wrong.
Redvibe
@Redvibe
Jan 24 2016 00:32

@agbales I'm getting errors on the If and Else lines. If line says I need a semi.
function checkObj(checkProp) {

If (myObj.hasOwnProperty(checkProp))

{return myObj[checkProp];}

else {return "Not Found"};

}

Andrew Bales
@agbales
Jan 24 2016 00:32
@jimillett For your first if statement, for example, you're looking to see if the collection[id].prop[value] is blank... but really you want to know if the value passed in is blank, I believe. Something as simple as this should work:
 if (prop === "tracks" && value !== "")
Ken Haduch
@khaduch
Jan 24 2016 00:33
@jimillett - so you are on the right track with your collection[id] part of the reference, but you need to do collection[id][prop] to be correct. It might be that there are other things that aren't right but please start with that change. The Javascript console is helpful to get the right things in place, too.
Jason
@jimillett
Jan 24 2016 00:33
@agbales I think you're right
Rory Smith
@alanbuchanan
Jan 24 2016 00:33
@Redvibe that should be if not If
Andrew Bales
@agbales
Jan 24 2016 00:33
@alanbuchanan Good eye!
Redvibe
@Redvibe
Jan 24 2016 00:36
@alanbuchanan @agbales omg thank you! that solved both probs. Why does the cap matter? I keep doing that! Also why on the function line do we not say myObj in front of checkprop - like this - function checkObj(myObj.checkProp)?
Rory Smith
@alanbuchanan
Jan 24 2016 00:37
@Redvibe javascript is case sensitive
Andrew Bales
@agbales
Jan 24 2016 00:37
@Redvibe The code is case sensitive
:)
Rory Smith
@alanbuchanan
Jan 24 2016 00:37
@Redvibe in a function you pass arguments so that you can use them within the function
Erland Lami
@Texber
Jan 24 2016 00:37
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++) {
      console.log(arr[i][j]);
    }

  }


  // Only change code above this line
  return product;
}
I'm struggling with this... these are the instructions:
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
Jason
@jimillett
Jan 24 2016 00:38
@khaduch how do I update the value? .push(value)? or += value?
Rory Smith
@alanbuchanan
Jan 24 2016 00:38
@Redvibe
function myFunction(myArgument){
   // do stuff with myArgument here
}
Redvibe
@Redvibe
Jan 24 2016 00:38
@alanbuchanan but how does it know I'm passing the argument to myObj?
Andrew Bales
@agbales
Jan 24 2016 00:38
@jimillett .push(value)
Jason
@jimillett
Jan 24 2016 00:39
@agbales ok
Redvibe
@Redvibe
Jan 24 2016 00:39
@Redvibe couldn't I have that same name in another parent?
Rory Smith
@alanbuchanan
Jan 24 2016 00:39
@Redvibe first you declare the function, that's not the same as calling the function
Erland Lami
@Texber
Jan 24 2016 00:39
Someone please help
Ken Haduch
@khaduch
Jan 24 2016 00:40

@jimillett

For an array, you want to .push(value).

oops, it quoted the wrong thing.
Brendan Kinahan
@BKinahan
Jan 24 2016 00:40
@Texber console.log() will just print out the current value
Rory Smith
@alanbuchanan
Jan 24 2016 00:40
function addTwoNums(a, b){
   // a and b could be called anything
   return a + b;
}
addTwoNums(20, 30); //50
@Redvibe just an example
matthew3454
@matthew3454
Jan 24 2016 00:41
I can't complete the counting cards lesson. Can someone help?
Jason
@jimillett
Jan 24 2016 00:41
@khaduch so the JSON objects are like arrays?
Brendan Kinahan
@BKinahan
Jan 24 2016 00:41
@Texber think what you can do with product that will make it equal to each value multiplied together after all the loop is complete
Erland Lami
@Texber
Jan 24 2016 00:44
I see.. I will try @BKinahan thanks
CamperBot
@camperbot
Jan 24 2016 00:44
texber sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 719 | @bkinahan | http://www.freecodecamp.com/bkinahan
matthew3454
@matthew3454
Jan 24 2016 00:47
var count = 0;

function cc(card) {
  // Only change code below this line
  case 2: answer = "5 Bet"
  case 3: answer = "5 Bet"
  case 4: answer = "5 Bet"
  case 5: answer = "5 Bet"
  case 6: answer = "5 Bet"
  break;
  case 7: answer = "0 Hold"
  case 8: answer = "0 Hold"
  case 9: answer = "0 Hold"
  break;
  case 10:
  case J: answer = "-5 Hold"
  case Q: answer = "-5 Hold"
  case K: answer = "-5 Hold"
  case A: answer = "-5 Hold"
  return "Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
That's what I have so far....
Redvibe
@Redvibe
Jan 24 2016 00:48
@alanbuchanan ya I understand that but confused about this whole problem actually. there is no "checkProp" category in the var given at the top - just gift, pet and bed. I guess I don't understand where the word checkProp comes from. It doesn't appear in the problem so, I'm guessing the result would be "Not Found"?
Andrew Bales
@agbales
Jan 24 2016 00:49
@matthew3454 You could do a switch, (breaking for each case). An if/else if/ else might be a simpler solution?
Jason
@jimillett
Jan 24 2016 00:49
@khaduch @alanbuchanan Im still getting errors? and the if and first else if are doing the same thing? not sure if I am supposed to do something different there.
function update(id, prop, value) {
    if (value !== "" && prop !== "tracks") {
        collection[id][prop].push(value);
    } else if (value !== "" && prop === "tracks") {
        collection[id][prop].push(value);
    } else if value === "") {
        delete collection[id][prop];
    }
   console.log(collection);
  return collection;
}
update(5439, "artist", "ABBA");
Bashir
@bashiros
Jan 24 2016 00:49
Hi campers, can anyone give me any pointer in how to solve the Find the longest word in a string challange? after spliting the string in to an array I dont think sort world work to order the array from smallest to largest word.
CamperBot
@camperbot
Jan 24 2016 00:49

welcome to FreeCodeCamp @bashiros!

matthew3454
@matthew3454
Jan 24 2016 00:50
@agbales
I put updated the code with a break after each statement
var count = 0;

function cc(card) {
  // Only change code below this line
 switch(card)
  case 2: answer = "5 Bet";
  case 3: answer = "5 Bet";
  case 4: answer = "5 Bet";
  case 5: answer = "5 Bet";
  case 6: answer = "5 Bet";
  break;
  case 7: answer = "0 Hold";
  case 8: answer = "0 Hold";
  case 9: answer = "0 Hold";
  break;
  case 10:
  case J: answer = "-5 Hold";
  case Q: answer = "-5 Hold";
  case K: answer = "-5 Hold";
  case A: answer = "-5 Hold";
      break;

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Rory Smith
@alanbuchanan
Jan 24 2016 00:51
@Redvibe that was my point with the example. the names of the values you pass into a function aren't relevant - they could be called whatever you want. as long as you refer to them the same within the function
@Redvibe so in this case checkProp represents whatever value you pass into the function
Adam
@Blakemilton6
Jan 24 2016 00:52
Hi guys I'm on the wordblank madlibs challenge what does this direction mean wordBlanks:("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Andrew Bales
@agbales
Jan 24 2016 00:52
@matthew3454 Still seeing the break after a series of cases. I was thinking more like this:
switch(expression) {
    case n:
        code block
        break;
    case n:
        code block
        break;
    default:
        default code block
}
Adam
@Blakemilton6
Jan 24 2016 00:52
Where is it entered?
matthew3454
@matthew3454
Jan 24 2016 00:52
@agbales okay I'll implement that information
Adam
@Blakemilton6
Jan 24 2016 00:53
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).
Redvibe
@Redvibe
Jan 24 2016 00:53
@alanbuchanan you deserve some marshmellows for patience with me! so, really we would be inputting a value somewhere? That's what that line checkObj("gift"); is about? I think I get it now.
Andrew Bales
@agbales
Jan 24 2016 00:54
@Blakemilton6 I think that question is asking you to set up your own sentence. You'll pick out words that are combined with the passed words to form a new sentence. "Hey there," + var + ...
Rory Smith
@alanbuchanan
Jan 24 2016 00:54
@Redvibe yeah, if you passed in 'gift', the value of checkProp is 'gift' within checkObj
Redvibe
@Redvibe
Jan 24 2016 00:55
@alanbuchanan :smile:
matthew3454
@matthew3454
Jan 24 2016 00:56
var count = 0;

function cc(card) {
  // Only change code below this line
 switch(card)
  case 2: answer = "5 Bet";
      break;
  case 3: answer = "5 Bet";
      break;
  case 4: answer = "5 Bet";
      break;
  case 5: answer = "5 Bet";
      break;
  case 6: answer = "5 Bet";
  break;
  case 7: answer = "0 Hold";
      break;
  case 8: answer = "0 Hold";
      break;
  case 9: answer = "0 Hold";
  break;
  case 10: answer = "-5 Hold";
      break;
  case J: answer = "-5 Hold";
      break;
  case Q: answer = "-5 Hold";
      break;
  case K: answer = "-5 Hold";
      break;
  case A: answer = "-5 Hold";
      break;

    default:
      default ="Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
\ @agbales how does this look?
Rory Smith
@alanbuchanan
Jan 24 2016 00:58
@jimillett in the first if you have to 'update or set the value for the prop' which isn't what your code is doing
Adam
@Blakemilton6
Jan 24 2016 00:58
@agbales so how would that sequence end with a semicolon?
Andrew Bales
@agbales
Jan 24 2016 00:59
@matthew3454 Remember, you'll be getting 5 cards. Not just 1. " You will receive a card parameter and increment or decrement the global count variable according to the card's value (see table)."
John Barbagallo
@john-barbagallo
Jan 24 2016 00:59
Hey ya'll, need help with "Using objects for lookups" .. Could someone take some time to explain my error?
// 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"
  };
val = lookup;



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

// Change this value to test
phoneticLookup("charlie");
Rory Smith
@alanbuchanan
Jan 24 2016 01:00
@john-barbagallo you should change the value of result to be the val item of lookup
John Barbagallo
@john-barbagallo
Jan 24 2016 01:00
@alanbuchanan one sec, I'll try it
Andrew Bales
@agbales
Jan 24 2016 01:01
@Blakemilton6 I'm not sure I get what you're asking... but the end of strings and variables would end with a semicolon.
return "My sentence " + myAdjective + "more words " + ..... ;
Looking at this challenge, you'll be assigning it to var result rather than returning the statement. But it's the same idea.
John Barbagallo
@john-barbagallo
Jan 24 2016 01:03
@alanbuchanan I've tried changing, still noda.
matthew3454
@matthew3454
Jan 24 2016 01:03
@agbales @alanbuchanan so how do I indicate in my code that I am getting 5 cards and not just one?
Rory Smith
@alanbuchanan
Jan 24 2016 01:04
@matthew3454 you don't need to do that
@john-barbagallo what did you try?
matthew3454
@matthew3454
Jan 24 2016 01:05
@alanbuchanan I did it but apparently I did not fully comprehend it.
Andrew Bales
@agbales
Jan 24 2016 01:05
@matthew3454 You are trying to add, subtract, or not change the value of a count. It depends on the card you get.
matthew3454
@matthew3454
Jan 24 2016 01:06
@agbales How do I code in my values?
John Barbagallo
@john-barbagallo
Jan 24 2016 01:06
I've tried many different things. heres one
// 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",
  };
result = lookup;



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

// Change this value to test
phoneticLookup("charlie");
Rory Smith
@alanbuchanan
Jan 24 2016 01:06
@john-barbagallo close
Ken Haduch
@khaduch
Jan 24 2016 01:06
@jimillett I'll be back shortly
Dinner time
Rory Smith
@alanbuchanan
Jan 24 2016 01:07
@john-barbagallo at the moment, result returns the object you just made, but you want it to refer to the val value
Uglješa Ijačić
@ugitch
Jan 24 2016 01:08
Hi, guys. I am doing Profile Lookup waypoint near the end of Basic JavaScript part. I did, and it works. Just, my version with method forEach instead of for loop doesn't. Can't figure why! Here's my code for both. Thanks in advance..
//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){
  contacts.forEach(function(contact){
    if (contact.firstName == firstName)
      if (prop in contact)
        return contact[prop];
      else
        return "No such property";
  });

  return "No such contact";
}
*/

function lookUp(firstName, prop){
  for (var i = 0; i < contacts.length; i++){        
    if (contacts[i].firstName == firstName)
      if (prop in contacts[i])
        return contacts[i][prop];
      else
        return "No such property";    
  }

  return "No such contact";  
}

// Change these values to test your function
lookUp("Akira", "likes");
John Barbagallo
@john-barbagallo
Jan 24 2016 01:11
@alanbuchanan give me something more to work with
@john-barbagallo i'm trying to get it to direct to val, but ya stumped.
Andrew Bales
@agbales
Jan 24 2016 01:13
@matthew3454 Perhaps a variable? A counter?
matthew3454
@matthew3454
Jan 24 2016 01:13
@agbales What would that look like for my code?
Rory Smith
@alanbuchanan
Jan 24 2016 01:15
@john-barbagallo what did you try to get it to direct to the val property of lookup?
Chris Burros
@cburros
Jan 24 2016 01:16
so, I need help from some administrator or something. I don't need an answer. I have an infinite loop in the factoralize a number bonfire and every time I go into it I am not able to reset it because it is automatically running my code and crashing my browser.
CamperBot
@camperbot
Jan 24 2016 01:16
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
John Barbagallo
@john-barbagallo
Jan 24 2016 01:16
// 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"
  };
result = val[lookup];





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

// Change this value to test
phoneticLookup("charlie");
Rory Smith
@alanbuchanan
Jan 24 2016 01:16
@john-barbagallo real close. one part is the wrong way round
Ken Haduch
@khaduch
Jan 24 2016 01:17
@cburros - there is a way to keep it from running, I know that I saw it somewhere. Let me look at my notes...
Rory Smith
@alanbuchanan
Jan 24 2016 01:17
@john-barbagallo you want the val prop of lookup, not the lookup prop of val
Andrew Bales
@agbales
Jan 24 2016 01:18
@matthew3454 It would mean that you create a counter. Then within each case you'd update the counter.
Ken Haduch
@khaduch
Jan 24 2016 01:20

@cburros - see if this helps you - some text from a wiki post that I snagged:

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL:
run=disabled

Example:

URL: http://www.freecodecamp.com/challenges/bonfire-meet-bonfire#?solution=function%20meetBonfire(argument)

No-Run URL: http://www.freecodecamp.com/challenges/bonfire-meet-bonfire#?run=disabled&solution=function%20meetBonfire(argument)

You would just have to copy the URL and when you paste it in the browser, add that code

Brian
@sludge256
Jan 24 2016 01:20
@cburros @khaduch
wiki auto
CamperBot
@camperbot
Jan 24 2016 01:20

:point_right: disable code auto run [wiki]

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL:
run=disabled

Example:

URL: http://www.freecodecamp.com/challenges/bonfire-meet-bonfire#?solution=function%20meetBonfire(argument)

No-Run URL: http://www.freecodecamp.com/challenges/bonfire-meet-bonfire#?run=disabled&solution=function%20meetBonfire(argument)

:pencil: read more about disable code auto run on the FCC Wiki

John Barbagallo
@john-barbagallo
Jan 24 2016 01:20
@alanbuchanan ty so much.. even tho it was frustrating with the hints( as I exhausted a ton of options before I tried the chat for help) .. highly worth you hinting me and not out right with the answer ! , it passed.
Ken Haduch
@khaduch
Jan 24 2016 01:20
@sludge256 - that's where I got it from, thanks for posting the official link...
CamperBot
@camperbot
Jan 24 2016 01:21
khaduch sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 1016 | @sludge256 | http://www.freecodecamp.com/sludge256
John Barbagallo
@john-barbagallo
Jan 24 2016 01:21
@alanbuchanan thanks
CamperBot
@camperbot
Jan 24 2016 01:21
john-barbagallo sends brownie points to @alanbuchanan :sparkles: :thumbsup: :sparkles:
:star: 745 | @alanbuchanan | http://www.freecodecamp.com/alanbuchanan
Rory Smith
@alanbuchanan
Jan 24 2016 01:21
@john-barbagallo :thumbsup:
Ken Haduch
@khaduch
Jan 24 2016 01:25
help search chat
CamperBot
@camperbot
Jan 24 2016 01:25
no wiki entry for: search chat
Ken Haduch
@khaduch
Jan 24 2016 01:25
help search
CamperBot
@camperbot
Jan 24 2016 01:25

:point_right: bonfire search and replace [wiki]

Problem Explanation:

  • You will create a program that takes a sentence, then search for a word in it and replaces it for a new one while preserving the uppercase if there is one.
:pencil: read more about bonfire search and replace on the FCC Wiki
Chris Moore
@dooglus
Jan 24 2016 01:25
wiki exact change
CamperBot
@camperbot
Jan 24 2016 01:25

:point_right: bonfire exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have enough cash or will have no cash after the transaction. Other than that it needs to return an array of the change in the form of an array, so that will be a 2D array.
:pencil: read more about bonfire exact change on the FCC Wiki
d wilder
@alhazen1
Jan 24 2016 01:33
@oogs Inside forEach() return (and break, continue also) don't behave as you were probably expecting. I'm not sure if you can do an early return from inside forEach()
Calvoxel
@Calvoxel
Jan 24 2016 01:37

I'm working on "Make Object Properties Private" and with the following code, myBike.getGear() should return 4 after myBike.setGear(4). Here is my code:

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

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

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

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

var Bike = function() {

  // Only change code below this line.
  var gear;
  this.setGear = function(change) {
    gear += change;
  };
  this.getGear = function() {
    return gear;
  };
};

var myCar = new Car();

var myBike = new Bike();

What am I doing wrong?

Chris Moore
@dooglus
Jan 24 2016 01:39
@Calvoxel setGear() should simply set the gear to whatever its parameter says. no addition
Mike
@mike259
Jan 24 2016 01:43
I can't find the .hasOwnProperty javascript waypoint. I swear there was one where we used that.
snow8261
@snow8261
Jan 24 2016 01:44
var myStr = '<a href="http://www.example.com" target="_blank">link</a>';
Mike
@mike259
Jan 24 2016 01:45
@HermanFassett thanks brother!
CamperBot
@camperbot
Jan 24 2016 01:45
mike259 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 1434 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
lightwavvves
@lightwavvves
Jan 24 2016 01:49
Hi All! I'm at the first javascript challenge - called Word Blanks - and I'm really not sure what to do. Could someone give me a hand?
Ken Haduch
@khaduch
Jan 24 2016 01:50
@mike259 - this might be it - the title doesn't say 'hasOwnProperty' - http://www.freecodecamp.com/challenges/testing-objects-for-properties
Herman Fassett
@HermanFassett
Jan 24 2016 01:51
@lightwavvves ever played mad libs? That's basically what it is, make up your own string that uses concatenation to include the variables passed in as arguments (if I remember right).
Ken Haduch
@khaduch
Jan 24 2016 01:51
oops - I see we collided...
fcastillo18
@fcastillo18
Jan 24 2016 01:51
Hi everyone
can somebody tell how to solve problem:
Ken Haduch
@khaduch
Jan 24 2016 01:52
@fcastillo18 - hi there! Just starting with FreeCodeCamp?
fcastillo18
@fcastillo18
Jan 24 2016 01:52
Instructions
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Devon Brown
@Token95
Jan 24 2016 01:52
var processed =2;
function process(num) {return (num+0)/1;}
processed=process(2):
Herman Fassett
@HermanFassett
Jan 24 2016 01:52
@fcastillo18 what have you tried?
lightwavvves
@lightwavvves
Jan 24 2016 01:52
Never mind. I got it. Thanks anyway haha
Ken Haduch
@khaduch
Jan 24 2016 01:52
@fcastillo18 - which lesson is that?
Devon Brown
@Token95
Jan 24 2016 01:52
i dont know what i done wrong
Uglješa Ijačić
@ugitch
Jan 24 2016 01:52
@alhazen1 Hey, thanks! I'll try workaround, and let you know
CamperBot
@camperbot
Jan 24 2016 01:52
oogs sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 293 | @alhazen1 | http://www.freecodecamp.com/alhazen1
lightwavvves
@lightwavvves
Jan 24 2016 01:53
Just didn't get the "mad libs" reference..
Ken Haduch
@khaduch
Jan 24 2016 01:54

@virginiecam

@khaduch ohhh ok th ank you a lot I understand the general idea now :) :) gonna try to figure things out now :)

How are things going with the record collection?

Herman Fassett
@HermanFassett
Jan 24 2016 01:55
@Token95 you should probably reset your code, looks like you changed the function itself. You should only be calling the function with an input value that will return 2
fcastillo18
@fcastillo18
Jan 24 2016 01:55
@khaduch well I started once and stop. Now Im rolling again
Ken Haduch
@khaduch
Jan 24 2016 01:56
@fcastillo18 - welcome back!
fcastillo18
@fcastillo18
Jan 24 2016 01:56
@HermanFassett var myStr = '\ \t \t \r \n ' this one more
thanks
Devon Brown
@Token95
Jan 24 2016 01:56
@HermanFassett thank you
CamperBot
@camperbot
Jan 24 2016 01:56
token95 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 1436 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
fcastillo18
@fcastillo18
Jan 24 2016 01:57
Escape Sequences in Strings - Java Script
@khaduch Escape Sequences in Strings - Java Script
Herman Fassett
@HermanFassett
Jan 24 2016 01:57
@fcastillo18 that looks good (unchanged by markup :P) but you should only have 1 space between stuff
fcastillo18
@fcastillo18
Jan 24 2016 01:58
@HermanFassett I have it, and it doesnt work :worried:
Herman Fassett
@HermanFassett
Jan 24 2016 01:58
var myStr = "\\ \t \t \r \n";
fcastillo18
@fcastillo18
Jan 24 2016 01:59
@HermanFassett I dond know how to show in this way man hehe
Herman Fassett
@HermanFassett
Jan 24 2016 01:59
help format
CamperBot
@camperbot
Jan 24 2016 01:59

: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

Tennile Edwards
@telaed
Jan 24 2016 02:01
Hey all! I am working on the first few Object Oriented Programming waypoints and I am confused as to the purpose of the object constructor functions? If I can easily create the object, why do I need the constructors?
fcastillo18
@fcastillo18
Jan 24 2016 02:02
var myStr = '\\ backslash \t tab \t tab \r carriage-return \n new-line'
@HermanFassett thanks :D
CamperBot
@camperbot
Jan 24 2016 02:02
fcastillo18 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 1437 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
fcastillo18
@fcastillo18
Jan 24 2016 02:03
@HermanFassett but I still have the problem !
Krista Handel
@meloncatty
Jan 24 2016 02:05
help testing objects
CamperBot
@camperbot
Jan 24 2016 02:05

:point_right: waypoint testing objects for properties [wiki]

Waypoint: Testing Objects for Properties

Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty([propname]) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.

Example

var myObj = {
  top: "hat",
  bottom: "pants"
};
myObj.hasOwnProperty("top");    // true
myObj.hasOwnProperty("middle");

:pencil: read more about waypoint testing objects for properties on the FCC Wiki

Alain Holly
@aholly38
Jan 24 2016 02:07

I'm having problems with challenge 'Record Collection' . I read the problem and the var for 'id' is (2548, 2468, 1245) & 'prop' is (artist) & 'value' is ( data ). I'm getting this error "TypeError: undefined is not an object (evaluating 'collection[id].prop.push') json `// 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"){

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

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

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

}

//return collection;
}

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

`

Mike
@mike259
Jan 24 2016 02:12
  if (firstName === 'Akira') {
    if (contacts[0].hasOwnProperty(prop)) {
      return contacts[0][prop];
    }else {
      return 'No such property';
    }
  }else if (firstName === 'Harry'){

    if (contacts[1].hasOwnProperty(prop)) {
      return contacts[1][prop];
    }
  }else if (firstName === 'Kristian') {

    if (contacts[3].hasOwnProperty(prop)) {
      return contacts[3][prop];
    }
  }else if (firstName === 'Sherlock') {

    if (contacts[2].hasOwnProperty(prop)) {
      return contacts[2][prop];
    }
  }else if (firstName === 'Bob') {
    return 'No such contact';

    }
this is basically cheating right?
Ken Haduch
@khaduch
Jan 24 2016 02:12

@aholly38 - you should go back and re-read the information in the challenges: http://www.freecodecamp.com/challenges/accessing-objects-properties-with-the-dot-operator, which says "The dot operator is what you use when you know the name of the property you're trying to access ahead of time." http://www.freecodecamp.com/challenges/accessing-objects-properties-with-bracket-notation, which says "The second way to access the properties of an object is bracket notation ([]). If the property of the object you are trying to access has a space in it, you will need to use bracket notation.", and http://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables. which has "Another use of bracket notation on objects is to use a variable to access a property. This can be very useful for iterating through lists of the object properties or for doing the lookup."

You are getting three variables as function arguments. One of them is prop, which is a variable, and by the information in the third challenge listed, you have to use bracket notation to access a property when you are using a variable.

Bharatian
@bharatian
Jan 24 2016 02:12
I can’t seem to understand challenge 181
Devon Brown
@Token95
Jan 24 2016 02:12
function process(num){return (num)
;} var processed= 2;
Bharatian
@bharatian
Jan 24 2016 02:12

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

return myArr; // Change this line
}

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

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

Devon Brown
@Token95
Jan 24 2016 02:13
i cant seem to assign process to processed? can some one help me out?
Bharatian
@bharatian
Jan 24 2016 02:13
yeah its just this processed = process();
just add whatever function value that needs go in process
DJ Bondoc
@DJBondoc
Jan 24 2016 02:14
help Introducing JavaScript Object Notation JSON
CamperBot
@camperbot
Jan 24 2016 02:14

:point_right: waypoint introducing javascript object notation json [wiki]

Waypoint: Introducing JavaScript Object Notation JSON

JavaScript Object Notation or JSON uses the format of JavaScript Objects to store data. JSON is flexible because it allows for Data Structures with arbitrary combinations of strings, numbers, booleans, arrays, and objects.

Here is an example of a JSON object:

var ourMusic = [
  {
    "artist": "Daft Punk",
    "title": "Homework",
    "release_year": 1997,
    "formats": [ 
      "CD", 
      "Cassette", 
      "LP" ],
    "gold": true
  }
];

:pencil: read more about waypoint introducing javascript object notation json on the FCC Wiki

Bharatian
@bharatian
Jan 24 2016 02:15

any suggestion for 181 challenge. function queue(arr, item) {
// Your code here

return myArr; // Change this line
}

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

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

Ken Haduch
@khaduch
Jan 24 2016 02:15
@bharatian - take a look at the Array operators .push() and .shift().
Bharatian
@bharatian
Jan 24 2016 02:15
right but how do i define them
i am confused
DJ Bondoc
@DJBondoc
Jan 24 2016 02:16
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
  [
    {
      "artist": "Sam Smith",
      "title": "In the Lonely Hour",
      "release_year": 2014,
      "formats": [
        "CS",
        "8T",
        "LP"]
  }
  ]
];
am i missing something?
Alain Holly
@aholly38
Jan 24 2016 02:18
@khaduch Thanks I'll re-read and review those links.
CamperBot
@camperbot
Jan 24 2016 02:18
aholly38 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 410 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jan 24 2016 02:18
@bharatian - you don't have to define them - they are part of the Array object methods. I'm willing to bet that if you google "implement queues with arrays in javascript" that you'll find some example, if you are stuck. But those two Array methods are the key.
Bharatian
@bharatian
Jan 24 2016 02:19
right
i dont understand the instructions, the game just changed!
Ken Haduch
@khaduch
Jan 24 2016 02:21
@aholly38 - I was going to add a comment, with the snippets of the text that I included from those challenges, you have to have the function argument prop in a bracket when you are using it to access the object properties. So as you have collection[id] you have to use [prop]. And if you play with this in the javascript console, you can see it work more easily than when you run the challenge tests.
help line
CamperBot
@camperbot
Jan 24 2016 02:21

:point_right: checkpoint stand in line [wiki]

Checkpoint: Stand In Line

About queues

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Instructions

Write a function queue which takes an "array" and an "item" as arguments.

Add the item onto the end of the array, then remove the first element of the array.

The queue function should return the element that was removed.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint stand in line on the FCC Wiki

Khademul Islam Mahin
@Mahin2k
Jan 24 2016 02:22
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line
what am i doing wrong?
djdrysdale
@djdrysdale
Jan 24 2016 02:22
help chunky monkey
CamperBot
@camperbot
Jan 24 2016 02:22

:point_right: bonfire chunky monkey [wiki]

Explanation

Our goal for this bonfire is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this bonfire:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the bonfire title and read the helpful links if you haven't yet.

:pencil: read more about bonfire chunky monkey on the FCC Wiki

Jamela
@Jamela08
Jan 24 2016 02:22
whats wrong with my code " return early pattern for functions" part
Ken Haduch
@khaduch
Jan 24 2016 02:23
@bharatian - if you follow that link mentioned in the help from the camperbot, https://github.com/freecodecamp/freecodecamp/wiki/checkpoint-stand-in-line, it will walk you through a couple hints and you can work on it without looking at the 'spoiler'
Jamela
@Jamela08
Jan 24 2016 02:23

function abTest(a, b) {
// Only change code below this line

if (a<0) {
return "undefined";

} else if (b<0) {
return "undefined";
}

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

Krista Handel
@meloncatty
Jan 24 2016 02:23
help testing objects
CamperBot
@camperbot
Jan 24 2016 02:23

:point_right: waypoint testing objects for properties [wiki]

Waypoint: Testing Objects for Properties

Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty([propname]) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.

Example

var myObj = {
  top: "hat",
  bottom: "pants"
};
myObj.hasOwnProperty("top");    // true
myObj.hasOwnProperty("middle");

:pencil: read more about waypoint testing objects for properties on the FCC Wiki

Ken Haduch
@khaduch
Jan 24 2016 02:24
@Jamela08 - what are you having a problem with?
Jamela
@Jamela08
Jan 24 2016 02:25
i think my code is right but then the console says something wrong
Ken Haduch
@khaduch
Jan 24 2016 02:25
what does the console tell you?
Jamela
@Jamela08
Jan 24 2016 02:25
Im at Return warly pattern for functions
its wrong if abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
but if i will input those numbers to abTest() it outputs the undefined
in the consoe
docsoul
@docsoul
Jan 24 2016 02:26
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function myFunction() {
  x = Math.random() * 10;
  //console.log(x);
x = Math.floor(x); 
 // console.log(x);
  return x;
}

You should have multiplied the result of Math.random by 10 to make it a number that is between zero and nine.

This condition is showing up

Bharatian
@bharatian
Jan 24 2016 02:26
@khaduch thank you. I was really confused about how to use the item. and how arr and item are related. I guess I am missing on understanding something here. I did use push with arr. push(0); first but apparently after seeing the wiki, it is clear the relationship between arr and item. not sure why this was just thrown in without any exercieses before.
CamperBot
@camperbot
Jan 24 2016 02:26
bharatian sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Ken Haduch
@khaduch
Jan 24 2016 02:26
@Jamela08 - oh, I think I have an idea!
CamperBot
@camperbot
Jan 24 2016 02:26
:star: 411 | @khaduch | http://www.freecodecamp.com/khaduch
Jamela
@Jamela08
Jan 24 2016 02:27
I got it
Khademul Islam Mahin
@Mahin2k
Jan 24 2016 02:27
can someone help?
Jamela
@Jamela08
Jan 24 2016 02:27
i deleted the "" after return
Thanks
Mike
@mike259
Jan 24 2016 02:28
  if (firstName === 'Akira') {
    if (contacts[0].hasOwnProperty(prop)) {
      return contacts[0][prop];
    }else {
      return 'No such property';
    }
  }else if (firstName === 'Harry'){

    if (contacts[1].hasOwnProperty(prop)) {
      return contacts[1][prop];
    }
  }else if (firstName === 'Kristian') {

    if (contacts[3].hasOwnProperty(prop)) {
      return contacts[3][prop];
    }
  }else if (firstName === 'Sherlock') {

    if (contacts[2].hasOwnProperty(prop)) {
      return contacts[2][prop];
    }
  }else if (firstName === 'Bob') {
    return 'No such contact';

    }
should I move on or redo this? I'm confused on how to make it dynamic
docsoul
@docsoul
Jan 24 2016 02:29
The third condition is showing up
Bharatian
@bharatian
Jan 24 2016 02:30
@khaduch - so we don’t have to declare the nature of arr and item at all. i am not sure how this worked.
Ken Haduch
@khaduch
Jan 24 2016 02:30
@Jamela08
if you walk through your code, you can probably see what is happening. You are returning the string "undefined", but it really wants the value undefined, which is basically what would happen if you just did this statement: return;
Billy
@billywaite
Jan 24 2016 02:30
@mike259 which waypoint is this?
Mike
@mike259
Jan 24 2016 02:30
@billywaite profile lookup
Ken Haduch
@khaduch
Jan 24 2016 02:31

@bharatian

@khaduch - so we don’t have to declare the nature of arr and item at all. i am not sure how this worked.

You are being passed an array in the first argument, so you just work with that as the array that you are using the .push() and .shift() methods on.

Bharatian
@bharatian
Jan 24 2016 02:31
@khaduch i do understand that
Ken Haduch
@khaduch
Jan 24 2016 02:33
@bharatian - maybe I missed the point of your question? Or what you are not sure if?
Khademul Islam Mahin
@Mahin2k
Jan 24 2016 02:33
can someone help???
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.list[1]; // Change this line
what am i doing wrong?
Bharatian
@bharatian
Jan 24 2016 02:33
what i dont understand is the first line of when the array is being passed.
because queue is a function
i am super unclear still
Ken Haduch
@khaduch
Jan 24 2016 02:34
@bharatian - could you show me in your code?
Bharatian
@bharatian
Jan 24 2016 02:35

its the same as the solution in the wiki function queue(arr, item) {
// Your code here
arr.push(item);
var removed = arr.shift();

return removed; // Change this line
}

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

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

Alex Rose
@thelyricalrose
Jan 24 2016 02:35
@Mahin2k what is the name of that specific challenge again?
Bharatian
@bharatian
Jan 24 2016 02:36
i am confused about this is working…as far as within the function is concerned.
i get the code.
Liz Emery
@lizardbrains
Jan 24 2016 02:36
Hi all. I'm trying to figure out the Escape Sequence in Strings problem and I can't figure out what they're asking me to do. Can someone please help me?
"Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr"
Khademul Islam Mahin
@Mahin2k
Jan 24 2016 02:37
@thelyricalrose accessing nestes arrays in JSON
Ken Haduch
@khaduch
Jan 24 2016 02:37
@bharatian - ok. You said that queue is a function, and that it is. In the test code, you are calling that with the line: console.log(queue(testArr, 10)); (Ignore the console.log part - you are just invoking the queue function with two arguments, the first is an array, the second is a value that you are going to add to the end of the array that you pass in. Then after that, they want you to remove the first element from the array and return that.
Liz Emery
@lizardbrains
Jan 24 2016 02:37
Ooops, nevermind. I figured it out :)
Ken Haduch
@khaduch
Jan 24 2016 02:38
@lizardbrains - good work!
hulk
@phillworden
Jan 24 2016 02:38
@bharatian i had a problem with the same one yesterday.
Bharatian
@bharatian
Jan 24 2016 02:38
@khaduch - yeah i do get that part really. but i dont understand the relationship between item and arr
Liz Emery
@lizardbrains
Jan 24 2016 02:38
@khaduch Thank you! Sometimes the magical solution comes to you the moment you ask for help :)
CamperBot
@camperbot
Jan 24 2016 02:38
lizardbrains sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 412 | @khaduch | http://www.freecodecamp.com/khaduch
Bharatian
@bharatian
Jan 24 2016 02:39
@khaduch - how is arr. push(item); pushes 1 into the array...
hulk
@phillworden
Jan 24 2016 02:39
if you rewrite your code like this itll work: Challenge - Stand in Line (phillworden's solution)
Ken Haduch
@khaduch
Jan 24 2016 02:39
@lizardbrains - that's why one of their methods for solving problems is ask, I guess! :laughing:
Alex Rose
@thelyricalrose
Jan 24 2016 02:39
@Mahin2k so you need to access myPlants[1] before you access list[1]
Liz Emery
@lizardbrains
Jan 24 2016 02:39
@khaduch Tee hee _
Khademul Islam Mahin
@Mahin2k
Jan 24 2016 02:40
@thelyricalrose so how would i do that
hulk
@phillworden
Jan 24 2016 02:40
@bharatian check my challenge. i think whoever setup the challenge did it wrong but if you rewrite it like i have it it will work.
Bharatian
@bharatian
Jan 24 2016 02:40
@phillworden - thanks i got the code but i am trying to understand how item is related to the array
CamperBot
@camperbot
Jan 24 2016 02:40
bharatian sends brownie points to @phillworden :sparkles: :thumbsup: :sparkles:
:star: 205 | @phillworden | http://www.freecodecamp.com/phillworden
Micah Bales
@micahbales
Jan 24 2016 02:40
Hi, is there someone here capable of assisting me with a fairly challenging (for me) bonfire?
Ken Haduch
@khaduch
Jan 24 2016 02:40
@phillworden - I think that his code is the same as yours, it is working, but he doesn't understand it., RIght @bharatian ?
Billy
@billywaite
Jan 24 2016 02:40
@mike259 i just started working on the problem and i'm thinking about starting it this way:
function lookUp(firstName, prop){
// Only change code below this line
if (contacts.hasOwnProperty("firstName"))
// Only change code above this line
Alex Rose
@thelyricalrose
Jan 24 2016 02:41
First you access trees with myPlants[1] as it is the second nested object,
Billy
@billywaite
Jan 24 2016 02:41
pretty sure you won't have to go into each individua name
hulk
@phillworden
Jan 24 2016 02:41
@bharatian item gets pushed on the end of the code aka if the array was 1 2 3 4 and item was 5 the new array would be 2 3 4 5
Bharatian
@bharatian
Jan 24 2016 02:41
@khaduch - yes exactly. The part i dont understand is that how is item being recognized…like where are we defining what item is?
hulk
@phillworden
Jan 24 2016 02:42
item is defined in the function @bharatian
Alex Rose
@thelyricalrose
Jan 24 2016 02:42
and by adding list[1] you get the second tree, so you're entire bit would just be those two put together so it would look like myPlants[1]list[1]
Bharatian
@bharatian
Jan 24 2016 02:42
@phillworden - where?
Alex Rose
@thelyricalrose
Jan 24 2016 02:43
@Mahin2k so you're end code looks like myPlants[1]list[1]
Ken Haduch
@khaduch
Jan 24 2016 02:43

@bharatian - there really is no relationship between item and arr, until you get into the queue function. (At least that's one way to look at it.) Then you take the value in the variable item, and push it on the end of the array arr that is passed in. So if you have the first test case where they pass this:

queue([], 1);

the function argument arr has the value of [], an empty array. The function argument item has the value of 1, since it is the second thing that was passed in the queue([], 1); function call. Within the function, you do this: arr.push(item), which takes the item variable value (which is 1) and adds it to the end of the arr argument (which is the empty array []), at which time you could represent it with the code [1]. The next step is to take that array, which now has the value of [1], and shift the first value off of it. That gets captured in your variable, which now has the value of 1, the array is now empty again, but you are only asked to return the value that you removed from the front of the queue, so you return the 1. Maybe that could help?

hulk
@phillworden
Jan 24 2016 02:43
function queue(arr, item) <- im pretty sure including it in here declares it as a new variable. if not they did it behind the scenes for you.
Krista Handel
@meloncatty
Jan 24 2016 02:43
I have a question about the information provided on the 'Introducing JavaScript Object Notation' page
Khademul Islam Mahin
@Mahin2k
Jan 24 2016 02:43
@thelyricalrose its myPlants.list[1] thanks!!
CamperBot
@camperbot
Jan 24 2016 02:43
mahin2k sends brownie points to @thelyricalrose :sparkles: :thumbsup: :sparkles:
:star: 249 | @thelyricalrose | http://www.freecodecamp.com/thelyricalrose
Micah Bales
@micahbales
Jan 24 2016 02:43
function destroyer(arr, arg1, arg2, arg3) {

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

      if (arr[i] === arg1) {
        arr.splice(i, 1);      
      }


      if (arr[i] === arg2) {
        arr.splice(i, 1);      
      }



      if (arr[i] === arg3) {
        arr.splice(i, 1);      
      }
    }

  return arr; 

}

destroyer([2, 3, 2, 3], 2, 3);
This is from "seek and destroy"
And I haven't quite figured how to destroy yet
This code is returning "[2]"
Bharatian
@bharatian
Jan 24 2016 02:45
@khaduch ah i get it…so arr basically becomes testArr and 10 becomes the item in the second console log. So we push the 10 at the end of the testArr and it pops out the first code because of the shift.
hulk
@phillworden
Jan 24 2016 02:45
@bharatian ya i just checked. by including item in the function declaration [ function queue (arr, item) { ] you are declaring it as a new variable. is that what you were looking for?
Bharatian
@bharatian
Jan 24 2016 02:46
i finally was able to connect it. thanks folks!!!
hulk
@phillworden
Jan 24 2016 02:46
no problem! happy coding!
Bharatian
@bharatian
Jan 24 2016 02:46
i was not connecting Arr with testArr and that was my problem.
hulk
@phillworden
Jan 24 2016 02:46
ah gotcha
Krista Handel
@meloncatty
Jan 24 2016 02:46
What does this mean: "It also has a nested formats array." why is the word 'format' important here? Is it emphasizing the fact that it's syntactically similar to JavaScript's array format?
Ken Haduch
@khaduch
Jan 24 2016 02:48
@meloncatty - hi Krystal.
Krista Handel
@meloncatty
Jan 24 2016 02:49
hello @khaduch
Alex Rose
@thelyricalrose
Jan 24 2016 02:49

function factorialize(num) {
var factor = 1;
for(var i = 1; i <= num; i++ ){
factor = factor * i;

}

return num;
}

factorialize(5);

Can anybody tell me why this isn't working for the second bonfire?

mmacedo
@mmacedoeu
Jan 24 2016 02:49
@meloncatty which question ?
Micah Bales
@micahbales
Jan 24 2016 02:50
function destroyer(arr, arg1, arg2, arg3) {

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

      if (arr[i] === arg1) {
        arr.splice(i, 1);      
      }


      if (arr[i] === arg2) {
        arr.splice(i, 1);      
      }



      if (arr[i] === arg3) {
        arr.splice(i, 1);      
      }
    }

  return arr; 

}

destroyer([2, 3, 2, 3], 2, 3);
Alex Rose
@thelyricalrose
Jan 24 2016 02:50

function factorialize(num) {
var factor = 1;
for(var i = 1; i <= num; i++ ){
factor = factor * i;

}

return num;
}

factorialize(5);

mmacedo
@mmacedoeu
Jan 24 2016 02:50
@thelyricalrose format
explain format
CamperBot
@camperbot
Jan 24 2016 02:50

: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

Alex Rose
@thelyricalrose
Jan 24 2016 02:50


function factorialize(num) {
  var factor = 1;
  for(var i = 1; i <= num; i++ ){
    factor = factor * i;

  }


  return num;
}

factorialize(5);
@mmacedoeu thank you, that was confusing me
CamperBot
@camperbot
Jan 24 2016 02:51
thelyricalrose sends brownie points to @mmacedoeu :sparkles: :thumbsup: :sparkles:
:star: 342 | @mmacedoeu | http://www.freecodecamp.com/mmacedoeu
Ken Haduch
@khaduch
Jan 24 2016 02:51
@meloncatty - the word format is important here because if you look at the code that they are presenting, there is a property of the object that has the name "formats". It is just a name, it could be named "meloncatty" :) just so you referred to it by the correct name. Their example is a music library so they are showing the different recording formats "CS" must be "cassette", "8T" is "8 Track Tape" ( most likely before your time...) and "LP" is the vinyl format. So it is all related to the name "formats" as the different media formats that the recording album is available in.
@meloncatty - Does that explain it? It is kind of a thing that they just took for granted that it would make sense, I think?
Alex Rose
@thelyricalrose
Jan 24 2016 02:54
Wow I got it, I forgot to change return num; to return factor; :P
Micah Bales
@micahbales
Jan 24 2016 02:54
Hi @khaduch Is my question too advanced for this space? Should I be asking for help in a different room?
Ken Haduch
@khaduch
Jan 24 2016 02:54
@micahbales - I didn't see your question? So many things happen so quickly here!
Micah Bales
@micahbales
Jan 24 2016 02:54
@khaduch Yeah, it's a busy night! Let me re-send
djdrysdale
@djdrysdale
Jan 24 2016 02:54
Hi, I am looking for help with String.indexOf()
Micah Bales
@micahbales
Jan 24 2016 02:55
This is from "seek and destroy"
function destroyer(arr, arg1, arg2, arg3) {

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

      if (arr[i] === arg1) {
        arr.splice(i, 1);      
      }


      if (arr[i] === arg2) {
        arr.splice(i, 1);      
      }



      if (arr[i] === arg3) {
        arr.splice(i, 1);      
      }
    }

  return arr; 

}

destroyer([2, 3, 2, 3], 2, 3);
this code is returning "[2]"
I know i'm doing something seriously wrong here
djdrysdale
@djdrysdale
Jan 24 2016 02:56
For some reason my code is telling me that there is no "f" in "floor" and I can't figure it out. My code is:
function mutation(arr) {

  response = false;
  var firstWord = arr[0];
  var secondWord = arr[1];
  var letterArray = secondWord.split("");

  for (i = 0; i < letterArray.length; i++) { 
    console.log("Current letter is " + letterArray[i] + ". Is it in " + firstWord + "?");

    if (firstWord.indexOf(letterArray[i])) {
      response = true;
      console.log("Yes!");
    } else {
      response =  false;
      console.log("No.");
      break;
    }
  } 
  return response;
}

mutation(["floor", "for"]);
Khalil Omar
@komar92
Jan 24 2016 02:57
hi all. i need help with the following
but im not sure how to copy/paste my screen as I see on here
Ken Haduch
@khaduch
Jan 24 2016 02:58
@micahbales - I was able to find it. So what you want to do is take the first argument (the array) and then get the remaining list of arguments (the 2 and 3) and remove any element from the first argument that exists in the remaining arguments. So you should return [], an empty array. Let's see what the code that you posted does?
Cole Perkins
@coleperkins
Jan 24 2016 02:58

Waypoint: Nesting For Loops

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Any ideas?

Micah Bales
@micahbales
Jan 24 2016 02:59
@khaduch One of the confusing things here for me is that there can be up to 3 arguments
Ken Haduch
@khaduch
Jan 24 2016 02:59
@micahbales - I think that the first problem that you'll run into is that you are using a for loop that is depending on the length of the array, and you are changing the array within the loop. That is generally not a good thing to do!
Micah Bales
@micahbales
Jan 24 2016 02:59
@khaduch oh, yeah...
John Barbagallo
@john-barbagallo
Jan 24 2016 03:00
I'm on testing objects for properties, and I'm stuck once more... can someone check out my code?
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
myObj.hasOwnProperty('gift'); // Your Code Here

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("pet");
Jonathan Thompson
@Jon-thomps
Jan 24 2016 03:00
@coleperkins product *= arr[i][j]
Ken Haduch
@khaduch
Jan 24 2016 03:02
@micahbales - and there could be any number of variables, so that is why they point you to the information about the "Arguments object" - that is a way to access all of the arguments that are passed, outside of the fact that they have any representation in the functions argument list.
Cole Perkins
@coleperkins
Jan 24 2016 03:02
@Jon-thomps Thank you! I was thinking in that direction right before you replied. Why would I not nest 'j' inside of [I]? E.g., [I[j]]?
CamperBot
@camperbot
Jan 24 2016 03:02
coleperkins sends brownie points to @jon-thomps :sparkles: :thumbsup: :sparkles:
:star: 228 | @jon-thomps | http://www.freecodecamp.com/jon-thomps
Micah Bales
@micahbales
Jan 24 2016 03:03
@khaduch I have had a really hard time understanding how to use the arguments object
Ken Haduch
@khaduch
Jan 24 2016 03:03
@micahbales - you'll see that some of the test cases have 2 extra arguments, and some have 3! So you have to do something different - you have to read about that Arguments object and how it can be useful. Let me go and look at that document, because I've used it a couple times now, but I don't have it firmly lodged in my brain. :)
Jonathan Thompson
@Jon-thomps
Jan 24 2016 03:04
@coleperkins No nested array specifications use subsequent brackets like [a][b][c] ect.
also you are welcome
Gordon Davidescu
@gordondavidescu
Jan 24 2016 03:04
and of course it helps to calculate the length
that is, how many arguments you even have
Jonathan Thompson
@Jon-thomps
Jan 24 2016 03:08
@john-barbagallo it should go like this myObj.hasOwnProperty(checkProp) because you want to take the input from checkProp
Ken Haduch
@khaduch
Jan 24 2016 03:09

@micahbales - the first thing that they say about the Arguments object:

it is an Array-like object corresponding to the arguments passed to a function.

and this:

The arguments object is not an Array. It is similar to an Array, but does not have any Array properties except length. For example, it does not have the pop method. However it can be converted to a real Array

I found some description somewhere of how to convert it - I don't know how their example code that they show works, but it is probably valid since they (mozilla) would not want to give bad information - their code:

var args = (arguments.length === 1?[arguments[0]]:Array.apply(null, arguments));

I assume would give you an actual array of all of the arguments passed in in the variable args

djdrysdale
@djdrysdale
Jan 24 2016 03:09
Can anyone offer any advice on my indexOf() question above? I'm confused because it works for 6 tests but not the last two in the Mutations bonfire.
Jonathan Thompson
@Jon-thomps
Jan 24 2016 03:10
@john-barbagallo this returns a true or false, so use an if statement to return that property, else "Not Found
Micah Bales
@micahbales
Jan 24 2016 03:10
@khaduch Yeah, I should use that code. I'd be hestitating to do so, because I don't understand entirely how the code functions. But I'm getting desperate to find a solution.
@khaduch I'll go give that a shot. Thanks for thinking through this a little with me.
CamperBot
@camperbot
Jan 24 2016 03:11
micahbales sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 413 | @khaduch | http://www.freecodecamp.com/khaduch
Tennile Edwards
@telaed
Jan 24 2016 03:13
Working on the "Split Strings with split" waypoint. I am calling the function correctly but attempted to use the "\s" expression to locate the whitespace. Any help is appreciated.
Ken Haduch
@khaduch
Jan 24 2016 03:14

@micahbales - this is some code from the javascript console that shows that you get from the arguments array I created a function and then called it.

> function testMe(junk) {
var args = Array.apply(null, arguments);
console.log("This is the junk argument: " + JSON.stringify(junk));
console.log("This is the arguments: " + JSON.stringify(arguments));
console.log("This is the resulting array: " + JSON.stringify(args));
return;
}
< undefined
> testMe("this is", "the first", "and last", "time I want to do this!");
  VM4598:4 This is the junk argument: "this is"
  VM4598:5 This is the arguments: {"0":"this is","1":"the first","2":"and last","3":"time I want to do this!"}
  VM4598:6 This is the resulting array: ["this is","the first","and last","time I want to do this!"]
undefined

So you can see that the function argument only captures the first part of what I passed in, but the arguments has it all as an object-type of thing. Then the final args variable that I created with that "Array.apply()" call has everything in an array...

Tennile Edwards
@telaed
Jan 24 2016 03:14
My code is below:

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split("\s");

djdrysdale
@djdrysdale
Jan 24 2016 03:15
@telaed Try array = string.split(" ");
What you have will search for a slash and an s in your strong, not a whitespace
Micah Bales
@micahbales
Jan 24 2016 03:16
@khaduch Whoa, that's a little over my head atm
djdrysdale
@djdrysdale
Jan 24 2016 03:16
because you have it in quotation marks
Tennile Edwards
@telaed
Jan 24 2016 03:16
I see. I tried array = string.split(""); previously but didn't include the space. Thanks @djdrysdale
CamperBot
@camperbot
Jan 24 2016 03:16
telaed sends brownie points to @djdrysdale :sparkles: :thumbsup: :sparkles:
:star: 263 | @djdrysdale | http://www.freecodecamp.com/djdrysdale
djdrysdale
@djdrysdale
Jan 24 2016 03:17
no problem! Happy to help.
John Barbagallo
@john-barbagallo
Jan 24 2016 03:17
@Jon-thomps so I modified my code.. please take a look! :)
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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


  else { 
  return "Not Found"; } }


// Test your code by modifying these values
checkObj("pet");
Ken Haduch
@khaduch
Jan 24 2016 03:19

@micahbales - just break it down. I basically have a function that I'm using just to manipulate the arguments structure.

  • first it shows the argument that is represented in the formal parameter junk, which is just the first substring that I passed in.
  • then it shows the contents of the mysterious arguments object, which has all of the pieces of the strings that I passed in the function call
  • Finally after that apply call, it shows the resulting arg, which is an actual array, represented with the standard array notation.

Using that, you can see how to access the extra arguments that are being passed into the destroyer function! Maybe it will help!

John Barbagallo
@john-barbagallo
Jan 24 2016 03:19
my code is not passing "checkObj("pet") should return "kitten"."
Tennile Edwards
@telaed
Jan 24 2016 03:20
I just finished all of my Waypoints and starting my Bonfires. I am so excited! Thanks for all the help guys!
John D
@DnOberon
Jan 24 2016 03:20
congrats @telaed
Ken Haduch
@khaduch
Jan 24 2016 03:20
@telaed - congratulations!!! Good luck as you forge ahead!
Micah Bales
@micahbales
Jan 24 2016 03:21
@khaduch Thanks! I'll give it a look.
CamperBot
@camperbot
Jan 24 2016 03:21
micahbales sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: micahbales already gave khaduch points
Jonathan Thompson
@Jon-thomps
Jan 24 2016 03:21
@john-barbagallo better, but rather than return a single string "pony" or kitten, just call the string from the object so it works for whatever checkProp is return myObj[checkProp]
John Barbagallo
@john-barbagallo
Jan 24 2016 03:24
@Jon-thomps like "checkObj"
Krista Handel
@meloncatty
Jan 24 2016 03:25
@khaduch yeah that makes sense. I thought it was more important than that. I read into it too much. Thanks for clearing that up!
CamperBot
@camperbot
Jan 24 2016 03:25
meloncatty sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 414 | @khaduch | http://www.freecodecamp.com/khaduch
Jonathan Thompson
@Jon-thomps
Jan 24 2016 03:26
@john-barbagallo sorry that response was poorly formated. like js myObj[checkProp]
Chris Burros
@cburros
Jan 24 2016 03:26
Got through the factorialize bonfire. Know it's not much but I feel empowered now.
Ken Haduch
@khaduch
Jan 24 2016 03:27

@meloncatty

@khaduch yeah that makes sense. I thought it was more important than that. I read into it too much.

You're welcome. It sometimes is easy to think about it a little too much. When you get old like me, you'll find that you don't have the time to think, or you quickly forget that you were thinking about something and it doesn't matter so much... :older_man: :smile:

John Barbagallo
@john-barbagallo
Jan 24 2016 03:28
@Jon-thomps still working on it. thinking
Jonathan Thompson
@Jon-thomps
Jan 24 2016 03:31
@john-barbagallo That's good. Remember you want your functions to work, no matter what the input is, so better to define things using your input variables rather than unchangeable strings. return myObj[checkProp]
Jamela
@Jamela08
Jan 24 2016 03:31
whats wrong with this code?

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;
}
var val="charlie";
// Change this value to test
phoneticLookup(val);

Using Object as Look Up
djdrysdale
@djdrysdale
Jan 24 2016 03:33
do you change what result is anywhere? it always stays as "" as far as I can see... @jamela08
Loren Baca
@vbroskas
Jan 24 2016 03:33
hey what's up guys, I have a beginner javascript objects question
if you have the object :
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};
and you want to make a call to the key of 'hat'
John Barbagallo
@john-barbagallo
Jan 24 2016 03:34
@vbroskas what do you want to know
Loren Baca
@vbroskas
Jan 24 2016 03:34
why do you use:
var hatValue = testObj.hat;
instead of:
var hatValue = testObj.'hat';
i dont get why you dont call it as a string
hat was never logged as anything other than a string
Jamela
@Jamela08
Jan 24 2016 03:35

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("charlie");

whats wrong with this code?
Thanks
John Barbagallo
@john-barbagallo
Jan 24 2016 03:36
@Jamela08 which challenge is that?
Loren Baca
@vbroskas
Jan 24 2016 03:36
so why can you make the call of testObj.hat;
Jamela
@Jamela08
Jan 24 2016 03:36
Using Objects for LookUps
John Barbagallo
@john-barbagallo
Jan 24 2016 03:36
@vbroskas so you've gotten the answer but don't understand?
Loren Baca
@vbroskas
Jan 24 2016 03:36
yes
it seems like you would have to make the call to 'hat' at a string
not just hat
hat has never been defined
'hat' has been defined
this is out of the javascript exercise: Accessing Objects Properties with the Dot Operator
John Barbagallo
@john-barbagallo
Jan 24 2016 03:38
@Jamela08 your "return result" must have "result = lookup[val];"
wish I understood it fully so I could explain a bit.
Jamela
@Jamela08
Jan 24 2016 03:38
@john-barbagallo thanks
CamperBot
@camperbot
Jan 24 2016 03:38
jamela08 sends brownie points to @john-barbagallo :sparkles: :thumbsup: :sparkles:
:star: 214 | @john-barbagallo | http://www.freecodecamp.com/john-barbagallo
John Barbagallo
@john-barbagallo
Jan 24 2016 03:38
@vbroskas i know exactly what your talking about
h-fiona
@h-fiona
Jan 24 2016 03:38
hey guys
i am woring on the counting cards challenge
Jamela
@Jamela08
Jan 24 2016 03:39
whats your question fiona
John Barbagallo
@john-barbagallo
Jan 24 2016 03:39
@vbroskas maybe because yours specifying a property?
@Jamela08 did that work for you?
Loren Baca
@vbroskas
Jan 24 2016 03:39
what do you mean by a property john?
Jamela
@Jamela08
Jan 24 2016 03:40
yup forgot to do that yeah the missing link lol @john-barbagallo
Ken Haduch
@khaduch
Jan 24 2016 03:40
@Jamela08 - you are not setting result with a value - you have to have some code like result = lookup[val]; and that will get returned.
Jamela
@Jamela08
Jan 24 2016 03:40
Thanks @khaduch
CamperBot
@camperbot
Jan 24 2016 03:40
jamela08 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
John Barbagallo
@john-barbagallo
Jan 24 2016 03:40
testObj is an "object"
CamperBot
@camperbot
Jan 24 2016 03:40
:star: 416 | @khaduch | http://www.freecodecamp.com/khaduch
h-fiona
@h-fiona
Jan 24 2016 03:40
i am lookign at the wiki page for hints
John Barbagallo
@john-barbagallo
Jan 24 2016 03:40
it has "properties"
h-fiona
@h-fiona
Jan 24 2016 03:40
and it is asking us to use a switch statement
John Barbagallo
@john-barbagallo
Jan 24 2016 03:41
@h-fiona may I see your code?
<<< the blind leading the blind :)
h-fiona
@h-fiona
Jan 24 2016 03:41
one second~
thanks guys
Loren Baca
@vbroskas
Jan 24 2016 03:41
ok i get that, but when you make that dot operator call to find the value of 'hat', how does the object find 'hat' when you call it as hat
Ken Haduch
@khaduch
Jan 24 2016 03:42
hey good people - it's time for me to check out for the evening. Any final questions? :) Otherwise - thanks for the fun times and coding practice!
John Barbagallo
@john-barbagallo
Jan 24 2016 03:42
@khaduch answer @vbroskas question :)
Loren Baca
@vbroskas
Jan 24 2016 03:42
unless it is referenced as a string, its like some undefined variable or something
Ken Haduch
@khaduch
Jan 24 2016 03:42
@john-barbagallo @vbroskas - what's the question?
Loren Baca
@vbroskas
Jan 24 2016 03:43
k
so in the object:
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
Jamela
@Jamela08
Jan 24 2016 03:43
post your code @h-fiona
Loren Baca
@vbroskas
Jan 24 2016 03:43
if you want to make a dot operator call to find the value of 'hat'
h-fiona
@h-fiona
Jan 24 2016 03:43

@Jamela08 var count = 0;

function cc(card) {
// Only change code below this line
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Loren Baca
@vbroskas
Jan 24 2016 03:43
why do you use:
h-fiona
@h-fiona
Jan 24 2016 03:43
so far i have added the switch function
Loren Baca
@vbroskas
Jan 24 2016 03:43
var hatValue = testObj.hat;
instead of:
h-fiona
@h-fiona
Jan 24 2016 03:43
statement*
Loren Baca
@vbroskas
Jan 24 2016 03:43
var hatValue = testObj.'hat';
it seems like it should be called as a string ('hat')
Jamela
@Jamela08
Jan 24 2016 03:44
whats the question for this @h-fiona
h-fiona
@h-fiona
Jan 24 2016 03:44
and the instructions ask us to use an if function to do a count
Loren Baca
@vbroskas
Jan 24 2016 03:44
because hat (non-string) as never been defined
Jamela
@Jamela08
Jan 24 2016 03:44
oh okay
h-fiona
@h-fiona
Jan 24 2016 03:44
@Jamela08 You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
hulk
@phillworden
Jan 24 2016 03:44
can someone help me with this challenge?
Jamela
@Jamela08
Jan 24 2016 03:45
yeah you can use if else statement just use or so that you will have 3 options
h-fiona
@h-fiona
Jan 24 2016 03:45
the function will return a string with the current count and the string bet / hold
John Barbagallo
@john-barbagallo
Jan 24 2016 03:45
@h-fiona return "Change Me"; you've got to make that go to bet if x or hold if y
hulk
@phillworden
Jan 24 2016 03:45
im not sure how im supposed to use result Challenge - Using Objects for Lookups (phillworden's solution)
Jamela
@Jamela08
Jan 24 2016 03:45
inside the if else you write the count++ or count=0
first make the if else @h-fiona then post it here
Ttvi
@XeCtvi
Jan 24 2016 03:46

Dear all. How can I resolve this situation that I want to set a value?

var s, needStr;
function titleCase(str) {
  s = str.toLowerCase().split(" ");
  for (var i in s) {
    console.log(s[i]);
    var c = s[i][0].toUpperCase();
    console.log(c);
    s[i][0] = c;          <-- I just wanna to value the c on this
    console.log(s[i][0]);
  }
  console.log(s);

  return str;
}

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

Thanks for your help ~~

h-fiona
@h-fiona
Jan 24 2016 03:46
would i be able to use the switch() statement for this
John Barbagallo
@john-barbagallo
Jan 24 2016 03:46

@h-fiona
if x > 0){
return x + " y";
} else {
return x + " z";

this is for the return "Change Me"

figure out the x,y,z

Jamela
@Jamela08
Jan 24 2016 03:46
yup you can but then the instruction says use if else
hulk
@phillworden
Jan 24 2016 03:47
nvrmd i looked at someone who had the same question
John Barbagallo
@john-barbagallo
Jan 24 2016 03:47
@Jamela08 his switch statement looks good? its the after code for the "return" that needs modification
Jamela
@Jamela08
Jan 24 2016 03:48
yup okay but i thought the instruction is to use if else
John Barbagallo
@john-barbagallo
Jan 24 2016 03:48
use both
h-fiona
@h-fiona
Jan 24 2016 03:48
@Jamela08 for the if else statements
Jamela
@Jamela08
Jan 24 2016 03:48
she missed the part if the card is 7,8,9
John Barbagallo
@john-barbagallo
Jan 24 2016 03:49
you really don't need it if it adds "0"
Jamela
@Jamela08
Jan 24 2016 03:49
oh okay lol
so my code is kinda long lol thanks @john-barbagallo
CamperBot
@camperbot
Jan 24 2016 03:49
jamela08 sends brownie points to @john-barbagallo :sparkles: :thumbsup: :sparkles:
:warning: jamela08 already gave john-barbagallo points
John Barbagallo
@john-barbagallo
Jan 24 2016 03:50
now I'm curious how you written it and passed that challenge :)
Jamela
@Jamela08
Jan 24 2016 03:51
ok wait
John Barbagallo
@john-barbagallo
Jan 24 2016 03:51
@h-fiona any closer to solving? I really don't want to outright answer this... but I know my hints are terrible as I'm new myself.
Jamela
@Jamela08
Jan 24 2016 03:51
I'll post it
hulk
@phillworden
Jan 24 2016 03:51
@h-fiona and everyone else trying to help. you need to create an if statement that returns count + " Bet" if count is greater than 0 and returns count + " hold" if count is less than or equal to 0
h-fiona
@h-fiona
Jan 24 2016 03:51
i am working on the if else statement

if (card < 6) {
count++;
}

else (card == 10 || card == "J" || card = "K" || card == "A") {
count--;
}

does tat work>
Jamela
@Jamela08
Jan 24 2016 03:51

var count = 0;

function cc(card) {
// Only change code below this line
if (card==2 || card==3 || card==4 || card==5 || card==6) {
count++;
return count + " Bet";
} else if (card==7 || card==8 || card ==9) {
count=0;
return count + " Hold";
} else if (card==10 || card=="J" || card=="Q" || card=="K" || card=="A") {
count=count-1;
return count + " Hold";
}

// Only change code above this line
}

John Barbagallo
@john-barbagallo
Jan 24 2016 03:51
hahah its sexy but I think I confused it.
h-fiona
@h-fiona
Jan 24 2016 03:51
the cc(value) function is only applied fo one instance no?
Jamela
@Jamela08
Jan 24 2016 03:52
That's how I did it @john-barbagallo
John Barbagallo
@john-barbagallo
Jan 24 2016 03:52
var count = 0;

function cc(card) {
  // Only change code below this line
 switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
wait my codes flawed .. deleted parts one sec.
hulk
@phillworden
Jan 24 2016 03:53
@h-fiona you are forgettiing to have it return count + a string " Hold" or " Bet"
h-fiona
@h-fiona
Jan 24 2016 03:53
i may be jumping to chapters here
but is there a "loop" or "update" going on here>
hulk
@phillworden
Jan 24 2016 03:53
var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
    default:
      count = count;

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
h-fiona
@h-fiona
Jan 24 2016 03:54
is the count value continously updating?
Aaron Graves
@gravesmeister
Jan 24 2016 03:54
Can anyone help me with Stand in Line? I thought I was starting to understand everything and this one totally lost me
h-fiona
@h-fiona
Jan 24 2016 03:54
based on the function calls?
cc(2), cc(3) etc?
hulk
@phillworden
Jan 24 2016 03:54
it updates each time the function is called
h-fiona
@h-fiona
Jan 24 2016 03:54
that makes sense
hulk
@phillworden
Jan 24 2016 03:55
yup. hope it helps
h-fiona
@h-fiona
Jan 24 2016 03:55

so in this case we see the following:

Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"

how will these be tested
based on the code
hulk
@phillworden
Jan 24 2016 03:56
@gravesmeister I did that one yesterday and I am pretty sure it is flawed. At any rate it is very poorly setup. Here is how i did it:
var arr = [1,2,3,4,5]

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

// Test Setup
//what the freaking heck
// Display Code
console.log("Before: " + JSON.stringify(arr));
console.log(queue(arr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(arr));
console.log(arr[4]);
Jamela
@Jamela08
Jan 24 2016 03:56
@gravesmeister i was not able to finish that part
i skipped dont understand how to pass it
h-fiona
@h-fiona
Jan 24 2016 03:57
would we need to update the section under fuction calls to test for each ask>
Aaron Graves
@gravesmeister
Jan 24 2016 03:57
The whole thing hardly made any sense to me
Jamela
@Jamela08
Jan 24 2016 03:57
@h-fiona comment the others and then you can test it one by one
John Barbagallo
@john-barbagallo
Jan 24 2016 03:57
function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }
  if (count > 0){
    return count + " Bet";
  } else {
    return count + " Hold";
  }
  // Only change code above this line
}
Aaron Graves
@gravesmeister
Jan 24 2016 03:58
because it appears that the function queue was already written so was I supposed to make another one?
Ken Haduch
@khaduch
Jan 24 2016 03:58

@vbroskas @john-barbagallo - I think that it has to do with the way the objects are stored in the javascript 'memory'. You can define those object keys with strings, when the object is stored, javascript knows that the property that was declared with "hat" has the property name of hat, and can be referred to either way, with the quotes or without. In the javascript console, you can see something:

var myObj = {
"hat" : "cowboy",
"shirt" : "Checkered",
"boots" : "brown"
}
undefined
JSON.stringify(myObj)
"{"hat":"cowboy","shirt":"Checkered","boots":"brown"}"

They are stored as strings. Now it gets a little confusing, in that you cannot write myObj."hat" without getting an error.

> myObj."hat"
< VM6491:2 Uncaught SyntaxError: Unexpected string(…)

But you can use myObj.hat:

> myObj.hat
< "cowboy"

One exception that they mention is that if the key has a space in it, then you have to use the quoted string form, and the only way that you can do that is with bracket notation, so if I add another property to my records with a space-separated name:

var myObj = {
"hat" : "cowboy",
"shirt" : "Checkered",
"boots" : "brown",
"horse color" : "black"
}
undefined
JSON.stringify(myObj)
"{"hat":"cowboy","shirt":"Checkered","boots":"brown","horse color":"black"}"

Then it says that i HAVE* to access this with the bracket notation. There isn't a way to use myObj."horse color" because we saw that that doesn't work, but we can use (and have to use) myObj['horse color']; as this console output shows:

myObj."horse color"
VM7477:2 Uncaught SyntaxError: Unexpected string(…)InjectedScript._evaluateOn @ VM7323:875InjectedScript._evaluateAndWrap @ VM7323:808InjectedScript.evaluate @ VM7323:664
myObj.horse color
VM7486:2 Uncaught SyntaxError: Unexpected identifier(…)InjectedScript._evaluateOn @ VM7323:875InjectedScript._evaluateAndWrap @ VM7323:808InjectedScript.evaluate @ VM7323:664
myObj['horse color']
"black"

All but the final attempt fail with gross errors.
You'd probably have to understand the javascript implementation to really understand it? Maybe some JS guru will happen along? :)

Jamela
@Jamela08
Jan 24 2016 03:58
comment ex.
//cc(2)
cc(3)
will only test cc(3)
John Barbagallo
@john-barbagallo
Jan 24 2016 03:59
@khaduch thanks a ton. you deserve brownies :)
CamperBot
@camperbot
Jan 24 2016 03:59
john-barbagallo sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 417 | @khaduch | http://www.freecodecamp.com/khaduch
h-fiona
@h-fiona
Jan 24 2016 03:59
@john-barbagallo @Jamela08 hey guys so i just ran the code
Jamela
@Jamela08
Jan 24 2016 03:59
notice that it executes the last cc("J")
hulk
@phillworden
Jan 24 2016 03:59
@Jamela08 @gravesmeister ya i think whoever set it up did something wrong. because it should be an easy shift off the first value of an array and have it store to a var and then push item on to the end, but they did something wrong so doing that doesnt work. I just edited the code outside of what i was supposed to edit to fix it and make it work.
Jamela
@Jamela08
Jan 24 2016 03:59
@phillworden sometimes i find the instructions confusing lol
Kurt Lehnardt
@KurtLehnardt
Jan 24 2016 03:59

'''javascript
function rot13(str) { // LBH QVQ VG!
var strArr = [];
for(i = 0; i < str.length; i++){
var code = str.charCodeAt(i);
if (code >= 65 && code <= 78){ // if code = 65, then transformed to 52.
code += 13;
strArr.push(code);
} else if (code > 78 && code <= 91){
code -= 13;
strArr.push(code);
} else {
strArr.push(str.charCodeAt(i));
}

}
var cipher = strArr.toString();
str = cipher.replace(/\,/g, ', ');
return String.fromCharCode(str);
}

// Change the inputs below to test
//rot13("SERR PBQR PNZC");
rot13("ABC ABC CBA CBA");
'''

CamperBot
@camperbot
Jan 24 2016 03:59
:bulb: to format code use backticks! ``` more info
hulk
@phillworden
Jan 24 2016 04:00
@Jamela08 ya esp on that one
Kurt Lehnardt
@KurtLehnardt
Jan 24 2016 04:00
Any help on this code for Caesar's Cipher?

```function rot13(str) { // LBH QVQ VG!
var strArr = [];
for(i = 0; i < str.length; i++){
var code = str.charCodeAt(i);
if (code >= 65 && code <= 78){ // if code = 65, then transformed to 52.
code += 13;
strArr.push(code);
} else if (code > 78 && code <= 91){
code -= 13;
strArr.push(code);
} else {
strArr.push(str.charCodeAt(i));
}

}
var cipher = strArr.toString();
str = cipher.replace(/\,/g, ', ');
return String.fromCharCode(str);
}

// Change the inputs below to test
//rot13("SERR PBQR PNZC");
rot13("ABC ABC CBA CBA");
```

Jamela
@Jamela08
Jan 24 2016 04:00
how was it @h-fiona ?
Kurt Lehnardt
@KurtLehnardt
Jan 24 2016 04:00
function rot13(str) { // LBH QVQ VG!
  var strArr = [];
  for(i = 0; i < str.length; i++){
    var code = str.charCodeAt(i);
    if (code >= 65 && code <= 78){ // if code = 65, then transformed to 52. 
      code += 13;
      strArr.push(code);
    } else if (code > 78 && code <= 91){
      code -= 13;
      strArr.push(code);
    } else {
      strArr.push(str.charCodeAt(i));
    }

  }
var cipher = strArr.toString();
  str = cipher.replace(/\,/g, ', ');
return String.fromCharCode(str);
}



// Change the inputs below to test
//rot13("SERR PBQR PNZC");
rot13("ABC ABC CBA CBA");
h-fiona
@h-fiona
Jan 24 2016 04:00
so i ran the code and i was able to go to the next challenge
it seems like it is irrelevant what the function calls are?
Jamela
@Jamela08
Jan 24 2016 04:01
what do you mean?
Aaron Graves
@gravesmeister
Jan 24 2016 04:02
@phillworden From my point of view it seemed to add to many elements all in one which made it really confusing for someone trying to learn this stuff.
h-fiona
@h-fiona
Jan 24 2016 04:03

@Jamela08 its asking for the following checks

Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"

however, i was just wondering if that is really necessary since i submitted the code and i could proceed to the next challenge

Aaron Graves
@gravesmeister
Jan 24 2016 04:03
I'm going to study it for a while until it makes sense.
Thanks @phillworden
CamperBot
@camperbot
Jan 24 2016 04:03
gravesmeister sends brownie points to @phillworden :sparkles: :thumbsup: :sparkles:
:star: 215 | @phillworden | http://www.freecodecamp.com/phillworden
hulk
@phillworden
Jan 24 2016 04:04
@gravesmeister it actually doesnt really add much. it is just a poorly worded prompt and the question is more of a test to see if you can apply what you know so far. and then they screwed up the rest of the code and said a bunch of unneccessary stuff in the prompt.
Jamela
@Jamela08
Jan 24 2016 04:04
That one will help if one part of your program has prob but since all of the sub chunks are correct
h-fiona
@h-fiona
Jan 24 2016 04:04
thanks for your help @Jamela08 @john-barbagallo
CamperBot
@camperbot
Jan 24 2016 04:04
h-fiona sends brownie points to @jamela08 and @john-barbagallo :sparkles: :thumbsup: :sparkles:
:star: 213 | @jamela08 | http://www.freecodecamp.com/jamela08
:star: 216 | @john-barbagallo | http://www.freecodecamp.com/john-barbagallo
Jamela
@Jamela08
Jan 24 2016 04:04
you proceeded directly to the next challenge
Aaron Graves
@gravesmeister
Jan 24 2016 04:04
So you think if it had been worded better I would have understood it better?
h-fiona
@h-fiona
Jan 24 2016 04:05
@Jamela08 ya it seemed like it just identified th code was correct and i could move on to the next chalenge
Jamela
@Jamela08
Jan 24 2016 04:05
Im using that as guide to troubleshoot whats wrong with my code :)
h-fiona
@h-fiona
Jan 24 2016 04:05
wihtout even updatng for the function calls
strabge
strange*
Jamela
@Jamela08
Jan 24 2016 04:05
@gravesmeister and then share to me your insights :)
I still couldnt get that part eh
John Barbagallo
@john-barbagallo
Jan 24 2016 04:06
@Jamela08 just tried stalking your progress, have you linked github?
Jamela
@Jamela08
Jan 24 2016 04:06
@john-barbagallo not yet
why?
Aaron Graves
@gravesmeister
Jan 24 2016 04:06
@Jamela08 You want me to post what I coded or share when I understand what was coded?
Jamela
@Jamela08
Jan 24 2016 04:07
only that part the Stand In Line
:)
Aaron Graves
@gravesmeister
Jan 24 2016 04:07
var testArr = [1,2,3,4,5];

function queue(arr, item) {
    // Your code here
  var a;
  arr.push(item);
  a = arr.shift();

  return a; // Change this line
}

// Test Setup


// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
John Barbagallo
@john-barbagallo
Jan 24 2016 04:07
@Jamela08 just curious. i think I'm too tired and intoxicated to push on with challenges. so I wanted to "size" you up... seeing were on about the same challenge.
Ken Haduch
@khaduch
Jan 24 2016 04:08

@john-barbagallo @vbroskas

@khaduch t hanks a ton. you deserve brownies :)

you're welcome - not sure if it is completely explained because I don't know the really gutty parts of javascript, but it shows that you cannot use the object.'string' notation at all, at least not in the console, and I'd expect not in the code... There was a page that someone else posted that took another stab at explaining this, but I don't know if I can find it? Let me see if it's in my browser history somewhere... https://medium.com/@prufrock123/js-dot-notation-vs-bracket-notation-797c4e34f01d#.k3q43y32l - that was it. Not sure if it makes complete sense, either. But it might be a better explanation than I could make! :)

Jamela
@Jamela08
Jan 24 2016 04:08
lol @john-barbagallo im slowly progressing
John Barbagallo
@john-barbagallo
Jan 24 2016 04:09
same, same.. steady progression wins this race..
Aaron Graves
@gravesmeister
Jan 24 2016 04:10
Yeah this is my second time through the Javascript lessons. I want to fully understand it. I'm also reading a kindle book which is explaining things a lot better.
hulk
@phillworden
Jan 24 2016 04:10
@gravesmeister yup. and if they had written the code correctly in the first place. if they had worded it like "Write the code for a function queue with two variables arr and item in which arr is an array and item is a number. add item to the back of the array and remove the first element of the array so that the array stays the same length. Then have the function return the removed element." i think that is a better desc. of the problem.
Jamela
@Jamela08
Jan 24 2016 04:10
what book?
DJ
@qualitymanifest
Jan 24 2016 04:10
@xxkazunarixx instead of pushing code you could push String.fromCharCode(code) and then just join in the return
(join your array)
Aaron Graves
@gravesmeister
Jan 24 2016 04:12
It's called "A smarter way to learn Javascript" by Mark Myers. I'm using along side this and it's helping but they both kind of touch on different things but the book just explains it all better. PLus after you read each chapter he directs you towards lessons on his website which really help. It's 7.99 for the kindle version
Jamela
@Jamela08
Jan 24 2016 04:13
Thanks @gravesmeister
CamperBot
@camperbot
Jan 24 2016 04:13
jamela08 sends brownie points to @gravesmeister :sparkles: :thumbsup: :sparkles:
Aaron Graves
@gravesmeister
Jan 24 2016 04:13
@phillworden For some reason I figured the array had to be within the function. I don't know why but the whole array things is becoming clearer by the day. Thanks again for your help man
CamperBot
@camperbot
Jan 24 2016 04:13
gravesmeister sends brownie points to @phillworden :sparkles: :thumbsup: :sparkles:
:warning: gravesmeister already gave phillworden points
:star: 204 | @gravesmeister | http://www.freecodecamp.com/gravesmeister
hulk
@phillworden
Jan 24 2016 04:14
no problem @gravesmeister ! Happy coding!
Alain Holly
@aholly38
Jan 24 2016 04:15
still lost
// 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){

   if (prop == 'tracks'){

   var result = collection[prop].push();

   }else{

     collectionCopy = collection[prop].push();

   }

     delete collection[prop];
   }


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Ken Haduch
@khaduch
Jan 24 2016 04:15

@vbroskas @john-barbagallo - one last link to read through: property accessors (for object properties) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors

Good night, all!

Jamela
@Jamela08
Jan 24 2016 04:15
NIght @khaduch
John Barbagallo
@john-barbagallo
Jan 24 2016 04:16
@khaduch good night
I'm actually looking @ the book
Jamela
@Jamela08
Jan 24 2016 04:19
@john-barbagallo are you done with Testing Objects for Properties?
John Barbagallo
@john-barbagallo
Jan 24 2016 04:19
@Jamela08 yessah
Jamela
@Jamela08
Jan 24 2016 04:20
how to do the if false then Not found?
John Barbagallo
@john-barbagallo
Jan 24 2016 04:21
@Jamela08 private msg.
Jamela
@Jamela08
Jan 24 2016 04:21
i dont know how to private essage?
.
John Barbagallo
@john-barbagallo
Jan 24 2016 04:22
left tabs, where your chatrooms are
look for my name.
Alain Holly
@aholly38
Jan 24 2016 04:23
good night
Aaron Chiandet
@achiandet
Jan 24 2016 04:27
Ola, I think I’m having a dissconect with iterating through an array with a for loop, can someone help me with it?
I’m not 100% sure where my missunderstanding is at this point
The for loop iteself makes sense to me, I believe I understand the concept of iterating through the nested array.
But my solution is returning null and that’s where my understanding is breaking down.

My solution:

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++) {
return product * arr[j];
}
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

eww…is there a better way of pasting code?
Cole Perkins
@coleperkins
Jan 24 2016 04:29

Waypoint: Profile Lookup

//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
  var i = 0;
  var j = 0;
  var answer1 = "";
  var answer2 = "";

  for (i=0; i < 4; i++) {
    if (contacts[i].firstName === firstName) {
      answer1 = "yes";
        if (contacts[i].prop !== "") {
          answer2 = "yes";
        }
      }
    if (answer1 === "yes" && answer2 === "yes") {
      return contacts[i].prop;
      }
  }


// Only change code above this line
}

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

Having some difficulty here. I'm getting lost. Can someone give me a direction to head in or some tips on how to get the ball rolling on this waypoint?

Aaron Chiandet
@achiandet
Jan 24 2016 04:30

'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++) {
return product * arr[j];
}
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);'

‘’'
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++) {
return product * arr[j];
}
}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
‘''

Cole Perkins
@coleperkins
Jan 24 2016 04:30
@achiandet paste your code inbetween two sets of ``` marks. One before and one after. Make sure you have a line break by pressing shift + enter.
Aaron Chiandet
@achiandet
Jan 24 2016 04:30
Thanks @coleperkins
CamperBot
@camperbot
Jan 24 2016 04:30
achiandet sends brownie points to @coleperkins :sparkles: :thumbsup: :sparkles:
:star: 250 | @coleperkins | http://www.freecodecamp.com/coleperkins
Aaron Chiandet
@achiandet
Jan 24 2016 04:31
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++) {
      return product * arr[j];
    }
  }



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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Jamela
@Jamela08
Jan 24 2016 04:33
Thanks @john-barbagallo
CamperBot
@camperbot
Jan 24 2016 04:33
jamela08 sends brownie points to @john-barbagallo :sparkles: :thumbsup: :sparkles:
:warning: jamela08 already gave john-barbagallo points
Cole Perkins
@coleperkins
Jan 24 2016 04:33
@achiandet I just worked on that a while ago. Notice, you are returning 'product' twice. You wan to reassign the value of 'product'. That can be accomplished by using the *=.
Aaron Chiandet
@achiandet
Jan 24 2016 04:34
Oh interesting, I completely overlooked that.
Cole Perkins
@coleperkins
Jan 24 2016 04:35
@achiandet Also, you want to reassign product with the product multiplied by arr[I][j], not just arr[I]. This means you are multiplying in each of the numbers inside each array of the object.
@achiandet that would look like
product *= arr[I][j];
Aaron Chiandet
@achiandet
Jan 24 2016 04:36
I just discovered that. I think this is something I’m not understanding.
Cole Perkins
@coleperkins
Jan 24 2016 04:36
What particularly?
Aaron Chiandet
@achiandet
Jan 24 2016 04:36
I’m failing to understand why I would want to multiply i
in my mind, [i] is the nested array itself
hulk
@phillworden
Jan 24 2016 04:37
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Aaron Chiandet
@achiandet
Jan 24 2016 04:37
and [j] is what I need to multiply product by
hulk
@phillworden
Jan 24 2016 04:37
having problems figuring out how to use .hasOwnProperty
can anyone help?
Jamela
@Jamela08
Jan 24 2016 04:38
@phillworden
hulk
@phillworden
Jan 24 2016 04:38
yes?
Jamela
@Jamela08
Jan 24 2016 04:38
should be this return myObj[checkProp]
;
and then put something like
hulk
@phillworden
Jan 24 2016 04:39
it worked
Jamela
@Jamela08
Jan 24 2016 04:39
if (myObj.hasOwnProperty(checkProp)===true)
Cole Perkins
@coleperkins
Jan 24 2016 04:39
@achiandet Correct! But you have to post arr[I][j] in order to show that you accessing array 'i' and multiplying by 'j'
Jamela
@Jamela08
Jan 24 2016 04:39
mine was like this
hulk
@phillworden
Jan 24 2016 04:39
how do i give you brownie points?
Jamela
@Jamela08
Jan 24 2016 04:39
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)===true){
return myObj[checkProp];
}
else {
return "Not Found";
}
}
Aaron Chiandet
@achiandet
Jan 24 2016 04:40
I see, thanks again @coleperkins. I appreciate you taking the time to clarify that.
CamperBot
@camperbot
Jan 24 2016 04:40
achiandet sends brownie points to @coleperkins :sparkles: :thumbsup: :sparkles:
:warning: achiandet already gave coleperkins points
Cole Perkins
@coleperkins
Jan 24 2016 04:40
@maxschlosser thanks!
CamperBot
@camperbot
Jan 24 2016 04:40
coleperkins sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 310 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
hulk
@phillworden
Jan 24 2016 04:40
how do you give brownie points?
Aaron Chiandet
@achiandet
Jan 24 2016 04:40
that + @username
Cole Perkins
@coleperkins
Jan 24 2016 04:40
@achiandet You aren't actually multiplying by 'i', just showing the computer to access 'j' in 'i' of arr.
Aaron Chiandet
@achiandet
Jan 24 2016 04:40
thanks*
hulk
@phillworden
Jan 24 2016 04:41
brownie points @Jamela08
didnt work
Jamela
@Jamela08
Jan 24 2016 04:41
aww thanks
hulk
@phillworden
Jan 24 2016 04:41
lol
Jamela
@Jamela08
Jan 24 2016 04:41
but i think i need brownies coding makes me hungry
hulk
@phillworden
Jan 24 2016 04:41
haha truuuu
brownie points + @Jamela08
Alexander Lamm
@ALamm
Jan 24 2016 04:42
@Jamela08 good one : )
hulk
@phillworden
Jan 24 2016 04:42
idek how to give brownie points ;...((
Jamela
@Jamela08
Jan 24 2016 04:42
and cafe latte
would be great lol
hulk
@phillworden
Jan 24 2016 04:43
seriously i wanna know how to give people brownie points
Cole Perkins
@coleperkins
Jan 24 2016 04:43
@phillworden say "@jamela08 thanks!
CamperBot
@camperbot
Jan 24 2016 04:43
coleperkins sends brownie points to @phillworden and @jamela08 :sparkles: :thumbsup: :sparkles:
:star: 215 | @jamela08 | http://www.freecodecamp.com/jamela08
:star: 216 | @phillworden | http://www.freecodecamp.com/phillworden
hulk
@phillworden
Jan 24 2016 04:43
oooooo
@Jamela08 thanks!
CamperBot
@camperbot
Jan 24 2016 04:43
phillworden sends brownie points to @jamela08 :sparkles: :thumbsup: :sparkles:
:star: 216 | @jamela08 | http://www.freecodecamp.com/jamela08
Jamela
@Jamela08
Jan 24 2016 04:43
aww thank
s
hulk
@phillworden
Jan 24 2016 04:43
ayyyyy i did it!
Jamela
@Jamela08
Jan 24 2016 04:43
great hulk
hulk
@phillworden
Jan 24 2016 04:43
@coleperkins thanks man!
CamperBot
@camperbot
Jan 24 2016 04:43
phillworden sends brownie points to @coleperkins :sparkles: :thumbsup: :sparkles:
:star: 251 | @coleperkins | http://www.freecodecamp.com/coleperkins
Jamela
@Jamela08
Jan 24 2016 04:43
:)
will camperbot receive brownie points?
Thanks @camperbot
CamperBot
@camperbot
Jan 24 2016 04:44
jamela08 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1008 | @camperbot | http://www.freecodecamp.com/camperbot
Jamela
@Jamela08
Jan 24 2016 05:01
can someone help me on this
Rex Schrader
@SaintPeter
Jan 24 2016 05:01
@Jamela08 What is "this"?
Jamela
@Jamela08
Jan 24 2016 05:02
Introducing JavaScript Object Notation JSON
Im just confuse where to put the additional code
Rex Schrader
@SaintPeter
Jan 24 2016 05:03
@Jamela08 You add it on after the last object in the list. You may need to put a comma before it
Aaron Graves
@gravesmeister
Jan 24 2016 05:03
Hello again. I'm having an issue with Comparisons with the Logical Or Operator. Any help.....
Jamela
@Jamela08
Jan 24 2016 05:03

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1993,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,

}

{
"artist":"abc",
"title":"def",
"release_year":1986,
"formats": [
"a",
"b"
]
}

// Add record here
];

Aaron Graves
@gravesmeister
Jan 24 2016 05:03
function myTest(val) {
  // Only change code below this line

  if (val >= 10 || <= 20) {
    return "Outside";
}
  return "Inside";
  // Only change code above this line



// Change this value to test
myTest(10);
Eina
@thelittleblacksmith
Jan 24 2016 05:05
@gravesmeister you have to compare both 10 and 20 to val, currently you're only comparing val to 10
Jamela
@Jamela08
Jan 24 2016 05:05

@SaintPeter you mean after the gold? ar myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1993,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,

"artist":"abc",
"title":"def",
"release_year":1986,
"formats": [
  "a",
  "b"
]

}

// Add record here
];

Rex Schrader
@SaintPeter
Jan 24 2016 05:05
@Jamela08
    ]
   },   // <-- Add comma 
// Add record here
  {
     "artist": "blah blah",
  } 
];
Aaron Graves
@gravesmeister
Jan 24 2016 05:06
@thelittleblacksmith Can you expand please?
Ooops I see what you're saying lol
function myTest(val) {
  // Only change code below this line

  if (val >= 10 || val <= 20) {
    return "Outside";
}
  return "Inside";
  // Only change code above this line



// Change this value to test
myTest(9);
Eina
@thelittleblacksmith
Jan 24 2016 05:07
@gravesmeister does it work now? (also totally off-topic, you're from the other vancouver! cool!)
Jamela
@Jamela08
Jan 24 2016 05:07
@SaintPeter now im confused
Aaron Graves
@gravesmeister
Jan 24 2016 05:08
You from BC? Awesome. I'll trade ya?
@thelittleblacksmith No it still doesn't run
Jamela
@Jamela08
Jan 24 2016 05:08

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1993,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true,

}

{
"artist":"abc",
"title":"def",
"release_year":1986,
"formats": [
"a",
"b"
]
}

// Add record here
];

whats wrong with that one?
hulk
@phillworden
Jan 24 2016 05:08

having trouble with this challenge ```js
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.trees.list[1]; // Change this line

```

Rex Schrader
@SaintPeter
Jan 24 2016 05:09
@Jamela08 Missing a comma between the } and {
hulk
@phillworden
Jan 24 2016 05:09
@Jamela08 put a comma after the closing } of the first element
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees.list[1]; // Change this line
Jamela
@Jamela08
Jan 24 2016 05:09
thanks @SaintPeter
CamperBot
@camperbot
Jan 24 2016 05:09
jamela08 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2374 | @saintpeter | http://www.freecodecamp.com/saintpeter
Jamela
@Jamela08
Jan 24 2016 05:09
Thanks @phillworden the hulk
CamperBot
@camperbot
Jan 24 2016 05:09
jamela08 sends brownie points to @phillworden :sparkles: :thumbsup: :sparkles:
:star: 220 | @phillworden | http://www.freecodecamp.com/phillworden
hulk
@phillworden
Jan 24 2016 05:10
no problem
Aaron Graves
@gravesmeister
Jan 24 2016 05:10
HULK SMASH JAVASCRIPT
hulk
@phillworden
Jan 24 2016 05:10
lol
Aaron Graves
@gravesmeister
Jan 24 2016 05:10
No seriously
hulk
@phillworden
Jan 24 2016 05:10
RRAAAAAAAAAAA
Aaron Graves
@gravesmeister
Jan 24 2016 05:10
make it go away
Eina
@thelittleblacksmith
Jan 24 2016 05:10
@gravesmeister don't need the equal sign :D
hulk
@phillworden
Jan 24 2016 05:11
what is wrong with my code. im trying to recall the second tree.
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees.list[1]; // Change this line
Aaron Graves
@gravesmeister
Jan 24 2016 05:11
@thelittleblacksmith Still a no go
Mike
@mike259
Jan 24 2016 05:12
@phillworden do you have an error
Aaron Graves
@gravesmeister
Jan 24 2016 05:12
Oh ok. I see something I'm missing
Eina
@thelittleblacksmith
Jan 24 2016 05:12
@phillworden myPlants is an array, so you want to access the array item that has the list of trees
hulk
@phillworden
Jan 24 2016 05:12
cannot read property 'list' of undefined
Aaron Graves
@gravesmeister
Jan 24 2016 05:12
I was missing a curly bracket from the function
hulk
@phillworden
Jan 24 2016 05:12
how do i do that?
Aaron Graves
@gravesmeister
Jan 24 2016 05:13
But I'm still missing someting. It has to do with the calling of the function but I'
m obviously missing something @thelittleblacksmith
Eina
@thelittleblacksmith
Jan 24 2016 05:13
@gravesmeister take a closer look at your greater than's and lesser than's
Gabriel Chan
@Gabriel-Chan
Jan 24 2016 05:13
Hello, I am having some trouble trying to figure out a javascript challenge called Return Early Pattern for Functions

// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0){
return "undefined";
}
else if (b < 0){
return "undefined";
}
else if (a < 0 && b < 0){
return "undefined";
}
// 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);

this is my code
ITCHAKHUN
@itchakhun
Jan 24 2016 05:14
Hi guys, how could nested variable access inside object attribute
Aaron Graves
@gravesmeister
Jan 24 2016 05:14
Should they be opposite? @thelittleblacksmith
Eina
@thelittleblacksmith
Jan 24 2016 05:14
@phillworden this is the lesson about accessing data inside arrays: http://www.freecodecamp.com/challenges/access-array-data-with-indexes
Jamela
@Jamela08
Jan 24 2016 05:15
@Gabriel-Chan what waypoint is this?
Mike
@mike259
Jan 24 2016 05:16
@phillworden you're trying to access the second property in the object you have to add that to your var secondTree
Eina
@thelittleblacksmith
Jan 24 2016 05:16
@gravesmeister yeah , the instructions are a bit tricky
Aaron Graves
@gravesmeister
Jan 24 2016 05:16
I switched them. Still no go
@thelittleblacksmith
Eina
@thelittleblacksmith
Jan 24 2016 05:16
Really? What tests aren't you passing @gravesmeister
hulk
@phillworden
Jan 24 2016 05:17
so it should be myPlants[1][1] @mike259 @thelittleblacksmith
Eina
@thelittleblacksmith
Jan 24 2016 05:17
@phillworden you got the second item in your array, now you gotta access the stuff that's inside that object
Aaron Graves
@gravesmeister
Jan 24 2016 05:17
I'm getting "Unreachable 'myTest' after 'return' on the myTest function call
Eina
@thelittleblacksmith
Jan 24 2016 05:18
Try refreshing?
Aaron Graves
@gravesmeister
Jan 24 2016 05:18
Nope
Eina
@thelittleblacksmith
Jan 24 2016 05:18
Ah I got it
you need to move that bracket before the return 'inside' to after it
Joshua Thomas
@Jkthomas88
Jan 24 2016 05:18
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty(checkProp);

  if (false) return "not Found";
}

// Test your code by modifying these values
checkObj("gift")
Hey guys, I'm on the challenge testing objects for properties....am I close?
Mike
@mike259
Jan 24 2016 05:19
@phillworden try just accessing the second property of the object using indexing.
Eina
@thelittleblacksmith
Jan 24 2016 05:19
@gravesmeister sorry too much scrolling, what i meant is that you're missing a bracket after the return "Inside". if you try refreshing your code you'll see that return inside and a closing curly bracket should be after that comment
hulk
@phillworden
Jan 24 2016 05:19
@Gabriel-Chan it isnt asking for you to have it return a string "undefined". remove the string so its just return ; not return "undefined";
Jamela
@Jamela08
Jan 24 2016 05:19
@Jkthomas88 theres something missing
hulk
@phillworden
Jan 24 2016 05:20
@gconde1974 undefined is a value like 1 2 or 3 not a string
Jamela
@Jamela08
Jan 24 2016 05:20
i agree with the hulk @phillworden @Gabriel-Chan mine worked that way
Joshua Thomas
@Jkthomas88
Jan 24 2016 05:20
@Jamela08 yeah I dont know how to make it return the properties value
Jamela
@Jamela08
Jan 24 2016 05:21
you have to declare something before the false
Gabriel Chan
@Gabriel-Chan
Jan 24 2016 05:21
oh I got it! thank you!
Aaron Graves
@gravesmeister
Jan 24 2016 05:21
@thelittleblacksmith Ok so the first curly bracket is for the function. I thought the false return statement went outside of the if statement
No the first curly bracket is for the if statement
Jamela
@Jamela08
Jan 24 2016 05:21
what is it that it will test as true or false @Jkthomas88 then you put that inside the if (_=true) then do this