---
# System prepended metadata

title: MaxIndex

---


### Challenge: MaxIndex

Implement a function **`maxIndex`** that takes in a vector of numbers and returns the index of the highest number in it. If the vector is empty, the function should return **`-1`**.

```=json
maxIndex([1, 2, 3]); // Returns 2
maxIndex([3, 2, 1]); // Returns 0
maxIndex([1, 3, 2, 3]); // Returns 1
maxIndex([]); // Returns -1
```

