In this example, We have two variables grade with value as "A" and message as blank and we will pass this grade to switch statement and this will result back with message as "Excellent". here is the JavaScript switch
statement: switch (grade) { case 'A': message = "Excellent"; break; case 'B': message = "Good"; break; case 'C': message = "OK"; break; case 'D': message = "Mmmmm...."; break; case 'E': message = "You must do better than this"; break; default: message = "What is your grade anyway?"; break; } See the code snippet and its output: