[javascript] How to replace item in array?