title: A Vector Class in Javascript
body: <p>I'm trying to implement a vector object instantiated like below...</p>
  <pre class="lang-js prettyprint-override"><code>var a = new Vector([1,2,3]);
  var b = new Vector ([2,2,2]);
  </code></pre>
  <p>...and when I do a math operation I need something like this...</p>
  <pre class="lang-js prettyprint-override"><code>a.add(b); // should return Vector([3,4,5])
  </code></pre>
  <p>...but my code below returns me just an array</p>
  <pre class="lang-js prettyprint-override"><code>function Vector(components) {
    // TODO: Finish the Vector class.
    this.arr = components;
    this.add = add;
  }
  
  function add(aa) {
    if(this.arr.length === aa.arr.length) {
      var result=[];
      for(var i=0; i&lt;this.arr.length; i++) {
         result.push(this.arr[i]+aa.arr[i]);
      }
      return result;
    } else {
      return error;
    }
  }
  </code></pre>
  <p>Please help me out here. Thank you!</p>