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
Trent Burkenpas
22,388 PointsNeed help with code challenge.
struct Expense {
var description: String
var amount: Double = 0.0
init (description: String) {
self.description = description
}
func calculateTaxes(percentage:Double) -> Double {
return self.amount * percentage/100
}
}
var item = Expense(description: "Cat Food!")
item.amount = 100
item.calculateTaxes(percentage: 7.5)
var taxes = item
Not sure what to do here...
this is my swift error, I don't quite understand it
swift_lint.swift:21:20: error: extraneous argument label 'percentage:' in call item.calculateTaxes(percentage: 7.5)
1 Answer
Jennifer Morkunas
20,037 PointsYou are almost there, you just need to add parentheses around the return:
return (self.amount * (percentage/100))
Trent Burkenpas
22,388 PointsTrent Burkenpas
22,388 Pointsohh because of math operations?
well that didn't seem to be the issue. Its telling me know that the taxes variable is not a Double