Start learning free

LESSON 40 OF 678 · FUNCTIONS I

Exercise: Create Function with Parameters in Swift

Practice

We've written this code:

func mainFunction() {
	print("My name is Andy")
	print("I code in Python")
	print("I have a dog")

	print("My name is Mike")
	print("I code in Java")
	print("I have a cat")

	print("My name is Sarah")
	print("I code in JavaScript")
	print("I have a parrot")
}

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

STEP 1 OF 5
    Ctrl + Enter to check