Font colors for data at tables from a dataset

@kariem-ryad if it’s a single page you can declare the same variable (or function) more than one time. And you don’t have to.
Try something like:

const getColor = (num) => num > 0 ? 'green' : num < 0 ? 'red' : 'black';
function formatTable(dataset, table, fieldsToFormat){
    dataset.onReady(() => {
        table.columns = table.columns.map(e => {
            if(fieldsToFormat.includes(e.dataPath)){
                e.type = 'richText';
            }
            return e;
        });
        let tableRows = table.rows;
        fieldsToFormat.forEach(e => {
            tableRows = tableRows.map(r => {
                r[e] = `<p style="color:${getColor(r[e])};">${r[e]}</p>`;
                return r;
            })
        })
        table.rows = tableRows;
    })
}

$w.onReady(() => {
    formatTable($w('#dataset6'), $w('#table7'), ['chg' ,'change']);
    formatTable($w('#dataset9'), $w('#table11'), ['transactiontype']);
})

[EDITED]