1

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'
}
Vesal _7
  • 11
  • 2

1 Answers1

2

There are two options:

  1. backticks:
IMG.src = `example.com/images/${i}` 
  1. the +:

IMG.src = 'example.com/images/'+i

Both work, but I prefer the first option.

Hermanboxcar
  • 418
  • 1
  • 13