I wrote a small javascript code, but it has a problem, the page can not show anything. I think the problem is in the line "else if..." or "else...", because if I comment these two lines, the code runs without any problem
<html>
<head>
<script language="javascript">
var var1 = window.prompt("please input");
var var2 = window.prompt("please input2");
var1 = parseFloat(var1);
var2 = parseFloat(var2);
if (var1< var2) {document.writeln("the second number is bigger")};
else if (var1> var2) {document.writeln("the first number is bigger")};
else {document.writeln("They are the same")};
</script>
</head>
<body>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire