Errors With Faulty Code On Number Guessing Game

I am currently using HTML and Javascript to create a number guessing game. The issue with my current code is that any number the user inputs is a number that is ruled as the correct number. The problem is that the random number generator is not being recognized for some reason. The game is simply supposed to pick a number from 1-100 and the user has to keep guessing a number to match the randomly generated number. And it should be able to reset once you click the new game button. I am just wondering how to resolve the issues with my code and how to get my desired output. Here's my code: https://jsfiddle.net/qg0froam/

  <!DOCTYPE html>
   <html lang="en">
       <head>
           <meta charset="utf-8">
           <meta name="viewport" content="width=device-width,initial-scale=1">
           <title>Homework 6</title>
          <script src="hw06.js"></script>
          <link rel="stylesheet" href="hw06.css">
      </head>
    <body onload="newgame()">
          <h1>High-low guessing game</h1>
          <div id="controls">
          <button onclick="newgame()">New game</button>
          <form onsubmit="guess(); return false;"><input id="guess_input" type="number">
          <input type="submit" value="Guess"></form>
          </div>
          <br><br>
          <div id="output"></div>
      </body>
  </html>

================================================================================================================================

var output;     // Global variable to reference the div element with id "output"
  var answer;     // This is the answer
  var guessCount = 1; // This variable counts the number of guesses
  var x = document.getElementById("guess_input"); // This is the number guessed by the user

   // Function that returns a random number in [minVal, maxVal].
   function randomNumber(minVal, maxVal) {
       return minVal + Math.floor(Math.random() * (maxVal - minVal + 1));
   }

 // Function that writes a message to the output div
  function writeOutput(message) {
      if (!output) {
          output = document.getElementById("output");
      }
      output.innerHTML = message + "<br>" + output.innerHTML;
  }

  // Function that starts a new game
      function newgame() {
      writeOutput("I'm thinking of a number between 1   and 100...");

      var answer = Math.floor(Math.random() * 100 + 1);

      var guessCount = 0;

      // TODO: use the randomNumber function to pick an answer for this game.
  }

  // Function that checks the player's guess against the answer

  function guess() {


  if(x == answer)
   {    
       writeOutput("Congratulations! You guessed the number correctly! "
               + guessCount + " Guesses ");
   }
   else if(x > answer) /* if guessed number is greater
                   than actual number*/ 
   {    
       guessCount++;
       writeOutput("The guess is incorrect! Try a lower number");
   }
   else
   {
       guessCount++;
       writeOutput("The guess is incorrect!! Try a higher number")
   }

      // TODO: look at the value of guess_input, compare it with the answer, and
      // tell the player whether the guess is too low, too high, or correct.
  }

How to create Hangman program?

I am currently creating a Hangman program using Object oriented programming in C++. I tested my words class and it runs perfectly with a sample main that I was using. The classes that I need help with are Hangman and HangmanConsole. I am not sure what to do to get the characters, guesses, and other variables stored and in sync with the rest of the program. I am looking for help or guidance on how to code those classes so, I can get my program running. Here is my code down below:

   #include <iostream>
   #include <fstream>
   #include <ctime>
   #include <string>

      class Words
      {
      private:
        int minlen{0};
       int maxlen{0};
       std::string file_name;

        std::string* choices = nullptr;
        int count{0};

    public:

        Words (int min, int max, std::string fName)
        {
            minlen = min;
            maxlen = max;
            file_name = fName;

            this->load_words();
            srand( time(NULL) );
        }

        ~Words()
        {
            delete [] choices;
        }

        int getCount()
        {
            return count;
        }

        void display_list()
        {
            for(int i = 0; i < count; i++)
            {
                std::cout << choices[i] << '\n';
            }
        }

        void load_words()
        {
            std::ifstream fwords(file_name);

            if(!fwords)
            {
                std::cout << "Cannot open file\n";
                return;
            }
           // This counts the words (1st file read)
            std::string temp;
            count = 0;
            while(fwords >> temp)
            {
                // Filter words
                if(temp.length() == minlen or temp.length()== maxlen)
                    count++;
            }



            // Setting up the array
            choices = new std::string[count];
            fwords.close();

            // Loading the array (2nd File read)
            fwords.open(file_name);
            int index{0};
            while(fwords >> temp)
            {
                if(temp.length() == minlen or temp.length() == maxlen)
                {
                    choices[index] = temp;
                    index++;
                }
            }
            fwords.close();
        }

        std::string pick_word()
        {
            if (count == 0)
            {
                return "Zero words available to select from";
            }

            return choices[rand() % count];
        }
    };

  class Hangman
  {
   private:
      char word[40];
   //   char progress[40]; // Progress will be the same length as char_word "----"
      int word_length;
   //   void clear_progress(int length); // This will set progress to contain

     protected:
      int matches;      // Characters that match
      char last_guess;  // Final guess
      string chars_guessed; //The characters guessed
      int wrong guesses;     // Number of wrong guesses
      int user_guess;    // Character that the user will use to guess
      int remaining;     // Number of guesses remaining
      const int total_guesses = 6; // Total number of tries
      bool check(char user_guess); // Function designed to accept a single character.
 class Hangman
  {
   private:
      char word[40];
   //   char progress[40]; // Progress will be the same length as char_word "----"
      int word_length;
   //   void clear_progress(int length); // This will set progress to contain

    protected:
      int matches;      // Characters that match
      char last_guess;  // Final guess
      string chars_guessed; //The characters guessed
      int wrong guesses;     // Number of wrong guesses
      int user_guess;    // Character that the user will use to guess
      int remaining;     // Number of guesses remaining
      const int total_guesses = 6; // Total number of tries
      bool check(char user_guess); // Function designed to accept a single character.

  public:
      Hangman(char w, char p, int wlen)
      {
         word = w; // This will be used to store the generated word
         progress = p;
         word_length = wlen;

      }

      Hangman(int m, char lg, string chg, int wg, int ug, int r)
      {
         matches = m;
         last_guess = lg;
         chars_guessed = chg;
         wrong_guesses = wg;
         user_guess = ug;
         remaining = r;
      }

      char * get_word()
      {
         return word;
      }
};
 class HangmanConsole : public Hangman
 {


 };

    int main()
 {
     std::string source_file;
     source_file = "enable1.txt"; // This text file contains the complete word list for Hangman

   //  string unknown(word.length(), '-'); Maybe use this to initialize with '-' character.


     rand(time(NULL)); // needs <ctime> included
     Words words(7,10); // words between 7 and 10 chars long

     HangmanConsole game(words.pick_word());

     cout << "HANGMAN" << endl << "-------" << endl << endl;
     cout << "Your word is: " << game.get_progress() << endl;

     while (!game.is_word_complete() && game.get_remaining() > 0)
     {
        cout << endl;
        cout << "Enter your guess: ";
        cin >> game;    // calls overloaded >> operator

        system("clear"); // NON-PORTABLE, ONLY WORKS ON LINUX
        game.show_info();
 }