i wanna make my calculator evaluate a single operation at a time but it doesn’t do that

the calculator should not evaluate more than a single pair of numbers at a time. Example: you press a number button (12), followed by an operator button (+), a second number button (7), and finally a second operator button (-). the calculator should then do the following: first, evaluate the first pair of numbers (12 + 7), second, display the result of that calculation (19), and finally, use that result (19) as the first number in your new calculation, along with the next operator
here’s my code

const numBtn = Array.from(document.querySelectorAll(".number"));

const operatorbtn = Array.from(document.querySelectorAll(".operator"));

const display = document.querySelector(".display");

let firstNum = null;

let secondNum = null;

let operator = null;



function add(a, b) {
    return a + b;
}

function subtract(a, b) {
    return a - b;
}

function multiply(a, b) {
    return a * b;
}

function divide(a, b) {
    return a / b;
}

function operate(num1, num2, operator) {
    switch (operator) {
        case "+":
            return add(num1, num2);
        case "-":
            return subtract(num1, num2);

        case "*":
            return multiply(num1, num2);
        case "/":
            if (num2 === 0) {
                return "lmao";
            }
            return divide(num1, num2);
    }
}

function updateDisplay(string) {
    if (display.textContent === "0") {
        display.textContent = "";
    }
    display.textContent += string;
}

numBtn.forEach((button) => {
    button.addEventListener("click", (e) => {
        console.log(typeof e.target.textContent);
        updateDisplay(e.target.textContent);
    });
});

operatorbtn.forEach((button) => {
    button.addEventListener("click", (e) => {
        console.log(typeof e.target.textContent);

        const operatorInput = e.target.textContent;
        if (operatorInput === "AC") {
            display.textContent = 0;
            firstNum = null;
            secondNum = null;
            operator = null;
            return;
        }
        if (operatorInput === "=") {
            // turn the operation into an array
            const operation = display.textContent.split("");

            //get operator index
            const operatorIndex = operation.findIndex((el) =>
                ["+", "-", "*", "/"].includes(el)
            );
            firstNum = parseInt(operation.slice(0, operatorIndex).join(""));
            operator = operation[operatorIndex];

            secondNum = parseInt(operation.slice(operatorIndex + 1).join(""));

            console.log(operate(firstNum, secondNum, operator));
            display.textContent = operate(firstNum, secondNum, operator);

            return;
        }
        updateDisplay(e.target.textContent);
    });
});

id like it if someone told me how to implement the functionality mentioned above