You are defining your yearDict object inside the loop, so it's getting recreated every time, losing any previous entries. Define it first outside of the loop, and use your array to populate the features array within it:
var YearList = [2018,2019,2020,2021,2022,2023]
var yearDict = {
fields: [{alias: "Year", name: "Year", type: "esriFieldTypeInteger"}],
geometryType: "",
features: []
}
for (var Yr in YearList){
Push(
yearDict['features'],
{attributes: {Year: YearList[Yr]}}
)
};
return FeatureSet(Text(yearDict));
Also, you don't need to specify the geometry or spatial reference if there isn't any.
- Josh Carlson
Kendall County GIS