Implement the method removeVowels that takes a string as input and returns the string after removing all vowels from it.

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.

Example 1

Input
s (string) = hello
Returns (string) hll

Example 2

Input
s (string) = Programming
Returns (string) Prgrmmng

Example 3

Input
s (string) = W3Schools
Returns (string) W3Schls

Example 4

Input
s (string) = sky
Returns (string) sky

To remove vowels from a string:

  1. Define a set of vowels (both uppercase and lowercase).
  2. Iterate through each character in the input string.
  3. If the character is not a vowel, include it in the result.
  4. 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
Ready to test your solutionRun Code checks your solution against the test cases.Shift + Enter to run

Notifications

Updates are enabled for this browser.

Receive new tutorials, articles and learning resources. You can turn updates off anytime.

Test browser code

Use this code in admin to send a test notification to this browser.