Switch Flashcards

1
Q

Create a switch statement that will alert “Hello” if fruits is “banana”, and “Welcome” if fruits is “apple”.

A
switch (fruits) {
case "Banana":
alert("Hello")
break;
case "Apple":
alert("Welcome")
break;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Add a default case to a switch that will alert(“Neither”) if fruits is neither “banana” nor “apple”.

A

default:

alert(“Neither”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly