Best way to check if a number contains another number
Convert to string and use indexOf
(752+'').indexOf('5') > -1
console.log((752+'').indexOf('5') > -1);
console.log((752+'').indexOf('9') > -1);
Convert to string
and use one of these options:
indexOf()
:
(number + '').indexOf(needle) > -1;
includes()
:
(number + '').includes(needle);