Answer the question
In order to leave comments, you need to log in
How to find and capitalize the first letter of the shortest word in an array?
How to find and capitalize the first letter of the shortest word in an array? There is an implementation that capitalizes the longest word in an array, but how do you capitalize the shortest word?
class MyStr {
ucMinWord(string) {
let i=0;
const wordArr=string.split(" ");
const minString=string.substring(string.lastIndexOf(" "));
for (i in wordArr)
{
if (wordArr[i].length>minString.length)
{
wordArr[i] = wordArr[i][0].toUpperCase() + wordArr[i].slice(1);
}
}
return wordArr.join(' ')
}
}
const app = new MyStr()
console.log(app.ucMinWord('deveveloper dev code'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question