Declaring a variable

**For the most part I understand how this code base works, except why we declare a variable with (“”). In the code below why do we declare let result =“”; ? **
Describe your issue in detail here.

Your code so far

// Setup
function phoneticLookup(val) {
let result = "";

// Only change code below this line
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;
}

phoneticLookup("charlie");




That’s an empty/default value. In this case it isn’t really needed, but it can be nice to provide a default value just in case the lookup doesn’t work.

Note - don’t use var. Only use let or const. Here I’d use const.

1 Like