Implement the method removeVowels
that takes a string as input and returns the string after removing all vowels from it.
Learner Level
String Manipulation Loop
The function should remove both lowercase and uppercase vowels:
- Vowels to remove:
a
,e
,i
,o
,u
,A
,E
,I
,O
,U
Only vowel characters should be removed — all other characters should remain unchanged and in the same order.
To remove vowels from a string:
- Define a set of vowels (both uppercase and lowercase).
- Iterate through each character in the input string.
- If the character is not a vowel, include it in the result.
- Return the result string after the loop.
Pseudocode:
Function removeVowels(s):
Define vowels as set of a, e, i, o, u, A, E, I, O, U
Initialize empty result string
For each character ch in s:
If ch is not in vowels:
Append ch to result
Return result