Say I have the following array:
const months = ['January', 'February', 'March', 'April', 'June'];
And I want to add the item December at position 11. From what I know I would do:
months.splice(11, 0, "December");
I would like it to be added in position 11 and positions 5 to 10 to be "null" or "undefined". However when I do:
months.indexOf("December")
I get a result of 5 and printing the array returns December as the last position right after June.
Is there a way to add this item at the specified position?
Thanks