JavaScript Not Running/Displaying

@Firepup650 I will say, the JavaScript doesn’t seem to be carrying out its functions and doing anything. I’m not getting errors, and have checked with AI but it couldn’t fix it.

Weird, sounds like a Replit issue TBH.
Also, I wouldn’t rely on AI.

Also also, why are you using snake_case?

Also also also, why are you using both let and var?
Here’s a tip: Whenever you’re making a variable with document.getElementById, use const because that variable will likely never change.
For everything else, use let.

Also, .onclick isn’t recommended.

const btn = document.getElementById("submit");

btn.addEventListener('click', event => {

@QwertyQwerty88 I added some print statements to see if it was just a display issue, but nothing appears in the console either.

import data from './question_sets.json';

const question_sets = data;

let answer;

function set_question() {
    let random = Math.floor(Math.random() * question_sets.planetary_set.length);
    let question = question_sets.planetary_set[random].question;
    answer = question_sets.planetary_set[random].answer;
    let icon = question_sets.planetary_set[random].icon;
    let type = question_sets.planetary_set[random].type;

    document.getElementById("icon").setAttribute("name", icon);
    document.getElementById("icon").setAttribute("type", type);
    document.getElementById("question").innerHTML = question;



let modal = document.getElementById("question-modal");

let modal_text = document.getElementById("modal-text");

document.querySelector('.q-a-wrapper').addEventListener('submit', function(event) {

    let answer_input = document.getElementById("answer-input");
    let answer_value = answer_input.value.toLowerCase();

    if (answer_value) { = "1";
        if (answer_value === answer.toLowerCase()) {
            modal_text.innerHTML = "Correct";
   = "var(--back)";
   = "var(--primary)";
        } else {
            modal_text.innerHTML = "Incorrect";
   = "var(--fore)";
   = "var(--back)";
        answer_input.value = '';


        setTimeout(function() {
   = "0";
            setTimeout(function() {
            }, 300);
        }, 2000);

1 Like