JSFiddle - React, Tailwind, and code Playground

by Shree Khanal

JavaScript

function checkName(authorName) {
    //console.log(authorName.split(' ')[0].length);
    //debugger;
    alert(authorName);
    var aName = authorName.split(' ')[0];//.length;
    //alert(aName.length);
    authorName = aName.length >= 5 ? aName.replace(/^([a-z])/g, : authorName;
    //console.log(authorName);
    return authorName;
  }

var nm=checkName('smapat chauhan');
alert(nm);