To check whether the character is inserted earlier in the encoded string or not
if ( arr [ key [ i ] . charCodeAt ( 0 ) - 65 ] == false ) { encoded += ( key [ i ] ) ; arr [ key [ i ] . charCodeAt ( 0 ) - 65 ] = true ; } } else if ( key [ i ] . charCodeAt ( 0 ) >= ' ' . charCodeAt ( 0 ) && key [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) { if ( arr [ key [ i ] . charCodeAt ( 0 ) - 97 ] == false ) { encoded += String . fromCharCode ( key [ i ] . charCodeAt ( 0 ) - 32 ) ; arr [ key [ i ] . charCodeAt ( 0 ) - 97 ] = true ; } } }