You are on the right track with map()
. Hopefully this code explains how you can do this:
// Your area of interest
var region = ee.Geometry.Point([12.492362, 41.890232]).buffer(500).bounds()
// Some collection of images. You're using MODIS here
var imageCollection = ee.ImageCollection('COPERNICUS/S2')
.filterDate('2019-01-01', '2019-02-01')
.filterBounds(region)
// A feature collection where each feature contains
// mean and max of each image in the image collection
var featureCollection = imageCollection.map(toMeanMax)
print(featureCollection)
// Calculates mean and max for an image
function toMeanMax(image) {
var meanMax = image.reduceRegion({
// Reduce the image to mean and max. Can be done separately,
// but combining two reducers is more efficient.
reducer: ee.Reducer.mean()
.combine(ee.Reducer.max(), null, true),
geometry: region, // The area of the image you want to reduce
scale: 10 // The resolution in meters to use
})
// When mapping over a collection you must return an
// image (map function returns an image collection)
// or a feature (map function returns a feature collection)
return ee.Feature(null, meanMax)
}
https://code.earthengine.google.com/68a509283944836705afc9dd989f92e6