Here is the function, it calls ‘Uncaught RangeError: Maximum call stack size exceeded’ when run, I’m not sure why this is happening. I’m thinking somewhere it’s getting caught in an infinite loop:

```
function mergeSort(vals) {
if (vals.length > 1) {
let mid = floor(vals.length / 2);
let left = [];
let right = [];
for (let i = 0; i <= mid; i++) {
left.push(vals[i]);
}
for (let i = mid+1; i < vals.length; i++) {
right.push(vals[i]);
}
mergeSort(left);
mergeSort(right);
// Merge
let i, j, k = 0;
while (i < left.length && j < right.length) {
if (left[i] < right[j]) {
values[k] = left[i];
i++;
}
else {
values[k] = right[j];
j++;
}
k++;
}
while (i < left.length) {
values[k] = left[i];
i++;
k++;
}
while (j < right.length) {
values[k] = right[j];
j++;
k++;
}
}
}
```