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