上QQ阅读APP看书,第一时间看更新
Checking the number of elements in an array
If you are keeping track, we now have nine items in our array. Luckily, we do not have to keep track of how many items are in our array because we have a property called count. This property will keep track of the current item count and give us the total count of our array when we want to check. Let's look at the count for states:
states.count
Your code will now look like this: