Swim 50 metres and you get a badge. In the starter, Swimmer already has a method Passed() that tells you whether someone made it. Write Badges(kids) to return the names that get a badge, in order; nobody gives an empty slice.
Badges([]Swimmer{{"Ivy", 50}, {"Leo", 25}, {"Max", 100}})→['Ivy', 'Max']Badges([]Swimmer{})→[]func Badges(kids []Swimmer) []stringpackage main
type Swimmer struct {
Name string
Meters int
}
func (s Swimmer) Passed() bool {
return s.Meters >= 50
}
func Badges(kids []Swimmer) []string {
names := []string{}
for _, k := range kids {
// your code here: if k passed, add the name to names
}
return names
}
Run tries the examples. When they look right, Submit.