Start learning free

LESSON 34 OF 671 · FUNCTIONS I

Exercise: Create Function in Go

Practice

We've written this code:

func mainFunction() {
    fmt.Println("Hello AlgoCademy!")
    fmt.Println("Coding is amazing!")
    fmt.Println("Functions are so useful!")

    fmt.Println("Hello AlgoCademy!")
    fmt.Println("Coding is amazing!")
    fmt.Println("Functions are so useful!")

    fmt.Println("Hello AlgoCademy!")
    fmt.Println("Coding is amazing!")
    fmt.Println("Functions are so useful!")
}

Write the same code in a better way by creating and calling a function printMessages().

The function should print:

Hello AlgoCademy!
Coding is amazing!
Functions are so useful!

Assignment
Define printMessages, then call it three times from mainFunction.


STEP 1 OF 5
    Ctrl + Enter to check