From 87a3518cf8739366fe61ae69743c52b0b0667e82 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 2 Apr 2019 16:52:33 -0400 Subject: [PATCH] Add basic math operations to equations.js --- src/equations.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/equations.js b/src/equations.js index cddcac9..a49184c 100644 --- a/src/equations.js +++ b/src/equations.js @@ -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;