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
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
<link rel="stylesheet" href="style.css">
</head>
<body>
<input class="starter" id="input" placeholder="input"/>
<h2>output:</h2>
<input class="starter" id="input" placeholder="How many seats would you like?"/>
<h2>Output</h2>
<p class="starter" id="output"></p>
<footer>
<img src="plane.png" alt="plane">
</footer>
<script>
document.querySelector('#input').addEventListener('change', function(event){
var currentInput = event.target.value;
var result = inputHappened(currentInput);
var result = priceCalc(currentInput);
display( result );
});

Expand Down
Binary file added plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 47 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
console.log("hello script js");

var inputHappened = function(currentInput){
console.log( currentInput );
return "WOW SOMETHING HAPPENED";

let price = 50;
let seatsSold = 0;
let seatsLeft = 10;
const seatNum = 10;
let seatsToNextBracket = 0;

//helper function to validate input
const invalid =(currentInput) => {
if(parseInt(currentInput)=== NaN)
return true
};
//for loop for looping user input
var priceCalc = function(currentInput) {

if (invalid){
return ('Please input a number from 1-10');
} else {

for( i=0; i < currentInput ; i++) {
seatsSold ++;
seatsLeft --;
console.log("seats sold is" + seatsSold);
console.log("seats left is" + seatsLeft);
//if statements to check price
if(seatsSold === 1) {
price = 50;
console.log("first seat is $" + price);
seatsToNextBracket= 0;
} else if (seatsSold > 1 && seatsSold < 6){
price *= 1.03;
seatsToNextBracket = 5 - parseInt(seatsSold);
console.log("seat is $" + price);
} else if (seatsSold < 9 && seatsSold > 5) {
price *= 1.05;
console.log("seat is $" + price);
seatsToNextBracket = 8 - parseInt(seatsSold);
} else if (seatsSold === 9) {
price = 91000;
console.log("last seat is $" + price);
seatsToNextBracket = 0;
}

}
//a message tell the user how many tickets are left before the price bracket goes up.
return `Your most expensive ticket is ${price} and there are only ${seatsLeft} seats left! There are ${seatsToNextBracket} seats left to the next price bracket!`;
}
}
29 changes: 25 additions & 4 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@

@import url('https://fonts.googleapis.com/css2?family=Baloo+Tamma+2:wght@400;500&display=swap');

.starter{
font-size:30px;
padding:10px;
padding:30px;
display:block;
margin:40px;
border:3px solid blue;
margin:40px auto;
border:1px solid lavender;
width: 50%;

}

#output{
background-color:pink;
background-color:white;
color: #3199DA;
}

body {
font-family: 'Baloo Tamma 2', cursive;
background-color: #3199DA;
color: white;
}

h2 {
text-align: center;
font-size: 50px;
}

footer {
margin: 50px;
}