Is this answer acceptable in the real world?

How can I overcome this habit of hardcoding? (staticIndex)

This answer works only for 4 sub arrays

function largestOfFour(arr) {

// You can do this!

var staticIndex = [0, 1, 2, 3];

var ans = [];

for (var i = 0; i < arr.length; i++) {

var max = arr[staticIndex[i]][0];

for (var j = 1; j < arr[i].length; j++) {

if (arr[i][j] > max) {

max = arr[i][j];

}

}

ans.push(max);

}

return ans;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

*I thought of using higher order functions but I didn’t know how*

**Link to challenge:**

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays