I'm trying to create a FeatureSet from an Array. I've setup a for loop to cycle through the array and add a new row for each record in the array. The issue that I'm running into is I cannot figure out how to add a new row. So I am always overwriting the previous record.
My array is YearList = [2018,2019,2020,2021,2022,2023] and I would like a table like:
| Year | FID |
| 2018 | 0 |
| 2019 | 1 |
| 2020 | 2 |
| 2021 | 3 |
| 2022 | 4 |
| 2023 | 5 |
var YearList = [2018,2019,2020,2021,2022,2023]
for (var Yr in YearList){
var yearDict = {fields: [{alias: "Year",name: "Year",type: "esriFieldTypeInteger",}],spatialReference: '',geometryType: "",features: [{geometry: "",attributes: {Year: YearList[Yr]},}]};
};
return FeatureSet(Text(yearDict));

Any suggestions would be greatly appreciated.
Thanks everyone.
~Dan