Objects

Object Spread Copies

Object Spread Copies

Object spread copies the own enumerable properties from one object into another object literal. When a later property uses the same key, the later value wins.

This pattern matters in UI state and data pipelines because callers often need the original object to remain unchanged.

Your task: Write completeTask(task) so it returns a new object with all of task's existing properties and done set to true. The original task object must not be changed.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Object Spread Copies

Object spread copies the own enumerable properties from one object into another object literal. When a later property uses the same key, the later value wins.

This pattern matters in UI state and data pipelines because callers often need the original object to remain unchanged.

Your task: Write completeTask(task) so it returns a new object with all of task's existing properties and done set to true. The original task object must not be changed.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.