Count of substrings consisting of even number of vowels | Utility function to check if a character is a vowel ; Function to calculate and return the count of substrings with even number of vowels ; Stores the count of substrings ; If the current character is a vowel ; Increase count ; If substring contains even number of vowels ; Increase the answer ; Print the final answer ; Driver Code
function isVowel ( c ) { if ( c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' ) return true ; return false ; } function countSubstrings ( s , n ) { let result = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let count = 0 ; for ( let j = i ; j < n ; j ++ ) { if ( isVowel ( s [ j ] ) ) { count ++ ; } if ( count % 2 == 0 ) result ++ ; } } document . write ( result ) ; } let n = 5 ; let s = " " ; countSubstrings ( s , n ) ;