sporto/planetproto

official solution to final problem doesn't work

Opened this issue · 1 comments

greph commented

// -> 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.

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