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
24 changes: 9 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
<link rel="stylesheet" href="style.css">
</head>
<body>
<input class="starter" id="input" placeholder="input"/>
<h2>output:</h2>
<p class="starter" id="output"></p>
<script>
document.querySelector('#input').addEventListener('change', function(event){
var currentInput = event.target.value;
var result = inputHappened(currentInput);
display( result );
});

var display = function( data ){
var output = document.querySelector('#output');
output.innerText = data;
}
</script>
<p>CheapCheap Airline</p>
<p id = "pricing"></p>
<p id = "seatLeft"></p>
<button type="button" onclick="buyTicket()" > Buy Ticket
</button>
<h2 id = "thankYouMessage"></h2>
<button type="button" onclick="admin()" > admin
</button>
<script src="script.js"></script>
</body>
</html>
s
84 changes: 79 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,80 @@
console.log("hello script js");
var totalSeat = 10;
var startPriceFirstHalf = 50;
var startPriceSecondHalf = 50;
var totalMoneyWeEarn = 50;

document.getElementById("pricing").innerHTML = startPriceFirstHalf +" for your ticket";
document.getElementById("seatLeft").innerHTML = totalSeat+" seats left";
function buyTicket(){
if(totalSeat <= 10 && totalSeat > 6){
document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn;
totalSeat -= 1;
startPriceFirstHalf = Number(startPriceFirstHalf * 1.03).toFixed(2);
var seatLeftBeforePriceIncrease = totalSeat - 5;
document.getElementById("seatLeft").innerHTML = seatLeftBeforePriceIncrease+" seats before price bracket increase";
document.getElementById("pricing").innerHTML = startPriceFirstHalf +" for your ticket";
totalMoneyWeEarn = parseFloat(totalMoneyWeEarn) + parseFloat(startPriceFirstHalf);
console.log(totalSeat);
console.log(startPriceFirstHalf);
console.log(totalMoneyWeEarn);
return seatLeftBeforePriceIncrease;
return totalMoneyWeEarn;
return startPriceFirstHalf;
return totalSeat;
}
if(totalSeat <= 6 && totalSeat > 2){
document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn;
document.getElementById("pricing").innerHTML = startPriceSecondHalf +" for your ticket";
var seatLeftBeforePriceIncrease = totalSeat - 2;
totalSeat -= 1;
totalMoneyWeEarn = parseFloat(totalMoneyWeEarn) + parseFloat(startPriceSecondHalf);
startPriceSecondHalf = Number(startPriceSecondHalf * 1.05).toFixed(2);
document.getElementById("seatLeft").innerHTML = seatLeftBeforePriceIncrease+" seats left before price bracket increase";
console.log(totalSeat);
console.log(startPriceSecondHalf);
console.log(totalMoneyWeEarn);
return totalMoneyWeEarn;
return startPriceSecondHalf;
return totalSeat;
return seatLeftBeforePriceIncrease;
}
if(totalSeat == 2){
document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn;
document.getElementById("pricing").innerHTML ="$91,000 for your ticket";
totalSeat -= 1;
startPriceSecondHalf = Number(startPriceSecondHalf * 1.05).toFixed(2);
document.getElementById("seatLeft").innerHTML = totalSeat+" seats left";
console.log(totalSeat);
console.log(startPriceSecondHalf);
return totalMoneyWeEarn;
return startPriceSecondHalf;
return totalSeat;
}
else if (totalSeat == 1 ){
totalMoneyWeEarn += 91000;
document.getElementById("thankYouMessage").innerHTML = "Thank you, we made : $"+ totalMoneyWeEarn;
document.getElementById("pricing").innerHTML = "call us to pay big money for ticket";
document.getElementById("seatLeft").innerHTML = "no seats left, come back tomorrow";
totalSeat -= 1;
}
else{
document.getElementById("thankYouMessage").innerHTML = "No ticket means no ticket";
}
}

function admin(){
var password = prompt("Please enter password");
if (password === "password1"){
totalSeat = 10;
startPriceFirstHalf = 50;
startPriceSecondHalf = 50;
totalMoneyWeEarn = 50;
document.getElementById("pricing").innerHTML = startPriceFirstHalf +" for your ticket";
document.getElementById("seatLeft").innerHTML = totalSeat+" seats left";
document.getElementById("thankYouMessage").innerHTML = "";
}
else {
document.getElementById("thankYouMessage").innerHTML = "wrong";
}
}

var inputHappened = function(currentInput){
console.log( currentInput );
return "WOW SOMETHING HAPPENED";
};
4 changes: 4 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
body{
background-color: white;
}

.starter{
font-size:30px;
padding:10px;
Expand Down