We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bec9e2f commit 5682909Copy full SHA for 5682909
Longest Word
@@ -0,0 +1,18 @@
1
+/*************************************************************************
2
+* *
3
+* Using the JavaScript language, have the function LongestWord(sen) *
4
+* take the sen parameter being passed and return the largest word in *
5
+* the string. If there are two or more words that are the same length, *
6
+* return the first word from the string with that length. Ignore *
7
+* punctuation and assume sen will not be empty. *
8
9
+*************************************************************************/
10
+
11
+function LongestWord(sen) {
12
13
+ var arr = sen.replace(/[^a-zA-Z ]/g,"").split(" ");
14
15
+ arr.sort(function(a,b) { return b.length - a.length } );
16
+ return arr.shift();
17
18
+}
0 commit comments