Home > Back-end >  concatenate string to variable within double quotes
concatenate string to variable within double quotes

Time:05-02

I wanted to concatenate the value of variable i to string item. i tried like below but it's not working. How can i achieve this?

var tableString = "<td><input type='text' id='item' i><td>"

i've already gone through this link: Put quotes around a variable string in JavaScript . Can i get some help on this?

CodePudding user response:

If you want to use variables inside string, you have to use template literal like this.

var tableString = `<td><input type='text' id='item${i}'><td>`
  • Related