SOURCE

var sum=0;
for(var i=0;i<=100;i++){
    sum+=i;
}
document.write("1+2+3+…+100 = " + sum + "<br/>");

var n = 1;
var sum = 0;
while (n < 101)
{
    sum=sum+n;
    n++;
}
document.write("1+2+3+…+100 = " + sum + "<br/>");


var n = 1;
var sum = 0;
do
{
    sum += n;
    n++;
}while (n <= 100);
document.write("1+2+3+…+100 = " + sum + "<br/>");
console 命令行工具 X clear

                    
>
console