'Stuck with eslint Error i.e Separately, loops should be avoided in favor of array iterations

I have the Code for some iterations and it works well. After installing eslint, One of my code generates an error by eslint.

My code is:

for (const column of columns) {
    for (const slugname of result[column.name]) {
        const alphabet = slugname.slugname;
        if (total[alphabet]) {
            total[alphabet] += column.value;
        } else {
            total[alphabet] = column.value;
        }
    }
}

eslint generates an error which is this

error iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations no-restricted-syntax

Any help or suggestion is really appreciated for that. According to me The code was written very precisely and very small, don't know about the clue of eslint error



Solution 1:[1]

columns.map(x => result[x.name].map((y) => {
  const alphabet = y.slugname;
  if (total[alphabet]) {
      total[alphabet] += x.value;
    } else {
      total[alphabet] = x.value;
    }
    return true;
}));

Solution 2:[2]

There is nothing wrong with your code, this is outdated guidance.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Aks
Solution 2 reconbot