Advertisement
Voldemord

js calc

Oct 1st, 2020 (edited)
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const _ = require('lodash');
  2.  
  3. module.exports = class Calculator {
  4.  
  5.   constructor(items){
  6.  
  7.     this.calc = _.filter(items,
  8.       function(o , index){
  9.         if(!_.isNumber(o))
  10.           console.log(" bledny typ argumentu: " + "["+index+"] "+o)
  11.         return _.isNumber(o)
  12.       }
  13.     )
  14.   }
  15.  
  16.   sum(){
  17.     console.log(_.reduce(this.calc, function(sum,n){return sum+n}))
  18.   }
  19.  
  20.   substract(){
  21.     console.log(_.reduce(this.calc, function(sub,n){return sub-n}))
  22.   }
  23.  
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement