Complete the code to check if a word starts with the given prefix.
if strings.[1](word, prefix) { return true } else { return false }
The strings.HasPrefix function checks if a string starts with the given prefix.
Complete the code to iterate over all words in the list.
for [1] := 0; i < len(words); i++ { word := words[i] }
The variable i is commonly used as the index in loops.
Fix the error in the code to correctly count words with the prefix.
count := 0 for _, word := range words { if strings.HasPrefix(word, prefix) { count [1] 1 } } return count
Use count += 1 to increase the count by one each time a word matches.
Fill both blanks to create a map of words and their prefix match status.
result := make(map[string]bool) for _, [1] := range words { result[word] = strings.[2](word, prefix) } return result
Use word to iterate and strings.HasPrefix to check prefix.
Fill all three blanks to build a prefix count map for a list of words.
prefixCount := make(map[string]int) for _, word := range words { for i := 1; i <= len(word); i++ { prefix := word[:[1]] prefixCount[prefix] [2] [3] 1 } } return prefixCount
Use i to slice prefixes, += to add counts, and + to increment.
