I have a NodeJS script that finds the longest string in a list, then appends spaces to make all other strings the same length. I have a problem, because I am using Chalk to color certain strings. The escape codes chalk produces are long, and when I get the length of 2 strings, let's say one is let 1 = chalk.greenBright("test") which its length should be 4, but it returns 14, and we have the other variable let 2 = "lorem ipsum" which its length should be 11. When I call .length, 1 is bigger than the other therefore causing this issue: (using E as space)
lorem ipsumEEE
test
Instead of the intended result:
lorem ipsum
testEEEEEEE