Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

duplicate an array in javascript n times

const makeRepeated = (arr, repeats) =>
  Array.from({ length: repeats }, () => arr).flat();
  
console.log(makeRepeated([1, 2, 3], 2));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #duplicate #array #javascript #times
ADD COMMENT
Topic
Name
9+3 =