SOURCE

function writeDocument(variable) {
    document.write(variable + "<br/>");
}

//1.for循环
var x = 1;
var sum = 0;
for (; x <= 100; x++) {
    sum += x;
}
writeDocument("for循环: " + sum);

//2.while循环
var y = 1;
var sum1 = 0;
while (y <= 100) {
    sum1 += y;
    y++;
}
writeDocument("while循环: " + sum1);

//3.do while循环
var z = 1;
var sum2 = 0;
do {
    sum2 += z;
    z++;
} while (z <= 100);
writeDocument("do while循环: " +sum2);
console 命令行工具 X clear

                    
>
console