title: Exporting Sentinel-2 cloudless image collection from Google Earth Engine
body: <p>I would like to export a composite cloudless Sentinel-2 image from Google Earth engine which compiles data from 2017 until current. I am looking to export composites for each individual band. </p>
  
  <pre><code>function maskS2clouds(image) {
    var qa = image.select('QA60');
  
    // Bits 10 and 11 are clouds and cirrus, respectively.
    var cloudBitMask = 1 &lt;&lt; 10;
    var cirrusBitMask = 1 &lt;&lt; 11;
  
    // Both flags should be set to zero, indicating clear conditions.
    var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
        .and(qa.bitwiseAnd(cirrusBitMask).eq(0));
  
    return image.updateMask(mask).divide(10000);
  }
  
  
  // Filter to only include images intersecting Colorado or Utah.
  var polygon = ee.Geometry.Polygon({
    coords: [[[-135.3539859086835, 64.45205192005692],
            [-135.3539859086835, 64.00063248338122],
            [-134.008160713371, 64.00063248338122],
            [-134.008160713371, 64.45205192005692]]],
    geodesic: false
  });
  
  // Map the function over one year of data and take the median.
  // Load Sentinel-2 TOA reflectance data.
  var dataset = ee.ImageCollection('COPERNICUS/S2')
                    .filterDate('2018-01-01', '2019-07-17')
                     .filter(ee.Filter.calendarRange(6,9,'month'))
                    .filterBounds(polygon)
                    // Pre-filter to get less cloudy granules.
                    .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30))
                    .map(maskS2clouds);
  
  var rgbVis = {
    min: 0.0,
    max: 0.3,
    bands: ['B4', 'B3', 'B2'],
  };
  </code></pre>