 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements
 