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

remove duplicates in an sorted array

  using System; public class HelloWorld {          public static void Main(string[] args)     {         int[] ar={2,2,3,3,4,6,6};          C...