-
-
Save jakub-kaninsky-epptec/770c66fd08cc86ac8ce418d42e05865e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // PART 1: Call the Decision Table: "People's age" and map the values from the response | |
| const peopleRiskFactors = DR.solve("e7b7ec2f-b156-18a8-a6a3-9a1d7c44db7d", input.people, "latest", SolverStrategy.FIRST_MATCH); | |
| // PART 1.1: Map the values from the response | |
| const peopleRiskFactorsMapped = peopleRiskFactors.map((element) => element[0].ageRiskFactor); | |
| // PART 2: Add all of the values from "peopleRiskFactors" together | |
| let totalAgeRiskFactor = peopleRiskFactorsMapped.reduce((a,b) => a+b,0); | |
| // PART 2.1: Round the number (this is caused by converting decimal values to binary floating point numbers) | |
| totalAgeRiskFactor = Math.round((totalAgeRiskFactor + Number.EPSILON) * 100) / 100; | |
| // PART 3: Set the "totalAgeRiskFactor" as an output | |
| output.peopleRiskFactor = totalAgeRiskFactor; | |
| return output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment