Kodewick
Start learning →
Mini challenge←→0 / 70

Who was mentioned

#036Mini challengeStringsSlices7 min

In a group chat, @name calls someone. Write Mentions(msg) to return the mentioned names in order, without the @. Words are separated by exactly one space; if nobody is mentioned, or the message is empty, return an empty slice.

Examples
Mentions("hi @ana and @ben")→['ana', 'ben']
Mentions("no one here")→[]
The functionfunc Mentions(msg string) []string
main.go
package main

import "strings"

func Mentions(msg string) []string {
	names := []string{}
	// your code here: split msg at spaces; for words starting with @, append the name after it to names
	return names
}
Ctrl + Enter runs too
Result

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