Array count and length
📖 Scenario: You are managing a small online store. You have a list of products in an array. You want to find out how many products are in the list.
🎯 Goal: Learn how to create an array, set a variable for counting, use the count() function to find the number of items in the array, and print the result.
📋 What You'll Learn
Create an array called
products with these exact items: 'Apple', 'Banana', 'Orange', 'Mango'Create a variable called
totalProducts to store the count of items in the products arrayUse the
count() function with the products array to get the number of itemsPrint the value of
totalProducts exactly as an integer💡 Why This Matters
🌍 Real World
Counting items in a list is common in online stores, inventory systems, and any place where you manage collections of things.
💼 Career
Knowing how to count array items helps you handle data collections efficiently, a key skill for web developers and programmers.
Progress0 / 4 steps