I have a feature collection of polygons that contains a property ("yrbegun") indicating the year I want to use to do some manipulation. I would like to start a loop from the year before to the year after, i.e. if the property indicates 2005, I want to loop from 2004 to 2006
// Determine the year the project was started
var projectyear = ee.Number(inFeature.get("yrbegun"))
// Define the "boundaries" of the loop
var startyear = projectyear.subtract(1)
var endyear = projectyear.add(1)
// Run the loop
for (var yr= projectyear; yr <= endyear; yr = yr + 1) {
print('This is year ' + yr)
print(yr)
}
However, the loop never runs. I tried to define projectyear without the ee.Number() function, but it also does not work.