Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

display only initials from full name reactjs

var getInitials = function (string) {
    var names = string.split(' '),
        initials = names[0].substring(0, 1).toUpperCase();
    
    if (names.length > 1) {
        initials += names[names.length - 1].substring(0, 1).toUpperCase();
    }
    return initials;
};

console.log(getInitials('FirstName LastName'));
console.log(getInitials('FirstName MiddleName LastName'));
console.log(getInitials('1stName 2ndName 3rdName 4thName 5thName'));
Comment

PREVIOUS NEXT
Code Example
Javascript :: include antoher file wagger 
Javascript :: Biliothek 
Javascript :: how to embed element in to array 
Javascript :: run strapi plugin at startup 
Javascript :: subdomain react app 
Javascript :: mongoose wont update value in array 
Javascript :: javascript sensory errors 
Javascript :: exemplo simples de socket com node 
Javascript :: use global variable in anonymous function 
Javascript :: how to push into an array javascript 
Javascript :: “new Set” is returning an empty set in nodejs 
Javascript :: convert to jsx 
Javascript :: scroll event counting using javascript stackoverflow 
Javascript :: how to store and extract local storage 
Javascript :: $(document).ready(function() { $(".more-items").click(function() { $(this).parent().find(".more").slideToggle(); }); }); 
Javascript :: node-google-spreadsheet color border 
Javascript :: return $this-response-withType("application/json")-withStringBody(json_encode($result)); 
Javascript :: how to get only citnames in google maps api js 
Javascript :: unexpected template string expression no-template-curly-in-string react 
Javascript :: single node elasticsearch with enable security basic in docker 
Javascript :: Uncaught TypeError: jQuery.browser is undefined 
Javascript :: thunk sintaxe 
Javascript :: append new element for each value in array d3.js 
Javascript :: jquery live notification 
Javascript :: likert scale javascript code 
Javascript :: flowjs attributes 
Javascript :: create react app theme_color 
Javascript :: react native sovrapporre immagini 
Javascript :: angular specific attributes and locators list 
Javascript :: facebook game files example 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =