How to create an array with same element repeated multiple times in JavaScript

1 Answer

0 votes
const arr = Array(10).fill(3)
     
console.log(arr);
 
 
 
/*
run:
 
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3] 
 
*/
  

 



answered May 20, 2021 by avibootz
edited Jul 7, 2022 by avibootz
...