js get initials from name
const fullName = nameString.split(' ');
const initials = fullName.shift().charAt(0) + fullName.pop().charAt(0);
return initials.toUpperCase();
js get initials from name
const fullName = nameString.split(' ');
const initials = fullName.shift().charAt(0) + fullName.pop().charAt(0);
return initials.toUpperCase();
get initials from full name javascript
const fullName1 = "Noah William";
const fullName2 = "Jackson";
const getInitials = (name) => {
let initials = name.split(' ');
if(initials.length > 1) {
initials = initials.shift().charAt(0) + initials.pop().charAt(0);
} else {
initials = name.substring(0, 2);
}
return initials.toUpperCase();
}
console.log(getInitials(fullName1)) // NW
console.log(getInitials(fullName2)) // JA
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us