fengchuanyu 1 tuần trước cách đây
mục cha
commit
59ec40a3d0

+ 34 - 0
3_JavaScript/练习24_字符串收集.html

@@ -0,0 +1,34 @@
+<!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 s(s){
+            var arr = ["0","1","2","3","4","5","6","7","8","9"];
+            if(arr.includes(s)){
+                return true
+            }else{
+                return false
+            }
+        }
+
+        function CollectDigits(str){
+            var arr = str.split("");
+            var res = arr.filter(function(item){
+                if(s(item)){
+                    return true;
+                }else{
+                    return false;
+                }
+            })
+            console.log(res);
+        }
+
+        CollectDigits("1abc23def4")
+    </script>
+</body>
+</html>

+ 32 - 0
3_JavaScript/练习25_字符串拼接.html

@@ -0,0 +1,32 @@
+<!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 Merge(s1,s2){
+            var longArr = "";
+            var shortArr = "";
+            var resStr = "";
+            if(s1.length > s2.length){
+                longArr = s1;
+                shortArr = s2;
+            }else{
+                longArr = s2;
+                shortArr = s1;
+            }
+            for(var i=0;i< shortArr.length;i++){
+                resStr = resStr.concat(longArr.charAt(i),shortArr.charAt(i));
+                
+            }
+            console.log(resStr+longArr.slice(shortArr.length));
+
+        }
+
+        Merge("123456","abcd");
+    </script>
+</body>
+</html>