Evaluate variable
See original GitHub issueThere is a possibility to evaluate any variable?
Example Javascript
var boxSize = 140
var boxSpace = 5
function calcBoxSize(size) {
return boxSize * size + boxSpace * ((size - 1) * 2);
}
for(var i = -1; ++i < 10;) {
eval('var boxSize' + i + ' = ' + calcBoxSize(i));
}
console.log(boxSize1); // 140
console.log(boxSize2); // 290
Suggestion in Sass
$boxSize: 140px
$boxSpace: 5px
@function calcBoxSize($size)
@return $boxSize * $size + $boxSpace * (($size - 1) * 2)
@for $c from 1 through 10
$calc: calcBoxSize($c)
eval('$boxSize#{$c}: #{$calc}')
// Output
// $boxSize1: 140px
// $boxSize2: 290px
...
Issue Analytics
- State:
- Created 9 years ago
- Comments:9
Top Results From Across the Web
Evaluating expressions with two variables - Khan Academy
Evaluating expressions with two variables. CCSS.Math: ... We've done a few examples together where we were faced with 1 variable. Why not try...
Read more >Evaluating an expression with one variable - Khan Academy
Learn how to evaluate an expression with variables using a technique called substitution (or "plugging in"). Created by Sal Khan and Monterey Institute...
Read more >Evaluating expressions with one variable - Khan Academy
A mixture of explanations, examples, and practice problems to have you evaluating expressions with one variable in no time!
Read more >How To Evaluate Expressions With Variables Using Order of ...
This Pre-Algebra video tutorial explains the process of evaluating expressions with variables, fractions, and exponents.
Read more >Evaluate Expressions with Variables | Find the Value of an ...
Welcome to Evaluating Expressions with Variables with Mr. J! Need help with how to evaluate expressions with variables ?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
eval
is pretty much the one structure that is always frowned upon in all languages, Javascript, PHP, etc. Why should it be in Sass?In the end…
Map solution