JSFiddle - React, Tailwind, and code Playground
HTML
<span id = 'textSpan'></span>
JavaScript
var num = "123456789";
var result = "";
while (num.length > 0)
{
result = result + " " + num.substring(0,3);
num = num.substring(3);
}
$("#textSpan").text(result);