diff --git a/app.js b/app.js new file mode 100644 index 0000000..819efdb --- /dev/null +++ b/app.js @@ -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!!!
the number is ${random}`; + + } + else{ + id4.textContent="You still have " + trails + " guesses left"; + } + + +} +} + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..f866a6b --- /dev/null +++ b/index.html @@ -0,0 +1,44 @@ + + + + + + + Practice.com + + + +

Guess The Number Game

+

Only 5 Trails Are Allowed

+
+ + + +
+
+
+ + +
+
+
+
+
+ + + + + + + + + + + diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..78bded5 --- /dev/null +++ b/styles.css @@ -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; +} \ No newline at end of file