Hi everybody,
I have a question about the “Using Objects for Lookups” challenge, even though I found the solution I was wondering about the fact that we have to remove the var keyword from the result variable even though it is inside a function which result in a global variable inside a function which is not so good as you can see in my code bellow
// Setup
function phoneticLookup(val) {
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
result = lookup[val];
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
I would like to know why we have to remove the var keyword for it to pass the test
Thanks