Dynamically Remove Vowel Letters Using JavaScript Source Code

In this tutorial we will create a Dynamically Remove Vowel Letters using JavaScript. This code will remove all the vowel letters in a string when the user click the remove button. The code use replace method to locate and find the vowels that exist in a string in order to successfully remove them. This program is a user-friendly feel free to use it in your system. We will use JavaScript to allow you to implement complex things on web pages. It enables you to create dynamically updating content and add some interactive visual for the user transactions.

Getting Started:

This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.

The Main Interface

This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.         <head>
  4.                 <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
  5.                 <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
  6.         </head>
  7.         <nav class="navbar navbar-default">
  8.                 <div class="container-fluid">
  9.                         <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a>
  10.                 </div>
  11.         </nav>
  12.         <div class="col-md-3"></div>
  13.         <div class="col-md-6 well">
  14.                 <h3 class="text-primary">Dynamically Remove Vowel Letters Using JavaScript Source Code</h3>
  15.                 <hr style="border-top:1px dotted #ccc;"/>
  16.                 <div class="col-md-8">
  17.                         <a class="btn btn-success" href="index.html"><span class="glyphicon glyphicon-refresh"></span> Restart</a>
  18.                         <button class="btn btn-danger" onclick="display();"><span class="glyphicon glyphicon-remove"></span> Remove Vowels</button>
  19.                         <br /><br />
  20.                         <div id="result" align="justify" style="padding:10px; border:10px SOLID #ccc;">With clarity and definition is associated a certain physical spareness. Most of the great deciduous trees of England give one the impression, at any rate in summer, of being rather obese. In Scandinavian mythology Embla, the elm, was the first woman. Those who have lived much with old elm trees—and I spent a good part of my boyhood under their ponderous shade will agree that the Scandinavians were men of insight.</div>
  21.                 </div>
  22.         </div>
  23. <script src="js/script.js"></script>   
  24. </body>
  25. </html>

Creating the Script

This code contains the script of the application. This code will remove all the vowel letters in a word when the button is clicked. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js directory
  1. function remove(str){
  2.         return str.replace(/[aeiou]/gi, '');
  3. }
  4.  
  5. function display(){
  6.         var data = document.getElementById('result');
  7.         data.innerHTML = remove(data.innerHTML);
  8. }
There you have it we successfully created a Dynamically Remove Vowel Letters using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!

Add new comment