Ed

Instead of complex inheritance hierarchies, compose objects from smaller, focused functions. This is the modern way to share behavior!

Your Task:

  • Create behavior functions: canSwim(), canFly(), canWalk()
  • Each returns an object with a method (e.g., swim())
  • Create a duck by composing all three behaviors
  • Create a fish with only swim
  • Use object spread to merge behaviors
TypeScript Solution
Loading...

Submit your code to see test results