Created
October 26, 2019 06:19
-
-
Save daubattu/2157a3208045adf32094e055e4931f95 to your computer and use it in GitHub Desktop.
[Hackerrank] Solution of Bon Appétit in JavaScript
This file contains hidden or 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
function bonAppetit(bill, k, b) { | |
const sum = bill.reduce((r, v) => r + v, 0); | |
const result = (sum - bill[k])/2; | |
if (b - result === 0) console.log('Bon Appetit'); | |
else console.log(b - result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks