Using for loops (with the exception of for..of) in JS nowadays is discouraged. Generally, anything that can be expressed as a for loop can be better expressed declaratively using Array.prototype methods ("you need to iterate over an array--but you don't need to tell JS how to do so").
Replace for loops with Array.prototype methods such as forEach, map, etc., as appropriate.
Using
for
loops (with the exception offor..of
) in JS nowadays is discouraged. Generally, anything that can be expressed as afor
loop can be better expressed declaratively usingArray.prototype
methods ("you need to iterate over an array--but you don't need to tell JS how to do so").Replace
for
loops withArray.prototype
methods such asforEach
,map
, etc., as appropriate.