Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript throw Statement</title> </head> <body> <script> var num = prompt("Please enter an integer value"); try { if(num == "" || num == null || !Number.isInteger(+num)) { throw new Error("Invalid value!"); } else { document.write("Correct value!"); } } catch(e) { document.write(e.message); } </script> </body> </html>