Kodewick
Start learning →
Basic←→0 / 70

Beach days

#028BasicSlicesLoops4 min

This week's temperatures are in temps, one per day; at 28 degrees or more it's a beach day. Write BeachDays(temps) to return which days are beach days (the first day is 1), in order. No beach days gives an empty slice.

Examples
BeachDays([]int{25, 30, 28, 22})→[2, 3]
BeachDays([]int{20, 21})→[]
The functionfunc BeachDays(temps []int) []int
main.go
package main

func BeachDays(temps []int) []int {
	days := []int{}
	for i, t := range temps {
		// your code here: hot enough? append the day number to days
	}
	return days
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.