Skip to main content

Task 11: JavaScript Arrays – Making a Breakfast Menu

Start with Affirmation​

  • "I am destined for greatness. Every step I take brings me closer to my goals. I embrace challenges, knowing they are stepping stones to success. My mind is focused, my heart is determined, and my actions are aligned with my dreams."

Daily Affirmations for Success

  • βœ… I am capable, confident, and unstoppable.
  • βœ… Success flows to me because I take consistent action.
  • βœ… I attract opportunities that align with my purpose.
  • βœ… My hard work and persistence create abundance.
  • βœ… I am always learning, growing, and evolving.
  • βœ… I believe in my potential and trust my journey.
  • βœ… I turn setbacks into comebacks with resilience.
  • βœ… I am grateful for every success, big and small.

Success Reflection​

"Every effort I made today has planted seeds for my future success. I release any doubts and trust the process. My dreams are possible, and I am getting closer every day. I am grateful, I am strong, and I am ready for more!"

πŸ’ͺ Repeat daily, feel the power, and watch your success unfold!


πŸ”Ή If you don’t understand the task, watch the video above for the answer.


Task​

Today, we’re learning about JavaScript Arrays by creating a breakfast menu! 🍽️ We’ll use an array to store different breakfast items and learn how to add, remove, and update items on the menu. By the end of this lesson, you’ll be able to:​

** Step 1: What is an Array?​

An array is like a plate with different food items on it. It helps us store multiple values in one place!

Let’s create an array of breakfast items:

let breakfastMenu = ["Pancakes", "Omelette", "Smoothie", "Toast"];

Step 2: Adding New Items to the Menu​

Let’s add a new item to our breakfast menu using the push method!

breakfastMenu.push("Coffee");
breakfastMenu.push("Waffles");

Step 3: Displaying the Menu​

console.log("🍽️ Breakfast Menu:");
breakfastMenu.forEach(function(item, index) {
console.log(`${index + 1}. ${item}`);
});

Output​

Breakfast Menu:

    1. Pancakes
    1. Omelette
    1. Smoothie
    1. Toast
    1. Coffee
    1. Waffles

Step 4: Removing an Item from the Menu​

breakfastMenu.splice(2, 1);

Step 5: Updating an Item on the Menu​

Let’s change 'Toast' to 'French Toast' because it sounds fancier!

breakfastMenu[2] = "French Toast";

Step 6: Displaying the Final Menu​

console.log("🍽️ Updated Breakfast Menu:");
breakfastMenu.forEach(function(item, index) {
console.log(`${index + 1}. ${item}`);
});


Output:​

Updated Breakfast Menu:

    1. Pancakes
    1. Omelette
    1. French Toast
    1. Coffee
    1. Waffles

Recap – What Did We Learn?​

Today, we learned how to:

  • βœ… Create and initialize an array
  • βœ… Add items using push
  • βœ… Remove items using splice
  • βœ… Update items in an array
  • βœ… Loop through an array to display items