QUESTION 1:
why can’t we:
A) combine a switch statement an with if statement ? or
B) use comparison operators like greater than inside a switch statement ?
examples :
FOR EXAMPLE 1(A)
case 1: case 2: case 3:
answer = “Low”;
break;
else if (case >= 4) { //else if case 4 is >= 4
return “this”;
}
FOR EXAMPLE 1(B)
case 1: case 2: case 3:
answer = "Low";
break;
case >= 4: //for a case >= 4
answer = "even higher";
or is there another way to do that?
QUESTION 2
why can’t we use the:
A) a return function instead of having to change a local variable ?
B). console.log() function instead of a local variable ?
for example:
FOR EXAMPLE 2(A)
function caseInSwitch(val) {
let answer = “”; // we do not use this local variable
switch (val) {
case 1:
//answer = “alpha”; // and this
return “alpha”; // but only use this
}
}
FOR EXAMPLE 2(B)
refer to above example, only this time replace the return statement with console.log(“alpha”);