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 starter-code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h2>Your pizza's price</h2>
<li>$3 white sauce</li>
<li>$5 gluten-free crust</li>
</ul>
<strong>$21</strong>
<strong>$13</strong>
</aside>
<!-- End Price -->

Expand Down Expand Up @@ -291,5 +291,6 @@ <h2>Your pizza's price</h2>

<script src="jquery-2.1.4.js"></script>
<script src="pizza.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
</body>
</html>
65 changes: 65 additions & 0 deletions starter-code/pizza.js
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
// Write your Pizza Builder JavaScript in this file.
let total = 13;
function calculatePrice() {
$(".price strong").text("$" + total);
}

$('.btn-pepperonni').click(function(e){
$("* .pep").toggle()
$(".btn-pepperonni").toggleClass("active");
$(".price ul li:nth-child(1)").toggle();
if($(".btn-pepperonni").hasClass("active")) {
total += 1;
} else {
total -= 1;
} calculatePrice();
});

$('.btn-mushrooms').click(function(e){
$("* .mushroom").toggle()
$(".btn-mushrooms").toggleClass("active");
$(".price ul li:nth-child(2)").toggle();
if($(".btn-mushrooms").hasClass("active")) {
total += 1;
} else {
total -= 1;
} calculatePrice();
});

$('.btn-green-peppers').click(function(e){
$("* .green-pepper").toggle()
$(".btn-green-peppers").toggleClass("active");
$(".price ul li:nth-child(3)").toggle();
if($(".btn-green-peppers").hasClass("active")) {
total += 1;
} else {
total -= 1;
} calculatePrice();
});

$(".sauce").toggleClass("sauce-white");
$(".btn-sauce").toggleClass("active");
$(".price ul li:nth-child(4)").toggle();
$('.btn-sauce').click(function(e){
$(".sauce").toggleClass("sauce-white");
$(".btn-sauce").toggleClass("active");
$(".price ul li:nth-child(4)").toggle();
if($(".btn-sauce").hasClass("active")) {
total += 3;
} else {
total -= 3;
} calculatePrice();
});

$(".crust").toggleClass('crust-gluten-free');
$(".btn-crust").toggleClass("active");
$(".price ul li:nth-child(5)").toggle();
$('.btn-crust').click(function(e){
$(".crust").toggleClass('crust-gluten-free');
$(".btn-crust").toggleClass("active");
$(".price ul li:nth-child(5)").toggle();
if($(".btn-crust").hasClass("active")) {
total += 5;
} else {
total-= 5;
} calculatePrice();
});