I am trying to read the JSON data
to find how many instances each trait_type’s value
appears for each nth
edition
and send the value to the HTML
table as a string with the trait_type value’s ID
. The filter
function currently returns 0 for each value.
var data = [
{
edition: 1,
attributes: [
{
trait_type: "hair",
value: "mullet"
},
{
trait_type: "hat",
value: "cap"
}
]
}
];
var mullet = data.filter(function (d) {
return d.value === "mullet";
}).length,
cap = data.filter(function (d) {
return d.value === "cap";
}).length;
document.getElementById("mullet").innerText = mullet;
document.getElementById("cap").innerText = cap;
<dl>
<dt>Hair?</dt>
<dd id="mullet"></dd>
<dt>Hat?</dt>
<dd id="cap"></dd>
</dl>