Y
Hacker News
new
|
ask
|
show
|
jobs
by
dagmx
2164 days ago
Edit: brain not woken up yet. Itβs because of zero indexing.
βββ-
Original question: Out of curiosity, why the +1?
2 comments
tryptophan
2164 days ago
Arrays start at 0. example_array[5] is actually the 6th number in the array.
link
dagmx
2164 days ago
Ah yeah that makes sense. I was thinking the `i` check already accounted for the zero indexing.
link
Sosh101
2164 days ago
Zero indexing probably
link
dagmx
2164 days ago
Makes sense. My brains clearly not woken up yet because I thought the `i` check accounted for the zero indexing.
link