commit 5c9dcaf38e891d0421176ac927cf817e22d04a18
parent 61b9ff29b9b7c15f338c3463940c910aa3d8612b
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 10 May 2023 12:45:06 +0200
JavaScript Challenge: Day 6
Diffstat:
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Problems/2626.js b/Problems/2626.js
@@ -0,0 +1,12 @@
+/**
+ * @param {number[]} nums
+ * @param {Function} fn
+ * @param {number} init
+ * @return {number}
+ */
+
+var reduce = function(nums, fn, init) {
+ let acc = init
+ for(i in nums) acc = fn(acc, nums[i]);
+ return acc;
+};
diff --git a/README.md b/README.md
@@ -537,6 +537,7 @@ for solving problems.
| 2492 | Medium | [Minimum Score of a Path Between Two Cities](Problems/2492.cpp) |
| 2497 | Medium | [Maximum Star Sum of a Graph](Problems/2497.cpp) |
| 2620 | Easy | [Counter](Problems/2620.js) |
+| 2626 | Easy | [Array Reduce Transformation](Problems/2626.js) |
| 2634 | Easy | [Filter Elements from Array](Problems/2634.js) |
| 2635 | Easy | [Apply Transform Over Each Element in Array](Problems/2635.js) |
| 2665 | Easy | [Counter II](Problems/2665.js) |