I'm working on a table constructor for one of my larger projects but the variables in the content I'm trying to send to the constructor function evaluate before they are sent. Here is a cut down version of the function that should show my problem:
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 output is:
<p>0</p>
<div>0</div>
But what I want is:
<p>0</p>
<div>1</div>
Can anyone help me?