DEV Community

Cover image for Repeat array element n times
Dezina
Dezina

Posted on

Repeat array element n times

const myArray = [ '3:00', '4:00']
const repeat = (a, n) => Array(n).fill(a).flat(1)
console.log( repeat(myArray, 3) )

Top comments (0)