use reduce instead of for loop : <p>I want to convert this code to use reduce instead of for loop.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var a = [1, 2, 30, 4, 5, 6];
var add = 0;
var r = [];

for (var i = 0; i &lt; a.length; i++) {
	add = 0;
	for (var j = 0; j &lt; i; j++) {
  	add += a[j];
  }
  if (a[i] &gt; add) {
 	r.push(a[i]);
  }
}
console.log(r); //  =&gt; [ 1, 2, 30 ]</code></pre>
</div>
</div>
</p>

<p>How we can get same out put using reduce?</p>
