fengchuanyu 4 ay önce
ebeveyn
işleme
08d7f7196d

+ 12 - 4
js复习/12_函数.html

@@ -35,12 +35,20 @@
         // console.log(num + 1);
 
         // 匿名函数
-        var foo = function(){
-            console.log("hello world");
-        }
+        // var foo = function(){
+        //     console.log("hello world");
+        // }
 
-        foo();
+        // foo();
 
+        // 函数内部可以访问全局变量
+        var a = 20;
+        function foo(){
+            // 函数内部可以定义变量  但是不能被外部访问 局部变量
+            // var a = 10;
+            console.log(a);
+        }
+        foo();
     </script>
 </body>
 </html>

+ 17 - 4
js复习/14_数值内置方法.html

@@ -7,10 +7,23 @@
 </head>
 <body>
     <script>
-        var a = 10;
-        // var b = a + "";
-        var b = a.toString();
-        console.log(b+2);
+        // var a = 10;
+        // // var b = a + "";
+        // var b = a.toString();
+        // console.log(b+2);
+
+        // var a = "5";
+        // a = 5.1;
+        // var b = parseInt(a);
+
+
+        // console.log(b);
+
+
+        var a = "5.1";
+        var b = parseFloat(a);
+        console.log(b+1);
+        
     </script>
 </body>
 </html>

+ 21 - 0
js复习/18_Math对象.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        var num = 3.19;
+        // 四舍五入
+        // console.log(Math.round(num)); 
+        // 向下取整
+        // console.log(Math.floor(num));
+        // 向上取整
+        // console.log(Math.ceil(num));
+        console.log(Math.pow(2,3));
+        
+    </script>
+</body>
+</html>

+ 35 - 0
js复习/综合题4_编程题1.html

@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        var age = window.prompt("请输入年龄");
+        age = age * 1;
+
+        // if(age>=0 && age<14){
+        //     console.log("儿童");
+        // }else if(age>=14 && age<24){
+        //     console.log("青少年");
+        // }else if(age>=24 && age<40){
+        //     console.log("青年");
+        // }else if(age>=40 && age<60){
+        //     console.log("中年");
+        // }else if(age>=60){
+        //     console.log("老年")
+        // }else{
+        //     console.log("输入错误");
+        // }
+
+        switch(true){
+            case (age>=0 && age<14):console.log("儿童");break;
+            case (age>=14 && age<24):console.log("青少年");break;
+            default:console.log("输入错误");break;
+        }
+        
+    </script>
+</body>
+</html>

+ 28 - 0
js复习/综合题4_编程题2.html

@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        var day = window.prompt("请输入今天是星期几0~6");
+        day = parseInt(day);
+
+        switch (day) {
+            case 0:console.log("星期日");break;
+            case 1:console.log("星期一");break;
+            case 2:console.log("星期二");break;
+            case 3:console.log("星期三");break;
+            case 4:console.log("星期四");break;
+            case 5:console.log("星期五");break;
+            case 6:console.log("星期六");break;
+            default:console.log("输入错误");
+        }
+        if("1"===1){
+
+        }
+    </script>
+</body>
+</html>

+ 17 - 0
js复习/综合题4_编程题3.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        var res = 1;
+        for(var i=1;i<=10;i++){
+            res = res * i;
+        }
+        console.log(res);
+    </script>
+</body>
+</html>

+ 21 - 0
js复习/综合题4_编程题4.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        var sum = 0;
+        for(var i=1;i<=10;i++){
+            var res = 1;
+            for(var j=1;j<=i;j++){
+                res *= j;
+            }
+            sum += res;
+        }
+        console.log(sum);
+    </script>
+</body>
+</html>

+ 21 - 0
js复习/综合题4_编程题5.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        // 控制行
+        for(var i=1;i<=6;i++){
+            // 控制列
+            for(var j=1;j<=i;j++){
+                document.write(j);
+                document.write("&nbsp;");
+            }
+            document.write("<br>");
+        }
+    </script>
+</body>
+</html>

+ 26 - 0
js复习/综合题4_编程题6.html

@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        // 打印一个6行5列的星号三角形
+        // 控制行数
+        for(var i=0;i<6;i++){
+            //控制每一行中的空格
+            for(var j=5;j>i;j--){
+                document.write("&nbsp;");
+            }
+            //控制每一行中的星号
+            for(var j=0;j<=i;j++){
+                document.write("*");
+                document.write("&nbsp;");
+            }
+            document.write("<br>");
+        }
+    </script>
+</body>
+</html>

+ 17 - 0
js复习/综合题4_编程题7.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        for(var i=100;i<1000;i++){
+            if(i%4==2&&i%7==3&&i%9==5){
+                console.log(i);
+            }
+        }
+    </script>
+</body>
+</html>

+ 24 - 0
js复习/综合题4_编程题8.html

@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+
+<body>
+    <script>
+        // 1234
+        for (var i = 1000; i < 10000; i++) {
+            var A = Math.floor(i / 1000);
+            var B = Math.floor(i / 100) % 10;
+            var C = Math.floor(i / 10) % 10;
+            if (i % 13 == 0 && A == (B + C)) {
+                console.log(i);
+            }
+        }
+    </script>
+</body>
+
+</html>

+ 49 - 0
js复习/综合题5_选择判断.html

@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+     
+    <script>
+        // function foo(){
+        //     var a = 1;
+        // }
+        // function bar(){
+        //     var a = "hello";
+        // }
+        // console.log(a);
+
+        // function baz(){}
+        // var foo2 = function(){}
+        // function(){};
+
+        // var b = 1;
+        // var b = "a";
+
+        // var a = "hello";
+        // function foo(){
+        //     var a = 10;
+        //     function foo2(){
+        //         console.log(a);
+        //     }
+        //     foo2();
+        // }
+        // foo();
+        // foo2();
+
+        function foo(){
+            function foo2(){
+                console.log("hello");
+            }
+            return foo2;
+        }
+
+        var foo3 = foo();
+        console.log(foo3);
+        foo3();
+    </script>
+</body>
+</html>