Start learning free

LESSON 42 OF 671 · FUNCTIONS I

Return: Buggy Code I in Go

Practice

We've written a program and expected it to print 20, but the function does not return the value it computes, so the Go compiler rejects it.

In Go, this function header promises to return an int:

func getDouble(n int) int

That means the function body must use return to send an integer back to the caller.

Assignment:

Fix the function so it returns double n and the program prints 20.


STEP 1 OF 1
    Ctrl + Enter to check