assume a for
loop .how we can add i
in src?
extracting src from local storage
for(let i;i<10;i++){
//create an img tag object with IMG name
IMG.src='/project/images/${i}/test.png'
}
assume a for
loop .how we can add i
in src?
extracting src from local storage
for(let i;i<10;i++){
//create an img tag object with IMG name
IMG.src='/project/images/${i}/test.png'
}
There are two options:
IMG.src = `example.com/images/${i}`
+
:IMG.src = 'example.com/images/'+i
Both work, but I prefer the first option.