Kodewick
Start learning →
Basic←→0 / 70

Count the toppings

#033BasicStringsSlices4 min

Bubble tea toppings are written as one string separated by commas, like "pearls,jelly,pudding". Write CountToppings(order) to return how many toppings there are. No toppings is the empty string "", which gives 0.

Examples
CountToppings("pearls,jelly,pudding")→3
CountToppings("")→0
The functionfunc CountToppings(order string) int
main.go
package main

import "strings"

func CountToppings(order string) int {
	count := 0
	if order != "" {
		// your code here: split order at the commas; count is the number of pieces
	}
	return count
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.