Introduction
In Go, maps are built-in associative data types that allow you to store key/value pairs. This challenge will test your ability to create, manipulate, and delete key/value pairs in a map.
This tutorial is from open-source community. Access the source code
In Go, maps are built-in associative data types that allow you to store key/value pairs. This challenge will test your ability to create, manipulate, and delete key/value pairs in a map.
In this challenge, you will need to create a map that stores the number of times each word appears in a given string. You will need to split the string into words, and then iterate over each word, adding it to the map if it doesn't already exist, or incrementing its count if it does.
## Note that maps appear in the form `map[k:v k:v]` when
## printed with `fmt.Println`.
$ go run maps.go
map: map[k1:7 k2:13]
v1: 7
v3: 0
len: 2
map: map[k1:7]
prs: false
map: map[bar:2 foo:1]
In this challenge, you learned how to use maps in Go to store key/value pairs. You also learned how to split a string into words, iterate over each word, and add it to a map. By completing this challenge, you should have a better understanding of how to use maps in your Go programs.