π Arrays for Kids
An array is a list β like your party guest list.
What's in a List?
A list of friends: ["Sam", "Riya", "Mo"]. A list of pets: ["dog", "cat", "fish"]. A list of high scores: [100, 95, 87].
Position Matters
The first item is at position 0 (yes, zero β coders are weird that way). The second is at position 1. So guests[0] would be "Sam" in our example.
Things You Can Do
- Add a new friend to the end.
- Take one out.
- Look at each one in turn (loop!).
- Sort them alphabetically.
π―
Try this!
Now you try! If your favorite-foods array is ["pizza", "ice cream", "pasta"], what's at position 2?
π¨βπ©βπ§
For grown-ups
Parent/teacher tip: Practice "0-indexed" thinking with real objects in a row.