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 Enums and Structs Structs and their Methods Struct Methods

Structs and their Methods Challenge 2

func calculateTaxes(percentage: Double) -> Double{ (self.amount * (percentage/100)) return (self.amount) }

I'm sure my second line is wrong, but I'm stuck after trying out several things

2 Answers

Ben Griffith
Ben Griffith
5,808 Points

Almost there. Instead of just returning the output of the calculation, you're simply returning self.amount. All you need to do is add return before the calculation.

return (self.amount * (percentage/100))

You could do the calculation, store it in a variable and return that like below, but I'm not sure if it would validate for this specific task.

var amountWithTax = (self.amount * (percentage/100))
return amountWithTax

Hope this helps!

Awesome, thanks.