Var result = "";?

Var result = "";?
0

#1

What does var result = “”; do exactly in this function?

// 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”,
};
result = lookup[val];
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup(“charlie”);


#2

It defines a variable named result and sets its value to an empty string. You could have just as easily deleted that and written further down

var result = lookup[val];

to have the result returned.


#3

It’s just declaring the variable and setting it’s datatype as a ""; (which means ‘a string’ in coding language). Later on it’s populated with the returned result from lookup.