Solving the Digits in a Book Problem
Find the number of pages in a book based on its summary.
For example, if the input summary is 25, then the output should be n=17. This means that the numbers 1 to 17 have a total of 25 digits: 1234567891011121314151617.
It is guaranteed that all inputs will be valid.
Here is my current solution:
function amountOfPages(summary){
let n=1;
let arrKc=[1]
while((arrKc.join('').toString().length)!=summary){
arrKc.push( n.toString())
n++
}
return n
}
All tests are passing successfully, but I am encountering a timeout error when running the function.