function insertAtIndex(array, index, elementIndex) {
    array.splice(index, 0, array[elementIndex]);
    array.splice(elementIndex + 1, 1)
    return array;
}
//insertAtIndex function takes an array, an index where the element should be inserted and elementIndex to get the element and also to delete the element at the old index.
insertAtIndex function takes an array, an index where the element should be inserted and elementIndex to get the element and also to delete the element at the old index.
insertAtIndex function takes an array an index where the element should be inserted and elementIndex to get the element and also to delete the element at the old index .
function insertAtIndex(array, index, elementIndex) {
    array.splice(index, 0, array[elementIndex]);
    array.splice(elementIndex + 1, 1)
    return array;
}
function insertAtIndex ( array , index , elementIndex ) { array . splice ( index , 0 , array [ elementIndex ] ) ; array . splice ( elementIndex + 1 , 1 ) return array ; }
insertAtIndex function takes an array, an index where the element should be inserted and elementIndex to get the element and also to delete the element at the old index.
insertAtIndex function takes an array an index where the element should be inserted and elementIndex to get the element and also to delete the element at the old index .