<!-- odd.html -->
<html>
<head>
<title>odd</title>
<style type="text/css">
body {
background-color:#22DD44;
color:#DD22EE;
font-size:30;
text-align:center;
}
</style>
</head>
<body>
<script type="text/javascript">
var limit, count, stroutput;
count = 1;
stroutput = "";
document.write("<h1>Odd</h1>");
limit = prompt("Enter the limit", "");
if (limit == null)
{
stroutput = ("You clicked cancel. No count will be shown.");
}
else if (limit == "")
{
stroutput = ("Limit must be entered.");
}
else if (limit != parseInt(limit))
{
stroutput = ("Limit must be a valid whole number");
}
else
{
while (count <= limit) {
stroutput = stroutput + count + "\n";
count = count + 1;
}
}
alert (stroutput);
document.write("<br /><br />");
document.write("<br /><br />");
document.write("<input type='button' name='cmdReload'");
document.write(" value='Do again' onclick='window.location.reload()' />");
</script>
</body>
</html>
As you can see so far it just shows you all numbers but i need it to only show odd numbers. How would i do this?


Sign In
Create Account


Back to top











