repeat array javascript code example
Example 1: javascript repeat element in array
Array(5).fill(2)
//=> [2, 2, 2, 2, 2]
Example 2: repeat an element in array in js
Array(5).fill(2)
//=> [2, 2, 2, 2, 2]
Example 3: js string times
let string = 'Plumbus'
let count = 3
string.repeat(count); // -> 'PlumbusPlumbusPlumbus'