Format string function for javascript