Index | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Index

How does adding an index help?

1st Dec 2016, 1:44 AM
Möbius
Möbius - avatar
2 Answers
0
Index is used to find an item within an array. Be an array of objects or even to go through a String, which is an array of chars.
1st Dec 2016, 8:52 AM
Felipe Cruz
Felipe Cruz - avatar
0
The point of an index is to remember where you are in a list, at a certain iteration, or in a string. Imagine you are using a function to find an item in a list for you. If you now wanted to go back and split the list in half where that item is, how would you know where to split it? Use the index in order to find the exact location.
20th Jan 2017, 7:07 PM
Gerrit
Gerrit - avatar