Automation Scripting Multiple Inputs on List of Records

Hi - I’m new to scripting so hoping this is an easy resolution! I’m making an automation to update a record based on if the values in two different columns are equal. If they’re equal, I’d like to set another column value as one thing (Booked), otherwise set it as something else (Not Booked).

In my automation, I find the records I’d like to check and can access their record IDs in the script. I can also get the values of the two columns I’d like to compare (teacherNameList and bookedTeacherList). I’m having trouble accessing the values of the teacherNameList and bookedTeacherList… I know that the first record pairs with the first value of the teacherNameList and the BookedTeacherList – is there a way to put these together and loop through?

I think I can do this by accessing the entire table and then finding the recordIDs, and using “getCellValue,” but since I already have the values from finding them in the previous automation step I feel like there’s a better way. I imagine the code something like

for (i = 0; i <records.length;){
    if(teacherNameList[i] === bookedTeacherList[i]){
        await table.updateRecordAsync(records[i], {
    <update>}
    })
    }
    else {
        await table.updateRecordAsync(records[i], {
    <update>}
    }
}