Condition to verify if index j does have frequency greater than 0 ;
if ( frequency_array [ j ] > 0 && j >= 0 ) { let str = String . fromCharCode ( j + ' ' . charCodeAt ( 0 ) ) ; ans += str ; frequency_array [ j ] -= 1 ; } else {