Last active
March 18, 2018 11:50
-
-
Save prettydiff/8682c3a4bbaadd1a0fe0103f1ad65c98 to your computer and use it in GitHub Desktop.
color cycle text for the commandline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changeColor(str) { | |
const arr = str.split(""); | |
let a = arr.length - 1, | |
b = 8; | |
do { | |
arr[a] = `\u001b[3${b}m${arr[a]}`; | |
a = a - 1; | |
b = b - 1; | |
if (b < 1) { | |
b = 8; | |
} | |
} while (a > 0); | |
return arr.join("") + "\u001b[0m"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment