const makeAbbr = words => words.trim().replace(/(\S)(\S*\s*)?/g , "$1").toUpperCase(); console.log(makeAbbr(' c a aaa w gggg bb '));