Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
pcm20001 committed Feb 19, 2024
1 parent 323fff7 commit 2256704
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion week-05/tip-calculator-master/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,25 @@ function updateValues(event){
/**
* Your code goes down here ...
* @todo Write functions for calculateTipPerPerson() and calculateTotalPerPerson()
*/
*/
function calculateTipPerPerson(totalValue, tipValue, peopleValue) {
totalValue = parseFloat(totalValue);
tipValue = parseFloat(tipValue);
peopleValue = parseFloat(peopleValue);

let tipPerPerson = (totalValue * (tipValue / 100)) / peopleValue;

tipPerPerson = tipPerPerson.toFixed(2);

return tipPerPerson;
}

function calculateTotalPerPerson(totalValue, tipValue, peopleValue) {
totalValue = parseFloat(totalValue);
tipValue = parseFloat(tipValue);
peopleValue = parseFloat(peopleValue);

let totalPerPerson = (totalValue + (totalValue *(tipValue / 100))) / peopleValue;
totalPerPerson = totalPerPerson.toFixed(2);
return totalPerPerson;
}

0 comments on commit 2256704

Please sign in to comment.