Array Basics
Array Basics
π¨βπΌ We're building an inventory system that tracks products. Let's start with
basic array operations.
π¨ Open
and:
- Create a
productsarray of strings starting with exactly:['Laptop', 'Mouse', 'Keyboard'] - Use
pushto add'Monitor'at the end - Log the first product (
products[0]) and the last product (products[products.length - 1]) - Log the total number of products (
products.length) - Export
products
After the push,
products should be
['Laptop', 'Mouse', 'Keyboard', 'Monitor'] (length 4, last item 'Monitor').π° Arrays store ordered values; you can push, index, and read length.
π MDN - Array