For the first iteration 'a' will be the first object in the array, hence a.x + b.x will return 1+2 i.e 3. Now in the next iteration the returned 3 is assigned to a, so a is a number now n calling a.x will give NaN.
Simple solution is first mapping the numbers in array and then reducing them as below:
arr.map(a=>a.x).reduce(function(a,b){return a+b})
here arr.map(a=>a.x)
will provide an array of numbers [1,2,4] now using .reduce(function(a,b){return a+b})
will simple add these numbers without any hassel
Another simple solution is just to provide an initial sum as zero by assigning 0 to 'a' as below:
arr.reduce(function(a,b){return a + b.x},0)