Using Objects for Lookups: Tests Aren't Running

Using Objects for Lookups: Tests Aren't Running
0

#1

Tell us what’s happening:
Every time I hit “Run the Tests” on this challenge, nothing happens–it doesn’t pass, nor do I get any messages on which parts of the challenge I have succeeded or failed at. I’m not sure that I’m getting the code entirely right, but right now I’m not even getting messages saying I got it wrong.

I tried refreshing my browser, and exiting and re-loading the browser altogether. Is there something else I need to do?

Thanks!

Your code so far


// 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";
  }

  lookup.alpha;

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

// Change this value to test
phoneticLookup("charlie");

Your browser information:

User Agent is: Chrome/68.0.3440.106 .

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups/


#2

It’s because you didn’t implement anything on the result variable, that is what returned to the output.

You should access the argument, not the value directly
Hint: Access the argument and store it inside result


#3

Thanks. I’m still having a bit of trouble with this part. I’ve changed the following line:
lookup.alpha;
to this:
result = lookup.val;

I thought that lookup.val accessed the argument, and result = then assigned whatever value came from lookup.val to the result that was returned. But I’m still not
getting anything when I run the tests. I’m also not getting anything in the console when I change the value at the bottom–phoneticLookup(“delta”);.

Can you help me make sense of this?


#4

val is a variable. To use variables to reference object properties, you should review this previous lesson.


#5

You are almost there, dot operators are used to access the props, well here val is an argument, and lookup is an object to which val should be passed to retrieve the value of the props inside lookup , try to figure out how to access items inside the lookup using the val


#6

I got it! Thanks for your help, everyone!

It worked when I replaced the semicolons inside my object with commas. So, to be clear: commas are necessary because I’m separating different properties/values within the object, and semicolons are used to execute commands? (More or less?)


#7

Semicolons define the end of a statements.