v1
4/22/2019 by stecman -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const types = ['in', 'out'];
const years = [2000, 2005, 2010, 2015, 2016, 2017];
const regions = ['Africa', 'Americas', 'Asia', 'Europe', 'Oceania'];
delete caserun single casemove downdrag and drop case


ready



var dataset = {};

for (let typ of types) {
  dataset[typ] = {};

  for (let year of years) {
    dataset[typ][year] = {};

    for (let region of regions) {
      dataset[typ][year][region] = [];
    }
  }
}
delete caserun single casemove updrag and drop case


ready



/*
  Convert regions to an object with each region as a property and
  the region's value as an empty array.
*/
const regionsObj = regions.reduce((acc, region) => {
  acc[region] = []
  return acc
}, {}) // The initial value of the accumulator (`acc`) is set to `{}`.

function copyObj(obj) {
  return JSON.parse(JSON.stringify(obj))
}

/*
  Do the same thing with the years, but set the value
  for each year to the regions object.
*/
const yearsObj = years.reduce((acc, year) => {
    acc[year] = copyObj(regionsObj)
  return acc
}, {})

// One more time for the type. This will return our final object.
const dataset = types.reduce((acc, type) => {
  acc[type] = copyObj(yearsObj)
  return acc
}, {})
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN