Professional Documents
Culture Documents
03
Semester:
SPRING 2018 CS101 –Introduction to
Computing
ID:mc180202899
You need to study the following JavaScript code carefully. Write the below code without if-else
to do the same job by using Switch Statement?
switch (true) {
case (MousePosition == 'Div1'):
alert("Div1");
break;
case (MousePosition == 'Div2'):
alert("Div2");
break;
case (MousePosition == 'Div3'):
alert("Div3");
break;
case (MousePosition == 'Div4'):
alert("Div4");
break;
case (MousePosition == 'Div5'):
alert("Div5");
break;
default:
alert("none");
break;