update array javascript