I have a JSON output as below
{
"556520000":{
"lmin":"35",
"dm":[
{
"Width":"147"
},
{
"Depth":"10"
},
{
"Height":"137"
}
],
"lmax":"68",
}
}
I'm trying to output the dm key, into html so I get something like
<span id="sku_DM">
<ul>
<li><span>A</span> Width: 147</li>
<li><span>B</span> Depth: 10</li>
<li><span>C</span> Height: 137</li>
</ul>
</span>
The JS I have so far outputs to console ok, but when I try and to output as HTML in ID #sku_DM it just puts the last value rather than what I have in the console. My JS code is below
var SKU = "556520000";
var dimBreak = obj[SKU]["dm"];
for(var i = 0; i < dimBreak.length; i++){
const dimAll = dimBreak[i];
let entries = Object.entries(dimAll);
for(const [prop, val] of entries) {
console.log(prop, val);
var fullDimensions = (prop, val);
document.getElementById("sku_DM").innerHTML = fullDimensions;
}
}
Would appreciate some help on this. Thanks