Kodewick
Start learning →
Basic←→0 / 70

Next in line

#027BasicSlices4 min

There's a queue at the post office counter; queue[0] is being served and the next people should get ready. Write NextUp(queue) to return the next two. queue has at least 1 person; if fewer than two are waiting, return those there are, or an empty slice.

Examples
NextUp([]string{"Ana", "Ben", "Cai", "Dee"})→['Ben', 'Cai']
NextUp([]string{"Ana", "Ben"})→['Ben']
The functionfunc NextUp(queue []string) []string
main.go
package main

func NextUp(queue []string) []string {
	next := queue[1:]
	// your code here: more than 3 people? change next to queue[1:3]
	return next
}
Ctrl + Enter runs too
Result

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