used array join instead of replace.

Array join should be simpler and resolve any possible inconsistency
problems with tostring between browsers.