array.repeat javascript code example
Example 1: repeat an element in array in js
Array(5).fill(2)
//=> [2, 2, 2, 2, 2]
Example 2: js repeat
function repeatStr (n, s) {
return s.repeat(n)
}
/////////////////////////////similar///////////////////////////////////////////
repeatStr = (n, s) => s.repeat(n);