Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

The switch Statement

//The switch Statement
const day = prompt(`write a week day`);

switch (day) {
  case "monday": 
    console.log("Go to gym in the morning");
    console.log(`Come back home and spend time with my lovely wife`);
    break;
  case "tuesday":
    console.log(`Sleep long with ZIZI`);
    break;
  case "wednesday":
  case "thursday":
    console.log(
      `Get up and go in university with ZIZI and then take care of BAQSI`
    );
    break;
  case "friday":
    console.log(`Test some games in my work`);
    break;
  case "saturday":
  case "sunday":
    console.log(`Enjoy the weekend with ZIZI `);
    break;
  default:
    console.log(`Not a valid day`);
}
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #The #switch #Statement
ADD COMMENT
Topic
Name
3+2 =