I have a function that split a given 16 digits into 4 groups of 4 digits each with space between each group (ie. AAAABBBBCCCCDDDD
β AAAA BBBB CCCC DDDD
I use the follow way to split the string but is there a more elegant way of doing it?
let confirmNo1 = confirmNo.toString().substring(0,4);
let confirmNo2 = confirmNo.toString().substring(4,8);
let confirmNo3 = confirmNo.toString().substring(8,12);
let confirmNo4 = confirmNo.toString().substring(12,16);
Below is how I display the split strings in the react code.
<div className="confirmNo">
{confirmNo1 + " " + confirmNo2 + " " + confirmNo3 + " " + confirmNo4}
</div>