Javascript function won't print

Javascript function won't print

I'm new to JavaScript and I'm doing a project for class. Haven't had any issues so far until this problem, where nothing prints when I enter the inputs. There are no changes at all when I enter the problems. This problem is just supposed to create a random number and see if the user guesses it correctly.

I'm new to JavaScript and I'm doing a project for class. Haven't had any issues so far until this problem, where nothing prints when I enter the inputs. There are no changes at all when I enter the problems. This problem is just supposed to create a random number and see if the user guesses it correctly.

<script>
function playGame() {
    var answer;
    var x = Math.floor((Math.random() * 100) + 1);
    var name = document.getElementById('name').value;
    var guess = document.getElementById('guess').value;
    if (x > guess) {
    var answer = "Guess is too low!");
    }
    else if (x < guess) {
    var answer = "Guess is too high!");
    }
    else if (x == guess) {
    var answer = "You guessed correctly!");
    }
    document.getElementById('final').innerHTML = "Answer: " + answer;
</script>

<h2>Random Number Game by </h2> <p>Enter Name: <input id="name" type="text"> </p> <p>Enter Guess: <input id="guess" type="number" min="1" max="100" onchange="playGame()"></p> <h2 id="final"></h2>


javascript html

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

HTML JavaScript - Add Javascript File to HTML

Learn HTML and javascript, their uses & importance, html javascript function, javascript tags list, why add javascript file to html, HTML Events with JavaScript etc

Countdown with HTML, CSS, and JavaScript / How to create JavaScript Countdown

Countdown with HTML, CSS, and JavaScript / How to create JavaScript Countdown. W will build a Responsive Website with HTML, CSS, and JavaScript

Render HTML with Vanilla JavaScript and lit-html

Sometimes you need to render HTML elements on a web page. And like Goldilocks' search for "just right", you have to try a few techniques before you find the right one. Using a framework may be too hard. Using pure HTML and the DOM API may be too soft. What you need is something in the middle that is just right. Is lit-html "just right"? Let's find out.

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview

How to Retrieve full Profile of LinkedIn User using Javascript

I am trying to retrieve the full profile (especially job history and educational qualifications) of a linkedin user via the Javascript (Fetch LinkedIn Data Using JavaScript)