Demonstration of write/writeln functions and for loop
The JavaScript code:
document.writeln('<p>Odd integers from 1 to 100:');
var sum = 0;
for (var i=1; i<=100; i+=2) {
document.write(' ' + i);
sum += i;
}
document.writeln('</p>');
document.writeln('<p>The sum is: ' + sum + '</p>');