js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Do something "n.times" (Simplifying "for" loops) #521

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/56e6a330715e7221d9000a3b/train/javascript

RazvanBugoi commented 4 years ago
Number.prototype.times = function (f) {
  let i=0;
  while(i<this) {
    f(i);
    i++
  }
}