August 20th, 2024
What's missing in this code?
// Remove the last vowel from every word!
// removeLastVowel('how are you today?');
// hw ar yo dong?
// removeLastVowel('coding beauty and javascript!');
// codng beaty nd javascrpt!
function removeLastVowel(str)
// Helper function to find and remove the last vowel in a word
const removeVowel = (word) =>
const vowels = 'aeiouAEIOU';
for (let i =
; i >= 0; i--)
if (vowels.
(word[i]))
return word.slice(0, i) + word.slice(
);
}
}
return word;
};
return str
.split(' ')
.map((word) => removeVowel(word))
.
(' ');
}
Type or select from these options