Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rguasp
Copy link

@rguasp rguasp commented Apr 3, 2018

No description provided.

}
}
console.log(longestWord);
if(longestWord.length === 0){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did not need to make an if statement for "undefined"...
If you would have just just changed line 29 to let longestWord = words[0]; , then you could have done this:

function findLongestWord(words) {

  let longestWord = words[0];

  for (i = 0; i < words.length; i++) {
    if (words[i].length > longestWord.length) {
      longestWord = words[i];
    }
  }

    return longestWord;

}
var longest = findLongestWord(words);
console.log(longest);

@ianizaguirre
Copy link

Try to apply this feedback on your next project.
If you have any questions on my feedback, just send me a message on Slack.
Aside from that, good job and keep up the good work! 😁

Kind Regards,
Ian Izaguirre | Ironhack TA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants