// Homework 23, challenge: Word frequency. // // Given a slice of words (some repeated), build a map from each unique word to // the number of times it appeared. Print every word and count, one pair per // line, in sorted order of the words. // // Hint: a missing key gives 0, so counts[word]++ works from the first time a // word is seen. // // You need another package for sorting. Change the import line to: // import ( // "fmt" // "slices" // ) // // Run with: go run exercises/23/homework/04-word-frequency.go package main import "fmt" func main() { words := []string{"apple", "banana", "apple", "cherry", "apple", "banana"} // TODO: write your code here, in place of this placeholder line: fmt.Println("TODO: replace this line", words) }