Download code/validation/JavaScript/0064156_getLongestWord.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 493 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0064156_getLongestWord.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/code/validation/JavaScript/0064156_getLongestWord.js
-
curl -L -o 0064156_getLongestWord.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0064156_getLongestWord.js
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; | |
| }; |