जावास्क्रिप्ट switch case स्टेटमेंट
Switch case स्टेटमेंट के प्रयोग में विभिन्न condition फलोदी बैंक स्टेटमेंट को एक्सीक्यूट करने हेतु प्रयोग में लाया जाता है। Switch case स्टेटमेंट का सिंटेक्स निम्न है।
switch (n)
{
case 1:
execute code block 1
break;
case 2:
execute code block 2
break :
default:
code to be executed if n age different from case 1 and case 2
}
PRACTICAL :- 3
JAVASCRIPT PRACTICAL :- 3
<html>
<body>
<script type=“text/javascript”>
//You will receive a different greating based
//on what day it is.Note that sunday=0,
//monday=1, tuesday=2, etc.
var d=new date();
the day=d.getday();
document.write(“today the day is”+theday);
switch (theday)
{
case3:
document.write(“finally wednesday”);
break;
case 4:
document.write(“Super Thursday”);
break;
case 0:
document.write(“Sleepy Sunday”);
break;
default:
document.write(“i’m looking forward to this weekend!”);
}
</script>
</body>
</html>