TypeScript · Exercise 6 of 6 Previous
Advanced
Write a Method Decorator
counted is a standard method decorator that should count how many times each decorated method is called, in the calls object, while still returning the method's result.
Finish the wrapper: increase calls[name] and then call the original method. The program should print pong, 2 and 1.
What Check tests
- Your code has no type errors
- The console prints
pongand2 1 - The decorated method keeps its signature
- The decorated method still checks its arguments
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.