写好了886最近学啥闭包快晕厥了(其实是困
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Login</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" media="screen" href="index2.css" /> <script src="main.js"></script> </head> <body> <!-- 用indexof查找一串字符中某个字符出现的次数 --> <script> var s="袁老师帅啊帅啊超级帅!!!"; var target="帅"; var count=0; var a=-1; var flag=0; function find(a){ if(a==-1&&flag!=0) return 0; else{ a=s.indexOf(target,a+1); count++; flag=1; return find(a); } } find(a); console.log(count-1); </script> </body> </html>
有3个"帅"呢
__________________________________________________________________________________________________________
先画饼