Hello! I'm currently facing an issue where I need to add two functions and store the sum in another array. Should I keep the revenue as an array or is it fine to leave it as a function? I was also thinking about setting numa in a function as an array due to that button.
Moreover, when I try to combine this.functionA+this.functionB
, the result shows up as ,.
Essentially, my goal is to calculate the revenue for each month by adding a button and creating arrays to input the results and then display them.
Here's the code snippet:
export default{
name: 'Home',
data(){
return{
FormData: {
revenue:[
{
lollipops:[
{
lolliSold:0,
pricePerLolli:0,
}
],
chocolate:[
{
numchocoSold:0,
pricePerChoco:0,
}
],
numa:0,
oprod:0
}
] }}
computed: {
lolliesSale(){
let SaleArray=[];
this.FormData.revenue.forEach((ItemL, indexL)=>{
SaleArray[indexL]=ItemL.lollipops[0].lolliSold+ItemL.lollipops[0].pricePerLolli;
});
return SaleArray;
},
chocolateSale(){
let choSaleArray=[];
this.FormData.revenue.forEach((ItemC, indexC)=>{
choSaleArray[indexC]=ItemC.chocolate[0].numchocoSold*ItemC.chocolate[0].pricePerChoco;
});
return choSaleArray;
},
numaSupport(){
let numaSuppArray=[];
this.FormData.revenue.forEach((ItemN, indexN)=>{
numaSuppArray[indexN]=ItemN.numa;
});
return numaSuppArray;
},
revenue(){
//return this.<anyfunction>; <- this is ok!!!!
}