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

Function tipCalculator

08_07e/script.js:6–24  ·  view source on GitHub ↗
(sum, percentage, currency, prefix)

Source from the content-addressed store, hash-verified

4 */
5
6const tipCalculator = (sum, percentage, currency, prefix) => {
7 let tip = sum * (percentage / 100);
8 let total = sum + tip;
9 if (prefix) {
10 console.log(`
11 Sum before tip: ${currency}${sum}
12 Tip percentage: ${percentage}%
13 Tip: ${currency}${tip.toFixed(2)}
14 Total: ${currency}${total.toFixed(2)}
15 `);
16 } else {
17 console.log(`
18 Sum before tip: ${sum}${currency}
19 Tip percentage: ${percentage}%
20 Tip: ${tip.toFixed(2)}${currency}
21 Total: ${total.toFixed(2)}${currency}
22 `);
23 }
24};
25
26tipCalculator(29.95, 18, "kr", false);

Callers 1

script.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected