Skip to content

Instantly share code, notes, and snippets.

@zbarnes757
Created April 29, 2018 20:00
Show Gist options
  • Save zbarnes757/f28784a9179cd4c9e2843c72eb2a23eb to your computer and use it in GitHub Desktop.
Save zbarnes757/f28784a9179cd4c9e2843c72eb2a23eb to your computer and use it in GitHub Desktop.
How Much Meat to Serve
function GuysHowMuchMeatShouldIServe(guests) {
let totalMeat = 0;
guests.forEach(guest => {
if (guest.age >= 18 && guest.gender == 'male') {
totalMeat += 1;
} else if (guest.age >= 18 && guest.gender == 'female') {
totalMeat += 0.5;
} else if (guest.age < 18 && guest.nationality == 'Texas') {
totalMeat += 1;
} else {
totalMeat += 0.25;
}
});
return totalMeat;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment