Counsyl coding challenge

Summary

From the tip of the tree and moving to adjacent nodes in the row below, find the path that maximizes the sum total.
Input
Output
(function() {
  var generateData = function(level) {
    var last = [];
    while (level > 0) {
      var current = [];
      for (var i=0; i<level; i++) {
        current.push(10 + (Math.round(Math.random() * 50)));
      }
      last.push(current);
      level--;
    }
    return last.reverse();
  };
  var renderTriangle = function(data) {
    var buffer = [];
    for (var i=0, l=data.length; i<l; i++) {
      buffer.push(data[i].join(' '));
    }
    return buffer.join("\n");
  };
  var parseData = function(data) {
    var sum = 0;
    var row;
    var pointer = 0;
    var max = [];
    for (var i=0, l=data.length; i<l; i++) {
      row = data[i];
      var n = 0;
      if (i===0) {
        n = row[0];
      } else {
        if (row[pointer + 1] > row[pointer]) {
          n = row[pointer + 1];
          pointer++;
        } else {
          n = row[pointer];
        }
      }
      sum += n;
      max.push(n);
    }
    return {
      'sum' : sum,
      'max' : max
    }
  };
  var interact = function(event) {
    event.preventDefault();
    event.stopPropagation();
    var LEVELS = 8;
    var data = generateData(LEVELS);
    var triangle = renderTriangle(data);
    var calculated = parseData(data);
    this.innerText = "Do it again.";
    document.getElementById('input').style.height = (LEVELS * 1.7).toString() + "em";
    document.getElementById('input').style.textAlign = "center";
    document.getElementById('input').innerHTML = triangle;
    document.getElementById('output-max').innerHTML =  calculated.sum;
    document.getElementById('output-path').innerHTML = calculated.max.join(' &raquo; ');
  };
  document.getElementById('start-demo').addEventListener('click', interact);
})();