I'm currently tackling a challenge with my table constructor in one of my more extensive projects. The issue I am facing is that the variables in the content I am trying to pass on to the constructor function are getting evaluated before they are actually sent. Here's a simplified version of the function that highlights my dilemma:
x = 0;
tableConstructor(["<p>" + x + "</p>", "<div>" + x + "</div>"]);
function tableConstructor (tableContent) {
for (x = 0; x < 2; x++) {
window["row" + x] = tableContent[x];
console.log(window["row" + x]);
}
}
The current output looks like this:
<p>0</p>
<div>0</div>
However, what I truly desire is this output:
<p>0</p>
<div>1</div>
Any insights or assistance would be greatly appreciated.