Kyle Coberly
kylecoberly.com
function getInsurancePremiumFactor(age){
if (age >= 18 && age < 24) {
return 1.75;
} else if (age >= 24 && age < 60) {
return 1;
} else if (age >= 60) {
return 1.35;
}
}
18
24
60
Equivalence Partitions
Boundaries
18
24
60
function getInsurancePremiumFactor(age){
if (age >= 18 && age < 24) {
return 1.75;
} else if (age >= 24 && age < 60) {
return 1;
} else if (age >= 60) {
return 1.35;
}
}
function getInsurancePremiumFactor(age){
return insurancePremiumFactors()[getAgeGroup(age)];
}
function getAgeGroup(age){
return ageGroups().find(ageGroup => {
age >= ageGroup.minimumAge
&& age < ageGroup.maximumAge
}).label;
}
function ageGroups(){
return [{
minimumAge: 18,
maximumAge: 24,
label: "youngAdult"
},{
minimumAge: 24,
maximumAge: 60,
label: "adult"
},{
minimumAge: 60,
maximumAge: 100,
label: "senior"
}];
}
function insurancePremiumFactors(){
return {
youngAdult: 1.75,
adult: 1,
senior: 1.35
};
}
...Confidently!
kylecoberly.com