Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
Lets simulate some merge conflicts

# Step 3
Changed to step 3 on master
Changed to step 3 on master

# Start terminal command:
npm start
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
38 changes: 38 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -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);
});