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
46 changes: 46 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@

// var userInput = readline();
// print("User input: " + userInput);

const readline = require('readline');

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.question("Enter first number ", (num1) => {
rl.question("Enter second number ", (num2) => {
rl.question("Enter operation (+, -, /, *, <, >, =) ", (operator) => {
let numOne = parseInt(num1)
let numTwo = parseInt(num2)
if(operator === "+") {
console.log((numOne) + (numTwo))
} else if(operator === "-") {
console.log((numOne) - (numTwo))
} else if(operator === "/") {
console.log((numOne) / (numTwo))
} else if(operator === "*") {
console.log((numOne) * (numTwo))
} else if (operator === ">" && numOne > numTwo){
console.log(`True! ${numOne} is greater than ${numTwo}`)
} else if (operator === ">" && numOne < numTwo){
console.log(`False! ${numOne} is less than ${numTwo}`)
} else if (operator === "<" && numOne < numTwo){
console.log(`True! ${numOne} is less than ${numTwo}`)
} else if (operator === "<" && numOne > numTwo){
console.log(`False! ${numOne} is greater than ${numTwo}`)
} else if ((operator === "<" && numOne === numTwo) ||
(operator === "<" && numOne === numTwo)) {
console.log(`False! ${numOne} is equal to ${numTwo}`)
} else if (operator === "=" && numOne === numTwo){
console.log(`True! ${numOne} is equal to ${numTwo}`)
} else if (operator === "=" && numOne !== numTwo){
console.log(`False! ${numOne} is not equal to ${numTwo}`)
} else {
console.log("Syntax errrrrrrrror!!!!")
}
return rl.close();
})
})
})

3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "aca-node",
"version": "1.0.0",
"description": "The purpose of this project is to demonstrate that node.js is nothing special. Anyone can create a program that interprets input as code, processes it accordingly and then outputs something.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tomsonkan/aca-node.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/tomsonkan/aca-node/issues"
},
"homepage": "https://github.com/tomsonkan/aca-node#readme"
}