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

Write a function, called double, that multiplies its input by 2.

I can't figure out step one to this 3 part. I don't really think I'm close with my answer but I've tried so many different variations, I am too confused at this point, can someone help me out?

$double: 10px;

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

15 Answers

I believe it is asking for a function called double, you are declaring a function called input then using a variable called double.

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

link The Sass Way

Thank you Adam, I knew I was over-complicating things.

No problem. Always ensure to re read the question ensure the task is fulfilled.

Mark Long
Mark Long
15,763 Points

Try this: div { font-size: unquote(double(5) + "px"); }

Jon Brady
Jon Brady
10,868 Points

This might help if you still need it :)

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

It's not working :(

Jason Breitigan
Jason Breitigan
15,074 Points

I can't figure out how to finish this:

Use the double function you just wrote to refactor this code: div { font-size: 5px * 2; }

and none of the stuff posted here work.

  • Got it. was a simple typographical error on my part.

Hey amrutabuge,

Your previous code was:

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

They are giving you this div:

div { font-size: 5px * 2;
}

So

font-size: 5px * 2; <----- This is the same as saying --> font-size= double(5px) since "double(5px)" is calling your function

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

and replacing ($input) for 5px.

Hope it helps. T.

Craig Steele
Craig Steele
582 Points

Hey Dylan,

You should change 10px to 10 (without the px) You can only perform multiplication on numbers.

Thanks for the tip Craig. After removing the 'px' I am still getting an error "We need a function named 'double'."

I am struggling on my code form for this section, do you know what else is wrong with my answer?

Any advice for the Challenge Task 2 in the Sass Functions? Specifically, the challenge asks "Use the double function you just wrote to refactor this code: div { font-size: 5px * 2; }" Link http://teamtreehouse.com/library/sass-functions

.

Craig Steele
Craig Steele
582 Points

Hey Dylan,

Now it's just a case of changing the name of the function to be called double. Try that. (I haven't used variables in CSS before, so there may be other syntax mistakes)

""" $number = 10;

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

"""

Help! I am struggling with Task 2 as well.

"Use the double function you just wrote to refactor this code: div { font-size: 5px * 2; }"

Link: http://teamtreehouse.com/library/sass-functions

Has anybody found an answer to this problem?

Yes the first answer. Been up voted 5 times

Dang five times!

Did it work?

Yep I figured it out shortly after I posted :)

Maria Victoria Reyes
Maria Victoria Reyes
17,731 Points

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

it is saying to use the double function and refactor the exisiting code div {font-size:5px *2;}

Ivan Franzone
Ivan Franzone
7,328 Points

I wrote: div { font-size: unquote(double(5px));} and I passed the task correctly! Do you think guys that´s correct?? I think maybe it was a bug :D