Write task list helpers that return updated arrays.
You are writing helper functions for a task list. Each helper should return a result without mutating the original tasks array.
Write these functions:
addTask(tasks, title) should return a new array with a new incomplete task added.
completeTask(tasks, taskId) should return a new array where only the matching task is completed.
removeTask(tasks, taskId) should return a new array without the matching task.
countIncompleteTasks(tasks) should return the number of incomplete tasks.
Sample checks:
Expected output:
The original tasks array should still have two items after these helper functions run.
Join the Community
roadmap.sh is the most starred project on GitHub and is visited by hundreds of thousands of developers every month.
Roadmaps Best Practices Guides Videos FAQs YouTube
roadmap.sh by @kamrify @kamrify
Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.
Login or Signup
You must be logged in to perform this action.