<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fakrul Islam Robin</title>
    <description>The latest articles on DEV Community by Fakrul Islam Robin (@fakrulrobin).</description>
    <link>https://dev.to/fakrulrobin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F768599%2F2d5f308d-682b-408d-aa3e-6975cd09343a.jpeg</url>
      <title>DEV Community: Fakrul Islam Robin</title>
      <link>https://dev.to/fakrulrobin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fakrulrobin"/>
    <language>en</language>
    <item>
      <title>The every and reduce method in javascript array</title>
      <dc:creator>Fakrul Islam Robin</dc:creator>
      <pubDate>Mon, 20 Dec 2021 15:24:44 +0000</pubDate>
      <link>https://dev.to/fakrulrobin/the-every-and-reduce-method-in-javascript-array-1eha</link>
      <guid>https://dev.to/fakrulrobin/the-every-and-reduce-method-in-javascript-array-1eha</guid>
      <description>&lt;ol&gt;
&lt;li&gt;every();&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The every method in JavaScript aray returns the Boolean value is the every element of an array passes the functions condition.&lt;/p&gt;

&lt;p&gt;The every method will executes the user specified function on every present element of an array until it finds falsy value. If any falsy value found by the callback function it immediately returns the false. Hence, the callback function returns truthy value for every element the every will return true.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const func = (value) =&amp;gt; value &amp;lt; 30;
const array1 = [25,28,15,19,7];
console.log(array1.every(func)); //returned true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;reduce() &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The reduce method in JavaScript&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hm8hAphH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6gtv2l9nrpj2px2l4mhl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hm8hAphH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6gtv2l9nrpj2px2l4mhl.png" alt="The every method and reduce method in javascript array operation" width="880" height="275"&gt;&lt;/a&gt; is execute a users specified callback function on each element of an array. The final result of the function will be a single value. &lt;/p&gt;

&lt;p&gt;When first time the callback function run no value will be return of the previous calculation. If we give any initial value as starts value it will use otherwise the 0 number index element will use as an initial value and iteration starts from index number 1./&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const array1 = [1, 2, 3, 4];
const reducer = (previousValue, currentValue) =&amp;gt; previousValue + currentValue;

// 1 + 2 + 3 + 4
console.log(array1.reduce(reducer));
// 5 + 1 + 2 + 3 + 4
console.log(array1.reduce(reducer, 5));
// expected output: 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
