Check if all the digits of the given number are same | Function to check if all the digits in the number N is the same or not ; Find the last digit ; Find the current last digit ; Update the value of N ; If there exists any distinct digit , then return No ; Otherwise , return Yes ; Driver Code
function checkSameDigits ( N ) { var digit = N % 10 ; while ( N != 0 ) { var current_digit = N % 10 ; N = parseInt ( N / 10 ) ; if ( current_digit != digit ) { return " " ; } } return " " ; } var N = 222 ; document . write ( checkSameDigits ( N ) ) ;