Using ES6 Classes

Visit http://weblogs.asp.net/dwahlin/getting-started-with-es6-using-classes for more details.

HTML

<h1>Using ES6 Classes</h1>
<div id="output"></div>

Babel + JSX

let points = [{x: 1, y: 1 }, {x: -1, y: 1 }, {x: -1, y: -1 }, {x: 1, y: -1 }, {x: 2, y: 2 }, {x: -1, y: 2 }, {x: -1, y: -2 }, {x: 1, y: -2 }, {x: 1, y: 6 }, {x: -1, y: 4 }, {x: -3, y: -1 }, {x: 1, y: -1 }, {x: 10, y: 1 }, {x: -1, y: 11 }, {x: -1, y: -1 }, {x: 1, y: -1 } ]

function findMaxVector(a) {
 
    var maxMagnitude = a[0].x * a[0].x + a[0].y * a[0].y;
    var maxIndex = 0;

    for ( var i = i; i < points.length; i++ ) {

      let point =  points[i];
      if ( point.x * a < 0 || point.y * a < 0 ){
          console.log('return')
          return; 
      }

      var magnitude = point.x*point.x + point.y*point.y;
			console.log(magnitude, maxMagnitude)
      if ( magnitude > maxMagnitude ) {
          maxMagnitude = magnitude;
          maxIndex = i;
      }

    }

    return maxIndex > -1 ? points[maxIndex] : false;

}
console.log(findMaxVector(points))