Longest substring of vowels | Javascript program to find the longest substring of vowels . ; Increment current count if s [ i ] is vowel ; Check previous value is greater then or not ; Driver code
function isVowel ( c ) { return ( c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' ) ; } function longestVowel ( str ) { let count = 0 , res = 0 ; let s = str . split ( " " ) ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( isVowel ( s [ i ] ) ) count ++ ; else { res = Math . max ( res , count ) ; count = 0 ; } } return Math . max ( res , count ) ; } let s = " " ; document . write ( longestVowel ( s ) ) ;