Sass str-reverse function
You want to reverse a string in your sass, scss? Here you go:
Sass:
@function str-reverse($string)
$reverse-string: ""
@for $i from 1 through str-length($string)
$c: str-slice($string, $i, $i)
$reverse-string: "#{$c}#{$reverse-string}"
@return $reverse-string
Scss:
@function str-reverse($string) {
$reverse-string: "";
@for $i from 1 through str-length($string) {
$c: str-slice($string, $i, $i);
$reverse-string: "#{$c}#{$reverse-string}";
}
@return $reverse-string;
}
Written by Maikel
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#