Check if a string is Isogram or not | function to check isogram ; loop to store count of chars and check if it is greater than 1 ; if count > 1 , return false ; Driver code ; checking str as isogram ; checking str2 as isogram
function check_isogram ( str ) { let length = str . length ; let mapHash = new Array ( 26 ) ; mapHash . fill ( 0 ) ; for ( let i = 0 ; i < length ; i ++ ) { mapHash [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; if ( mapHash [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] > 1 ) { return false ; } } return true ; } let str = " " ; let str2 = " " ; if ( check_isogram ( str ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ; if ( check_isogram ( str2 ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ;