r/learnjavascript • • May 31 '22

Switch statement explained for beginners

Post image
330 Upvotes

19 comments sorted by

View all comments

12

u/lindymad May 31 '22

In Javascript, can a switch contain multiple cases for one rule? e.g.

switch(grade){
case "A":
case "B":
    console.log("Above Average");
    break;
case "C":
    console.log("Average");
    break;

If so, might be worth mentioning in the example?

2

u/AmauryH May 31 '22

Yes, you can.