-
-
Save noisy/a232b992fd42a27b2b1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<script src="main.js"></script> | |
<title>odd and even</title> | |
</head> | |
<body> | |
<h2>A</h2><input id="a" type="number"> | |
<h2>B</h2><input id="b" type="number"> | |
<button onclick="run()">Run</button> | |
<h2 id="view"></h2> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function run(){ | |
var a = parseInt(document.getElementById("a").value); | |
var b = parseInt(document.getElementById("b").value); | |
for (var i = a; i <= b; i++){ | |
document.getElementById("view").innerHTML += i + (i % 2 === 0 ? " even" : " odd") + "<br>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment