javascript to check each digit in the number

Solutions on MaxInterview for javascript to check each digit in the number by the best coders in the world

showing results for - "javascript to check each digit in the number"
Katniss
28 Apr 2018
1function test_same_digit(num) {
2  const first = num % 10;
3  while (num) {
4    if (num % 10 !== first) return false;
5num = Math.floor(num / 10);
6  }
7  return true
8}
9
10console.log(test_same_digit(1234));
11console.log(test_same_digit(1111));
12console.log(test_same_digit(22222222));
13