problem description
need to use the path of the picture, but there are many pictures, but the format is / static/pic/bg0 1 2 3 4 5
the environmental background of the problems and what methods you have tried
I tried to traverse with the following code, but failed
related codes
const arr = new Array(6)
const imgsPath = arr.map((item, index) => `/static/pic/bg${index}`)
what result do you expect? What is the error message actually seen?
expect / static/pic/bg0 to 5 in imgsPath, a total of 6 path strings, but the arr.map method is not executed. So in the end, it can only be written as const arr = [0,1,2,3,4,5]
to solve this problem.
what if I have 100 such paths to deal with in the future?