i followed the code under 3. Find the Longest Word With the reduce() Method source
why does the result show 2 instead of 5? my logic as follows:
- longest.length = 0 ("") > currentWord.length = 5 (howss) -> false, output 5
- longest.length = 5 (howss) > currentWord.length = 5 (fuund) -> false, output 5 (fuund)
- longest.length = 5 (fuund) > currentWord.length = 2 (se) -> true, output 5 (fuund)
let arr = ['howss', 'fuund', 'se']
let longestLength = arr.reduce((longest, currentWord) =>
longest.length > currentWord.length ?
longest.length : currentWord.length , "")
console.log(longestLength)
also, how do i shift line 97 to start from the same position as line 92 in the image below? the formatting currently shows that line 97 is a part of line 93. the code runs fine however