Program to check if a number is divisible by any of its digits | JavaScript implementation of above approach ; Converting integer to string ; Traversing the string ; find the actual digit ; If the number is divisible by digits then return yes ; If no digits are dividing the number then return no ; Driver Code ; passing this number to get result function
function getResult ( n ) { let st = n . toString ( ) ; for ( let i = 0 ; i < st . length ; i ++ ) { let d = st [ i ] . charCodeAt ( 0 ) - 48 ; if ( n % d == 0 ) { return " " ; } } return " " ; } let n = 9876543 ; document . write ( getResult ( n ) ) ;