Kodewick
Start learning →
Basic←→0 / 70

Place in line

#020BasicLoopsSlices4 min

There's a queue outside the bakery; queue holds the names from front to back. Write PlaceInLine(queue, name) to return where name is in line (the front is 1). If they aren't in the queue, return 0.

Examples
PlaceInLine([]string{"Ana", "Ben", "Cai"}, "Ben")→2
PlaceInLine([]string{"Ana"}, "Zoe")→0
The functionfunc PlaceInLine(queue []string, name string) int
main.go
package main

func PlaceInLine(queue []string, name string) int {
	for i, person := range queue {
		// your code here: is this the person? return their place in line
	}
	return 0
}
Ctrl + Enter runs too
Result

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