Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. const orders = [500, 30, 99, 15, 223];
  2.  
  3. // ×
  4.  
  5. const total = 0;
  6. const withTax = [];
  7. const highValue = [];
  8. for (i = 0; i < orders.length; i++) {
  9.  
  10. // Reduce
  11. total += orders[i];
  12.  
  13. // Map
  14. withTax.push(orders[i] * 1.1);
  15.  
  16. // Filter
  17. if (orders[i] > 100) {
  18. highValue.push(orders[i])
  19. }
  20. }
  21.  
  22. // ○
  23.  
  24. // Reduce
  25. const total = orders.reduce((acc, cur) => acc + cur)
  26.  
  27. // Map
  28. const withTax = orders.map(v => v * 1.1)
  29.  
  30. // Filter
  31. const highValue = orders.filter(v => v > 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement