Blogger Information
Blog 23
fans 1
comment 0
visits 16937
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
while循环、对象字面量、函数表达式2019年5月6日22时00分课后作业
布衣大汉的博客
Original
1164 people have browsed it

1、写一个while循环, 输出一个数值数组所有的奇数

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>写一个while循环, 输出一个数值数组所有的奇数</title>
</head>
<body>
<script>
    var i = 0;

    while (i < 15) {
        if (i % 2 === 1){
            console.log(i);
        }
        i++;
    }
</script>
</body>
</html>

运行实例 »

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

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

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>写一个对象字面量, 描述一款你喜欢的手机信息</title>
</head>
<body>
<script>
    var phoneinfo = {
        name: 'Iphone X',
        size: '5.8英寸',
        memory: '3GB',
        CPU:'苹果 A11+M11协处理器',
        price:'8399'
    };

    console.log('name: ' + phoneinfo.name);
    console.log('size: ' + phoneinfo.size);
    console.log('memory: ' + phoneinfo.memory);
    console.log('CPU: ' + phoneinfo.CPU);
    console.log('price: ' + phoneinfo.price);
</script>
</body>
</html>

运行实例 »

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

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

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>写一个函数表达式计算三个数字之和</title>
</head>
<body>
<script>

    var sum = 0;
    function add(x,y,z) {
        sum = x + y + z;
        return sum;
    }
    add(20,30,40);

    console.log(sum);
</script>
</body>
</html>

运行实例 »

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


Correction status:Uncorrected

Teacher's comments:
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