Typescript Replace Object In Array Javascript Iteration Method