Javascript Replace Item In Array By Index