Kodewick
Start learning →
Starter←→0 / 70

Ice cream scoops

#038StarterMapsLoops3 min

The ice cream shop's orders for the day are in orders, one flavour per scoop. Write CountScoops(orders) to return a map of how many scoops of each flavour were ordered. No orders gives an empty map.

Examples
CountScoops([]string{"mint", "mango", "mint"})→{'mango': 1, 'mint': 2}
CountScoops([]string{})→{}
The functionfunc CountScoops(orders []string) map[string]int
main.go
package main

func CountScoops(orders []string) map[string]int {
	count := map[string]int{}
	// your code here: range over orders and add 1 for this flavour
	return count
}
Ctrl + Enter runs too
Result

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