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
85 changes: 85 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// // document.getElementById("p").innerHTML = "Java Script.";
// // document.getElementsBy.innerHTML("p").textContext="Java Script:"

// function myFunction() {
// document.getElementById("demo").innerHTML = "Paragraph changed.";
// }
// function myFunction1() {
// const myImage = document.getElementById("demo1");
// // myImage.src = "https://images.unsplash.com/photo-1525673812761-4e0d45adc0cc?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8bmljZSUyMHBob3RvfGVufDB8fDB8fHww&w=1000&q=80";
// console.log(myImage.src)
// if (myImage.src == "file:///home/odoo/Downloads/trail.jpeg")
// {
// myImage.src = "https://images.unsplash.com/photo-1525673812761-4e0d45adc0cc?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8bmljZSUyMHBob3RvfGVufDB8fDB8fHww&w=1000&q=80"
// }
// else
// {
// myImage.src = "file:///home/odoo/Downloads/trail.jpeg"
// }
// }
// const demo2 = document.getElementById("demo");
// demo.style.color = "red";
// const newParagraph = document.createElement("p");
// newParagraph.textContent = "Practice 1!";
// document.body.appendChild(newParagraph);
// // const newParagraph = document.getElementById("p");
// // newParagraph.parentNode.removeChild(newParagraph );
// // let person = {
// // name: 'John',
// // sayHi: function() {
// // console.log('Hi, my name is ' + this.name);
// // }
// // }
// // person.sayHi();



// ---------------------------------------------------------------------------------------------
// guess the number:



let random = Math.floor((Math.random() * 100) + 1);
const id3 = document.getElementById("id3");
const id4 = document.getElementById("id4");
var trails = 5;

function restartValue()
{
document.getElementById("demo").value = "";
trails = 5;
random = Math.floor((Math.random() * 100) + 1);
}
function checkValue() {
if(document.getElementById("demo").value!="" && trails > 0) {

const value = parseInt(document.getElementById("demo").value);
console.log (typeof value)
if (value === random) {
id3.textContent="Your guess was correct";
id4.textContent="You won";
return;
}
else if (value > random) {
id3.textContent="Your guess is high";

}
else{
id3.textContent="Your guess is low";

}
trails --;

if(trails==0){
id4.innerHTML=`You lost!!! <br> the number is ${random}`;

}
else{
id4.textContent="You still have " + trails + " guesses left";
}


}
}


44 changes: 44 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!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>Practice.com</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1> Guess The Number Game</h1>
<h3> Only 5 Trails Are Allowed</h3>
<div id="id1">
<label for="num"> Enter the number</label>
<input type="number" id="demo" name="num"/>

</div>
<br>
<div id="id2">
<button type="button" onclick="checkValue()"> Check Now!!!</button>
<button type="button1" onclick="restartValue()"> Restart now!!!</button>
</div>
<div id="id3">
</div>
<div id ="id4">
</div>






<!-- <p id="demo">this a practice module</p>
<br> <button type="button" onclick="myFunction()">Try it</button>

<img id="demo1" src ="/home/odoo/Downloads/trail.jpeg" />

<button type="button" onclick="myFunction1()">Try it1</button>

<button type="button" onclick="myFunction1()">Try it1</button> -->

<script src="app.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
body {
text-align: center;
}

body {
font-family: 'Montserrat', sans-serif;
background-image: url("https://wallpaperaccess.com/full/2312654.jpg");
}

button {
background-color: transparent;
border: none;
font-size: 16px;
padding: 0.5em;
background-image: linear-gradient(to right, #fbc2eb 0%, #a6c1ee 51%);
}
#id1 input[type="number"]{
width: 10%;
margin: 10px;
font-size: 15px;
border-color: black;
border-width: 4px;
}
#id3{
margin: 2rem;
font-size: 20px;
font-style:italic;
font-weight: bold;

}
#id4{
margin: 2rem;
font-style: oblique;
}