JSFiddle - React, Tailwind, and code Playground
by Pavel Kityan
HTML
<div id="mon">
</div>
JavaScript
var input = {
years: ["2016","2017","2018","2019","2020","2021","2022","2023","2024","2025"],
test: {
"####": {bad: 0.2, mode: 1, good: 0.2}
}
}
//expand
for (var line in input) {
if (input[line]["####"]) {
var sample = input[line]["####"];
input.years.forEach(function(el,i){
if (!input[line][el]) {input[line][el] = sample}
});
}
}
//
input.test['2025'].good = 100;
document.getElementById('mon').innerText = JSON.stringify(input);