Skip to content

Instantly share code, notes, and snippets.

@jakub-kaninsky-epptec
Created December 21, 2022 12:23
Show Gist options
  • Select an option

  • Save jakub-kaninsky-epptec/770c66fd08cc86ac8ce418d42e05865e to your computer and use it in GitHub Desktop.

Select an option

Save jakub-kaninsky-epptec/770c66fd08cc86ac8ce418d42e05865e to your computer and use it in GitHub Desktop.
// 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