Skip to content

Instantly share code, notes, and snippets.

@Nasah-Kuma
Created October 2, 2022 01:07
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 Nasah-Kuma/0c7ba9912b6c81cc4c670a6b6a98b710 to your computer and use it in GitHub Desktop.
Save Nasah-Kuma/0c7ba9912b6c81cc4c670a6b6a98b710 to your computer and use it in GitHub Desktop.
/*
* Complete the 'bonAppetit' function below.
*
* The function accepts following parameters:
* 1. INTEGER_ARRAY bill
* 2. INTEGER k
* 3. INTEGER b
*/
function bonAppetit(bill, k, b) {
let actualBill = 0;
let totalCost = 0;
for (let item of bill) totalCost+=item;
actualBill = (totalCost - bill[k])/2;
console.log(actualBill === b ? 'Bon Appetit' : b - actualBill);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment