Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the comment to match the used reduceRight() #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions open-in-web-browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ <h3>1.4 : New ES5 <code>Array</code> Methods</h3>
<strong>right to left</strong> and returning a final value.</p>

<pre class="line-numbers"><code class="language-js">
// add up numbers in array from left to right i.e. (((2+5) +5 ) + 5)
// add up numbers in array from right to left i.e. (((2+5) +5 ) + 5)
var reduceRightMethod = [5, 5, 5, 2].reduceRight(function(accumulator, value, valueIndex, wholeArray){
return accumulator + value;
});
Expand All @@ -351,7 +351,7 @@ <h3>1.4 : New ES5 <code>Array</code> Methods</h3>
/** reduce also accepts a second parameter that sets the first accumulator value,
instead of using the first value in the array. **/

// add up numbers in array from left to right, but start at 10 i.e. ((((10+2) + 5 ) +5 ) + 5)
// add up numbers in array from right to left, but start at 10 i.e. ((((10+2) + 5 ) +5 ) + 5)
var reduceRightMethod = [5, 5, 5, 2].reduceRight(function(accumulator, value, valueIndex, wholeArray){
return accumulator + value; // first iteration of func accumulator is 10 not 5
}, 10);
Expand Down