Guys i'm having trouble to understand why the comparison does not work here - Basic Algorithm

Tell us what’s happening:

Your code so far

function findLongestWordLength(str) {
let arr1 = str.split(" ").reverse();
let arr2 = str.split(" ");
let final = 0;
for(let i = 0;i<arr1.length;i++){
    final = arr1[i];
return console.log(final.length);


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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0.

Challenge: Find the Longest Word in a String

Link to the challenge:


I’m curious… why are you reversing the string? And comparing the reversed string to the original string?

1 Like

I also need help

Welcome, Rafael.

The main issues are:

  1. You are returning console.log()
  2. What if arr1[i] and arr2[i] are the same length?

Hope this helps

1 Like

I did not know what I was doing, but your question made sense and I did the challenge, thank you man