--- id: 56533eb9ac21ba0edf2244e0 title: Replacing If Else Chains with Switch challengeType: 1 videoUrl: '' localeTitle: '' --- ## Description undefined ## Instructions undefined ## Tests
```yml tests: - text: '' testString: 'assert(!/else/g.test(code), "You should not use any else statements anywhere in the editor");' - text: '' testString: 'assert(!/if/g.test(code), "You should not use any if statements anywhere in the editor");' - text: '' testString: 'assert(code.match(/break/g).length >= 4, "You should have at least four break statements");' - text: '' testString: 'assert(chainToSwitch("bob") === "Marley", "chainToSwitch("bob") should be "Marley"");' - text: '' testString: 'assert(chainToSwitch(42) === "The Answer", "chainToSwitch(42) should be "The Answer"");' - text: '' testString: 'assert(chainToSwitch(1) === "There is no #1", "chainToSwitch(1) should be "There is no #1"");' - text: '' testString: 'assert(chainToSwitch(99) === "Missed me by this much!", "chainToSwitch(99) should be "Missed me by this much!"");' - text: '' testString: 'assert(chainToSwitch(7) === "Ate Nine", "chainToSwitch(7) should be "Ate Nine"");' - text: '' testString: 'assert(chainToSwitch("John") === "", "chainToSwitch("John") should be "" (empty string)");' - text: '' testString: 'assert(chainToSwitch(156) === "", "chainToSwitch(156) should be "" (empty string)");' ```
## Challenge Seed
```js function chainToSwitch(val) { var answer = ""; // Only change code below this line if (val === "bob") { answer = "Marley"; } else if (val === 42) { answer = "The Answer"; } else if (val === 1) { answer = "There is no #1"; } else if (val === 99) { answer = "Missed me by this much!"; } else if (val === 7) { answer = "Ate Nine"; } // Only change code above this line return answer; } // Change this value to test chainToSwitch(7); ```
## Solution
```js // solution required ```