SyntaxFix
Write A Post
Hire A Developer
Questions
map is the most logical solution for this problem.
map
let xs = [1, 2, 3]; xs = xs.map(x => 42); xs // -> [42, 42, 42]
However, if there is a chance that the array is sparse, you'll need to use for or, even better, for .. of.
for
for .. of
See: