I just started learning JavaScript, and ran into such a problem, I have a nested array, I want to summarize the price value of these arrays and return the existing sum, I wonder which method is applicable for it, which does not hurt the performance, I need one example to understand the way to solve the problem. Thanks in advance
const initialData = [
      {
          title: 'm2212',
          data: [
              {
                  id: 98233181232,
                  variations:[{
                          warranty: '',
                          price: 120,
                          comment: '',
                      }]
  
              },
          ]
      },
      {
          title: 'm2',
          data: [
              {
                  id: 982812,
                  variations:[{
                          warranty: '',
                          price: 92,
                          comment: '',
                      }]
  
              },
               {
                  id: 92182812,
                  variations:[{
                          warranty: '',
                          price: 922,
                          comment: '',
                      }]
  
              },
          ]
      },
 ]
 
 
 
 //what i tried
 let sum = 0
 initialData.forEach((el)=>{
   el.data.forEach((el1)=>{
     sum = sum + el1.variations[0].price
    })
 })
 console.log(sum);



initialDatafirst, loop throughdataarray next then throughvariationsarray. Keep on addingvariationsvalue to a variable. This will give the sum.