Exercise: Timestamped Logs

Practice how to create a proxy for the logging function to prepend the current timestamp to the message.

Problem statement

Create a proxy for the console object that enhances every logging function (log(), error(), debug(), and info()) by prepending the current timestamp to the message you want to print in the logs. For instance, executing consoleProxy.log('hello') should print something like 2020-02-18T15:59:30.699Z hello in the console.

Coding challenge

Write your solution code in the following code widget. We’ve already added the package.json file for your ease.

Get hands-on with 1200+ tech skills courses.