Check if a string can be converted to another string by replacing vowels and consonants | Function to check if the character is vowel or not ; Function that checks if a string can be converted to another string ; Find length of string ; If length is not same ; Iterate for every character ; If both vowel ; Both are consonants ; Driver Code
function isVowel ( c ) { if ( c === " " c === " " c === " " c === " " c === " " ) return true ; return false ; } function checkPossibility ( s1 , s2 ) { var l1 = s1 . length ; var l2 = s2 . length ; if ( l1 !== l2 ) return false ; for ( var i = 0 ; i < l1 ; i ++ ) { if ( isVowel ( s1 [ i ] ) && isVowel ( s2 [ i ] ) ) continue ; else if ( ! isVowel ( s1 [ i ] ) && ! isVowel ( s2 [ i ] ) ) continue ; else return false ; } return true ; } var S1 = " " , S2 = " " ; if ( checkPossibility ( S1 , S2 ) ) document . write ( " " ) ; else document . write ( " " ) ;