Friday, 26 April 2024

reduce in typescipt

 calculate sum of the amount use below logic

this.TotalAmount=  res.reduce((total, current) => total +
(current.Quantity * current.UnitPrice), 0);



i have two arrays need to loop those and and description.
intad of getting data usign joins i have using below logic to add description ot items list



 if(this.lstGlcode.length >0){
            res.forEach(y=>{
              let gldesc=this.lstGlcode.find(x=>x.Id === y.GldescriptionId)
              if(gldesc){
                y.GlDescription=gldesc.Description;
              }
            })
        }

No comments:

Post a Comment

Car pooling app

 I'll create a car pooling app with real-time vehicle tracking, pickup/drop time estimates, and a list of onboard users. Since we don...