I have 4 variables containing different strings, and I would like to use a for-loop to create a table and populate the cells with these strings. However, when I run my current code, I end up with "content1", "content2", etc. instead of the actual content stored in the variables content1, content2, and so on. Is there a way to convert the generated strings (e.g., "content1") back to the original variables? If yes, how can this be achieved?
var content1 = "Text1";
var content2 = "Text2";
var content3 = "Text3";
var content4 = "Text4";
for (var i = 1; i < 5; i++){
var td = document.createElement('td');
var text = document.createTextNode("content" + [k]);
td.appendChild(text);
tr.appendChild(td);
}
table.appendChild(tr);