---
title: "Comment by Juan Vidal Pich on \"How to Solve the Staircase Problem with JavaScript using Memoization\" | Hashnode"
description: "You could also do away with recursion altogether by applying dynamic programming. Start with an array of 3 values [1,2,4] for the possibilities of the first 3 s"
url: "https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a/comment/62d04bf26b0f8eeb0e0671f3"
---

[Discussion](https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a)

Comment [How to Solve the Staircase Problem with JavaScript using Memoization](https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a)

[Juan Vidal Pich](https://hashnode.com/@juanvp)

[Jul 14, 2022](https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a/comment/62d04bf26b0f8eeb0e0671f3)

You could also do away with recursion altogether by applying dynamic programming. Start with an array of 3 values \[1,2,4\] for the possibilities of the first 3 steps and then calculate the following positions as the sum of the previous 3 positions in the array. The value at N - 1 is the number of possibilities.

[Jack Follansbee](https://hashnode.com/@MrPeach)

[Jul 23, 2022](https://hashnode.com/posts/how-to-solve-the-staircase-problem-with-javascript-using-memoization/62c8bcbde62bf98e0fb06a4a/comment/62d04bf26b0f8eeb0e0671f3#reply-62db8320cf7a8a6d54f061b7)

See above, that's fairly close to what my code does.
