Skip to content
Draft
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 task-1/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>
<h2 style="margin-top:5%">Type The Number </h2><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>
25 changes: 25 additions & 0 deletions task-1/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const randomNumber = Math.floor(Math.random() * 10) + 1;

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 too high.`),
(output.style.color = "red"))
: randomNumber > number
? ((output.innerHTML = `Number is too 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";
}
}
76 changes: 76 additions & 0 deletions task-1/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
* {
box-sizing: border-box;
margin: 0;
padding: 0;
background-color: #f7f5eb;
color: #6a80e1;
font-family: Arial, sans-serif;
}
.game {
text-align: center;
}
.title {
color: #2db8eb;
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);
}