Simple addition calculator accepting addition expressions Maybe someone can help me to optimize the calculate method. I think that it can be simplified from that what I have now.

The objective is: grab a string via the incoming argument of the calculate method and get the amount of it or difference (based on the sign standing between numbers). Count of numbers should be  2.

My function, method and constructor are working fine, but I think it is too lengthy/complex for such a simple task.

function Calculator() {

  this.calculate = function(sum) {
    this.summ = 0;

    this.sumArr = sum.split(' '); // make array from string to clear from non-numbers values
    this.newSum = this.sumArr.filter(function(number) {
      return number &gt; 0;
    });

    for (var i = 0; i &lt; this.sumArr.length; i++) { // based on the sign standing between numbers calculate it
      if (this.sumArr[i] == '+') {
        return this.summ = parseInt(this.newSum[0]) + parseInt(this.newSum[1]);
      } else if (this.sumArr[i] == '-') {
        return this.summ = parseInt(this.newSum[0]) - parseInt(this.newSum[1]);
      }
    }
  };
};

var calc = new Calculator;

console.log(calc.calculate("3 + 7")); // 10
console.log(calc.calculate("3 - 7")); // -4
Instance method vs. class method vs. function:
You declared a constructor function Calculator whose instances all come with their own individual calculate method. Since the calculate method doesn't rely on other instance properties, it should probably be a class method instead.
In JavaScript, a class method is simply a property of the constructor function:
function Calculator() { ... }

Calculator.calculate = function(sum) { ... };

Using class syntax, this is equivalent to:
class Calculator { 
  ...
  static calculate(sum) { ... }
}

However, unless your Calculator will have additional properties later on, a simple function calculate(sum) { ... } instead of a class will do the job just fine.
Instance properties and side effects:
Within your calculate method, you create new instance properties such as this.sumArr, this.newSum and this.summ holding the result of the calculation. This is called a side effect. Pure functions without such side effects are easier to understand and debug.
Also, those property names are not very descriptive.
Consistency:
For different inputs, the values of this.summ and the return values of calculate(sum) are inconsistent:
sum         calculate(sum)  this.summ 
-------------------------------------
undefined   TypeError       0
&quot;&quot;          undefined       0
&quot;1 x 1&quot;     undefined       0
&quot;1 + x&quot;     NaN             NaN

Filtering your operands with number &gt; 0 leads to strange effects such as returning NaN for inputs with a zero such as 0 + 1 and returning 1 for input bla - bla + 3 + 2.
Parsing:
Instead of parseInt(str) I recommend using the unary plus operator +str which is &quot;the fastest and preferred way of converting something into a number&quot; according to MDN.
To split an expression into operands and operator, I recommend using robust regular expressions. A regular expression makes it much easier to understand which input strings will be accepted as valid and which input strings will be rejected.
Implementation:
First, the available operations are declared. Then, the input is parsed. For valid input, the result of the operation is returned. For invalid (non-matching) input, undefined is returned:


function calculate(expression) {
  const operations = {
    '+': (left, right) =&gt; left + right,
    '-': (left, right) =&gt; left - right,
  };
  const [match, left, op, right] = expression.match(/^(\d+) (\+|\-) (\d+)$/) || [];
  return match ? operations[op](+left, +right) : undefined;
}

// Example:
console.log(calculate("3 + 7")); // 10
console.log(calculate("3 - 7")); // -4



Replacing above regular expression with e.g. a much more refined ^\s*([\+\-]?(?:\d*[.])?\d+)\s*(\+|\-)\s*([\+\-]?(?:\d*[.])?\d+)\s*$/ allows you to capture floating point numbers, negative numbers and whitespace. To support more operations, simply append them to the operations object literal, e.g. '*': (left, right) =&gt; left * right and add \* to the operator capture group within the regular expression.