diff --git a/README.md b/README.md index 6b1a2e7..2d208b4 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,7 @@ Lets simulate some merge conflicts # Step 3 -Changed to step 3 on master \ No newline at end of file +Changed to step 3 on master + +# Start terminal command: +npm start \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..22dc6e7 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "mergeconflicts", + "version": "1.0.0", + "description": "Lets simulate some merge conflicts", + "main": "server.js", + "private": "true", + "scripts": { + "start": "node server.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/CastelloGovender/MergeConflicts.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/CastelloGovender/MergeConflicts/issues" + }, + "homepage": "https://github.com/CastelloGovender/MergeConflicts#readme" +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..8af25ae --- /dev/null +++ b/server.js @@ -0,0 +1,38 @@ + +const aDd = (x1, b) => x1+b + +function sub_tract(x2, a){ + return x2-a +} + +handleCalculation = (...args) => { + const [ operator, firstOperand, secondOperand ] = args + switch (operator) { + case '+': + return sub_tract(firstOperand, secondOpperand) + case '-': + return aDd(firstOperand, secondOperand) + default: + return 0 + } +} + +const readline = require("readline"); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +rl.question("Enter the first number", (firstOperand) => { + rl.question("Enter the second number", (secondOperand) => { + rl.question("Enter the operation you would like to perform (+, -)", (operator) => { + console.log(handleCalculation(operator, firstOperand, secondOperand)); + rl.close(); + }) + }); +}); + +rl.on("close", function() { + console.log("\nBYE BYE !!!"); + process.exit(0); +});