If you struggle with it, you are no alone.
That's why modern languages introduces a concept of iterator or iterator methods. In JS, you can use forEach to achieve similar purpose of a for loop. There are also for ... in and for ... of loops where you don't have to care about indexes.
forEach
for ... in
for ... of
Thank you!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If you struggle with it, you are no alone.
That's why modern languages introduces a concept of iterator or iterator methods. In JS, you can use
forEachto achieve similar purpose of a for loop. There are alsofor ... inandfor ... ofloops where you don't have to care about indexes.Thank you!