Skip to content

Tag: reduce

How to .reduce() an array that contains functions?

Lets say we have an array of functions Is there a way to funcArray.reduce() and have all three functions apply on the string using reduce? Answer Compose is an HOC, which means it takes function and returns function. Trick is to decide when to execute the functions. Here is a sample function that will work li…

Use reduce instead of nested for loops? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 months ago. Improve this question I’m trying to print out the multiplication table using js. Is …

How to proper use reduce() javascript/typescript

I try to solve task below with reduce() and actually the result is ok. But I don’t know how to use acc in reduce() instead of acc1 or indexMax. How to apply typescript to this task. The task: Find first word with max repeated letter count. For example rrrtygggg and ttbvfddjklyyyaseqq – the winner …

How to write this function with forEach?

I am trying to group the people by their age and as you can see, my code works with the reduce method. I managed to get this working but now I want to do the same with forEach method. Here’s my code: Answer Reduce accepts initial value that you update each iteration and return. So if you wish to use