I know you guys can catch my error here. I'm very, very new to JavaScript and don't have the ability to catch simple syntax errors, which I think might be my problem here. I also get a "missing } after function body" error on line 1, which I don't think I actually have.
Code:
<!doctype html>
<html>
<head>
<title>Sum of Numbers Below N that are Multiples of 3 or 5</title>
<script type="text/javascript">
function sumOfMultiples(){
//runs the sum of all natural multiples of 3 and 5 below 1000
var i = 1, ans = '', sum = 0;
//generate natural numbers 1 .. 999
while(i < 1000){
//test: multiple of 3 or 5?
if((i % 3 == 0) || (i % 5 == 0)){
sum += i;
ans = ans + i + ' ';
}
++i;
}
//display result
alert(sum);
</script>
</head>
<body>
<p>
Contents of the page.
</p>
<input type="button" value="Sum of Mults" onclick="sumOfMulitples();">
<hr>
<div id="outputDiv">
Welcome to my site!
</div>
</body>
</html>