JavaScript Object Spread — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Object Spread lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Copy an object
easy10 minCopy an object, change the copy, and show the original is untouched.
- 2
Merge two objects
easy10 minMerge defaults with user settings so the user value wins.
- 3
Update one property
easy10 minBuild a new object with active set to true, leaving the original alone.
- 4
Collect the rest
easy10 minPull out the id and collect the remaining properties, then list their names.
- 5
Add a property while copying
medium10 minCopy an object and add a year in the same expression.
Find the bug(5)
- 1
Fix the shared object
easy8 minAssigning does not copy, so both names point at the same object.
- 2
Fix the merge order
easy8 minThe defaults are overwriting the user's choice.
- 3
Fix the original being changed
easy8 minThe update should build a new object rather than editing the old one.
- 4
Fix the rest that took everything
easy8 minThe id should be pulled out before the rest is collected.
- 5
Fix the property added after the spread
easy8 minThe added property is being overwritten by the spread that follows it.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace