Complete the code to create an array of 5 integers.
arr := [5]int[1]
The correct way to initialize an array of 5 integers with zeros is {0, 0, 0, 0, 0}.
Complete the code to check if a key exists in a Go map.
value, ok := myMap[[1]]To check if a key exists in a map, use the key variable inside the brackets.
Fix the error in the linked list traversal code by completing the blank.
for current != nil { fmt.Println(current.value) current = current.[1] }
prev instead of next.value as the next node.To move to the next node in a linked list, use the next pointer.
Fill both blanks to create a map comprehension that stores word lengths for words longer than 3 characters.
lengths := map[string]int{}
for _, word := range words {
if len(word) [1] 3 {
lengths[word] = [2]
}
}We check if the word length is greater than 3 and then store the length in the map.
Fill all three blanks to create a map that stores keys and their values only if the value is positive.
result := map[string]int{}
for k, v := range data {
if v [1] 0 {
result[[2]] = [3]
}
}We check if the value is greater than 0, then store it with the original key in the result map.
