Sử dụng prompt() nhập 2 số, kiểm tra tích có lớn hơn 50 không, hiển thị kết quả bằng document.write().
Mã HTML/JS
<!DOCTYPE html>
<html lang="en"> ... <body></body>
<script>
var firstvalue = parseInt(prompt("Enter the value1"));
var secondvalue = parseInt(prompt("Enter the value2"));
if (firstvalue * secondvalue > 50) document.write("<h1>Result is correct</h1>");
else document.write("<h1>Result is not correct</h1>");
</script>
</html>
Kết quả
Nhập 10 và 10 → tích 100 > 50 → hiển thị "Result is correct".