Find the Number which contain the digit d | Function to display the values ; Converting d to character ; Loop to check each digit one by one . ; Initialize the string ; Checking for digit ; Driver code
function printNumbers ( n , d ) { let st = " " + d ; let ch = st [ 0 ] ; for ( let i = 0 ; i < n ; i ++ ) { st = " " ; st = st + i ; if ( i == d || st . indexOf ( ch ) >= 0 ) document . write ( i + " " ) ; } } let n = 100 , d = 5 ; printNumbers ( n , d ) ;