Remove Vowels from a String
Description
Given a string s
, remove the vowels 'a'
, 'e'
, 'i'
, 'o'
, and 'u'
from it, and return the new string.
Example 1:
Input: s = "leetcodeisacommunityforcoders" Output: "ltcdscmmntyfrcdrs"
Example 2:
Input: s = "aeiou" Output: ""
Constraints:
1 <= s.length <= 1000
s
consists of only lowercase English letters.
Solution(javascript)
/**
* @param {string} s
* @return {string}
*/
var removeVowels = function(s) {
let array = s.split('');
for (let letter = 0; letter < array.length; letter++) {
if(array[letter] === "a") {
array[letter] = ""
} else if (array[letter] == 'e') {
array[letter] = ""
} else if (array[letter] == 'i') {
array[letter] = ""
} else if (array[letter] == 'i') {
array[letter] = ""
} else if (array[letter] == 'o') {
array[letter] = ""
} else if (array[letter] == 'u') {
array[letter] = ""
}
}
return array.join("");
};