Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = gets().split(' ');
- let specialCharacters = [];
- // Removing all letters, whitespaces and numbers from each word of the input
- input.forEach(element => {
- let specialWord = element.replace(/[0-9a-zA-Z .]/g, "");
- specialCharacters.push(specialWord);
- });
- // Removing the empty strings (if any) from the specialCharacters array
- let filteredSpecialCharacters = specialCharacters.filter(function(e){return e});
- // Finding the longest word from te specialCharacters array
- let longestSymbols = Math.max(...(specialCharacters.map(el => el.length)));
- print(longestSymbols);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement