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

Angelica Hart Lindh
Angelica Hart Lindh
19,465 Points

Possible refactor...

Wasn't sure why Dale assigns logic to variables before return them inside of the functions and then again inside of the mixin? Wouldn't this be a more efficient way of achieving the same result?

@function grid-width($count, $gutter, $width) {
  @return ($count - 1) * $gutter + ($count * $width);
}

@function context-width($context, $gutter, $width) {
  @return $context * ($width + $gutter);
}

@mixin the-grid($count, $context: 12, $width: 60, $gutter: 20) {
  width: percentage(grid-width($count, $gutter, $width) / context-width($context, $gutter, $width));
}

.block {
  @include the-grid(10);
}