Find the greater number closest to N having at most one non | Function to get closest greater number with at most non zero digit ; Stores the closest greater number with at most one non - zero digit ; Stores length of str ; Append 10 to the end of resultant string ; Append n - 1 times '0' to the end of resultant string ; Driver code
function closestgtNum ( str ) { var res = " " ; var n = str . length ; if ( str [ 0 ] < ' ' ) { res = res + String . fromCharCode ( str [ 0 ] . charCodeAt ( 0 ) + 1 ) ; } else { res = res + ' ' ; res = res + ' ' ; } for ( var i = 0 ; i < n - 1 ; i ++ ) { res = res + ' ' ; } return res ; } var str = " " ; document . write ( closestgtNum ( str ) ) ;