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 trialPatrick Johnson
9,505 PointsAdvanced Sass: Introspection Code Challenge
Running into an issue with this particular question, its asking me to complete the function using the 'comparable' function, but when I do I get an error that asks me to return a value ONLY IF something is true.
I've set up a if/else directive that should work but isn't. Have no clue why.
4 Answers
Nathan Beste
28,366 PointsThis one took me a while as well. I guess I never caught where he uses the comparable function so I kept trying to use "@if type-of($alpha)==type-of($bravo)" which always resulted in true since they are both numbers. Problem is Sass will not allow you to add pixels and % which is why you need to use the comparable function. The comparable function is built into Sass just like lighten and darken colors.
@function add-if-comparable($alpha, $bravo) { @if comparable($alpha,$bravo) { @return $alpha+$bravo; } @else { @return 'error'; } }
Erik McClintock
45,783 PointsPatrick,
Please post the code that you've tried to help us diagnose the issue :)
Erik
Steve N. Peralta R.
31,097 PointsOh my god! Thx Nathan, that made me mad for over 2 hours!
Andrew Dalbey
8,403 PointsThank you, Nathan! Very helpful.
Wilson Usman
35,206 PointsWilson Usman
35,206 PointsI know this is the same code, but it's a little easier to understand, thanks Nathan!