Using the @return Statement in Sass Functions
📖 Scenario: You are creating a simple Sass function to calculate the double of a number. This is useful when you want to reuse a calculation in your styles without repeating the math.
🎯 Goal: Build a Sass function called double that takes a number and returns its double using the @return statement.
📋 What You'll Learn
Create a Sass function named
double that accepts one parameter called $number.Inside the function, use the
@return statement to return the value of $number multiplied by 2.Use the function to set a CSS variable
--double-value inside the :root selector with the double of 5.💡 Why This Matters
🌍 Real World
Sass functions with @return help you write reusable style calculations, making your CSS easier to maintain and update.
💼 Career
Knowing how to write Sass functions and use @return is valuable for front-end developers working with scalable and efficient stylesheets.
Progress0 / 4 steps