I have a Google Sheets table: Sheet 1 data table
and this function:
function loopMovement(movement, variation, range, a, b, c) {
let arr = [];
let projection = null;
for (let i=0; I<=range.length; i++) {
if (range[i][a]===movement && range[i][b]===variation){
projection = range[i][c];
arr.push(projection);
let maxProjection = Math.max(arr);
}
}
return maxProjection;
}
and here is the cell I have in Sheet 2: =loopMovement(Squat,Competition,Sheet1!A$2:E$7,0,1,4). However I am returned an error in the line: if (range[i][a]===movement && range[i][b]===variation){: TypeError: Cannot read property '0' of undefined (line 8).
I tried testing and here are the return values:
Return range.length:6Return range[0][a]:SquatReturn range[0][c]:110