thanks for your explanation, now i get it. by initializing v with a value of 0 it was gonna see that zero in a subarry with neagtive numbers only. this is my updated code and it’s working
function largestOfFour(arr) {
// You can do this!
var largest = [];
for(var i = 0; i < arr.length; i++){
var v = arr[i][0];
for(var j = 0; j < arr[i].length; j++){
if(arr[i][j] > v){
v = arr[i][j];
}
}
largest.push(v);
}
return largest;
}
console.log(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]));