Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • May 10 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 25 17:12
    @mstellaluna banned @cmal
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:09
    thecodingaviator commented #31179
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:07
    thecodingaviator commented #31182
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator commented #31190
  • Apr 01 18:05
    thecodingaviator commented #31157
  • Apr 01 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

  • Apr 01 18:04
    thecodingaviator closed #31157
  • Apr 01 18:04
    thecodingaviator closed #33788
  • Apr 01 18:04
    thecodingaviator commented #33788
  • Apr 01 18:02
    thecodingaviator closed #31059
  • Apr 01 18:02
    thecodingaviator commented #31059
Nate Petersen
@blueExcess
@AliMusa8790 Haha, no worries. You wouldn't believe how long it took me to get some of these concepts. So what you need to do now is point result to the correct value.
Guzman Monne
@guzmonne
@chris1819 what is the error now? because that function if you pass "a" should return "staff", but not an error anymore.
chris1819
@chris1819
thats exactly what it passed. "stuff"
Ariel
@ArielLeslie
@chris1819 You are passing myTest the character a, but you are only checking it against 1, 2, and 3 so you should just get stuff in the return
Nate Petersen
@blueExcess
charlie would be the property, while Chicago would be the value of charlie, except that they're all under one heading essentially.
Ali Musa
@AliMusa8790
so would it be: var result = lookup.something?
chris1819
@chris1819
yes, that is what the directions are telling me to do.as i understand them anyhow.
Guzman Monne
@guzmonne
@chris1819 And will only return something else if you pass 1, 2 or 3. I don't know if the function should do something else. What test is failing?
Nate Petersen
@blueExcess
@AliMusa8790 exactly! But in bracket notation. result=lookup[xxx]
Ariel
@ArielLeslie
@chris1819 I don't think that's what it's supposed to do. What is it supposed to return when you pass it a?
chris1819
@chris1819
myTest("a") should have a value of "apple"
myTest("b") should have a value of "bird"
myTest("c") should have a value of "cat"
Guzman Monne
@guzmonne
@chris1819 You have wrong tests on the switch statement
Ariel
@ArielLeslie
@chris1819 But none of those will happen the only thing that will return "apple" is myTest(1)
because you have
case 1:
      answer = "apple";
      break;
Guzman Monne
@guzmonne
@chris1819 You are checking for numbers instead of strings. Change your numbers for "a", "b" and "c"
Ali Musa
@AliMusa8790
@blueExcess so would it be result = lookup[val]?
Nate Petersen
@blueExcess
@blueExcess bracket notation should be used when you're using a variable or if there's a space in the name of the property (lookup[variable] or lookup["variable one"])
Ali Musa
@AliMusa8790
with a semicolon
Nate Petersen
@blueExcess
@AliMusa8790 You've got it :)
chris1819
@chris1819
thats what i thought but the red X's tell me it should say. the checks that it is doing to advance to the next lesson
Ali Musa
@AliMusa8790
Hooray! I'm having some difficulty understanding when and when not to use quotations
Ariel
@ArielLeslie
@chris1819 Why are you doing a switch block looking for numbers?
@AliMusa8790 How so?
chris1819
@chris1819
Got it. Silly (confusing) directions. Thats why IKEA is so popular.Thanks a lot.
Norman Dela Cruz
@dcnr

@AliMusa8790 eh don't call yourself stupid
Objects have key(or property)/value pairs

var myObj = {
  property : "value"
}

And you can access them with . or with []
If you use the . notation, you should specify the literal name of the property

var person = {
  name: "Ali"
}

With the . you will look it up as

result = person.name;

and result will be "Ali"

With the [] notation, you can use it two ways. The first one is like the . and it would look like

result = person["name"]; // result is "Ali"

note the ""

The other way of using the [] is with variables.

var propertyWanted = "name";
result = person[propertyWanted]; // result is "Ali"

note that there are no ""

And that's just about it. Sorry took too long to type.

Ali Musa
@AliMusa8790
@ArielLeslie I don't know, honestly. Most of the time I understand what FCC is asking me to do at that very moment but sometimes even on the next step, I completely forget what I just learned in the previous step. I don't know if I'm just not understanding it, or my memory is shot or what.
penzinho
@penzinho
Could someone please help me with Adding a default option in Switch statements
Nate Petersen
@blueExcess
@AliMusa8790 @dcnr just explained it better than I ever could have haha
penzinho
@penzinho
I'm stuck :smile:
http://bit.ly/1KBIKeL is the problem
my code is:

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

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

// Change this value to test
myTest(a);

and I get ReferenceError: a is not defined
Nate Petersen
@blueExcess
@penzinho you need to put quotations around the a I think
Ariel
@ArielLeslie
@AliMusa8790 For one thing, you're probably cramming a lot into your head at a fast pace. That might mean you're retaining less and it would be a good idea to slow it down and really play with each new thing you learn to help it sink in before moving on. Another thing is just that a huge part of learning to program is just repetition. Using tools and skills over and over in slightly different ways until they become second nature
penzinho
@penzinho
I've tried and I get the same error
I've tried with and without quotations in all case
cases
Ariel
@ArielLeslie
@penzinho when you don't put a in quotes, it thinks it's a variable name
chris1819
@chris1819
thats it. just got it myself. the myTest function at bottom needs " "
your firs case a need quate marks
Ali Musa
@AliMusa8790
@ArielLeslie you're probably right about the cramming. But I was under the impression that you continue doing the steps every day for as long as possible, step by step until you reach the end? Am I just approaching this all wrong?
penzinho
@penzinho
@chris1819 thank you very much mate, that was it!
CamperBot
@camperbot
penzinho sends brownie points to @chris1819 :sparkles: :thumbsup: :sparkles:
:star: 202 | @chris1819 | http://www.freecodecamp.com/chris1819
penzinho
@penzinho
stupid me, I've been focusing on code itself instead of mytest
chris1819
@chris1819
two silly questions here. How do you address replys to someones screenname and what are brownie points?
Sergey
@SZharkov
// 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 (prop !== "tracks") {
  if (value !== ""){
    return collection[id].prop.value;
  } else {
    delete collection[id].prop;
  }
}

}

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

Task : 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.
What's wrong?

Ariel
@ArielLeslie
@AliMusa8790 It's not wrong per se. The important thing is not to move forward until you really "get" what you just did, even if that makes you slower. This isn't like school where you just want to pass everything and call it done. You're here because you want to learn and understand, so you're only shortchanging yourself by rushing. Sometimes you just need to give your brain time to absorb too. After something particularly tricky: have a snack, go for a walk, try for a good poop, play with a dog.
greg
@wearenotgroot
@SZharkov use bracket notation