Solution Review: Pascal's Triangle
This review provides a detailed analysis of the solution to Pascal's Triangle problem.
We'll cover the following...
Solution: Using Recursion
Press + to interact
function printPascal(testVariable) {// Base caseif (testVariable == 0) {return [1];}else {var line = [1];// Recursive casepreviousLine = printPascal(testVariable - 1);for (let i = 0; i < previousLine.length - 1; i++) {line.push(previousLine[i] + previousLine[i + 1]);}line.push(1);}return line;}// Driver Codevar testVariable = 5;console.log(printPascal(testVariable));
Explanation:
Each row in Pascal’s triangle starts with a ...