Advertisement
CR7CR7

sumandproduct

Sep 18th, 2022
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let numbers = [1, 2 -4, 3, 7, 3];
  2.  
  3. let sum = 0;
  4. let product = 1;
  5.  
  6. for (let i = 0; i < numbers.length; i++) {
  7.   sum = sum + numbers[i];
  8.   product = product * numbers[i];
  9. }
  10.  
  11. console.log(`Sum = ${sum}`);
  12. console.log(`Product = ${product}`);
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement