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 trialDylan George
1,293 PointsWrite 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
Adam Sackfield
Courses Plus Student 19,663 PointsI 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
Mark Long
15,763 PointsTry this: div { font-size: unquote(double(5) + "px"); }
Jon Brady
10,868 PointsThis might help if you still need it :)
div {
font-size: double(5px);
}
abuge
990 PointsIt's not working :(
Jason Breitigan
15,074 PointsI 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.
Mark Long
15,763 Pointsunquote
Tavo Zambrano
5,240 PointsHey 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
582 PointsHey Dylan,
You should change 10px to 10 (without the px) You can only perform multiplication on numbers.
Dylan George
1,293 PointsThanks 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?
Scott Sundsvold
Web Development Techdegree Student 4,479 PointsAny 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
Dylan George
1,293 Points.
Craig Steele
582 PointsHey 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;}
"""
abuge
990 PointsHelp! I am struggling with Task 2 as well.
"Use the double function you just wrote to refactor this code: div { font-size: 5px * 2; }"
Timothy Crandall
4,354 PointsHas anybody found an answer to this problem?
Adam Sackfield
Courses Plus Student 19,663 PointsYes the first answer. Been up voted 5 times
Timothy Crandall
4,354 PointsDang five times!
Adam Sackfield
Courses Plus Student 19,663 PointsDid it work?
Timothy Crandall
4,354 PointsYep I figured it out shortly after I posted :)
Maria Victoria Reyes
17,731 Pointsdiv{ font-size:double(5px) }
it is saying to use the double function and refactor the exisiting code div {font-size:5px *2;}
Ivan Franzone
7,328 PointsI 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
Dylan George
1,293 PointsDylan George
1,293 PointsThank you Adam, I knew I was over-complicating things.
Adam Sackfield
Courses Plus Student 19,663 PointsAdam Sackfield
Courses Plus Student 19,663 PointsNo problem. Always ensure to re read the question ensure the task is fulfilled.