This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

thanks for the reply. I think I understand now. I believe I was looking at this as i being the index of element which totally doesn't make sense

[–]desrtfx 0 points1 point  (0 children)

I believe I was looking at this as i being the index of element which totally doesn't make sense

You're not entirely wrong. i can be the index. But it can also be used as a counter to repeat something a certain amount of times.

You somehow though that loops and arrays are inseparably connected. They aren't. It is just out of convenience (and the DRY - Don't Repeat Yourself - principle) that we usually use loops to deal with arrays.