Last active
August 29, 2015 14:20
-
-
Save lenka21/0a465f4b25d238cf32b6 to your computer and use it in GitHub Desktop.
Parzyste, nieparzyste
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++){ | |
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