constcapitalizeFirstAndLast=string=>{constsplitString=str=>str.split('');constfixWords=array=>array.map(v=>v.length<2?v.toUpperCase():`${v.charAt(0).toUpperCase()}${v.toLowerCase().substr(1,v.length-2)}${v.charAt(v.length-1).toUpperCase()}`);constjoinString=array=>array.join('');returnstring|>splitString|>fixWords|>joinString};//TESTINGconsttests=["and still i rise","when words fail music speaks","WHAT WE THINK WE BECOME","hello",];console.log(tests.map(capitalizeFirstAndLast));/*
[
'AnD StilL I RisE',
'WheN WordS FaiL MusiC SpeakS',
'WhaT WE ThinK WE BecomE',
'HellO'
]
*/
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.
Another JS example