Exercise: count words
- Count how many times each word appears in a given slice
- You can use this skeleton:
examples/count-words-in-slices-skeleton/count_words_in_slices_skeleton.go
package main import ( "fmt" ) func main() { celestialObjects := []string{"Moon", "Gas", "Asteroid", "Dwarf", "Asteroid", "Moon", "Asteroid"} fmt.Println(celestialObjects) }
- Expected output:
[Moon Gas Asteroid Dwarf Asteroid Moon Asteroid] Moon 2 Gas 1 Asteroid 3 Dwarf 1