Below is what I have so far. And do I place the user prompt within the function or leave it where it is? What I am "trying" to accomplish is to add
<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta charset="utf-8">
<script type="text/javascript">
/* Input: user types in an integer
* Processing: adds all odd numbers between input and 0
* Output: the sum of the odd numbers
*/
function addOdds() {
var n = parseInt(document.getElementById('number').value);
var sum = i=i+2;
for **(var i = -1; i < 6; i = i + 2)** {
if (n == 0) {
break;
}
sum += n;
}
window.alert(sum);
}
</script>
</head>
<body>
Please enter a number. <input type="text" id="number">
<button type="button" onclick="addOdds()"> Get the sum </button>
<div id=""> </div> <!--is this part need? -->
</body>
</html>