Check if a number is a Mystery Number | Finds reverse of given num x . ; if found print the pair , return
function reverseNum ( x ) { let s = x . toString ( ) ; let str = " " ; for ( let i = s . length - 1 ; i >= 0 ; i -- ) { str = str + s [ i ] ; } let rev = parseInt ( str ) ; return rev ; } function isMysteryNumber ( n ) { for ( let i = 1 ; i <= Math . floor ( n / 2 ) ; i ++ ) { let j = reverseNum ( i ) ; if ( i + j == n ) { document . write ( i + " " + j + " " ) ; return true ; } } document . write ( " " ) ; return false ; } let n = 121 ; isMysteryNumber ( n ) ;