Hello:
I find I am better able to learn and more fully comprehend the material when, in addition to required solution, I test being able to change to alternate code approach for same result. To that end, I completed this challenge and am working to duplicate in ‘conditional ternary’… i am not understanding what the error/failure in translation. I get similar syntax error on repl for this. the conditional ternary attempt starts about line 25 below. thank for your thoughts (yes, I know people don’t gen use or like ternary, not the point). again, thx you anyone that can provide some guidance for me to success identify problem/debug this alternate solution.
**Your code so far**
// function caseInSwitch(val) {
// let answer = "";
// // Only change code below this line
// switch (val) {
// case 1:
// answer = 'alpha';
// break;
// case 2:
// answer = 'beta';
// break;
// case 3:
// answer = 'gamma';
// break;
// case 4:
// answer = 'delta';
// break;
// };
// // Only change code above this line
// return answer;
// }
// caseInSwitch(1);
function caseInSwitch(val) {
return val === 1 ? 'alpha'
: val === 2 ? 'beta'
: val === 3 ? 'gamma'
: val === 4 ? 'delta'
};
caseInSwitch(1);
FreeCodeCamp error message=
SyntaxError: unknown: Unexpected token, expected “:” (31:0)
29 | : val === 4 ? ‘delta’
30 |
31 | };
| ^
32 |
33 | caseInSwitch(1);
Repl IDE error
/home/runner/MessedUpFreeCodeCamp/index.js:99
: val === 4 ? ‘delta’;
^
SyntaxError: Unexpected token ‘;’
Challenge: Selecting from Many Options with Switch Statements
Link to the challenge: