https://www.codewars.com/kata/5e18743cd3346f003228b604
i am working on this task - "How many Integers in the range [0..n] contain at least one 9 in their decimal representation?". My function passed all test but final output is "Execution Timed Out (12000 ms)" what probably means that my function algorithm is inefficient. What's wrong there? Appriciate any help.
function nines(n) {
let amountOfNines = 0;
for (let i = 0; i <= n; i++) {
if (/9/.test(i)) amountOfNines++;
}
return BigInt(amountOfNines);
}