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