71 lines
1.4 KiB
Markdown
71 lines
1.4 KiB
Markdown
|
---
|
||
|
id: 56533eb9ac21ba0edf2244dd
|
||
|
title: Selecting from Many Options with Switch Statements
|
||
|
challengeType: 1
|
||
|
videoUrl: ''
|
||
|
localeTitle: ''
|
||
|
---
|
||
|
|
||
|
## Description
|
||
|
undefined
|
||
|
|
||
|
## Instructions
|
||
|
undefined
|
||
|
|
||
|
## Tests
|
||
|
<section id='tests'>
|
||
|
|
||
|
```yml
|
||
|
tests:
|
||
|
- text: ''
|
||
|
testString: 'assert(caseInSwitch(1) === "alpha", "<code>caseInSwitch(1)</code> should have a value of "alpha"");'
|
||
|
- text: ''
|
||
|
testString: 'assert(caseInSwitch(2) === "beta", "<code>caseInSwitch(2)</code> should have a value of "beta"");'
|
||
|
- text: ''
|
||
|
testString: 'assert(caseInSwitch(3) === "gamma", "<code>caseInSwitch(3)</code> should have a value of "gamma"");'
|
||
|
- text: ''
|
||
|
testString: 'assert(caseInSwitch(4) === "delta", "<code>caseInSwitch(4)</code> should have a value of "delta"");'
|
||
|
- text: ''
|
||
|
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||
|
- text: ''
|
||
|
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Challenge Seed
|
||
|
<section id='challengeSeed'>
|
||
|
|
||
|
<div id='js-seed'>
|
||
|
|
||
|
```js
|
||
|
function caseInSwitch(val) {
|
||
|
var answer = "";
|
||
|
// Only change code below this line
|
||
|
|
||
|
|
||
|
|
||
|
// Only change code above this line
|
||
|
return answer;
|
||
|
}
|
||
|
|
||
|
// Change this value to test
|
||
|
caseInSwitch(1);
|
||
|
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Solution
|
||
|
<section id='solution'>
|
||
|
|
||
|
```js
|
||
|
// solution required
|
||
|
```
|
||
|
</section>
|