let res = [];
function largestOfFour(arr) {
for(let i of arr){
res.push((Math.max(...i)))
}
return res;
}
largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])
this code doesn’t seem to be working, but as soon as I put let res = [];
inside of the function it works… I thought that since I declared res in global scope it should be accessible in all of the functions I declare…? so why didn’t it work when it was outside?