My assignment for my programming class is to create a script using JavaScript that asks a user to enter a number in a pop up dialog box on their browser, and then tell them if they entered an odd or an even number. This is what I have come up with so far, whenever I test it on a browser it says that every number is even. I have dug through my textbook looking for answers, but that has not helped much. All I am asking for is a push in the right direction. Thanks.
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Exercise 6.27: 6.27.html -->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Exercise 6.27</title>
<script type="text/javascript">
var numberS; //number as a string
var numberI; //number as an integer
var result; //result from dividing integer by 2
//user enters a string
numberS = window.prompt( "Please enter an integer, we will let you know if what you entered is even or odd" );
//convert string into an integer
numberI = parseInt( numberS );
//divide integer by 2
result = numberI / 2;
//if result has no remainder print "This integer is even"
if ( result % 2 )
document.writeln( "This integer is even" );
//else print "This integer is odd"
else
document.writeln( "This integer is odd" );
</script>
</head><body></body>
</html>