как подождать пока обработается
var txt = ["a","b","c" ];
var i = 0;
var res = [];
while (i < txt.length) {
document.querySelector("#fet").value = txt[i];
if (document.querySelector("#fet").value != ""){
document.querySelector("#conv").click();
///////как подождать пока обработается код и в #output измениться значение?///////
res.push(document.querySelector("#output").innerText);
} else{
console.log("fields are not filled correctly");
}
i++;
}
console.log(res);
в самом коде вопрос при запуске, как есть получаю пустые значения