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

Mark Mueller
Mark Mueller
6,635 Points

sass function quiz-- do I need quotes ( or unquote )

If I'm multiplying the $input in the $function by two ($input *2) does the 2 need quotes? M Sorry if this is confusing.

2 Answers

Armando Leon
Armando Leon
15,245 Points

It doesn't need quotes, and in fact, I think quotes would cause an error. Using quotes would cause the two to change from a number to a string, and you can't multiply a length by a string.

@function double($input) {
  @return $input * 2 // Works as expected
}
@function double($input) {
  @return $input * "2" // Does not work, since you can't multiply a length by a string.
}

Hopefully this helps answer your question. :)

Ismael Jimenez
Ismael Jimenez
6,704 Points

You don't need to put the double quotes to perform operations:

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

Check this link for more information:

http://sass-lang.com/documentation/file.SASS_REFERENCE.html?#number_operations