# Finding max length in string

Question is regarding this challenge: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/find-the-longest-word-in-a-string

I am wondering why in the solution code here:

function findLongestWordLength(s) {
return s.split(' ')
.reduce(function(x, y) {
return Math.max(x, y.length)
}, 0);
}

it shows y.length but not x.length? Why is it only y that has .length after it.
I thought that with reduce we compare the x and the y so shouldn’t they both have .length after?

.reduce((acc,cur) => { ... codes return value} , 0)

In this example,
x in place of accumulator (acc), (its value = 0 for the first time)
y in place of current value (cur). ( array’s item in relation to its iteration)

Each iteration, x will be result of Math.max(x, y.length). Then, you will again compare new x value with y.length and asign the result of Math.max(x, y.length ) to x again.

In short, you are not comparing the string values inside array to each other. Y is string so you can access lenght property on it, but X is number.