Skip to content

Instantly share code, notes, and snippets.

@AMEYCHAVAN
Created July 8, 2016 07:02
Show Gist options
  • Save AMEYCHAVAN/56795146f5deb45e071aadfd28466095 to your computer and use it in GitHub Desktop.
Save AMEYCHAVAN/56795146f5deb45e071aadfd28466095 to your computer and use it in GitHub Desktop.
merabill.js
/*
Candidate Name:_________________________
B2X |Developer Interview | ProGram Test-1
Story:
Some friends goto a restaurant for lunch.
They Eat..They get bill.
calculate the 'share' each has to pay.
Each will pay only for items he has Consumed.
assume each friend has unique name.
*/
var bill = [{
foodchoice: "vegfriedrice",
names: ['bob', 'charlie'],
cost: 120
}, {
foodchoice: 'ice Cream',
names: ['charlie'],
cost: 30
}, {
foodchoice: 'dosa',
names: ['bob'],
cost: 80
}, {
foodchoice: 'Pizza',
names: ['charlie', 'john'],
cost: 200
}]
var calc = function(bill) {
return result;
}
console.log("----------------------")
output = calc(bill);
console.log(output);
console.log("-----------------------")
/*
output expected
result = {
totalbill: 430,
charlie: 190,
bob: 140,
john: 100,
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment