throw Satement in Javascript

Sabarimahesh
Posted by Sabarimahesh under JavaScript category on | Points: 40 | Views : 983
var x=prompt("Enter 1 t0 10 ,"");
try
{
if(x==1)
{
throw "One";
}
else if(x<5)
{
throw "X greater five";
}

}
catch(Error)
{
if(Error=="One")
{
document.write("Error 1.");
}
if(Error==X greater five")
{
document.write("Error 2);
}

}

Comments or Responses

Login to post response