Leetcode Mountain Array
It would be better to try and use built in functions for iterating over arrays. It appears that you are trying to generate and store all possible mountains. This would not be necessary. This would be my approach.

var longestMountain = function(arr) {
  //get nodes that may be the peaks of mountains
  var candidates = arr.map(function(currentValue, index) {
    if (index == 0 || index === arr.length - 1) {
      return false;
    } else {
      return arr[index - 1] &lt; currentValue &amp;&amp; arr[index + 1] &gt; currentValue;
    }
  });

  //for each index, calculate the height of the slope where arr[i - 1] &lt; arr[i]
  var increasingMountainCounts = arr.map(function(currentValue, index) {
    if (index == 0 || arr[index - 1] &gt;= currentValue) {
      return 0;
    } else {
      return arr[index - 1] + 1;
    }
  });

  //for each index, calculate the height of the slope where arr[i - 1] &gt; arr[i]
  var decreasingMountainCounts = arr.reverse().map(function(currentValue, index) {
    if (index == 0 || arr[index - 1] &gt;= currentValue) {
      return 0;
    } else {
      return arr[index - 1] + 1;
    }
  });

  //for each candidate peak, get the height of the mountain with that peak
  var maxMountainHeight = 0;

  candidates.forEach(function(currentValue, index) {
    if (currentValue !== true) {} else {
      maxMountainHeight = Math.max(maxMountainHeight, increasingMountainCounts[index - 1] + decreasingMountainCounts[index + 1] + 1);
    }
  });

  return maxMountainHeight;

};


An alternative approach which uses more javascript array iterators but in my opinion makes the code a bit less readable.

var longestMountain = function(arr) {
  var candidates = arr.map(function(currentValue, index) {
    if (index == 0 || index === arr.length - 1) {
      return false;
    } else {
      return arr[index - 1] &lt; currentValue &amp;&amp; arr[index + 1] &gt; currentValue;
    }
  });

  var increasingMountainCounts = arr.map(function(currentValue, index) {
    if (index == 0 || arr[index - 1] &gt;= currentValue) {
      return 0;
    } else {
      return arr[index - 1] + 1;
    }
  });

  var decreasingMountainCounts = arr.reverse().map(function(currentValue, index) {
    if (index == 0 || arr[index - 1] &gt;= currentValue) {
      return 0;
    } else {
      return arr[index - 1] + 1;
    }
  });

  var maxMountainHeightAccumulator = (maxMountainHeight, currentValue, index) =&gt; {
    if (currentValue !== true) {
      return maxMountainHeight;
    } else {
      return Math.max(maxMountainHeight, increasingMountainCounts[index - 1] + decreasingMountainCounts[index + 1] + 1);
    }
  };

  return candidates.reduce(maxMountainHeightAccumulator, 0);

};


In terms of improving performance, this reminds me of the problem of finding the (contigious) subsequence with the maximum sum/product. That solution would probably require completely rewriting your code.