Correction status:Uncorrected
Teacher's comments:
用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> 运行实例 » 点击 "运行实例" 按钮查看在线实例