Question: Write a function that receives a key - value pair ( for example: { 3 . 5 : 4 0 } ) where the key
Write a function that receives a keyvalue pair for example: : where the key in this case: is the note and the value in this case: is the percentage of the respective note. The function returns an object with two properties:
accumulatedPercentage equal to the sum of all percantages values
accumulatedNote equal to the sum of products of each note and its corresponding percentage keyvalue pairs Make sure that the input entered is fully correct with the validations needed.
Hints
Since the notes and percentages are entered in an object, the notes keys must all be different.
You can use console. to debug the output from your solution.
Requirements
The function accepts an object that cannot be empty. Arrays are not allowed.
Keys or values that are null, undefined or empty are not allowed.
A key must be a number in the range key
A value must be an integer number in the range value
The total sum of percentage values must be a maximum of
Output is an object that contains accumulatedPercentage and accumulatedNote properties.
In some particular cases described in section below an error message should be thrown.
Examples
Case : Output is an object that contains accumulatedPercentage and accumulatedNote properties.
Input: academicNotes::
Expected Output: object as example accumulatedPercentage: accumulatedNote:
Case : Input is not an object arrays are not allowed
Input: academicNotes :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
