Created
August 15, 2021 07:43
-
-
Save ameer/1b94793573e2a90f2cb05d639bba28c4 to your computer and use it in GitHub Desktop.
Have you ever seen those very long names which truncated into little ones? Like i18n for Internationalization? Here is a fun function for doing this using j8t (aka JavaScript).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function trimmer(word){ | |
const len = word.length | |
const number = len - 2 | |
return (word.charAt(0) + number + word.charAt(len - 1)).toLowerCase() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment