Command Palette

Search for a command to run...

Hectal
Phase 5: Arrays
JavaScript · Exercise 4 of 6 PreviousNext
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

  1. The returned array has task 2 done
  2. It returns a new array
  3. The original task object is not changed
  4. Unchanged tasks are the same objects
  5. 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.