Blogger Information
Blog 38
fans 1
comment 0
visits 24259
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
5月6日javascript 作业1
鲨鱼辣椒的博客
Original
398 people have browsed it

用javascript的while循环输出一个数组的值所有奇数

代码如下

实例
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>1. 写一个while循环, 输出一个数值数组所有的奇数</title>
</head>
<body>
<script>
    var arr = [4,5,7,9,10,12];
    var i = 0;
    var length = arr.length;
    while (i < length){
        if ( arr[i]%2!==0){
            console.log(arr[i]);
        }
        i++;
    }
</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
Author's latest blog post