EXERCISE 4: Loops and Arrays - Shopping List

Assignment

Create a shopping list program that:

  1. Creates an array of at least 5 items (strings) that you need to buy
  2. Uses a for loop to display each item with its index number (e.g., "1. Apples", "2. Bread")
  3. Uses forEach to display all items again, but this time with a checkmark emoji (✓) before each item
  4. Uses a while loop to count and display the total number of items in the list
  5. Uses filter to create a new array containing only items that have more than 4 characters, then display this filtered list

Requirements:

  • Use proper array methods (forEach, filter)
  • Display results using both console.log() and document.write()
  • Use template literals for string formatting
  • Use an external JavaScript file (script.js) linked to your HTML

Create an index.html file and a script.js file with your solution.