Solving Robot Paths with Pascal's Triangle
You can collapse the two base cases (n === 1 and n === 0) in getPaths() into one n &lt; 2 condition, which then also matches the base case used in pascal().

Also Pascal's triangle only needs to be calculated if n is more than 1, so the call to pascal() can be put into the else-clause rather than at the beginning of the function.

function getPaths(n) {
    if (n &lt; 2) {
        return n;
    } else {
        var tri = pascal(n * 2);
        var oddElement = (n + (n - 2));
        var mid = Math.floor(tri[oddElement].length / 2);
        // console.log(oddElement);
        return tri[oddElement][mid];
    }
}