"Write a function called countNumbers which accepts a string of numbers and returns the count of numbers between 0 and 9."
For example:
countNumbers("this is so wonderful") // 0
countNumbers("this is so 1234") // 4
This is what I have so far:
function countNumbers(string) {
var matches = string.match(/..0.1.2.3.4.5.6.7.8.9/gi)
var regex = new RegExp(matches, 'gi')
if (matches) {
return matches.length
}
return 0;
}
I keep getting 0 returned, and it won't count the numbers within the string.