Hi lexi,
You are nearly there! Andre sent you on the right track and you now test ‘val’. If you re-read the instruction, then that should have followed from there:
Write a switch statement which tests
val
and setsanswer
for the following conditions:
So it expects your switch to take the variable val and test that, like so:
switch(val){
...
}
Then from the table we see the outcome of the test and what answer it should yield:
1 - alpha
2 - beta
3 - gamma
4 - delta
If no type is given, this means ‘the number 4’ and ‘the string delta’. So your case tests should read like
switch(val){
case 1 : // no quotes as we test a number
answer = "alpha"; // the assignment tells us to 'set answer'
break;
...
}
The switch will take the value passed into the function caseInSwitch(val){..}
and test it in the switch switch(val){...}
against the known outcomes 1,2,3,4 for case
and when found, it sets the value for answer
to the correct string, and then steps out of the switch with break
.
You can leave the last break
out as the switch
is finished but leaving it there is absolutely fine (and consistent).
Very close! Keep going, you’re doing great.