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

Patrick Westwood
Patrick Westwood
8,299 Points

Refactoring code, SASS

"Now that you've refactored this code into something that no one would ever actually do in real life, please make this code the way you should write it. (Just because you can do something with a Sass feature, doesn't mean you should.)"

Just one question.... what? Make this code the way I should write it?

My code:

@function double($input) {
    @return $input * 2;
  }

  div {
    font-size: double(5px);
    }

3 Answers

It's much more work to declare a function that takes a value and doubles it when you can just do it on the fly like this:

div {
    font-size: 10px; // even multiplying here would be more work than necessary
}
Alan Fidelino
Alan Fidelino
12,846 Points

Tricky question but Eirik got it right. It just says that even though we know have a basic understanding of Sass, we always go by the simpler route. It's a case-to-case basis. Glad, that like you I figured it without freaking out. :)

Maria Victoria Reyes
Maria Victoria Reyes
17,731 Points

i made a new code and wrote this just below the last code: div {}. Based this code it in the existing html

p{ width:double(50%); }

Or just hit 'check' again without changing anything...