Last active
December 20, 2015 20:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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