remove an index number from array

You are calling the remove function on the Int value at the given index, not on the array:

func deleteElementInArray(arr: [Int], index: Int) -> [Int] {
    // make a mutable copy of the array
    var array = arr
    // remove the item at given index
    array.remove(at: index)
    // return the array  
    return array
}

Leave a Comment