Last active
September 25, 2021 08:58
-
-
Save Stefanacef/bd358d710dd694fbf2e7f0505e5dd3a4 to your computer and use it in GitHub Desktop.
Longest word |Solution | JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Return the length of the longest word in the provided sentence. | |
function findLongestWordLength(str) { | |
const strSplit = str.split(" ").map((val, i, arr) => { | |
return val.split("").length; | |
}); | |
const strL = Math.max(...strSplit); | |
return strL; | |
} | |
console.log( | |
findLongestWordLength("The quick brown fox jumped over the lazy dog") | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment