'iterate for each element of variable, got TypeError [duplicate]

I would like to do something for each element in my_var:

// get selected rows of DataTable
let table_data = dtMember.rows({ selected: true }).data();
const COL_INDEX = 4 ; // column index of the column to count
let my_var = table_data.reduce(function (col_to_count, currentValue) {
    if (currentValue[COL_INDEX] in kulturen) {
        col_to_count[currentValue[COL_INDEX]]++;
    }
    else {
        col_to_count[currentValue[COL_INDEX]] = 1;
    }
    return col_to_count;                            
}, {});   

I tried:

for (const element of my_var) {
    console.log(element);
}

But getting the

TypeError: my_var is not eterable

I tried also my_var.entries() and my_var.keys() which are suggested on the help page of firefox but let to is not a function

How can I do it correctly?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source