Check if absolute difference between prev digit and current digit is 1
if ( Math . abs ( prevDigit - curDigit ) != 1 ) return false ; } prevDigit = curDigit ; n = parseInt ( n / 10 , 10 ) ; } return true ; }