Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
on("init", () => {
var state = {
Status: "New"
};
return state;
});
on("loan-submission", (state, req) => {
state.Amount = req.Amount;
if(req.CreditScore < 500) {
state.Status = "Denied";
return "Credit score too low";
}
if(req.Amount < 1000) {
state.Status = "Approved";
return "Credit score is good and loan amount is small";
}
if(req.LifeInsurance == null) {
state.Status = next("life-insurance-setup");
return;
}
state.Status = next("compute-apr");
return;
});
on("life-insurance-setup", (state, req) => {
if(req.Denied){
state.Status = "Denied";
return "Cannot get a loan for this ammount without life insurance";
}
state.Status = next("compute-apr");
});
on("compute-apr", (state, req) => {
if(req.APR > 25) {
state.Status = "Denied";
return "Better to refuse the loan than handle usury charges";
}
state.Status = next("offer-to-user");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.