Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
20 changes: 20 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Task-1</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="game">
<h1 class="title">GUESS THE NUMBER</h1>
<h3>Pleasse Guess The number</h3><br />
<input type="number" id="num" /></br></br>
<button id="btn1" onclick="checkNumber()">Check</button>
<h3 id="output"></h3>
</section>
<script src="index.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const randomNumber = Math.floor(Math.random() * 10) + 1;
console.log(randomNumber);

const output = document.getElementById("output");

let trial = 0;

function checkNumber() {
trial += 1;
let number = document.getElementById("num").value;
if (number) {
const ans =
randomNumber < number
? ((output.innerHTML = `Number is high.`),
(output.style.color = "red"))
: randomNumber > number
? ((output.innerHTML = `Number is low.`),
(output.style.color = "red"))
: ((output.innerHTML = `Correct guess - ${trial} Trials.`),
(output.style.color = "green"));
document.getElementById("num").value = "";
} else {
output.innerHTML = "Please enter the number.";
output.style.color = "red";
}
}
77 changes: 77 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
* {
box-sizing: border-box;
margin: 0;
padding: 0;
background-color: #42f569;
color: #0a174e;
font-family: Arial, sans-serif;
}
.game {
text-align: center;
}
.title {
background-color:blue;
color: #f5d042;
font-size: 50px;
}
h3 {
margin: 30px 0 0 0;
font-size: 35px;
}
input[type="number"] {
height: 30px;
width: 150px;

padding: 5px;

font-size: 14px;

border: 1px solid #ccc;
border-radius: 5px;

box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);

background-color: #f5f5f5;

text-align: center;

-moz-appearance: textfield;
appearance: textfield;
}

input[type="number"]::-webkit-inner-spin#btn1,
input[type="number"]::-webkit-outer-spin#btn1 {
-webkit-appearance: none;
margin: 0;
}

input[type="number"]:hover,
input[type="number"]:focus {
border-color: #888;
outline: none;
}

#btn1 {
padding: 10px 20px;

font-family: Arial, sans-serif;
font-size: 14px;

border: none;
border-radius: 5px;

background-color: #0a174e;
color: #f5d042;

box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);

transition: background-color 0.3s ease;
}
#btn1:hover {
background-color: #4b60c2;
}
#btn1:focus {
outline: none;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}