
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Finding the length of longest vowel substring in a string using JavaScript
Problem
We are required to write a JavaScript function that takes in a string. Our function should return the length of the longest contiguous substring that contains only vowels.
Example
Following is the code −
const str = 'schooeal'; const findLongestVowel = (str = '') => { let cur = 0 let max = 0 for (let i = 0; i < str.length; ++i) { if ("aeiou".includes(str[i])) { cur++ if (cur > max) { max = cur } } else { cur = 0 } } return max }; console.log(findLongestVowel(str));
Output
4
- Related Articles
- Program to find length of longest substring with even vowel counts in Python
- Finding the character with longest consecutive repetitions in a string and its length using JavaScript
- Finding the longest substring uncommon in array in JavaScript
- Finding the longest consecutive appearance of a character in another string using JavaScript
- Finding longest substring between two same characters JavaScript
- Finding the longest word in a string in JavaScript
- Finding the longest common consecutive substring between two strings in JavaScript
- Program to find length of longest repeating substring in a string in Python
- Finding the longest Substring with At Least n Repeating Characters in JavaScript
- Length of longest string chain in JavaScript
- Finding the longest string in an array in JavaScript
- Find length of longest subsequence of one string which is substring of another string in C++
- How to find the length of the longest substring from the given string without repeating the characters using C#?
- Find the Length of the Longest possible palindrome string JavaScript
- Finding the length of the diagonal of a cuboid using JavaScript

Advertisements