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
69 changes: 48 additions & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,22 @@
font-family: sans-serif;
margin-left: 30px;
margin-right: 30px;
background-color: rgb(32, 97, 81);
text-align: center;
}

#header {
text-align: center;
}

#container {
background-color: pink;
background-color: rgb(127, 192, 181);
margin: 40px auto;
max-width: 800px;
padding: 38px 31px;
}

input {
font-size: 21px;
line-height: 33px;
margin: 0 0 23px 0;
padding: 0 9px;
width: 100%;
}


button {
font-size: 21px;
line-height: 33px;
Expand All @@ -48,7 +43,7 @@
}

#output-div {
background-color: lightgrey;
background-color: rgb(100, 165, 149);
margin: 20px auto;
padding: 20px;
width: 100%;
Expand All @@ -59,17 +54,21 @@
<!-- The <body> element defines the document's body, and is a container for all the visible contents that will be rendered by the browser. -->
<body>
<!-- The <h1> element defines a large heading. There are 6 pre-set header elements, <h1> to <h6> -->
<h1 id="header">Basics! 🚀</h1>
<h1 id="header" style="color: white">Basics! Blackjack Game 2️⃣1️⃣🚀</h1>
<br />
<p style="color:white"> <strong> Rules of the game:</strong></p>
<p style="color:white">Dealer has to hit if their hand is less than 17</p>
<p style="color:white">Ace can be either 1 or 11 for player</p>
<!-- The <div> tag defines a division or a section in an HTML document, and is commonly use as a "container" for nested HTML elements. -->
<div id="container">
<!-- The <p> tag defines a paragraph element. -->
<p>Input:</p>
<!-- The self-closing <input /> tag represents a field for a user to enter input. -->
<input id="input-field" />

<!-- The self-closing <br /> tag represents a line break - a line's worth of spacing before dispalying the next element. -->
<br />
<!-- The <button> tag represents.. you guessed it! a button. -->
<button id="submit-button">Submit</button>
<button id="start-button">Start</button>
<button id="hit-button">Hit</button>
<button id="stand-button">Stand</butoon>
<button id="reset-button">Reset</button>
<p>Output:</p>
<div id="output-div"></div>
</div>
Expand All @@ -80,22 +79,50 @@ <h1 id="header">Basics! 🚀</h1>
<!-- Define button click functionality -->
<script>
// Declare and define a variable that represents the Submit Button
var button = document.querySelector("#submit-button");
var startButton = document.querySelector("#start-button");
// When the submit button is clicked, access the text entered by the user in the input field
// And pass it as an input parameter to the main function as defined in script.js
button.addEventListener("click", function () {
startButton.addEventListener("click", function () {
// Set result to input value
var input = document.querySelector("#input-field");
//var input = document.querySelector("#input-field");
// Store the output of main() in a new variable
var result = main(input.value);
var result = main("start");

// Display result in output element
var output = document.querySelector("#output-div");
output.innerHTML = result;

// Reset input value
input.value = "";
// input.value = "";
});

//Declare and define a variable that represents the Hit Button
//When the Hit button is clicked, input is assumed to be "hit"
var hitButton = document.querySelector("#hit-button");
hitButton.addEventListener("click", function(){
var result = main("hit");
var output = document.querySelector("#output-div");
output.innerHTML = result;
})

//Declare and define a variable that represents the Stand Button
//When the stand button is clicked, input is assumed to be "stand"
var standButton = document.querySelector("#stand-button");
standButton.addEventListener("click", function(){
var result = main("stand");
var output = document.querySelector("#output-div");
output.innerHTML = result;
})

//Declare and define a variable that represents the Reset Button
//When the reset button is clicked, input is assumed to be "reset"
var resetButton = document.querySelector("#reset-button");
resetButton.addEventListener("click", function(){
var result = main("reset");
var output = document.querySelector("#output-div");
output.innerHTML = result;
})

</script>
</body>
</html>
Loading