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; }
2
Q
Add a default case to a switch that will alert(“Neither”) if fruits is neither “banana” nor “apple”.
A
default:
alert(“Neither”);