Check if two numbers have same number of digits | Function that return true if A and B have same number of digits ; Both must be 0 now if they had same lengths ; Driver code
function sameLength ( A , B ) { while ( A > 0 && B > 0 ) { A = parseInt ( A / 10 ) ; B = parseInt ( B / 10 ) ; } if ( A == 0 && B == 0 ) return true ; return false ; } let A = 21 , B = 1 ; if ( sameLength ( A , B ) ) document . write ( " " ) ; else document . write ( " " ) ;