Define Area in switch case
let area = "circle";
let PI = 3.142,
l = 9,
b = 7,
r = 6;
switch (area) {
case "circle":
console.log("Area of the circle is : " + PI * r ** 2);
break;
case "triangle":
console.log("Area of the triangle is : " + (l * b) / 2);
break;
case "rectangle":
break;
console.log("Area of the rectangle is : " + l * b);
default:
console.log("please enter valid data");
}
Output
Area of the circle is : 113.112