Skip to content

Instantly share code, notes, and snippets.

@lenka21
Last active August 29, 2015 14:20
Show Gist options
  • Save lenka21/0a465f4b25d238cf32b6 to your computer and use it in GitHub Desktop.
Save lenka21/0a465f4b25d238cf32b6 to your computer and use it in GitHub Desktop.
Parzyste, nieparzyste
<!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++){
if (i % 2 === 0){
var result = (i + " even" + "<br>");
} else {
var result = (i + " odd" + "<br>");
}
document.getElementById("view").innerHTML += result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment