Skip to content

Instantly share code, notes, and snippets.

@OneCent01
Created May 25, 2017 16:58
Show Gist options
  • Save OneCent01/c7b71f5f236d0e904fc30217f87dab8b to your computer and use it in GitHub Desktop.
Save OneCent01/c7b71f5f236d0e904fc30217f87dab8b to your computer and use it in GitHub Desktop.
Pascal's Triangle attempt
var generate = function(numRows) {
var result = [];
for(var i = 1; i <= numRows; i++) {
var inner = [];
for(var j = 0; j < i; j++) {
inner.push(Math.abs(j + 1));
}
for(var q = i - 1; q >= 1; q--) {
inner.push(Math.abs(q));
}
result.push(inner);
} return result;
};
generate(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment