Created
February 5, 2020 21:22
-
-
Save eliorivero/c6bb310ad6bc47654e211909a6dadddd to your computer and use it in GitHub Desktop.
Get word initials
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
/** | |
* Given a string of words separated by spaces, return the first letter of the first two words. | |
* Originally intended to get the initials of a "name lastName" string. | |
* | |
* @param {string} words A list of words. Only the first two are taken into account the rest are ignored. | |
* | |
* @returns {string} | |
*/ | |
const getNameInitials = words => name.split(' ').slice(0, 2).reduce( (acc, cur) => acc + cur[0], '' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment