https://leetcode.com/problems/find-the-middle-index-in-array/


Runtime: 73 ms, faster than 88.00% of TypeScript online submissions for Find the Middle Index in Array.

Memory Usage: 46.8 MB, less than 8.00% of TypeScript online submissions for Find the Middle Index in Array.


```typescript
const getSum = (nums: number[]) => {
    return nums.reduce((a, b) => a + b, 0)
}

function findMiddleIndex(nums: number[]): number {
    //08:02
    let index = 0
    while (index < nums.length) {
        const firstPart = nums.slice(0, index)
        const secondPart = nums.slice(index+1, nums.length)
        //console.log(firstPart, secondPart)
        const a = getSum(firstPart)
        const b = getSum(secondPart)
        //console.log(index, a, b)
        if (a == b) {
            return index
        }
        index += 1
    }
    return -1
    //8:11
};
```

