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!
Task Answer - Video Linkβ
πΉ 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:
- Pancakes
- Omelette
- Smoothie
- Toast
- Coffee
- 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:
- Pancakes
- Omelette
- French Toast
- Coffee
- 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