Skip to content

Commit

Permalink
revert(times): **replacing while loop with for loop**
Browse files Browse the repository at this point in the history
  • Loading branch information
psparsa authored and customcommander committed Apr 12, 2022
1 parent 3141d1a commit e6b0047
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions source/times.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _curry2 from './internal/_curry2.js';


/**
* Calls an input function `n` times, returning an array containing the results
* of those function calls.
Expand All @@ -25,18 +26,17 @@ import _curry2 from './internal/_curry2.js';
*/
var times = _curry2(function times(fn, n) {
var len = Number(n);
var idx = 0;
var list;

if (len < 0 || isNaN(len)) {
throw new RangeError('n must be a non-negative number');
}

list = [];
for (var x = 0; x < len; x += 1) {
list.push(fn(x));
while (idx < len) {
list.push(fn(idx));
idx += 1;
}

return list;
});

export default times;

0 comments on commit e6b0047

Please sign in to comment.