constinitialiseMiddleNames=(fullName)=>{constnames=fullName.split('')if(names.length<=2)returnfullNameconstfirstName=names.shift()constlastName=names.pop()constinitials=names.map(name=>name.charAt(0))return`${firstName}${initials.join('. ')}. ${lastName}`}initialiseMiddleNames('Jack Ryan')// Jack RyaninitialiseMiddleNames('Lois Mary Lane')// Lois M. LaneinitialiseMiddleNames('Dimitri')// DimitriinitialiseMiddleNames('Alice Betty Catherine Davis')// Alice B. C. Davis
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Javascript
This was fun :)