Question

In: Computer Science

Please Use JavaScript and HTML 5) Number guesser (easier) Create a number guessing name, using an...

Please Use JavaScript and HTML

5) Number guesser (easier)

Create a number guessing name, using an input and a button to gather a number.
The number to be guessed should be a hard-coded whole number between 1 and 20.
Tell the user if the number is too high, equal to, or too low than a number you have hard-coded in your application.
Remove the text in the input when the user clicks the button.

Solutions

Expert Solution

                       <!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <title>Guessing Game (Numeric Value 1-10)</title>
   <style>
   body {
   width: 50%;
   max-width: 800px;
   min-width: 480px;
   margin: 0 auto;
   }
   </style>
</head>

<body>
<h1>Guess The Number</h1>

<p>Here random number between 1 - 10 is Generated so Guess Now </p>

<div class="form">
   <label>Enter a guess: </label>
   <input type = "text" id = "guessField" class = "guessField">
   <input type = "submit" value = "Submit guess"
       class = "guessSubmit" id = "submitguess">
</div>
<script type = "text/javascript">
   var y = Math.floor(Math.random() * 10 + 1); //here random number from 1 to 10 is generated
   var guess = 1; //initilize value start with guess 1 with start
   document.getElementById("submitguess").onclick = function(){
var x = document.getElementById("guessField").value;
if(x == y)
{     
   alert("Suceessfully Guess!!! YOU GUESSED IT RIGHT IN "+ guess + " GUESS ");
}
else if(x > y) /* if guessed number is greater
               than actual number*/
{     
   guess++;
   alert("Entered Number is smaller then You Entered");
}
else
{
   guess++;
   alert("Enter Number is Greater then You entered")
}
}
</script>
</body>
</html>

Output

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........


Related Solutions

For this assignment you need to create a ToDo list using Javascript, along with HTML and...
For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link in CSS from a...
For this assignment you need to create a ToDo list using Javascript, along with HTML and...
For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link in CSS from a...
The code to create a Search/Filter Data with Javascript or html from html page.
The code to create a Search/Filter Data with Javascript or html from html page.
Using HTML and JavaScript, receive a positive number, n, and output all prime numbers that are...
Using HTML and JavaScript, receive a positive number, n, and output all prime numbers that are smaller than n and have a digit 7. For example, if n is 100, the program should output 7, 17, 37, 47, 67, 71, 73, 79, and 97.
Write the below code to use HTML and JavaScript. 1. a) Write a JavaScript program to...
Write the below code to use HTML and JavaScript. 1. a) Write a JavaScript program to display the current day and time. b) Write a JavaScript program to print the contents of the current window.   c) Write a JavaScript program where the program takes a random integer between 1 to 10 d) Write a JavaScript program to calculate multiplication and division of two numbers (input from the user). e)Write a JavaScript program to create a new string from a given...
For this assignment, you will write a tic-tac-toe application in HTML and JavaScript, using an HTML...
For this assignment, you will write a tic-tac-toe application in HTML and JavaScript, using an HTML <canvas> tag. The game will be played "hot seat" where players take turns using the same device. Requirements: The canvas should be 600px tall and wide, with the gameplay area occupying most of the canvas. The X's and O's may be drawn using polygons or large-font text The grid should be drawn using polygons, specifically long, thin rectangles Before & between games, the canvas...
Use JavaScript/HTML to create a Tic Tac Toe game displaying X's O's. Score the result. Each...
Use JavaScript/HTML to create a Tic Tac Toe game displaying X's O's. Score the result. Each player takes a turn putting their mark until done or tied.
Build an application using HTML, CSS, javascript, json. It is not necessary for backend to be...
Build an application using HTML, CSS, javascript, json. It is not necessary for backend to be working but the frontend should be good. App should to simple and useful in our day to day life. For eg- grocery shopping list or alarm or weather forecast or reminder.
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts...
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts a Date object dateStr and returns a string that is the day of the week in English form (i.e. “Sunday”, “Monday”, etc.). Test your function by creating a date object that is a significant date to you (such as your birthday) and passing that date object to your function. Test your function at least twice with two different dates. Submit the dayOfWeek.js file to...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1 and 100. Console Welcome to the Guess the Number Game ++++++++++++++++++++++++++++++++++++ I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 You got it in 1 tries. Great work! You are a mathematical wizard. Try again? (y/n): y I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 Way too high! Guess...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT