Created
April 30, 2018 22:33
-
-
Save alexko30/4455bbef5c577735fc0b6791925f5fb0 to your computer and use it in GitHub Desktop.
make Initials From Name
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 makeInitialsFromName(strName) { | |
const arrName = strName.split(''); | |
const firstLetter = strName.charAt(0).toUpperCase(); | |
let arrInitials = []; | |
arrInitials.splice(0, 0, firstLetter, '. ') | |
for (var i = 0; i < arrName.length; i++) { | |
if (arrName[i] == ' ') { | |
const secondLetter = arrName[i + 1].toUpperCase(); | |
arrInitials.splice(0, 0, secondLetter, '.'); | |
const initials = arrInitials.toString().replace(/,/g, ''); | |
console.log(initials); | |
} | |
} | |
} | |
makeInitialsFromName('alex ko'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment