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 Sass Basics (retired) Speeding up Workflow with Sass Sass Functions

write a function, called double, that multiplies its input by 2

Please guys help on this question under Sass Basics course on Sass Functions. The question says: Write a function, called double, that multiplies its input by 2.

4 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi there,

It's quite a simple function really.

@function double (double) {

a {
Font-size: double * 2;

double(4px);

This is a Sass function that takes in a parameter that will hold them value we want to double. To get the actual value we want to double we just need to pass it in at function call.

double(4px);

Double is both the function name and the band of the parameter and 4px is the value. you should see 8px output to the screen.

John Lukacs
John Lukacs
26,806 Points

Its asking for an $input * 2 so I wrote /* Write your SCSS code below. */ @function double ($input) { $input * 2 } but it diden't work

John Lukacs
John Lukacs
26,806 Points
@function double ($input) {
@return unquote($input * "2")
}

still not working

John Lukacs
John Lukacs
26,806 Points
@function double ($input) {
@return $input * 2
}

ahhh there it is