[javascript] Why does javascript replace only first instance when using replace?