From abe200e909c57bc3affc4f56027d112475b46d1a Mon Sep 17 00:00:00 2001 From: Darwin Date: Sun, 20 Jan 2019 11:29:16 -0600 Subject: [PATCH 1/3] init commit --- index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/index.js b/index.js index 8b13789..b52d630 100644 --- a/index.js +++ b/index.js @@ -1 +1,14 @@ +const readline = require('readline-sync'); +var firstNum = readline.question("Please enter a number "); +var secondNum = readline.question("Please enter a second number "); +var operator = readline.question("Please enter +, -, *, or / ") + +function calculate(){ + if(operator === '+'){ + console.log(parseInt(firstNum) + parseInt(secondNum)) + } + +} + +calculate(); \ No newline at end of file From 7db706b17c67fc3d2d401a6e08c30357245a55ec Mon Sep 17 00:00:00 2001 From: Darwin Risser Date: Sun, 20 Jan 2019 15:41:09 -0600 Subject: [PATCH 2/3] mostly working v --- index.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/index.js b/index.js index 8b13789..b42ce69 100644 --- a/index.js +++ b/index.js @@ -1 +1,44 @@ +const readline = require('readline'); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +function doMath () { + rl.question('', (answer) => { + var newArr = answer.split(' '); + var num1 = Number(newArr[0]); + var operator = newArr[1]; + var num2 = Number(newArr[2]); + if (operator === '+'){ + console.log(num1 + num2); + } else if (operator === '-'){ + console.log(num1 - num2); + } else if (operator === '/'){ + console.log(num1 / num2) + } else if (operator === '*'){ + console.log(num1 * num2) + } else if (operator === '>'){ + if (num1 > num2){ + console.log(true) + } else { + console.log(false) + } + } else if (operator === '<'){ + if (num1 < num2){ + console.log(true) + } else { + console.log(false) + } + } else if (operator === '==='){ + if (num1 === num2){ + console.log(true) + } else { + console.log(false) + } + } + }); +} + +doMath(); \ No newline at end of file From fc62990692d7c21fde6b603fbeb7e331d0e113a1 Mon Sep 17 00:00:00 2001 From: Darwin Risser Date: Mon, 21 Jan 2019 10:32:17 -0600 Subject: [PATCH 3/3] added basic variables --- index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b42ce69..b7c1a96 100644 --- a/index.js +++ b/index.js @@ -5,9 +5,20 @@ const rl = readline.createInterface({ output: process.stdout }); -function doMath () { +const variable = { + name: "", + value: "" +} + +function doMath() { rl.question('', (answer) => { var newArr = answer.split(' '); + if (newArr[0] === 'let'){ + variable.name = newArr[1]; + variable.value = newArr[3]; + } else if (newArr[0] === variable.name){ + console.log(variable.value) + } else { var num1 = Number(newArr[0]); var operator = newArr[1]; var num2 = Number(newArr[2]); @@ -37,7 +48,9 @@ function doMath () { } else { console.log(false) } - } + } + } + doMath(); }); }