Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write both JavaScript (util.js) and Python Code (util.py) for the following questions. We recommend that you use another file (testUtil.js and testUtil.py) to test the
Write both JavaScript (util.js) and Python Code (util.py) for the following questions. We recommend that you use another file (testUtil.js and testUtil.py) to test the functionality of the code written. However, only the util files will be evaluated using our testing suite Questions 1 to 4 are based on Figure 1 "name": "John" "sex": "m" "country": "tt" products": [H name . "peanut "category": "food" "value": 15, "date": "2019-03-12" Figure 1-Structure of a record Write a function called "getMostValuable" that accept an array/list of customer records stored as object-literals/dictionaries. Each record has a field called 'products' which stores additional records that contain the fields 'name' and 'value. This structure is illustrated in Figure 1. The function "getMostValuable" will return the position of the customer record with the highest total value from the products they purchased 1. [51 2. Write a function called "addCustomer" that will add a new customer record to a sorted array/list of customer records. The structure of the customer record is provided in Figure 1. The records are sorted in ascending order based on the name field of the customer record [51 Write a function called "getBySex" that accepts an array/list of customer records stored as object-literals/dictionaries illustrated in Figure 1. The function will return an array/list that contains customers that matches the sex specified as a parameter. The function will accept both the word ['male', 'female'] or the letter ['m', 'f] as valid inputs. [5] 3. Write a function called "getCustomerWhoBought" that accepts an array/list of customer records stored as object-literals/dictionaries and a second parameter which stores the product category. The function will return an array/list that contains customers who has products belonging to the category specified as a parameter 4. Write both JavaScript (util.js) and Python Code (util.py) for the following questions. We recommend that you use another file (testUtil.js and testUtil.py) to test the functionality of the code written. However, only the util files will be evaluated using our testing suite Questions 1 to 4 are based on Figure 1 "name": "John" "sex": "m" "country": "tt" products": [H name . "peanut "category": "food" "value": 15, "date": "2019-03-12" Figure 1-Structure of a record Write a function called "getMostValuable" that accept an array/list of customer records stored as object-literals/dictionaries. Each record has a field called 'products' which stores additional records that contain the fields 'name' and 'value. This structure is illustrated in Figure 1. The function "getMostValuable" will return the position of the customer record with the highest total value from the products they purchased 1. [51 2. Write a function called "addCustomer" that will add a new customer record to a sorted array/list of customer records. The structure of the customer record is provided in Figure 1. The records are sorted in ascending order based on the name field of the customer record [51 Write a function called "getBySex" that accepts an array/list of customer records stored as object-literals/dictionaries illustrated in Figure 1. The function will return an array/list that contains customers that matches the sex specified as a parameter. The function will accept both the word ['male', 'female'] or the letter ['m', 'f] as valid inputs. [5] 3. Write a function called "getCustomerWhoBought" that accepts an array/list of customer records stored as object-literals/dictionaries and a second parameter which stores the product category. The function will return an array/list that contains customers who has products belonging to the category specified as a parameter 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started