Why can’t I match the word I entered in the textbox to Firebase database?

// Form submission and user creation
document.getElementById(‘registrationForm’).addEventListener(‘submit’, function(event) {
event.preventDefault(); // Prevent the form from submitting

// Get user inputs
var firstName = document.getElementById('fname').value;
var lastName = document.getElementById('lname').value;
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;
var phone = document.getElementById('phone').value;
var enteredWord = document.getElementById('matched').value; // Get the entered word

// Reference to the Firebase Database
var database = firebase.database();

// Retrieve the stored word from Firebase
database.ref('messages/message').once('value', function(snapshot) {
    var storedWord = snapshot.val();

    // Check if storedWord exists and matches the entered word
    if (storedWord && enteredWord === storedWord) {
        // Validate password
        if (!validatePassword(password)) {
            alert('Password should be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, one digit, and one special character.');
            return;
        }

        // Create user with email and password
        auth.createUserWithEmailAndPassword(email, password)
            .then(function(userCredential) {
                // User created successfully
                var user = userCredential.user;

                // Update user profile with phone number
                user.updateProfile({
                    displayName: firstName + " " + lastName,
                    phoneNumber: phone
                }).then(function() {
                    // Profile updated successfully
                    console.log("User profile updated with phone number.");
                }).catch(function(error) {
                    // Handle errors
                    console.error('Error updating user profile: ', error);
                });

                // Now you can add additional user data to your database
                database.ref('users/' + user.uid).set({
                    firstName: firstName,
                    lastName: lastName,
                    email: email,
                    phone: phone,
                    password: password
                })
                .then(function() {
                    // Clear input fields
                    clearFields();

                    alert('User registered successfully!');
                    // Redirect to index.html
                    window.location.href = "index.html";
                })
                .catch(function(error) {
                    console.error('Error adding user data: ', error);
                    alert('Error registering user!');
                });
            })
            .catch(function(error) {
                // Handle errors
                var errorCode = error.code;
                var errorMessage = error.message;
                console.error('Error creating user: ', errorMessage);
                alert(errorMessage);
            });
    } else {
        // Entered word does not match the stored word
        alert('The entered word does not match the stored word.');
    }
}, function(error) {
    console.error('Error retrieving data from Firebase: ', error);
    alert('Error retrieving data from Firebase. Please try again later.');
});

});

I want to retrieve the data that is stored in my database and match it to the textbox that I entered. If it matches, it will proceed to creating a user. I’m still learning JavaScript, and I can’t figure it out.