```
function minimumTotal(triangle) {
for (var i = 1; i < triangle.length; i++) {
for (var j = 0; j < triangle[i].length; j++) {
var l = triangle[i - 1][j - 1] === undefined ? Number.MAX_VALUE: triangle[i - 1][j - 1];
var r = triangle[i - 1][j] === undefined ? Number.MAX_VALUE: triangle[i - 1][j];
triangle[i][j] += Math.min(l, r);
}
}
return Math.min(...triangle.slice(-1)[0]);
}
```