Kodewick
Commencer à apprendre →
Bases←→0 / 70

Objets trouvés

#039Basesplace, ok := shelf[item]3 min

Au bureau des objets trouvés, la map shelf indique où chaque objet est rangé. Écris FoundAt(shelf, item) pour renvoyer l’endroit où se trouve l’objet, comme "box 3", ou "not found" s’il n’est pas dans la map.

Exemples
FoundAt(map[string]string{"umbrella": "shelf A", "scarf": "box 3"}, "scarf")→'box 3'
FoundAt(map[string]string{"umbrella": "shelf A"}, "keys")→'not found'
La fonctionfunc FoundAt(shelf map[string]string, item string) string
main.go
package main

func FoundAt(shelf map[string]string, item string) string {
	// ton code ici: cherche où est rangé item et renvoie l'endroit s'il y est
	return "not found"
}
Ctrl + Entrée lance aussi le code
Résultat

Exécuter teste les exemples. Quand ils sont bons, appuie sur Envoyer.