Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Functions and Optionals Functions Syntax and Parameters

What does it mean in challenge three of three when I have to call function greeting and pass it the string "Tom"?

I figured that within the function already created, i could out side the last squible parenthesis place greeting(Tom). But it doesn't know what Tom is so i placed var person = Tom. Still nothing. What am I doing wrong?

1 Answer

Rodrigo Chousal
Rodrigo Chousal
16,009 Points

Hey Cory!

You need to declare Tom a string, like so: "Tom".

You could try declaring Tom as a variable before, but it's pretty redundant. To declare Tom before calling the function, you'd do this:

var person = "Tom" // Notice the quotation marks (""). These declare your variable as a string, containing Tom.

greeting(person)

The right way to call this function would be like this:

greeting("Tom")

Hope this helps!