File tree Expand file tree Collapse file tree 2 files changed +8
-18
lines changed Expand file tree Collapse file tree 2 files changed +8
-18
lines changed Original file line number Diff line number Diff line change 1
- var math = require ( ' ./math' ) ;
1
+ var math = require ( " ./math" ) ;
2
2
3
3
var command = process . argv [ 2 ] ;
4
- var arguments = process . argv . slice ( 3 ) . map ( function ( arg ) {
5
- return parseFloat ( arg ) ;
6
- } ) ;
4
+ var num1 = parseFloat ( process . argv [ 3 ] ) ;
5
+ var num2 = parseFloat ( process . argv [ 4 ] ) ;
7
6
8
- if ( math [ command ] ) {
9
- console . log ( "running:" , command ) ;
10
- console . log ( math [ command ] . apply ( math , arguments ) ) ;
11
- } else {
12
- console . log ( "command " + command + " not found!" ) ;
13
- console . log ( "allowed commands are: " , Object . keys ( math ) . join ( ', ' ) ) ;
14
- }
7
+ console . log ( math [ command ] ( num1 , num2 ) ) ;
Original file line number Diff line number Diff line change 1
1
module . exports = {
2
- add : function ( x , y ) {
3
- return x + y ;
4
- } ,
5
- subtract : function ( x , y ) {
6
- return x - y ;
2
+ multiply : function ( x , y ) {
3
+ return x * y ;
7
4
} ,
8
- squareRoot : function ( x ) {
9
- return Math . sqrt ( x ) ;
5
+ add : function ( x , y ) {
6
+ return x + y ;
10
7
}
11
8
} ;
You can’t perform that action at this time.
0 commit comments