HTML5 for Beginners 6 – Count the Vowels using JavaScript

This article is the sixth post in the series that introduces HTML5 and JavaScript to beginners. In this article, we'll create an HTML5 application that allows the user to enter...

This article is the sixth post in the series that introduces HTML5 and JavaScript to beginners.  In this article, we'll create an HTML5 application that allows the user to enter a text as an input and then by pressing the button we'll provide a count of all vowels that user has typed in. 

Contents

Application Code 1

1. Online Plunker Demo 1

Final Product 2

Project Structure 3

Functionality 3

1. Header 3

2. Text Entry 3

3. Submit (‘Count Vowels’) Button 7

4. Results Boxes 8

5. countVowels() Function 10

6. showHideResults() Function 13

7. CSS styling 14

Lessons Learned 14

References 14

Application Code

Online Plunker Demo

I’ve created a running code using IDE and using Plunker. Thus, if you prefer working with interactive online console, you can see the code of here: https://embed.plnkr.co/9o12fWILFlKMTWMcZXBn/

Final Product

The Following is a screenshot of the final product. As you can see, the project includes a lot more functionality than we were asked to implement. In below sections of this document, I’ll explain all functions of this web-based application.

C:\Users\jaros\AppData\Local\Temp\SNAGHTMLac0b3d5.PNG

Project Structure

Let's keep the project structure very simple. Only three files in total:

- index.html - this files hold HTML5 code

- script.js – JavaScript code

- style.css – Cascading Style Sheet

Functionality

Header

Application page starts with a simple H1 header and my name as an author:

Preview:

Code:

Text Entry

As required, our application includes a