Expected an assignment or function call and instead saw an expression no-unused-expressions. forEach javascript

Viewed 36

I am using forEach inside a function in javascript and code compilation is getting failed with error Expected an assignment or function call and instead saw an expression no-unused-expressions. I am using 2 forEach and error coming for both. My code is as below

const mapRole = (data, worker = false) => {
const byServiceGroup = [];
data?.forEach((obj) => {
const { roleName = '', groupCombination = [] } = obj;
const serviceGroupIds = groupCombination?.find(({ groupName }) => groupName === 
'service_group')
  ?.ids;
serviceGroupIds?.forEach((group) => {
  let path = `/att/${worker ? 'w' : 'en'}/${
    roleName ? roleName + '/' : ''
  }ds`;
  if (group === 'ALL') return; // skipping for 'ALL'
  byServiceGroup.push({
    serviceGroup: group,
    worker: worker,
    path: path,
    userRole: roleName,
  });
});
});
 return byServiceGroup;
};
1 Answers
Related