File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -43,14 +43,4 @@ Fraction.prototype.div = function (f) {
43
43
return new Fraction ( this . _numerator * f . _denominator , this . _denominator * f . _numerator ) ;
44
44
} ;
45
45
46
- var onehalf = new Fraction ( 1 , 2 ) ;
47
- var twothird = new Fraction ( 2 , 3 ) ;
48
- console . log ( onehalf . toString ( ) + ' + ' + twothird . toString ( ) + ' = ' + onehalf . add ( twothird ) . toString ( ) ) ;
49
- console . log ( onehalf . toString ( ) + ' / ' + twothird . toString ( ) + ' = ' + onehalf . div ( twothird ) . toString ( ) ) ;
50
-
51
- var almost_pi = new Fraction ( 22 , 7 ) ;
52
- var two = new Fraction ( 2 , 1 ) ;
53
- console . log ( almost_pi . toString ( ) + ' * ' + two . toString ( ) + ' = ' + almost_pi . mul ( two ) ) ;
54
-
55
- var f = onehalf . div ( twothird ) ;
56
- console . log ( 'f = ' + f . toString ( ) + ' ~= ' + f . toNumber ( ) ) ;
46
+ module . exports = Fraction ;
Original file line number Diff line number Diff line change
1
+ const Fraction = require ( './fraction' ) ;
2
+
3
+ var onehalf = new Fraction ( 1 , 2 ) ;
4
+ var twothird = new Fraction ( 2 , 3 ) ;
5
+ console . log ( onehalf . toString ( ) + ' + ' + twothird . toString ( ) + ' = ' + onehalf . add ( twothird ) . toString ( ) ) ;
6
+ console . log ( onehalf . toString ( ) + ' / ' + twothird . toString ( ) + ' = ' + onehalf . div ( twothird ) . toString ( ) ) ;
7
+
8
+ var almost_pi = new Fraction ( 22 , 7 ) ;
9
+ var two = new Fraction ( 2 , 1 ) ;
10
+ console . log ( almost_pi . toString ( ) + ' * ' + two . toString ( ) + ' = ' + almost_pi . mul ( two ) ) ;
11
+
12
+ var f = onehalf . div ( twothird ) ;
13
+ console . log ( 'f = ' + f . toString ( ) + ' ~= ' + f . toNumber ( ) ) ;
You can’t perform that action at this time.
0 commit comments