-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (33 loc) · 837 Bytes
/
app.js
File metadata and controls
40 lines (33 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// This file reads information from the console and outputs the result
// It also handles exit requests
/* jshint esversion: 6 */
console.log("[ OLDEST --> NEWEST ]");
const calc = require("./calc.js");
const readline = require("readline");
var nums = [];
function getAns(){
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question(":", function(data){
if(data.split(" ").length == 1){
nums[nums.length] = data;
}
else{
var part = data.split(" ");
while(part.length > 0){
nums = calc.proc((nums + ',' + part[0]).split(","));
part.shift();
}
}
nums = calc.proc(nums, true);
setTimeout(function(){
console.log(nums);
if(nums !== "exit")
getAns();
}, 0);
rl.close();
});
}
getAns();