Blogger Information
Blog 26
fans 1
comment 0
visits 22287
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS/Jquery第课 12月16号作业
孤忆寻昔R
Original
831 people have browsed it

作业

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>js</title>
  6. </head>
  7. <body>
  8. <input type="text" id="username" value="" placeholder="输入数字">
  9. <script>
  10. var num2 = 123;
  11. var num1 = 456;
  12. // alert(num2<num1?'num2小于num1':'num2大于num1');
  13. function myfunc()
  14. {
  15. var num2 = 123;
  16. var num1 = 456;
  17. if(num1<num2){
  18. alert('num1小于num2');
  19. } else{
  20. alert('num2大于num1');
  21. }
  22. }
  23. // function func1()
  24. // {
  25. // var num3 = 90;
  26. // if(num3>90){
  27. // alert('优秀');
  28. // } else if(num3<=90 && num3>70){
  29. // alert('一般');
  30. // } else if(num3<=70 && num3>60){
  31. // alert('合格');
  32. // } else
  33. // alert ('不及格');
  34. // }
  35. // function func2()
  36. // {
  37. // var num4 = 90;
  38. // switch(num4){
  39. // case num4>90:
  40. // alert('优秀');
  41. // break;
  42. // case num4<=90 && num4>80;
  43. // alert('一般');
  44. // break;
  45. // case num4<=80 && num4>70;
  46. // alert('合格');
  47. // break;
  48. // case num4<60;
  49. // alert('不及格');
  50. // }
  51. // }
  52. // var num5 = 90;
  53. function func3()
  54. {
  55. var num5 = 90;
  56. if(num5>90){
  57. alert('优秀');
  58. } else if(num5<=90 && num5>70){
  59. alert('一般');
  60. } else if(num5<=70 && num5>60){
  61. alert('合格');
  62. }else
  63. alert('不合格');
  64. }
  65. function func4()
  66. {
  67. if(num5>90){
  68. return alert('优秀');
  69. }
  70. if(num5<=90 && num5>70){
  71. return alert('一般');
  72. }
  73. if(num5<=70 && num5>60){
  74. return alert('不及格');
  75. }
  76. }
  77. // func4();
  78. // for(var i=0;i<10;i++){
  79. // console.log('i='+i);
  80. // }
  81. function func5()
  82. {
  83. var arr=['a','b','c'];
  84. for(var i=0;i<arr.length;i++){
  85. console.log(arr[i]);
  86. }
  87. }
  88. // func5();
  89. var numx = 22;
  90. if(typeof(numx)=="undefined"){
  91. alert('未定义');
  92. } else {
  93. alert('numx='+numx);
  94. }
  95. </script>
  96. </body>
  97. </html>




总结

1、alert();弹窗 console.log 阻断生成日志 在浏览器上的控制台Console查看内容
2、声明变量 使用 var 数组没有foreach遍历
3、写条件判断时主语代码的可读性,尽量优化

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:用console.log()会更方便些
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