JSFiddle - React, Tailwind, and code Playground

by SwampFall

HTML

type text here & press enter, then copy the text that shows up: <input id="inp" type="text" onchange="chng()"/>
<p id="p">

</p>

JavaScript

function chng() {
  var inp = document.getElementById('inp');

  var parts = inp.value.split(' ');

  var c = ["red", "#fa0", "#ff0", "#0f0", "blue", "#f0f", "#f88"];

  var outp = "";

  for (let i = 0; i < parts.length; i++) {
    outp += "[c=" + c[i % c.length] + "]" + parts[i] + " ";
  }
 	outp += "[c=#000][c=#000]"
  document.getElementById("p").innerHTML = outp;
}