'Loop through some results to find a path and push it to an array

I need to create a loop to search into some results to find a path and push it into an array but the way I wrote the loop, it searches only the first position, the [0].

How do I loop all of results positions in order to extract the path from all of them?

For better understanding, please check the image and the code below: structure

The code so far looks like:

let results = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;

//loop on each results
results[0].Cells.results.forEach(el => {
  let filePath = el.value;
  let fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length);

  // push to array
 pathResults.push(fileName);
});

Thanks in advance for any suggestions!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source