daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Oct 20th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var f = wrapFunc(function() {
  2.   function Fraction(nom, denom) {
  3.     this.nominator   = nom
  4.     this.denominator = denom
  5.   }
  6.  
  7.   Fraction.prototype['*'] = function(other) {
  8.     return new Fraction(this.nominator   * other.nominator,
  9.                         this.denominator * other.denominator)
  10.   }
  11.  
  12.   Fraction.prototype.toString = function() {
  13.     return this.nominator + "/" + this.denominator
  14.   }
  15.  
  16.   var one_half  = new Fraction(1, 2)
  17.     , one_third = new Fraction(1, 3)
  18.  
  19.   return one_half * one_third
  20. })
  21.  
  22. console.log(String(f())) // 1/6
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top