Skip to content

Instantly share code, notes, and snippets.

@alexitaylor
Created April 6, 2017 16:46
Show Gist options
  • Save alexitaylor/83a92c51ad5519cb7ed2c1fc7d18e3ae to your computer and use it in GitHub Desktop.
Save alexitaylor/83a92c51ad5519cb7ed2c1fc7d18e3ae to your computer and use it in GitHub Desktop.
if (numRows === 0) {
return [];
}
var triangle = [[1]];
for(var i = 0; i < numRows - 1; i++ ) {
var row = [1];
for(var j = 1; j < triangle[i].length; j++) {
row[j] = triangle[i][j] + triangle[i][j-1];
}
row.push(1);
triangle.push(row);
}
console.log(triangle);
return triangle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment