This commit adds the pre-existing challenge guide topics in the forum to the forntmatter of their challenge markdown files.
		
			
				
	
	
	
		
			2.6 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.6 KiB
		
	
	
	
	
	
	
	
id, title, challengeType, videoUrl, forumTopicId
| id | title | challengeType | videoUrl | forumTopicId | 
|---|---|---|---|---|
| 56533eb9ac21ba0edf2244dd | Selecting from Many Options with Switch Statements | 1 | https://scrimba.com/c/c4mv4fm | 18277 | 
Description
switch statement. A switch statement tests a value and can have many case statements which define various possible values. Statements are executed from the first matched case value until a break is encountered.
Here is a pseudocode example:
switch(num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
...
  case valueN:
    statementN;
    break;
}
case values are tested with strict equality (===). The break tells JavaScript to stop executing statements. If the break is omitted, the next statement will be executed.
Instructions
val and sets answer for the following conditions:1 - "alpha"2 - "beta"3 - "gamma"4 - "delta"
Tests
tests:
  - text: <code>caseInSwitch(1)</code> should have a value of "alpha"
    testString: assert(caseInSwitch(1) === "alpha");
  - text: <code>caseInSwitch(2)</code> should have a value of "beta"
    testString: assert(caseInSwitch(2) === "beta");
  - text: <code>caseInSwitch(3)</code> should have a value of "gamma"
    testString: assert(caseInSwitch(3) === "gamma");
  - text: <code>caseInSwitch(4)</code> should have a value of "delta"
    testString: assert(caseInSwitch(4) === "delta");
  - text: You should not use any <code>if</code> or <code>else</code> statements
    testString: assert(!/else/g.test(code) || !/if/g.test(code));
  - text: You should have at least 3 <code>break</code> statements
    testString: assert(code.match(/break/g).length > 2);
Challenge Seed
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);
Solution
function caseInSwitch(val) {
  var answer = "";
  switch(val) {
    case 1:
      answer = "alpha";
      break;
    case 2:
      answer = "beta";
      break;
    case 3:
      answer = "gamma";
      break;
    case 4:
      answer = "delta";
  }
  return answer;
}