Home > database >  I want to multiply between two arrays values in flutter
I want to multiply between two arrays values in flutter

Time:05-08

I have 2 Array called A and B, and I want to multiply 2 array values and create a new result array

  final a = <int>[2, 3, 4];
  final b = <int>[1, 2, 3];
          
  final result = <int>[2, 6, 12];

Please help me to achieve this thing in the flutter

CodePudding user response:

Try this

void main() {
      final a = <int>[2, 3, 4];
      final b = <int>[1, 2, 3];
    
      final result = <int>[];
    
      for (int i = 0; i < a.length; i  ) {
        result.add(a[i] * b[i]);
      }
    
      print(result);
    }
  • Related