I have a JSON file with a category structure of unknown depth. I want to make sure all pages can be accessed. I established three nested calls, but I think it would be better to recursion here. Unfortunately, I have no experience with Typescript regarding recursion. Can someone be so kind as to help me put the logic into a function I can call?

```
  test.setTimeout(28800000); // 8 hours max.
    // console.log(ofcJSON)
  for (let i = 0; i < ofcJSON.items.length; i++) {
    let currentPage = ofcJSON.items[i].link
    console.log(currentPage)
    if (!currentPage.startsWith("http")) await page.goto(currentPage)
    if (ofcJSON.items[i].items != null) {
        for (let j = 0; j < ofcJSON.items[i].items!.length; j++) {
            let currentPage1 = ofcJSON.items[i].items![j].link
            console.log(currentPage1)
            if (!currentPage1.startsWith("http")) await page.goto(currentPage1)
            if (ofcJSON.items[i].items![j].items != null) {
                for(let k = 0; k < ofcJSON.items[i].items![j].items!.length; k++) {
                    let currentPage2 = ofcJSON.items[i].items![j].items![k].link
                    console.log(currentPage2)
                    if (!currentPage2.startsWith("http")) await page.goto(currentPage2)
                    if (ofcJSON.items![i].items![j].items![k].items != null) {
                        for(let l = 0; l < ofcJSON.items[i].items![j].items![k].items!.length; l++) {
                            let currentPage3 = ofcJSON.items[i].items![j].items![k].items![l].link
                            console.log(currentPage3)
                            if (!currentPage3.startsWith("http")) await page.goto(currentPage3)
                        }
                    }
                }
            }
        }
    }
  }
});

```

The JSON has 1 **items** object, which in turn can have 1 **items** object. This is optional. I don't know the depth.
['https://Stackoverflow.com/questions/73659886', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/558120/']
Personally, I'd recommend using an f-string. These allow you to input variables of any type within your code without too much issue. Wrap your variables in {}, like I've shown below.

```
sqlcuery=f"insert into position {position}"

```
Try this:

```
"insert into position ('position'), values('"+str(position)+"')"

```

To transform the integer or float to a string.

You can do this more elegantly with a f-string:

```
f"insert into position ('position'), values('{position}')"

```