xgqfrms / learning

learning : A collection of all kinds of resources, videos, pdf, blogs, codes... 📚 + 💻 + ❤
https://learning.xgqfrms.xyz
MIT License
16 stars 12 forks source link

js repeatify #91

Open xgqfrms opened 4 years ago

xgqfrms commented 4 years ago

js repeatify

https://www.sitepoint.com/5-typical-javascript-interview-exercises/


String.prototype.repeatify = function (times = 1) {
  console.log(this)
  // String {"abx"}
  return [...``.padStart(times, ` `)].map((item, i) => item = this).join(``);
};

`abx`.repeatify(3);
// "abxabxabx"

``
xgqfrms commented 4 years ago

https://www.cnblogs.com/xgqfrms/p/8982974.html

xgqfrms commented 4 years ago

https://www.cnblogs.com/xgqfrms/p/13034475.html