Javascript string formatting utility