unicole-random-color
Version:
Printing a string with random color
23 lines (19 loc) • 613 B
JavaScript
const colors = require("colors");
function printRandomColor(text) {
const num = Math.floor(Math.random() * 5) + 1;
switch (num) {
case 1: console.log(colors.red(text));
break;
case 2: console.log(colors.green(text));
break;
case 3: console.log(colors.blue(text));
break;
case 4: console.log(colors.yellow(text));
break;
case 5: console.log(colors.magenta(text));
break;
case 6: console.log(colors.cyan(text));
break;
}
}
module.exports = printRandomColor;