Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

<body>
<h1>Section 2: JavaScript Language Basics</h1>
<script src='script.js'></script>
</body>
</html>
</html>
28 changes: 28 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -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);