![]() |
The task is to write a JavaScript program that takes a string as input and returns the same string with all vowels removed. This means any occurrence of ‘a’, ‘e’, ‘i’, ‘o’, ‘u’ (both uppercase and lowercase) should be eliminated from the string. Given a string, remove the vowels from the string and print the string without vowels. Examples: Input : welcome to horje Using Regular ExpressionsRegular expressions provide a concise and powerful way to manipulate strings in JavaScript. We can use the In this approach, the regular expression Example: Implementation to remove vowels from a String using regular expression.
Output Hy Gks f GksfrGks! Time Complexity: O(n), where n is the length of the string Auxiliary Space: O(1) Using a LoopA simple loop can also be used to iterate over each character in the string and exclude vowels. Example: Implementation to remove vowels from a String using iterative approach.
Output Hy Gks f GksfrGks! Time Complexity: O(n), where n is the length of the string Auxiliary Space: O(1) Using Array MethodsAnother approach is to split the string into an array of characters, filter out the vowels, and then join the remaining characters back into a string. Example: Implementation to remove vowels from a String using array methods.
Output Hy Gks f GksfrGks! Time Complexity: O(n), where n is the length of the string Auxiliary Space: O(n) |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |