function getSum(){ var sum = 0; for(var i = 1; i <= 100; i++) { sum += i; } console.log('1到100相加结果为:' + sum) var i = 0, sum = 0; while(i <= 99){ i ++; sum += i; } console.log('1到100相加结果为:' + sum) var i = 1, sum = 0; do{ sum += i i++; }while(i<=100) console.log('1到100相加结果为:' + sum) } getSum()