Question: I have SSRS report that has around 80+ columns. I have requirement where in dynamically hide\show columns in report based on user selection. I could able to do it by setting expression for "Visiblity" property and having report parameter thro' which columns to display can be choosen.

My problem is 2 points

1. fox example if columns 2 and 4 to be hidden, then there is an empty column between 1 and 3 and 5 columns. How to avoid this
2. When i export to PDF / Excel these spaces prevail.

Let me know your suggestions / help.

Answer: 
Here is the shortest version I could come up with.

```
_.reduce = function(list, iteratee, memo){
  var memoUndefined = arguments.length < 3;
  _.each(list, function(elem, index, list){
    if(memoUndefined) {
      memoUndefined = false;
      memo = elem;
    } else memo = iteratee(memo, elem, index, list);
  });
  return memo;
};

```
Reduce accepts three parameters: A collection (array or object), callback, and accumulator (this one is optional).

Reduce iterates through the collection, which invokes the callback and keeps track of the result in the accumulator.

If an accumulator is not passed in, we'll set it to the first element of the collection.

If an accumulator is available, we'll set the accumulator to be equal to the result of invoking the callback and passing in the current accumulator and the current element of the collection. Remember: Javascript executes its operations in right-to-left order, meaning the right side of the operator occurs first before it gets assigned to the variable on the left.

```
  _.reduce = function(collection, callback, accumulator){
    _.each(collection, function(elem){
      return accumulator === undefined ? accumulator = collection[0] : accumulator = callback(accumulator, elem);
    });

    return accumulator;
  };

```