JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

【polyfill】_repeat

发布时间 2023-07-07 18:56:58作者: 万物有序
 1 function _repeat(str, num) {
 2   if (
 3     typeof str !== "string" ||
 4     typeof num !== "number" ||
 5     num.toString().includes(".") ||
 6     num < 0
 7   )
 8     throw Error("参数不合法");
 9 
10   let s = "";
11   while (num) {
12     if (num & 1) {
13       s += str;
14     }
15     num = num >> 1;
16     str += str;
17   }
18   return s;
19 }

THE END

    本栏目推荐文章
  • mysql-循环(while 、repeat、loop)
  • 【五期李伟平】CCF-A(TMC'22)Enabling Long-Term Cooperation in Cross-Silo Federated Learning: A Repeated Game Perspective
  • 【THM】Burp Suite:Repeater(Burp Suite重放器·更新版)-学习
  • 『LeetCode』3. 无重复字符的最长子串 Longest Substring Without Repeating Characters
  • 深入了解C#中Linq的Range和Repeat方法
  • Confluence7.4.6突然爆事务隔离级别问题-解决方案-MySQL session isolation level 'REPEATABLE-READ' is no longer supported.
  • 汇编-.if和.while和.repeat注意事项
  • 汇编-.repeat循环语句
  • 如何使用Grid中的repeat函数
  • .NET(C#) Linq Range和Repeat的使用
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们