SOURCE

console 命令行工具 X clear

                    
>
console
//#1.while语句
function sum1() {
        var result1 = 0;
        var i = 0;
        while (i <= 100) {
            result1 += i;
            i++;
        }
        return result1
    }
document.write(sum1()+'<br/>');

//#2.do...while语句
function sum2() {
        var result2 = 0;
        var i = 0;
        do{
            result2 += i;
            i++;
        }while (i <= 100) 
        return result2
    }
document.write(sum2()+'<br/>');

//#3.for循环
function sum3() {
        var result3 = 0;
        var i;
        for (i=0;i <= 100;i++) {
            result3 += i;
        }
        return result3
    }
document.write(sum3()+'<br/>');
<!DOCTYPE html> 
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
    </script>
</head>
<body>
</body>
</html>