I have to make the abbreviation function in JavaScript, but whatever I do, I can not find the way to abbreviate a phrase such as 'National Aeronautics Space Administration' to NASA. I just can return N. here is the code I wrote:
function makeAbbr(words) {
let abbreviation = words.trim();
for (let i=0; i< words.length; i++){
if(words[i]!==''){
return abbreviation.toUpperCase().charAt(0);
}if(words[i]===''){
abbreviation+= words.charAt();
}
}
}
Try giving a white space instead of empty string
Apply this to else portion also