Description
- Create a function to remove all the lowercase vowels in a given string.
- 문자열에서 모든 소문자 모음(vowel)을 제거한다.
Solution 01
function removeVowels(str) {
const vowels = 'aeiou';
let result = '';
for (let i = 0; i < str.length; i++) {
if (vowels.indexOf(str[i]) === -1) {
result += str[i];
}
}
return result;
}
removeVowels('aeiou'); // ''
removeVowels('AEIOU'); // AEIOU
removeVowels('Codewars'); // Cdwrs
removeVowels('Hello world'); // Hll wrld
Solution 02
function removeVowels(str) {
const vowels = 'aeiou';
return str.split('').filter(i => {
return vowels.indexOf(i) === -1;
}).join('');
}
removeVowels('aeiou'); // ''
removeVowels('AEIOU'); // AEIOU
removeVowels('Codewars'); // Cdwrs
removeVowels('Hello world'); // Hll wrld
Solution 03
function removeVowels(str) {
return str.replace(/[aeiou]/g, '');
}
removeVowels('aeiou'); // ''
removeVowels('AEIOU'); // AEIOU
removeVowels('Codewars'); // Cdwrs
removeVowels('Hello world'); // Hll wrld