TypeScript · Exercise 6 of 6 Previous
Intermediate
Build a Callable Logger
A logger is a function you call with a message, and it also has a count of the messages so far and a reset() method. Describe it with a type named Logger: a call signature taking a string and returning nothing, plus count: number and reset(): void.
The code below already builds it; only the type is missing. Calls with a number, and assigning text to count, must be rejected.
What Check tests
- Your code has no type errors
- The console prints both log lines, then
2and0 info(42)is rejected- Assigning text to
countis rejected newis not allowed on a logger
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.