Array modification (push, pop, shift, unshift)
📖 Scenario: You are managing a simple to-do list app. You need to add and remove tasks from your list using basic array methods.
🎯 Goal: Build a Ruby program that modifies an array of tasks by adding and removing items using push, pop, shift, and unshift.
📋 What You'll Learn
Create an array called
tasks with initial tasksAdd a new task to the end of the
tasks array using pushRemove the last task from the
tasks array using popRemove the first task from the
tasks array using shiftAdd a new task to the beginning of the
tasks array using unshiftPrint the final
tasks array💡 Why This Matters
🌍 Real World
Managing lists of tasks or items is common in apps like to-do lists, shopping lists, or event planners.
💼 Career
Understanding how to modify arrays is essential for many programming jobs, especially those involving data manipulation and user interfaces.
Progress0 / 4 steps