The challenge is this:
Write a function that returns the middle element of an array. When array size is even, return the first of the two middle elememnts.
The word elements is written wrong.
The solution from the book doesn’t work for me.
Instead of:
return array[array.count/2]
my solution is:
return array[(array.count - 1) / 2]
@djangolizer Both solutions return the array’s middle element if the array’s size is odd. Your solution returns the first of the two middle elements if the array’s size is even, while the book solution returns the second middle element for the same case.