Created
February 9, 2025 17:12
-
-
Save sierscse/b7c404ab7f19cf3d97c4b09b813f2611 to your computer and use it in GitHub Desktop.
SNAP Michigan Medical Deduction Calculator in JavaScript
This file contains 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
console.log("SNAP Michigan Medical Expense Deduction Calculator\n"); | |
/* I want to learn JavaScript, so I'm rebuilding my python SNAP MI calculator using JS | |
This calculates the total medical expense deduction for a SNAP household in Michigan | |
using the following benefit rules: https://mdhhs-pres-prod.michigan.gov/olmweb/ex/BP/Public/BEM/554.pdf | |
If total medical expenses exceed $35/mo for senior or disabled households members, | |
the SNAP household can take a standard medical deduction of $165/mo. If their countable medical expenses exceed $200/mo, | |
they can deduct the actual amount minus $35/mo */ | |
// I couldn't find a good equivalent for python's input() function so I created person objects for testing purposes | |
let person1 = { | |
name: "Allan", | |
age: 42, | |
disability: "yes", | |
medical_expenses: 30, | |
}; | |
let person2 = { | |
name: "Sally", | |
age: 60, | |
disability: "no", | |
medical_expenses: 25, | |
}; | |
let person3 = { | |
name: "Jordan", | |
age: 58, | |
disability: "no", | |
medical_expenses: 215, | |
}; | |
let household = [person1, person2, person3]; | |
function calculate_medical_deductions(_household_details) { | |
countable_medical_expenses = 0; | |
for (person in household) { | |
if ( | |
(household[person]["age"] >= 60) | | |
(household[person]["disability"] == "yes") | |
) { | |
countable_medical_expenses += household[person]["medical_expenses"]; | |
} | |
} | |
if (countable_medical_expenses <= 35) { | |
console.log( | |
"You are unable to take a medical expense deduction. Your countable medical expenses do not exceed $35 per month. ", | |
); | |
} else if ( | |
countable_medical_expenses > 35 && | |
countable_medical_expenses <= 200 | |
) { | |
console.log("You qualify for the standard medical deduction of $165. "); | |
} else { | |
countable_medical_expenses -= 35; | |
console.log( | |
"You qualify for a medical deduction of $" + countable_medical_expenses, | |
); | |
} | |
} | |
calculate_medical_deductions(household); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment