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

Anton Bredl
Anton Bredl
15,359 Points

Code Challenge Question 1

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

I can't get past this code challenge. I have have tried several variations of the code above. What am I doing incorrectly? Does the return argument need a semicolon after it or not? In the video it didn't put one forward.

Any help would be greatly appreciated.

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Anton,

There's nothing wrong with your function declaration. You just need a CSS selector and property to apply it too. What your function is doing is making a calculation and providing a variable to store the data in for use later.

So you have your function as below.

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

But then how do you use it? Like in programming you pass in the value as a function call.

Let's say you want Sass to double the width of an element. Say in this example an element with the class of blog. To do this you'd have the width: property as normal but then call the function and give it a value.

  .blog {
   width: double(10px);
  } 

So width and the function name and double the value of what you pass by 2. This would then output the following CSS.

.blog {
  width: 20px;
}

Don't worry about struggling. I had to remind myself of all of this too. If you haven't heard of it already SassMeister is a great way to practice Sass.

Good luck. :)