getRegion = (data, region) =>
Object.entries(
data.find(({ RegionName }) => RegionName.match(new RegExp(region, "i"))) ||
data.find(({ RegionName }) => RegionName === "United States")
).reduce((result, [key, value]) => {
if (key.startsWith("20")) {
return [...result, { date: new Date(key), price: parseFloat(value) }];
}
return result;
}, [])