code: function mapCOW(arr, func) {
      var res = null;
  
      for(var i=0; i<arr.length; i++) {
          var item = func(arr[i]);
  
          if(item !== arr[i]) {
              if(!res) {
                  res = arr.slice();
              }
  
              res[i] = item;
          }
      }
  
      return res || arr;
  }
docs: copy-on-write version of map