Intermediate
Mark a task done without mutating
Write markDone(tasks, id). tasks is an array of { id, title, done } objects.
Return a new array in which the task with that id has done: true. The original array and its task objects must not change.
Tasks that don't change should be the same objects as before (not copies). If no task has that id, return a new array with the same tasks.
What Check tests
- The returned array has task 2 done
- It returns a new array
- The original task object is not changed
- Unchanged tasks are the same objects
- An unknown id changes nothing
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.