1

Let the var t = [1,2,3,4,5,6,7,8,9]. I want to sum up the first 5 values in the list and print the number. I want the number 15.

1 Answers1

3

For this you can:

var t = ee.List([1,2,3,4,5,6,7,8,9]);
var t2 = t.slice(0,5);
print(t2.reduce(ee.Reducer.sum()));

hope it helps,

HamiEbra
  • 310
  • 2
  • 7