Using Methods in Javascript Replace Method