Switch Case Statement : Javascript
Print day : according to number
let day = 5;
switch (day) {
case 1: console.log("Monday");
break;
case 2: console.log("Tuesday");
break;
case 3: console.log("Wednesday");
break;
case 4: console.log("Thurusday");
break;
case 5: console.log("Friday");
break;
case 6: console.log("Saturday");
break;
case 7: console.log("Sunday");
break;
default: console.log("Condition not Fullfilled");
}
-------------------------------------------------------Calculate Area----------------------
let area = "rectangle";
let radius = 5, pi = 3.14
let lentgth = 7, breadth = 10;
switch (area) {
case "rectangle":
const areaOfRec = lentgth * breadth
console.log(areaOfRec);
break;
case "circle":
const areaOfCircle = pi * radius * radius
console.log(areaOfCircle);
break;
case "triangle":
break;
}
Comments
Post a Comment