I am working with an array of objects that have a year and count property like this:
[{year: "1920", count: 0}, {year: "1921", count: 2}, {year: "1925", count: 0}, {year: "1930", count: 21}, ....]
My goal is to populate all the years between a starting year (e.g. 1900) and an ending year (e.g. 2000) in the array with objects like {year: -year-, count: 0}. For example, filling in the years between 1900 and 1920, 1921 and 1925, 1925 and 1930, and 1930 and 2000.
If anyone has encountered a similar issue and can offer some guidance, I would greatly appreciate it!
Edit: So far, I have attempted a simple for loop, checking each iteration if the year is in the array. However, I believe there may be a more efficient and effective solution to this problem.