Skip to content

Instantly share code, notes, and snippets.

@afrieirham
Last active February 9, 2019 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afrieirham/a7c4bfae1c115b557e5c3d0edf9d97c6 to your computer and use it in GitHub Desktop.
Save afrieirham/a7c4bfae1c115b557e5c3d0edf9d97c6 to your computer and use it in GitHub Desktop.
Basic JavaScript: Using Objects for Lookups #FCC
// Setup
function phoneticLookup(val) {
var result = "";
let lookup = {
alpha: 'Adams',
bravo: 'Boston',
charlie: 'Chicago',
delta: 'Denver',
echo: 'Easy',
foxtrot: 'Frank',
}
result = lookup[val];
return result;
}
// Change this value to test
phoneticLookup("alpha");
phoneticLookup("bravo");
phoneticLookup("charlie");
phoneticLookup("delta");
phoneticLookup("echo");
phoneticLookup("foxtrot");
phoneticLookup("");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment