✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Loop Plotly.newPlot over divs

I currently have a script that creates/names divs according to files in a folder (below). I’m looking to create a graph for each file in that folder.

<script>

            var files = fs.readdirSync(filepath)

            var x;

            for (x of files) {

              document.write("<div id = "+x+"></div>");

            }

          </script>

I’ve found the below will create and place the first graph but I’m unable to put this into a loop so I can have each graph printed beneath each other. Would anyone know how to do this?

Plotly.newPlot(x, data, layout, {responsive:true});

Thank you in advance.