Section 1 - Instruction

We've seen how arrays hold collections of items, and how we can add (.push()) or remove (.pop()) items.

But how can we easily find out exactly how many items are currently inside an array?

Engagement Message

Any ideas?

Section 2 - Instruction

Every array has a length, which is simply the count of items it contains.

An array like [10, 20, 30] has a length of three. An empty array [] has a length of zero.

Engagement Message

Does the length change when we push or pop items?

Section 3 - Instruction

JavaScript arrays have a built-in property called .length to get the number of items. Unlike a method, it's a property that you access directly without parentheses ().

You use it like this: yourArray.length.

What kind of value do you expect .length to give back?

Engagement Message

Do you think it'll be a string, a number, or something else?

Section 4 - Instruction

That's right! The .length property returns a number representing the count of items.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal