Skip to content

Commit 874e2b3

Browse files
Merge pull request #6 from faizanu94/master
utilized fill prototype if available
2 parents 8e7fe80 + 64445c5 commit 874e2b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
'use strict';
99

1010
module.exports = function repeat(ele, num) {
11+
if (Array.prototype.fill) {
12+
return new Array(num).fill(ele);
13+
}
14+
1115
var arr = new Array(num);
1216

1317
for (var i = 0; i < num; i++) {

0 commit comments

Comments
 (0)