Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

official solution to final problem doesn't work #28

Open
greph opened this issue Aug 4, 2015 · 1 comment
Open

official solution to final problem doesn't work #28

greph opened this issue Aug 4, 2015 · 1 comment

Comments

@greph
Copy link

greph commented Aug 4, 2015

// -> Add 'core' to robby.parts, cranky.parts should still be empty
// -> Add 'fly' to robby.capabilities, after doing that cranky.capabilities must
// also have 'fly' without adding to it directly, so this property has to be
// shared

official solution:
robby.parts.push('core');
robby.capabilities.push('fly');

working solution:
robby.parts = ['core'];
robby.proto.capabilities.push('fly');

Please correct me if I am wrong here, but it looks like the array.push updates the values for both instances.

@sporto
Copy link
Owner

sporto commented Aug 4, 2015

hi @greph
robby.parts.push('core') should not update the value of both instances, but this really depends on where you declare the 'parts' array. Figuring this out is part of the exercise.

You can see it here https://github.com/sporto/planetproto/blob/master/exercises/100_function_prototype/solution/solution.js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants