Extract data from a column and read into another column - script

Hey folks - new here and would definitely appreciate some help.

Problem space: I have a table with two columns, column A and column B. Each row of column A has a string, and each string may or may not contain any number of emails. My goal is to extract all the emails (if there are any) from the string in column A and put them in the currently empty corresponding field in column B.

Sample Row 1:

Column A: “There are a few emails relevant here, and they are jack@gmail.com and ashley@yahoo.com

Column B (if implemented correctly should look like): jack@gmail.com, ashley @yahoo.com

In javascript, I know how to implement a basic function using regex to solve this problem:

function getEmails(emailString) {
    var words = emailString.split(" ");
    for (var i = 0; i < words.length; i += 1) {
        if (/^.+@.+\..+$/.test(words[i])) {
          console.log(words[i]);
        }
    }
}

But I’m not quite sure how to implement this using airtable, as I’m getting tripped up on the syntax for accessing the columns. Here’s what I’ve written so far, but it’s not working as hoped:

let table = base.getTable('TableName');
let result = await table.selectRecordsAsync();

for (let record of result.records) {
let emailString = record.getCellValue('ColA');
var words = emailString.split(" ");
for (var i = 0; i < words.length; i += 1) {
    if (/^.+@.+\..+$/.test(words[i])) {
         await table.updateRecordAsync(record, {
 "ColB": words[i]
 });
    }
}
}