Category "reduce"

How to create a nested data structure from 2 arrays?

Hi guys I get confused trying to qcheave this, so any help would be great! I have two arrays from which I need a specific object. Source arrays: 1-Types (1D):

Google Earth Engine - use reduce(ee.Reducer.max())

I tried to used reduce(ee.Reducer.max()) and reduce(ee.Reducer.min())in the follow function, but doesn't work very well. Max and min return the same value. How

how to alter reduce function so it produce different result

I have this array: data: [ '+section1+', 'big text 1 here.', 'big text 2 here followed by list:', '-this is list item;', '-this is another list item;'

Transform array into object with custom properties

I have this array myarr = [ '=title1', 'longText0...', 'longtText1...', '=title2', 'longTextA...', 'longtTextB...', 'longtTextC...' ]; symbo

How can I get the indexes of a filtered array items

I have this situation, I have an array and I need to filter it and get the indexes of the filtered items, like this example: var arr = ['2022-05', '2023-01', '2

How can i use reduce or any other array method, to count and sum up specific properties?

I try to learn more about the array methods and also working with objects. I come up with this dummy example that simulate an incoming data. const data = [

freeCodeCamp Challenge Guide: Use the reduce Method to Analyze Data

I am in the freeCodeCamp Use the reduce Method to Analyze Data challenge. I tried: function getRating(watchList){ // Add your code below this line var count

retrieve store data from react redux

I'm new to redux, I can't get data from the store.I get this message in the console: Error: Invalid hook call. Hooks can only be called inside of the body of a

Boolean values list to integer in Python

I'm having trouble with this lambdas syntax. I'm trying to translate a list of booleans to an integer value, but I'm getting an error, I don't understand why.

How to sort array of objects by dates and make new arrays which will contain all objects with same date [closed]

I have a very specific problem in Javascript. I have array of objects, and each object contains some date. const array = [ {name: 'first', dat

Reduce javascript map change key dynamically

I would like to have the array in output using the input array in the reduce function. But I can't manage to dynamically add a key like this "${keyOrigin}": cur

Using reduce() to find min and max values?

I have this code for a class where I'm supposed to use the reduce() method to find the min and max values in an array. However, we are required to use only a si

How to group array or column based data by a specific item's/column's value while summing-up the values of another?

We are building an integration in a SAAS product which exports data from a table and writes it to a CSV file. Tool allows JavaScript (Which i am not very famili

How would you use .reduce() on arguments instead of a specific array or object?

I want to define a function .flatten that flattens several elements into one single array. I know that the following is not possible, but essentially I would li

Java Stream: divide into two lists by boolean predicate

I have a list of employees. They have isActive boolean field. I would like to divide employees into two lists: activeEmployees and formerEmployees. Is it possib

python: union keys from multiple dictionary?

I have 5 dictionaries and I want a union of their keys. alldict = [dict1, dict2, dict3, dict4, dict5] I tried allkey = reduce(lambda x, y: set(x.keys()).un