Kodewick
Start learning →
Basic←→0 / 70

Last song

#026BasicSlices3 min

The playlist is in the slice playlist. Write LastSong(playlist) to return the name of the last song. An empty playlist gives "".

Examples
LastSong([]string{"Rain", "Sunny", "Moon"})→'Moon'
LastSong([]string{})→''
The functionfunc LastSong(playlist []string) string
main.go
package main

func LastSong(playlist []string) string {
	last := ""
	// your code here: not empty? put the last song in last
	return last
}
Ctrl + Enter runs too
Result

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