1. 写一个while循环, 输出一个数值数组所有的奇数 <html> <head> <title>js学习</title> <meta charset="utf-8"> <script type="text/javascript"> var arr = [1,3,5,2,4,6,12,14,15,37]; var a = 0; var lenth = arr.length; while (a<lenth) { if(arr[a]%2!==0){ console.log(arr[a]) } a+=1; } </script> </head> <body> </body> </html>
2.写一个对象字面量, 描述一款你喜欢的手机信息
<script type="text/javascript"> var myphone = { pname:"ipone8plus", pprice:6388, pmade:'China' }; console.log('手机***信息: '+ myphone.pname ); console.log('手机价格信息: '+ myphone.pprice ); console.log('手机产地信息: '+ myphone.pmade ); </script>
3. 写一个函数表达式, 计算三个数之和
<script type="text/javascript"> var res = function sum(a,b,c){ return console.log(a+b+c); }; res(11,33,55); </script>