switch case in function code example

Example 1: switch function

var rand = Math.round(random(1,4));
        
    switch(rand){
        case 1: console.log("Chosen Number : 1");
        break;
        case 2: console.log("Chosen Number : 2");
        break;
        case 3: console.log("Chosen Number : 3");
        break;
        case 4: console.log("Chosen Number : 4");
        default: break;
    }

Example 2: switch case in

function whatToDrink(time){
    var drink ;
          switch (time) {
            case "morning":
              drink = "Tea";
              break;
            case "evening":
              drink = "Shake";
              break;
            default:
              drink="Water";   
          }
  	return drink;
}
console.log(whatToDrink("morning")) //Tea
console.log(whatToDrink("evening")) //Shake
console.log(whatToDrink("night"))   //Water
console.log(whatToDrink("daytime")) //Water