Correction status:Uncorrected
Teacher's comments:
1.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JS循环,对象与函数</title> <script> // while 循环输出 var user1 = [1,2,3,4,5,6,7,8,9]; var i = 0; //循环变量 // 循坏开始 while (i<user1.length) { // 数组元素%2,余数不等于0,就是奇数 if (user1[i] % 2 !==0) { document.write(user1[i]); } i++; // 更新条件 +1 } document.write( "<br>"); // 对象字面量花括号包裹起来非法的名称用引号包裹起来 var user2 ={ name:'一加7pro', battery:'4000mAh' , cpu:' 骁龙855', screen:'6.67', price:'3999' }; document.write('名字:'+user2.name+ "<br>"); document.write('电池容量:'+user2.battery+ "<br>"); document.write('处理器:'+user2.cpu+ "<br>"); document.write('屏幕尺寸:'+user2.screen+ "<br>"); document.write('价格:'+user2.price+ "<br>"); // 函数表达式求三个数值之和 var user3 = function(a,b,c) { var w=a+b+c; document.write('a+b+c='+w); }; // 匿名函数花括号末尾要加分号 user3(9,99,999); </script> </head> <body> </body> </html>
点击 "运行实例" 按钮查看在线实例