SyntaxFix
Write A Post
Hire A Developer
Questions
The ES6 approach is very clean. So first you initialize an array of x length, and then call the fill method on it.
fill
let arr = new Array(3).fill(9)
this will create an array with 3 elements like:
[9, 9, 9]