Created
April 6, 2017 16:46
-
-
Save alexitaylor/83a92c51ad5519cb7ed2c1fc7d18e3ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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