how to change the colour of text outputted in the console using javascript code example

Example 1: js console log with color

console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');

Example 2: console.log with color font

var colors = require('colors');

console.log('This is rainbow'.rainbow);
console.log('This is zebra'.zebra);
console.log('This is america'.america);
console.log('This is trap'.trap);
console.log('This is random'.random);
console.log('This is random2'.random);
console.log('This is random3'.random);