← Back to challenges

Through the Grid

JavaScriptHardalgorithmsnumberslogic

Instructions

How many ways are there to navigate through a grid (w * h)?

Grid

Suppose you're on a 4 × 6 grid, and want to go from the bottom left to the top right. How many different paths can you take? Avoid backtracking, you can only move right or up.

Create a function that takes width and height and returns the amount of possibilities.

Examples

gridPos([1, 1]) ➞ 2

gridPos([6, 4]) ➞ 210

gridPos([5, 5]) ➞ 252

Notes

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.