Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Add basic math operations to equations.js
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Apr 2, 2019
1 parent 8c74b87 commit 87a3518
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/equations.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,20 @@ Equation.prototype._isCubic = function(variable) {
return this._maxDegree() === 3 && this._onlyHasVariable(variable);
};

Equation.prototype.subtract = function(val, simplify) {
return new Equation(this.lhs.subtract(val, simplify), this.rhs.subtract(val, simplify));
};

Equation.prototype.add = function(val, simplify) {
return new Equation(this.lhs.add(val, simplify), this.rhs.add(val, simplify));
};

Equation.prototype.multiply = function(val, simplify) {
return new Equation(this.lhs.multiply(val, simplify), this.rhs.multiply(val, simplify));
};

Equation.prototype.divide = function(val, simplify) {
return new Equation(this.lhs.divide(val, simplify), this.rhs.divide(val, simplify));
};

module.exports = Equation;

0 comments on commit 87a3518

Please sign in to comment.