We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dda2819 commit 3c581e8Copy full SHA for 3c581e8
2-calc/calc.js
@@ -0,0 +1,14 @@
1
+var math = require('./math');
2
+
3
+var command = process.argv[2];
4
+var arguments = process.argv.slice(3).map(function(arg) {
5
+ return parseFloat(arg);
6
+});
7
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
+}
2-calc/math.js
@@ -0,0 +1,11 @@
+module.exports = {
+ add: function(x, y) {
+ return x+y;
+ },
+ subtract: function(x, y) {
+ return x-y;
+ squareRoot: function(x) {
+ return Math.sqrt(x);
+ }
+};
0 commit comments