15.5 Array Best Practices (15 mins)
let shoppingList = ["Milk", "Eggs", "Bread"];
let studentNames = ["Alice", "Bob", "Charlie"]; // Clear and descriptive
let numbers = [1, , 3]; // Index 1 is missing (avoid this)
let numbers = [1, 2, 3, 4]; let doubled = numbers.map((num) => num * 2); // Doubles each number in the array console.log(doubled); // Outputs: [2, 4, 6, 8]
// A Set will only store unique values let uniqueNumbers = new Set([1, 2, 2, 3]);
Student Activity (15 mins):
Step-by-Step Activity:
Explanation:
Run the file in a browser:
Challenge:
Activity Follow-up Questions:
Expected Outcome:
Last updated