Files

37 lines
779 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Using Objects for Lookups
---
# Using Objects for Lookups
2018-10-12 15:37:13 -04:00
---
## Solutions
2018-10-12 15:37:13 -04:00
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2018-10-12 15:37:13 -04:00
```javascript
function phoneticLookup(val) {
var result = "";
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
// After converting our case statements into object properties you can make use of the variable `result` to let the function return the correct value.
2018-10-12 15:37:13 -04:00
result = lookup[val];
// Only change code above this line
return result;
}
```
2018-10-12 15:37:13 -04:00
#### Relevant Links
2018-10-12 15:37:13 -04:00
- ["JavaScript object basics" - *MDN JavaScript reference*](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics)
</details>
2018-10-12 15:37:13 -04:00