js get initials from name

Solutions on MaxInterview for js get initials from name by the best coders in the world

showing results for - "js get initials from name"
Reef
28 Oct 2018
1const fullName = nameString.split(' ');
2const initials = fullName.shift().charAt(0) + fullName.pop().charAt(0);
3return initials.toUpperCase();
Felipe
29 Feb 2019
1const fullName1 = "Noah William";
2const fullName2 = "Jackson";
3
4const getInitials = (name) => {
5  let initials = name.split(' ');
6  
7  if(initials.length > 1) {
8    initials = initials.shift().charAt(0) + initials.pop().charAt(0);
9  } else {
10    initials = name.substring(0, 2);
11  }
12  
13  return initials.toUpperCase();
14}
15
16console.log(getInitials(fullName1)) // NW
17console.log(getInitials(fullName2)) // JA
queries leading to this page
get initialsjavascript get the first and last letter of first and last namehow get initials from name in javascriptjs get initials from stringjs initials from namedisplay initials with last name javascriptget initials of name javascriptjavascript shorten name and give full name by that short namget first initial javascripthow to return only the initials in a name javascriptfunction to identify initials from a name jsconvert fullname into initials in javascriptinitials string jsreturn initials javascripthow to get initial javascriptget initals only of word jsjs extract initialshow to get name first intial in javascriptget first nad last letter initial jshow to show names with only the first letter of the lastname reactjquery get intials from namehow to get initials from name javascriptjs get name initialshow to print initials of words from array javascriptgetinitials in lodashget first initial name typescript get initials in javascriptgetinitials jshow to get only initials in javascriptjavascript first letter of first name and last namehow to get initials from name in javascript wit do in betweenjavascript get intials from nameget the first letter of first name and last name in javascripthow to get initials for firstname and lastname in vuejshow to take the first letter of fullname in jsjavascript get initials from full namereduce fullname to initialscreate initials from a username jsjavascript initials from nameget initials javascript functionget initials from a name jsget firstname and lastname intials from string in lodashjavascript get initialstake only initials of name jsgetting the first initials in an array in javascriptjavascript get initials from name real timeget initials javascriptjavascript get name initialshow to get initials from name in javascripthow to get the initials of name in jsget initials from name javascriptstrip out initials from name javascriptget initials of name typescriptgetting name initials using jsjavascript extract initials from namejs get initials from nameget name initials javascriptget initials jsjavascript function get initialsget only name initials letters jsget first character of name and sername in jsdisplay initials in javascriptfunction turn name into intial javascripttake initial from name jquerydisplay initials with last name in the middle in javascriptget the first initals of full name in lodashgenerate code from first letters of given name javascriptget initials from full name javascriptjavascript get user initialstypescript get initials from namehow to get initials from name in javascript with do in betweenhow to print word initials like a k in javascriptgetting starting letter in name in jsinitials javascriptjavascript get initials from nameget initials regex javascripttake first initial javascriptjavascript name initialsfind initials in javascript with split 28 29js get initials from name