There is an array, let's say this:

var arr = [// Кол-во | множитель ['12', '2'], ['20', '3'], ['2, '1'] ]; 

Is it possible to count like this:

(12 * 2) + (20 * 3) + (2 * 1)

And get the result in a variable, let's say:

 var arrsum = *result* //86 

    3 answers 3

     let arr = [// Кол-во | множитель ['12', '2'], ['20', '3'], ['2', '1'] ]; console.info(arr.map(a => a.reduce((a, c) => a * +c, 1)).reduce((a, c) => a + c, 0)); 

    Oh, how many answers at once.
    I will not delete myself!

    • one
      I congratulate with 14000 - Igor
    • one
      At the finish line to protect! :) Thank you. - user207618

     var arr = [// Кол-во | множитель ['12', '2'], ['20', '3'], ['2', '1'] ]; console.log( arr.reduce((res, item) => res + item[0]*item[1], 0) ); 

       var arr = [ ['12', '2'], ['20', '3'], ['2', '1'] ]; var m = arr.map(function(x) { return parseInt(x[0]) * parseInt(x[1]); }); var arrsum = m.reduce(function(acc, val) { return acc + val; }); console.log(arrsum);