What wrong did I do?

Hi
What wrong did I do?
Please help me to link a dialog called Select Action Set.
This is My CODE:

const { alert, confirm, prompt, error, warning } = require("./notice.js");


 function ActionList() {
    const getActionSet = require('photoshop').app.actionTree;
    const ActionSet = document.getElementById("list_AS")
    const AcrionList = document.getElementById("list_AC")
    const core = require("photoshop").core;

    for (let i = 0; i < getActionSet.length; i++) {
        ActionSet.insertAdjacentHTML("beforeend", `<sp-menu-item>${getActionSet[i].name}</sp-menu-item>`);
    }

    const dialog = document.createElement('dialog');
    dialog.addEventListener("change", evt => {
        dialog.innerHTML = "";
        for (let i = 0; i < getActionSet.length; i++) { var getActionItens = getActionSet[evt.target.selectedIndex] }
        for (let i = 0; i < getActionItens.actions.length; i++) {
            dialog.insertAdjacentHTML("beforeend", `<sp-menu-item>${getActionItens.actions[i].name}</sp-menu-item>`);
            dialog.selectedIndex = 0;
        }
    })

    document.querySelector("#btnRun").addEventListener("click", evt => {
        core.executeAsModal(async () => {
            const list_AS = ActionSet.value;
            list_AC = AcrionList.value;
            await app.batchPlay([{ "_obj": "play", "_target": [{ "_name": list_AC, "_ref": "action" }, { "_name": list_AS, "_ref": "actionSet" }] }], {});
        })
    })
}

my problem
Please help me solve this problem
Regards
Mohammed Abed.

When you define dialog you define your getActionItens
variable inside a for loop and then try and access it in the next loop when it no longer exists.
It’s called scope .

Thanks :pray::+1:.
Timothy _Bennett.
I will check :heavy_check_mark:.

Regards :pray:
Mohamed fathi.