A gift card code is made of letters, digits and -. Write CountDigits(code) to return how many digits (0 to 9) it has. An empty string gives 0.
CountDigits("AB12C3")→3CountDigits("")→0func CountDigits(code string) intpackage main
func CountDigits(code string) int {
count := 0
for _, ch := range code {
// your code here: ch is a digit? add 1 to count
}
return count
}
Run tries the examples. When they look right, Submit.