Merge pull request #9410 from JamesWorsnop/fix/replacingifelsechains
Fixing if/if else text in replacing if else chains with switch challenge
This commit is contained in:
@ -3602,12 +3602,12 @@
|
|||||||
"id": "56533eb9ac21ba0edf2244e0",
|
"id": "56533eb9ac21ba0edf2244e0",
|
||||||
"title": "Replacing If Else Chains with Switch",
|
"title": "Replacing If Else Chains with Switch",
|
||||||
"description": [
|
"description": [
|
||||||
"If you have many options to choose from, a <code>switch</code> statement can be easier to write than many chained <code>if</code>/<code>if else</code> statements. The following:",
|
"If you have many options to choose from, a <code>switch</code> statement can be easier to write than many chained <code>if</code>/<code>else if</code> statements. The following:",
|
||||||
"<blockquote>if (val === 1) {<br> answer = \"a\";<br>} else if (val === 2) {<br> answer = \"b\";<br>} else {<br> answer = \"c\";<br>}</blockquote>",
|
"<blockquote>if (val === 1) {<br> answer = \"a\";<br>} else if (val === 2) {<br> answer = \"b\";<br>} else {<br> answer = \"c\";<br>}</blockquote>",
|
||||||
"can be replaced with:",
|
"can be replaced with:",
|
||||||
"<blockquote>switch (val) {<br> case 1:<br> answer = \"a\";<br> break;<br> case 2:<br> answer = \"b\";<br> break;<br> default:<br> answer = \"c\";<br>}</blockquote>",
|
"<blockquote>switch (val) {<br> case 1:<br> answer = \"a\";<br> break;<br> case 2:<br> answer = \"b\";<br> break;<br> default:<br> answer = \"c\";<br>}</blockquote>",
|
||||||
"<h4>Instructions</h4>",
|
"<h4>Instructions</h4>",
|
||||||
"Change the chained <code>if</code>/<code>if else</code> statements into a <code>switch</code> statement."
|
"Change the chained <code>if</code>/<code>else if</code> statements into a <code>switch</code> statement."
|
||||||
],
|
],
|
||||||
"releasedOn": "January 1, 2016",
|
"releasedOn": "January 1, 2016",
|
||||||
"challengeSeed": [
|
"challengeSeed": [
|
||||||
|
Reference in New Issue
Block a user