With your code, you can actually have it change the console type too, like so
function customLog(message, color='black') { let logType = 'log'; switch (color) { case 'success': color = 'Green'; break case 'info': color = 'Blue'; logType = 'info'; break; case 'error': color = 'Red'; logType = 'error'; break; case 'warning': color = 'Orange'; logType = 'warning'; break; default: color = color } console[logType](`%c${message}`, `color:${color}`); } customLog('Hello World!') customLog('Success!', 'success') customLog('Error!', 'error') customLog('Warning!', 'warning') customLog('Info...', 'info')
Also, console.count('nameToCount') will count how many times it is called, which can be handy.
console.count('nameToCount')
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
With your code, you can actually have it change the console type too, like so
Also,
console.count('nameToCount')
will count how many times it is called, which can be handy.