A week of temperatures is in the slice (at least one day). Write MinMax(temps) to return the lowest and the highest, both at once.
MinMax([]int{18, 25, 21})→(18, 25)MinMax([]int{7})→(7, 7)func MinMax(temps []int) (int, int)package main
func MinMax(temps []int) (int, int) {
low, high := temps[0], temps[0]
for _, t := range temps {
// your code here: lower than low? replace low. Higher than high? replace high
}
return low, high
}
Run tries the examples. When they look right, Submit.