Blogger Information
Blog 9
fans 0
comment 0
visits 9084
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字符串控制,流程控制,循环控制
不忘初心
Original
369 people have browsed it

字符串控制

  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. let cpc ="中国共产党万岁";
  11. console.log(cpc);
  12. cpc="中国共产党万岁!".concat("战无不胜的毛泽东思想万岁!","中华人民共和国万岁!");
  13. console.log(china);
  14. str=cpc.slice(0,5);
  15. console.log(str);
  16. str=cpc.substr(5,2);
  17. console.log(str);
  18. str=cpc.substr(-10);
  19. console.log(str);
  20. let arr=['马克思列宁主义','毛泽东思想','邓小平理论','三个代表重要思想','科学发展观','习近平新时代中国特色社会主义']
  21. console.dir(arr);
  22. </script>
  23. </body>
  24. </html>

建立数组

  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. let arr=['马克思列宁主义','毛泽东思想','邓小平理论','三个代表重要思想','科学发展观','习近平新时代中国特色社会主义']
  11. console.dir(arr);
  12. </script>
  13. </body>
  14. </html>

流程控制 判断成绩

  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. let cj=100;
  11. if (cj >= 0 && cj<60){
  12. console.log("您的成绩为"+cj+"分。"+"成绩不及格!")}
  13. else if (cj>=60 && cj<80){
  14. console.log("您的成绩为"+cj+"分。"+"成绩良好!")
  15. } else if(cj>=80 && cj<=100){
  16. console.log("您的成绩为"+cj+"分。"+"成绩优异!")
  17. } else {
  18. console.log("您的成绩为"+cj+"分。"+"成绩不能大于100分且不能为负数")
  19. }
  20. </script>
  21. </body>
  22. </html>

循环

1.while循环

  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. let arr=['马克思列宁主义','毛泽东思想','邓小平理论','三个代表重要思想','科学发展观','习近平新时代中国特色社会主义']
  11. let i=0;
  12. while (i<=arr.length){
  13. console.log(arr[i]);
  14. i++
  15. }
  16. </script>
  17. </body>
  18. </html>

2.for循环

  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. let arr=['马克思列宁主义','毛泽东思想','邓小平理论','三个代表重要思想','科学发展观','习近平新时代中国特色社会主义']
  11. let i=0;
  12. while (i<arr.length){
  13. console.log(arr[i]);
  14. i++
  15. }
  16. for(i=0;i<arr.length;i++){
  17. alert(arr[i]);
  18. }
  19. </script>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
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