Pendigard's picture
Upload folder using huggingface_hub (part 7)
ae4627d verified
Raw History Blame Contribute Delete
493 Bytes
var coderbyte = coderbyte || {};
// Version 1: A regular expression and a for-loop with an artificial termiantion.
coderbyte.getLongestWord = function(string) {
var sanitizedSentence = string.replace(/[^a-z]+/gi, " "),
words = sanitizedSentence.split(" "),
longestWord = "",
i,
len;
for (i = 0, len = words.length; i < len; i++) {
if (words[i].length > longestWord.length) {
longestWord = words[i];
}
}
return longestWord;
};