I am looking to enhance the functionality of my Vue.js composition API web application by calculating the total number of employed workers in different sectors. However, I want to multiply the number of workers by another key:value property instead of just adding them up.
export default {
setup( props, {emit}) {
let data = reactive({
let chosenCompanies: [
{ id: 'Big', workers: 250, clones: 9 },
{ id: 'Medium', workers: 75, clones: 2 },
{ id: 'Small', workers: 10, clones: 6 },
{ id: 'Individual', workers: 1, clones: 7}
]
});
const employedWorkers = () => {
let employedworkersPrivate = 0;
data.chosenCompanies.forEach(function(sector){
for (const [key, value] of Object.entries(sector)) {
if (key === 'workers') {
employedworkersPrivate += parseInt(value)
// In this context, I aim to factor in the number of clones per worker to get an accurate count instead of simply aggregating the workers
// Is there a way to access the 'clones' value here?
}
}
})
return employedworkersPrivate
}
}
}