Advertisement
andreadc

iteration.js

Apr 26th, 2020
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function multy(arr) {
  2.     let result = 0;
  3.     for (var j = 0; j < arr.length; j++) {
  4.         result += arr[j][0] * arr[j][1];
  5.     }
  6.     return result;
  7. }
  8. const arr = [[5, 6], [2, 3], [1, 2]];
  9. console.log(multy(arr));
  10.  
  11. //or more cool
  12.  
  13. function multy(arr) {
  14.     let result = 0;
  15.     arr.map(arr => {
  16.         result += arr[0] * arr[1]
  17.     });
  18.     return result;
  19. }
  20. const arr = [[5, 6], [2, 3], [1, 2]];
  21. console.log(multy(arr));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement