JavaScript to find the position of the left most vowel in a string

By | July 22, 2017

This program includes Javascript to find the position of the left most vowel in a string. This javascript is quite simple. We run a loop until the length of the input string is reached. Inside the loop, we go through each character of the string and check if a vowel (a, e, i, o, u) is present.

Input Parameter: A string
Output:
Left-most vowel and the position of the left most vowel in the string

 

Suggested Read:

 

Go through the following video to understand how to run this javascript:

Input:

JavaScript to find the position of the left most vowel in a string

 

Output 1: Success case

Output of the left most vowel in a given string using javascript

diagram showing the left most vowel in the given string using javascript

 

Output 2: When the input string contains a white space

Output of the left most vowel in the given string with space using javascript

Diagram shows the left most vowel in a string when there is a white space

 

Output 3: When there is no vowel present

javascript to find left most vowel in a string output

How to execute this script?

  1. Copy the code to a text file and save it with a .html extension.
  2. Open this file in a  browser.
  3. You will be asked to enter a string and result will be displayed.
  4. To check for another string, refresh the web page and enter a new string. You can refer to the video for easy understanding.

Please let me know if you encounter any problems.

Suggested articles for you:

Did it help? Comment here..

This site uses Akismet to reduce spam. Learn how your comment data is processed.