Skip to content

Instantly share code, notes, and snippets.

@troutacular
Created January 8, 2019 19:19
Show Gist options
  • Save troutacular/5e00f6c8749df846ac01c1d4d24559a9 to your computer and use it in GitHub Desktop.
Save troutacular/5e00f6c8749df846ac01c1d4d24559a9 to your computer and use it in GitHub Desktop.
Console Messages
/**
* Checks if console exists and allows command types for output.
*
* @param {comman.['log', 'warn', 'error', 'info']} console command type
* @param {message.string} Message to be passed to the console type
* @return cosole.[command]([message]) if console available
*/
function consoleMessage(command, message) {
'use strict';
if (window.console) {
switch (command) {
case 'log':
window.console.log(message);
break;
case 'warn':
window.console.warn(message);
break;
case 'error':
window.console.error(message);
break;
case 'info':
window.console.info(message);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment