Last active
August 16, 2021 19:05
-
-
Save mvcds/42ec8a628223cd73ed659c4a40a235d1 to your computer and use it in GitHub Desktop.
Testing data or rules 2
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
// this is hard-coded data | |
// probably it comes from the business rules | |
const MIN_POINTS = 5 | |
// the argument is a dynamic data | |
// it might come from another place on the codebase | |
// or somewhere else, like a database | |
function calculateFidelity({ type, experiments }: User, products: [Product]) { | |
const points = products.reduce( | |
(total,{ fidelityPoints }) => total + fidelityPoints, | |
MIN_POINTS | |
) | |
if (experiments.includes(INCREASE_FIDELITY_GAMA)) { | |
points *= 3 | |
} | |
//in js/ts we don't know if `type.fidelity` is a data or a rule (getter) | |
return type.fidelityModifier * points | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment