| 12345678910111213141516171819202122232425262728293031323334 |
- <!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>
|