Skip to content

Instantly share code, notes, and snippets.

@jbilcke
Created March 7, 2016 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbilcke/005d1942737373e6bc82 to your computer and use it in GitHub Desktop.
Save jbilcke/005d1942737373e6bc82 to your computer and use it in GitHub Desktop.
Calcul du total par personne
function total(opts){
var plats = opts.plats.reduce((r,p) => r + p)
return plats + (opts.livraison / opts.nbPersonnes) - (plats * opts.reduction)
}
total({
plats: [3.10, 8.20, 0.30], // prix des plats d'une personne
livraison: 1.50, // 12h-13h
reduction: 0.15, // 15%
nbPersonnes: 4
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment