Created
April 18, 2017 05:54
-
-
Save schan90/ff1ac24f348516fb1e99f2eeea7123fb to your computer and use it in GitHub Desktop.
cs-longestWord
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
| var userInput = prompt("Enter a String:"); | |
| var longestWord = function(sen) { | |
| var slicedArr = sen.split(" "); | |
| var maximumString = ""; | |
| for (var i = 0; i < slicedArr.length; i += 1) { | |
| if (slicedArr[i].length > maximumString.length) { | |
| maximumString = slicedArr[i]; | |
| } | |
| } | |
| return maximumString; | |
| } | |
| console.log(longestWord(userInput)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment