Skip to content

Commit

Permalink
Merge pull request #483 from alzatin/equation-x
Browse files Browse the repository at this point in the history
Equation using same variable more than once fix
  • Loading branch information
BarbourSmith committed Jul 29, 2020
2 parents 88050e3 + 3a092ce commit 95fd9d8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/js/molecules/equation.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ export default class Equation extends Atom {
}

if(this.inputs.every(x => x.ready)){

//Substitute numbers into the string
//Substitute numbers into the string
var substitutedEquation = this.currentEquation
for (var key in this.inputs){
substitutedEquation = substitutedEquation.replace(this.inputs[key].name, this.findIOValue(this.inputs[key].name))
for (variable in variables){
for (var i= 0; i<this.inputs.length; i++){
if (this.inputs[i].name == variables[variable]) {
substitutedEquation = substitutedEquation.replace(this.inputs[i].name, this.findIOValue(this.inputs[i].name))
}
}
}

//Evaluate the equation
this.value = GlobalVariables.limitedEvaluate(substitutedEquation)

Expand Down

0 comments on commit 95fd9d8

Please sign in to comment.