जावास्क्रिप्ट if else स्टेटमेंट
जावास्क्रिप्ट if else स्टेटमेंट का सिंटेक्स निम्न है:
if (condition)
{
stmt; stmt; // अगर उपरोक्त condition true है तो या स्टेटमेंट्स एक्सीक्यूट होंगे
}
else
{
stmt; stmt;// अगर उपरोक्त condition false हैं तो यह स्टेटमेंट एक्सीक्यूट होंगे
}
javascript practical:- 1
<html>
<body>
<script type=“text/javascript”>
//if the time is less than 10, you will get a “good morning” greating.
// otherwise you will get a “good morning” greating.
var d =new date();
var time =d.get hourse();
if(time <12)
{
document.write(“good morning”)
}
else
{
document.write(“good morning”);
}
</script>
</body>
</html>