function check_digit_exists(n, digit) {
while (n > 0) {
if (digit == n % 10) {
return true;
}
n = parseInt(n / 10);
}
return false;
}
const num = 230168;
console.log(check_digit_exists(num, 1));
console.log(check_digit_exists(num, 5));
/*
run:
true
false
*/