0

I'm looking to create an array of image elements and the filenames are all automatically generated as a sequence, like so:

File_00000.png
File_00001.png
File_00002.png
etc...

To generate my array of images, I'm using this:

const images = [...Array(143).keys()].map((image) => {
    return (
        <img
            key={image}
            src={require(`./images/File_0000${image}.png`)}
        />
    )
})

But as it reaches 10, I can't figure out how to generate the filename when it always has 5 trailing numbers, since it's sequential but at the end of the filename.

jpea
  • 3,114
  • 3
  • 26
  • 26

0 Answers0