Created
April 4, 2016 17:38
-
-
Save mmloveaa/1f0fa59f7c77e350e393902c69f05dd0 to your computer and use it in GitHub Desktop.
4-4 freecodecamp Q4
This file contains hidden or 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. | |
| Your response should be a number. | |
| Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
| function findLongestWord(str) { | |
| var arr = str.split(' '); | |
| var max=0; | |
| for(var i=0; i<arr.length; i++){ | |
| if(arr[i].length > max) { | |
| max=arr[i].length; | |
| } | |
| } | |
| return max; | |
| } | |
| findLongestWord("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