-
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Sum of Odd/Even</title> </head> <body> <script type="text/javascript"> var sumOdd = 0; var sumEven = 0; var i; for(i=1; i<=100; i++) { if(i%2 != 0) { sumOdd += i; } else { sumEven += i; } } document.write("The sum of 1~100 odd is "+sumOdd+"<br />"); document.write("The sum of 1~100 even is "+sumEven+"<br />"); </script> </body> </html>