Skip to content

Instantly share code, notes, and snippets.

@gavinmcfarland
Last active December 20, 2015 20:49
Show Gist options
  • Select an option

  • Save gavinmcfarland/6192838 to your computer and use it in GitHub Desktop.

Select an option

Save gavinmcfarland/6192838 to your computer and use it in GitHub Desktop.
This is SASS function which adds up all the values in a list.
@function sum($list) {
$total: 0;
// Check it's the first item in the list and set it as the total
@each $item in $list {
@if $item == nth($list, 1) {
$total: $item;
}
// For each item in the list, add it to the total
$total: $total + $item;
}
@return $total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment