I have some code which loops through an array and adds the data to a HTML table.
For one of the fields 'Unit_Sell', I would like to prefix the HTML with a '£' symbol.
Here is what I have tried.
for (var i = 0; i < arr.length; i++) {
var node = win.document.createElement("tr")
for (var key of ['description', 'ref_date_start', 'ref_date_end', 'unit_sell', 'qty', 'price']) {
var tb = win.document.createElement("td")
if (key = 'unit_sell') {
tb.innerHTML = '£' + arr[i][key]
}
tb.innerHTML = arr[i][key]
tb.style.paddingLeft = "30px";
node.appendChild(tb)
}
}
The loop works fine, but the if statement condition is not being met.