Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

duplicate elements of array multiple times

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