Skip to content

Commit d931d34

Browse files
committed
LongestWord
1 parent 93fafbf commit d931d34

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

LongestWord.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function LongestWord(sen) {
2+
sen=sen.replace(/[^a-zA-Z ]/ig,'')
3+
words = sen.split(" ")
4+
LongestWord = words[0]
5+
for (i = 0; i<words.length; i ++) {
6+
if (words[i].length > LongestWord.length) {
7+
LongestWord = words[i]
8+
}
9+
}
10+
return LongestWord
11+
}
12+
13+
14+
15+
16+
// keep this function call here
17+
LongestWord(readline());

0 commit comments

Comments
 (0)