Skip to content

Commit

Permalink
+Improved OOP method structure
Browse files Browse the repository at this point in the history
  • Loading branch information
CalGrimes committed Jun 27, 2021
1 parent 6e0cf05 commit f4376e9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Binary file modified .vs/CalGrimes-Blog-Postings/v16/.suo
Binary file not shown.
3 changes: 2 additions & 1 deletion .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"ExpandedNodes": [
"",
"\\js",
"\\posts",
"\\projects",
"\\_includes",
"\\_includes\\layouts"
],
"SelectedNode": "\\_includes\\layouts\\base.njk",
"SelectedNode": "\\_includes\\postslist.njk",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
40 changes: 27 additions & 13 deletions js/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,44 @@
// 1. Tip Calculate

//1. Tip Calculate starts here
function calculateTip() {
var billAmt = document.getElementById("billamt").value;
var serviceQual = document.getElementById("serviceQual").value;
var numOfPeople = document.getElementById("peopleamt").value;
//validate input
if (billAmt === "" || serviceQual == 0) {
alert("Please enter values");
return;
}
//Check to see if this input is empty or less than or equal to 1
function verifyInput(numOfPeople) {
if (numOfPeople === "" || numOfPeople <= 1) {
numOfPeople = 1;
document.getElementById("each").style.display = "none";
return document.getElementById("each").style.display = "none";
} else {
document.getElementById("each").style.display = "block";
return document.getElementById("each").style.display = "block";
}
//Calculate tip
}
function tipResult(billAmt, serviceQual, numOfPeople) {
var total = (billAmt * serviceQual) / numOfPeople;
//round to two decimal places
total = Math.round(total * 100) / 100;
//next line allows us to always have two digits after decimal point
total = total.toFixed(2);
//Display the tip
displayTip(total);
}
function displayTip(total) {
document.getElementById("totalTip").style.display = "block";
document.getElementById("tip").innerHTML = total;
}


function calculateTip() {
var billAmt = document.getElementById("billamt").value;
var serviceQual = document.getElementById("serviceQual").value;
var numOfPeople = document.getElementById("peopleamt").value;
//validate input
if (billAmt === "" || serviceQual == 0) {
alert("Please enter values");
return;
}
//Check to see if this input is empty or less than or equal to 1
verifyInput(numOfPeople);

//Calculate tip
tipResult(billAmt, serviceQual, numOfPeople);


}
//Hide the tip amount on load
Expand All @@ -40,6 +53,7 @@ document.getElementById("calculate").onclick = function () {
// Tip Calculate ends here
//-------------------------


//ISBN Verifier starts here

//ISBN form properties
Expand Down

0 comments on commit f4376e9

Please sign in to comment.