Skip to content

Instantly share code, notes, and snippets.

@maxfunke
Created February 2, 2017 09:19
Show Gist options
  • Save maxfunke/f903a3dee1d556e4b768e60808942fe7 to your computer and use it in GitHub Desktop.
Save maxfunke/f903a3dee1d556e4b768e60808942fe7 to your computer and use it in GitHub Desktop.
color codes for console.log() in javascript / Node.js
'use strict';
let colorReset = "\x1b[0m"; //reset
let colorCode = (p) => {
if (p >= 100){
return "\x1b[31m"; //red
} else if (p < 100 && p >= 90){
return "\x1b[36m"; //cyan
}
return "\x1b[32m"; //green
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment