replaceall is not a function javascript error