From e9866adacd247ebbdc9998c5873b853291de0016 Mon Sep 17 00:00:00 2001 From: jess2896 Date: Thu, 26 Sep 2019 11:40:21 -0400 Subject: [PATCH 1/2] Calculates the tips and the total bill amounts --- index.html | 3 ++- script.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 script.js diff --git a/index.html b/index.html index 975ef26..955e354 100644 --- a/index.html +++ b/index.html @@ -8,4 +8,5 @@

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..400bed8 --- /dev/null +++ b/script.js @@ -0,0 +1,24 @@ +let bills=[124,48,268]; + +function tipCalc(bill){ + if(bill<50){ + return bill*0.2; + } + else if(bill<200){ + return bill*0.15; + } + else{ + return bill*0.1; + } +} + +let allTips=[]; +let finalAmounts=[]; + +for(let i=0;i Date: Mon, 30 Sep 2019 11:32:12 -0400 Subject: [PATCH 2/2] Fixed the code's format --- index.html | 2 +- script.js | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 955e354..3a077e6 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,6 @@

Section 2: JavaScript Language Basics

+ - diff --git a/script.js b/script.js index 400bed8..d7a4d13 100644 --- a/script.js +++ b/script.js @@ -1,24 +1,28 @@ -let bills=[124,48,268]; +const bills = [124, 48, 268]; +const allTips = []; +const finalAmounts = []; -function tipCalc(bill){ - if(bill<50){ - return bill*0.2; +function tipCalc(bill) { + + if (bill < 50) { + return bill * 0.2; } - else if(bill<200){ - return bill*0.15; + + else if (bill < 200) { + return bill * 0.15; } - else{ - return bill*0.1; + + else { + return bill * 0.1; } } -let allTips=[]; -let finalAmounts=[]; +bills.forEach(bill => { -for(let i=0;i