How to get first letter of each word in a string with Node.js

1 Answer

0 votes
function getFirstLetters(s) {
    const firstLetters = s.split(' ')
    					.map(word => word[0])
    				    .join('');

    return firstLetters;
}


const str = "javascript php vb typescript node.js";
 
console.log(getFirstLetters(str));
  
     
      
      
/*
run:
      
jpvtn
      
*/

 



answered Feb 15, 2022 by avibootz

Related questions

...