Question: Use a reduce function to find how many small medium and large transactions. You have been contracted by Figs Unlimited - a company that runs

 Use a reduce function to find how many small medium andlarge transactions. You have been contracted by Figs Unlimited - a company

Use a reduce function to find how many small medium and large transactions.that runs a global marketplace for Fig based Jams and Jellies. They

You have been contracted by Figs Unlimited - a company that runs a global marketplace for Fig based Jams and Jellies. They have a pretty sizeable database of transaction history and have contracted you to write some code that will help them gather some information from this data. This project will be a test of your fledgling JavaScript abilities. Objectives 1. Write a JavaScript program 2. Implement and use Higher Order functions 3. Submit an Assignment Requirements Figs Unlimited has given you 2 arrays of data. The first is a list of transactions. A transaction has the following form: id: 12345,// a number uniquely identifying the transaction amount: 110.85, // a number indicating the amount in dollars the transaction was for product: "FIG_JAM", // a string indicating the type of product; one of ["FIG_JAM", "FIG_JELLY", "SPICY_FIG_JAM", "ORANGE_FIG_JELLY"] customerId: 12345 , // a number that stores the ID of the customer that made the transaction. 3 The second set of data is a list of customers. A customer has the following form: How many small, medium, and large transactions are there? A transaction under $25 is considered small. A transaction between $25 and $75 is considered medium. Transactions $75 and over are considered large. They would like the output in the following form. // the real numbers will be different than this. \{ small: 2437, medium: 1101, large: 233, \} reduce: creates an accumulated result based on the reducer function. The value returned is returned is the return value of the reducer function for the final iteration. @data: an array of any arbitrary data @reducer: a function that takes a single datapoint from each input array as an argument and the result of the reducer function from the previous iteration. Returns the result to be passed to the next iteration @initialValue: the starting point for the reduction. @return: the value from the final call to the reducer function. function reduce(data1, data2, callback) Example Usage const nums =[1,2,3,4,5]; const sum = reduce ( nums, (value, accumulatedResult) value + accumulatedResult, 0 ); console. log( sum); //15 const evensAnd0dds = reduce (nums, (value, acc) { if (value %2=0){ acc. evens.push(value); \} else \{ acc.odds.push(value); return acc; \}, \{evens: [ ], odds: []\}); console. log (evensAnd0dds); //{ evens: [2,4], odds: [1,3,5]}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!