MCPcopy Create free account
hub / github.com/LinkedInLearning/javascript-essential-training-2832077 / tipCalculator

Function tipCalculator

08_10e/script.js:41–53  ·  view source on GitHub ↗
(sum, percentage, locale, currency, printHTML)

Source from the content-addressed store, hash-verified

39
40// Create a finalTip object with all the data. Send it to the printHTML callback.
41const tipCalculator = (sum, percentage, locale, currency, printHTML) => {
42 let tip = sum * (percentage / 100);
43 let total = sum + tip;
44
45 const finalTip = {
46 sum: formatter(locale, currency, sum),
47 percentage: percentage + "%",
48 tip: formatter(locale, currency, tip),
49 total: formatter(locale, currency, total),
50 };
51
52 printHTML(finalTip);
53};
54
55tipCalculator(29.95, 18, "de-DE", "EUR", printHTML);

Callers 1

script.jsFile · 0.70

Calls 2

formatterFunction · 0.70
printHTMLFunction · 0.70

Tested by

no test coverage detected