Skip to content

Instantly share code, notes, and snippets.

@noisy
Forked from lenka21/index.html
Last active August 29, 2015 14:20
Show Gist options
  • Save noisy/a232b992fd42a27b2b1b to your computer and use it in GitHub Desktop.
Save noisy/a232b992fd42a27b2b1b to your computer and use it in GitHub Desktop.
<!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>
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