We've written this code:
func mainFunction() {
fmt.Println("My name is Andy")
fmt.Println("I code in Python")
fmt.Println("I have a dog")
fmt.Println("My name is Mike")
fmt.Println("I code in Java")
fmt.Println("I have a cat")
fmt.Println("My name is Sarah")
fmt.Println("I code in JavaScript")
fmt.Println("I have a parrot")
}
Write the same code in a better way by creating and calling a function with parameters named printMessages.
The function should accept name, language, and animal, then print the three matching lines.
Assignment
Define printMessages, then call it for Andy, Mike, and Sarah.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
