Blogger Information
Blog 7
fans 0
comment 0
visits 4715
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
循环,函数 2019年5月7日13:47:11
MrLv的博客
Original
617 people have browsed it
  1. 写一个while循环, 输出一个数值数组所有的奇数


    0-100以内奇数偶数输出实例

    <script>
    
        var sum = 0;
        var i = 1;//循环变量
        while (i < 100){
            sum = i;
            i ++;
            if (sum%2==1){
                console.log(sum+'是奇数');
            } else {
                console.log(sum+'是偶数')
            }
     }
    
    </script>

    运行实例 »

    点击 "运行实例" 按钮查看在线实例

  2. 写一个对象字面量, 描述一款你喜欢的手机信息

    phone对象字面量实例

    <script>
    var phone = {
        'Name':'xiaomi',
        'Model':'xiaomi 6',
        'Color':'black',
        'Screen_size':'1920*1080'
    }
    console.log('手机***:'+ phone['Name']);
    console.log('手机型号:'+ phone['Model']);
    console.log('手机颜色:'+ phone['Color']);
    console.log('手机分辨率:'+ phone['Screen_size'])
    </script>

    运行实例 »

    点击 "运行实例" 按钮查看在线实例

  3. 写一个函数表达式, 计算三个数之和

    3个数字求和函数实例

    <script>
    
    var num = function (x,y,z) {
    var i = x+y+z;
    console.log('x+y+z=' + i)
    }
    num (10,20,20);
    </script>

    运行实例 »

    点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments