Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var generate = function(numRows) {
- var previousLine = []; //array to hold each line of the triangle
- var overallArr = []; //final array that has all the lines of the triangle in it
- if(overallArr === undefined){ //if the final array is undefined
- previousLine.push(1); //make the first nested array equal to one to start the triangle
- overallArr.push(previousLine); //put the first line of triangle into the overall array
- numRows--; //decrement numRows left
- }
- if(numRows === 0){ //if we run out of number of rows
- return overAllArr; //return overallArr/triangle
- }
- var add = function (rowNumber, previousLine)
- if(n > 0){
- for(var i = 0; i < previousLine.length < i++){ //loop through previous line
- //add the two numbers above (same index + index - 1)
- //push sum into previousLine array
- //once gone through the previousLine array loop
- //push this previousline to the outcome array
- }
- }
- };
Add Comment
Please, Sign In to add comment