Longest Subsequence of a String containing only vowels | Function to check whether a character is vowel or not ; Returns true if x is vowel ; Function to find the longest subsequence which contain all vowels ; Length of the string ; Iterating through the string ; Checking if the character is a vowel or not ; If it is a vowel , then add it to the final string ; Driver code
function isVowel ( x ) { x = ( x . toLowerCase ( ) ) ; return ( x == ' ' x == ' ' x == ' ' x == ' ' x == ' ' ) ; } function longestVowelSubsequence ( str ) { var answer = " " ; var n = str . length ; for ( var i = 0 ; i < n ; i ++ ) { if ( isVowel ( str [ i ] ) ) { answer += str [ i ] ; } } return answer ; } var str = " " ; document . write ( longestVowelSubsequence ( str ) ) ;