2800: {Date: '2022-01-14', Open: 514.48999, High: 522.570007, Low: 511.269989, Close: 520.599976, …}
2801: {Date: '2022-01-18', Open: 510.390015, High: 519.390015, Low: 504.980011, Close: 513.340027, …}
2802: {Date: '2022-01-19', Open: 516.47998, High: 528.919983, Low: 515.299988, Close: 516.580017, …}
2803: {Date: '2022-01-20', Open: 522.380005, High: 532.030029, Low: 509.640015, Close: 510.850006, …}
2804: {Date: '2022-01-21', Open: 508.5, High: 513.859985, Low: 499.269989, Close: 499.910004, …}
2805: {Date: '2022-01-24', Open: 491.070007, High: 520.429993, Low: 483.309998, Close: 519.659973, …}
2806: {Date: '2022-01-25', Open: 505.51001, High: 514.26001, Low: 500.01001, Close: 502.720001, …}
I have the following historical price data of ADBE spanning more than 10 years. I am trying to get the min and max value every year according to their reporting date, period ending Nov each year.
I am trying to get the output in an array:
[2010 min price, 2011 min price, 2012 min price ...]
const startDate = new Date("2010-12-01");
const endDate = new Date("2022-04-30");
const data2 = data.filter(a => {
const date = new Date(a.Date);
return (date >= startDate && date <= endDate);
});
console.log(data)
function findMinMax(key) {
const datas = data2.map((node) => node[key]);
return {
min: Math.min(...datas),
max: Math.max(...datas),
}
}
const checkit = findMinMax('Close')
As per the code, how can I do it without having to change the start and end date for each year just to get the min max value?