Start learning free

LESSON 44 OF 671 · FUNCTIONS I

Return: Buggy Code II in Go

Practice

We've written a program and expected it to print Hey, Andy, but the function prints instead of returning the greeting, so the Go compiler rejects it with missing return.

The caller already stores the returned value in greeting and prints it afterwards, so the function should use return.

Assignment:

Fix getGreeting so it returns "Hey, " + name.


STEP 1 OF 1
    Ctrl + Enter to check