Help! Stuck on the "Find the Longest Word in a String" problem

Hello! I’m stuck on the “Find the Longest Word in a String” problem. I have met all the requirements except one. Please can anyone review my code and tell me what I’m doing wrong?

Here is the code:

var ultimateMax = 0;
function findLongestWord(str) {
    var arr = str.split(' ');
    for (var a = 1; a < arr.length; a++) { 
      var max1 = arr[a].length; 
      for (var b = 0; b < a; b++) { 
        var max2 = arr[b].length; 
        if (max1 > max2) { 
          var totalMax = max1; 
          if (totalMax > ultimateMax) {
            ultimateMax = totalMax;
            }
          }
        }
    }
  return ultimateMax;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

Here is a screenshot of the problem:

Solved it! I just changed the position of var ultimateMax = 0; from the top to under var arr = str.split(' ');