Weird I used the ask for help button inside that lesson called: Basic JavaScript: Using Objects for Lookups
with that code inside it? Could you elaborate what you mean excatly?
well you might be right there i did find it odd that i could’t find the switch one
i go reset the lesson see if it helps :3
Update:
Something is not quite right. A report has been generated and the freeCodeCamp.org team have been notified.
seems like there was an error somwhere
// Setup
function phoneticLookup(val) {
var result = "";
// Only change code below this line
var lookup = {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}
var lookup = "var";
lookup [result];
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
// 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 [val]; // "val"
var value = result;
result[val]; // "val"
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("val");
Thanks that helped :3
i removed the extra space
and deleted the extra lines
// Setup
function phoneticLookup(val) {
var result = "";
// Only change code below this line
var lookup = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};
var result = lookup;
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("val");
the last lines are troublesome
Use it to look up val and assign the associated string to the result variable.
the example they give out is kinda vague for me as well
how do you access an object property using a variable? that’s what you need to remember. there is a challenge just on this if you need to review
be careful of not changing the object before accessing the property. it you write lookup = "val" you are overwriting the object, and so can’t access the property anymore
right now you are just returning the lookup object (per the line result = lookup)