In the below code, I'm going to remove some images from image collection by if condition in .map() instead of filter.neq(), what should I do for this purpose?
Map.centerObject(table);
Map.addLayer(table);
var s2 = ee.ImageCollection("COPERNICUS/S2")
.filterBounds(table)
.filterDate('2016-01-01','2020-01-01')
.filter(ee.Filter.lessThan('CLOUDY_PIXEL_PERCENTAGE',45))
.filter(ee.Filter.eq('system:index','20170910T071621_20170910T073037_T39SUR').not())
.filter(ee.Filter.eq('system:index','20180518T071621_20180518T071934_T39SUR').not());
print(s2);
code link: https://code.earthengine.google.com/7dc1cf120153095b7f48c133015398ca