Initial solution to recursion puzzle in js.