From c1776d5788411f89da09725b048522eacf60f9b6 Mon Sep 17 00:00:00 2001 From: Ali Helmi Date: Thu, 25 Apr 2024 08:51:46 +0200 Subject: [PATCH] update the comment to match the used HOF reduceRight --- open-in-web-browser.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open-in-web-browser.html b/open-in-web-browser.html index f4754b3..71fdfce 100644 --- a/open-in-web-browser.html +++ b/open-in-web-browser.html @@ -342,7 +342,7 @@

1.4 : New ES5 Array Methods

right to left and returning a final value.


-// 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;
 });
@@ -351,7 +351,7 @@ 

1.4 : New ES5 Array Methods

/** 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);