How can I write this so it works?
document.getElementById("td-`${i}`")
How can I write this so it works?
document.getElementById("td-`${i}`")
You should use a template literal instead of the quoted string, not inside it:
document.getElementById(`td-${i}`)
// Here ----------------^-------^