Last updated 4 years ago
Was this helpful?
iterate from begin to end
while iterate convert current index(begin) as string and search that '5' exist, if does not exist increase count
increase index(begin)
return count
const dontGiveMeFive = (begin, end) => { let count = 0; while (begin <= end) { if (!String(begin).match(/5/)) { count += 1; } begin += 1; } return count; };