Libove Blog

Personal Blog about anything - mostly programming, cooking and random thoughts

Rainbow Log

# Published: by h4kor

Inspired by: I thought console.log() needed some more flair and Benargee/rainbowLog.js

console.rainbow = (s) => {
    const [cs, c] = s
        .split("")
        .map((c,i) => ['%c'+c, `color:hsl(${20*i%360}, 100%, 50%)`])
        .reduce((p, c) => [p[0] + c[0], p[1].concat(c[1])], ["", []])
  console.log(cs, ...c)
}
console.rainbow("Hello World!")