How to insert an element at a specific array index with JavaScript