JavaScript Prototype Chain — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Prototype Chain 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
Find the prototype
easy10 minReport whether an instance's prototype is the class prototype.
- 2
List the own properties
easy10 minReport the own keys of an instance that also has a method.
- 3
Tell own from inherited
easy10 minReport hasOwnProperty for a property and a method.
- 4
Walk two links up
easy10 minCall a method inherited from the grandparent class.
- 5
Shadow a prototype method
medium10 minGive one instance its own method and leave the other alone.
Find the bug(5)
- 1
Fix the method copied onto the instance
easy8 minA method in the constructor becomes an own property of every instance.
- 2
Fix hasOwnProperty used for a method
easy8 minAn inherited method is not an own property.
- 3
Fix the broken chain
easy8 minThe middle class does not extend, so the chain stops short.
- 4
Fix the prototype changed for everyone
easy8 minAssigning to the prototype affects every instance, not just one.
- 5
Fix the prototype compared to the class
easy8 minAn instance's prototype is the class prototype, not the class.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace