diff --git a/index.html b/index.html index 975ef26..3a077e6 100644 --- a/index.html +++ b/index.html @@ -7,5 +7,6 @@

Section 2: JavaScript Language Basics

+ - \ No newline at end of file + diff --git a/script.js b/script.js new file mode 100644 index 0000000..d7a4d13 --- /dev/null +++ b/script.js @@ -0,0 +1,28 @@ +const bills = [124, 48, 268]; +const allTips = []; +const finalAmounts = []; + +function tipCalc(bill) { + + if (bill < 50) { + return bill * 0.2; + } + + else if (bill < 200) { + return bill * 0.15; + } + + else { + return bill * 0.1; + } +} + +bills.forEach(bill => { + + const tip = tipCalc(bill); + allTips.push(tip); + finalAmounts.push(tip + bill); +}); + +console.log(allTips); +console.log(finalAmounts);