Nontrivial undulant Numbers | Function to check if a string is double string or not ; a and b should not be equal ; Condition to check if length is odd make length even ; First half of s ; Second half of s ; Double string if first and last half are equal ; Function to check if N is an Nontrivial undulant number ; Driver Code
function isDouble ( num ) { let s = num . toString ( ) ; let l = s . length ; if ( s [ 0 ] == s . charAt [ 1 ] ) return false ; if ( l % 2 == 1 ) { s = s + s [ 1 ] ; l ++ ; } let s1 = s . substr ( 0 , l / 2 ) ; let s2 = s . substr ( l / 2 ) ; return ( s1 == s2 ) ; } function isNontrivialUndulant ( N ) { return N > 100 && isDouble ( N ) ; } let n = 121 ; if ( isNontrivialUndulant ( n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }