Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 题目要求!
- * function repeat (func, times, wait) {
- * }
- * 这个函数能返回一个新函数,比如这样用
- * var repeatedFun = repeat(alert, 10, 5000)
- * 调用这个 repeatedFun ("hellworld")
- * 会alert十次 helloworld, `每次`间隔5秒
- */
- function repeat( func, times, wait) {
- if(times-- === 0) {
- return ;
- }
- func('helloworld ');
- setTimeout(function() {
- repeat( func, times, wait);
- }, wait);
- }
- var repeatedFun = repeat(console.log, 10, 1000)
Add Comment
Please, Sign In to add comment