Return Largest Numbers in Arrays - Feeback Question

I’ve since managed to solve this challenge but was wondering why this code wasn’t accepted. It seems to give the correct answers when you test it. Anyone know why?

var large, miniArr, i;
    var result = [];
    function largestOfFour(arr) {
      for (i = 0 ; i < arr.length; i++){
        large = Math.max.apply(null, arr[i]);
    return result;

You are using global variables. After the function runs for the first test, global variables will still contain their last values when the function is run again for subsequent tests. Your function will only work once.

Ah right, works fine now! Thanks a lot, that was driving me mad.