Undulating numbers | JavaScript program tto check whether a number is undulating or not ; Considering the definition with restriction that there should be at least 3 digits ; Check if all alternate digits are same or not . ; Driver Code
function isUndulating ( n ) { if ( n . length <= 2 ) return false ; for ( let i = 2 ; i < n . length ; i ++ ) if ( n [ i - 2 ] != n [ i ] ) return false ; return true ; } let n = " " ; if ( isUndulating ( n ) == true ) document . write ( " " ) ; else document . write ( " " ) ;