Wednesday, May 17, 2017

Throw statement in Java Script in HTML

<html>
<body>
<script language= "javascript"type="text/javascript">
var x = prompt("Enter a number between 0 and 10:","")
try
{
if(x>10)
throw "Err1"
else if(x<0)
throw "Err2"
}
catch(err)
{
if(er=="Err1")
alert("Error! the value is too high"
if(er=="Err2")
alert("Error! the value is too low"
}
</script>
</body>
</html>

No comments:

Post a Comment