Skip to content

Instantly share code, notes, and snippets.

@nyarly
Created December 13, 2016 04:19
Show Gist options
  • Save nyarly/5f59c06e480c9e5ce86df8af10f44968 to your computer and use it in GitHub Desktop.
Save nyarly/5f59c06e480c9e5ce86df8af10f44968 to your computer and use it in GitHub Desktop.
function buildStandardMatch(field, hasValue, value, otherField) {
return function(person) {
if (person[field] == value) == hasValue) {
return person[otherField]
} else {
return 0
}
}
}
religiousFreedom = {
match: buildStandardMatch("religion", 0, "christianity", "loyalty"),
}
@miriamrobern
Copy link

function valuation(person,coreValue,secondaryValue,conditionalValue,condition,bool,key) {
var issueStrength = person.values[coreValue] * 2 ;
if (secondaryValue !=== undefined) {
issueStrength += person.values[secondaryValue];
} else if ((person[condition].name === key) === bool) {
issueStrength += person.values[conditionalValue];
}
return issueStrength;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment