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

CSS Advanced Sass Advanced Functions Introspection: Part 2

Nick Basile
Nick Basile
17,942 Points

[Solved] Advanced Sass: Advanced Functions

Can anyone catch where my code is failing? I can't seem to understand why it isn't passing. I'm using the comparable() function to check whether $alpha and $bravo are true, and then adding them together.

style.scss
$ems: 2em;
$pixels: 5px;
$percents: 25%;
$inches: 1in;

@function add-if-comparable($alpha, $bravo) {
//My code starts here
  @if comparable($alpha, $bravo) == true {
    $output: $alpha + $bravo;
  } @else {
    $output: "error";
  }
  @return $output;
}

.block {
  display: block;
  background-color: orange;
  font-size: add-if-comparable($ems, $ems);
  content: add-if-comparable($pixels, $percents);
}
Nick Basile
Nick Basile
17,942 Points

Figured it out: needed to define $output prior to the if statement.

@function add-if-comparable($alpha, $bravo) {
  /* Add your code here! */
  $output: null;
  @if comparable($alpha, $bravo) == true {
    $output: $alpha + $bravo;
  } @else {
    $output: "error";
  }
  @return $output;
}