Modifying arrays
π Scenario: You are managing a small online store's product list. You want to update the list by adding new products and removing old ones.
π― Goal: Build a simple JavaScript program that starts with an initial array of products, adds a new product, removes a discontinued product, and then shows the updated list.
π What You'll Learn
Create an array called
products with the exact values: 'apple', 'banana', 'carrot'Create a variable called
newProduct and set it to the string 'date'Add the
newProduct to the end of the products arrayRemove the product
'banana' from the products arrayPrint the final
products arrayπ‘ Why This Matters
π Real World
Managing product lists is common in online stores and inventory systems where items are added or removed regularly.
πΌ Career
Knowing how to modify arrays is essential for frontend and backend developers working with lists of data.
Progress0 / 4 steps