96 lines
2.3 KiB
Markdown
96 lines
2.3 KiB
Markdown
|
---
|
||
|
id: 56533eb9ac21ba0edf2244ca
|
||
|
title: Using Objects for Lookups
|
||
|
challengeType: 1
|
||
|
videoUrl: ''
|
||
|
localeTitle: ''
|
||
|
---
|
||
|
|
||
|
## Description
|
||
|
undefined
|
||
|
|
||
|
## Instructions
|
||
|
undefined
|
||
|
|
||
|
## Tests
|
||
|
<section id='tests'>
|
||
|
|
||
|
```yml
|
||
|
tests:
|
||
|
- text: ''
|
||
|
testString: 'assert(phoneticLookup("alpha") === "Adams", "<code>phoneticLookup("alpha")</code> should equal <code>"Adams"</code>");'
|
||
|
- text: ''
|
||
|
testString: 'assert(phoneticLookup("bravo") === "Boston", "<code>phoneticLookup("bravo")</code> should equal <code>"Boston"</code>");'
|
||
|
- text: ''
|
||
|
testString: 'assert(phoneticLookup("charlie") === "Chicago", "<code>phoneticLookup("charlie")</code> should equal <code>"Chicago"</code>");'
|
||
|
- text: ''
|
||
|
testString: 'assert(phoneticLookup("delta") === "Denver", "<code>phoneticLookup("delta")</code> should equal <code>"Denver"</code>");'
|
||
|
- text: ''
|
||
|
testString: 'assert(phoneticLookup("echo") === "Easy", "<code>phoneticLookup("echo")</code> should equal <code>"Easy"</code>");'
|
||
|
- text: ''
|
||
|
testString: 'assert(phoneticLookup("foxtrot") === "Frank", "<code>phoneticLookup("foxtrot")</code> should equal <code>"Frank"</code>");'
|
||
|
- text: ''
|
||
|
testString: 'assert(typeof phoneticLookup("") === "undefined", "<code>phoneticLookup("")</code> should equal <code>undefined</code>");'
|
||
|
- text: ''
|
||
|
testString: 'assert(code.match(/return\sresult;/), "You should not modify the <code>return</code> statement");'
|
||
|
- text: ''
|
||
|
testString: 'assert(!/case|switch|if/g.test(code.replace(/([/]{2}.*)|([/][*][^/*]*[*][/])/g,"")), "You should not use <code>case</code>, <code>switch</code>, or <code>if</code> statements"); '
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Challenge Seed
|
||
|
<section id='challengeSeed'>
|
||
|
|
||
|
<div id='js-seed'>
|
||
|
|
||
|
```js
|
||
|
// Setup
|
||
|
function phoneticLookup(val) {
|
||
|
var result = "";
|
||
|
|
||
|
// Only change code below this line
|
||
|
switch(val) {
|
||
|
case "alpha":
|
||
|
result = "Adams";
|
||
|
break;
|
||
|
case "bravo":
|
||
|
result = "Boston";
|
||
|
break;
|
||
|
case "charlie":
|
||
|
result = "Chicago";
|
||
|
break;
|
||
|
case "delta":
|
||
|
result = "Denver";
|
||
|
break;
|
||
|
case "echo":
|
||
|
result = "Easy";
|
||
|
break;
|
||
|
case "foxtrot":
|
||
|
result = "Frank";
|
||
|
}
|
||
|
|
||
|
// Only change code above this line
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
// Change this value to test
|
||
|
phoneticLookup("charlie");
|
||
|
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Solution
|
||
|
<section id='solution'>
|
||
|
|
||
|
```js
|
||
|
// solution required
|
||
|
```
|
||
|
</section>
|