eternalmeg

01

Jun 21st, 2024
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. (function() {
  2. Array.prototype.last = function() {
  3. return this[this.length - 1];
  4. };
  5.  
  6. Array.prototype.skip = function(n) {
  7. return this.slice(n);
  8. };
  9.  
  10. Array.prototype.take = function(n) {
  11. return this.slice(0, n);
  12. };
  13.  
  14. Array.prototype.sum = function() {
  15. return this.reduce((acc, curr) => acc + curr, 0);
  16. };
  17.  
  18. Array.prototype.average = function() {
  19. return this.sum() / this.length;
  20. };
  21. })()
Advertisement
Add Comment
Please, Sign In to add comment