-
Notifications
You must be signed in to change notification settings - Fork 0
/
calSymple.js
43 lines (33 loc) · 872 Bytes
/
calSymple.js
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
41
42
43
//code by FazzRqy
//Please those who are experienced in JavaScript to help me so that I am more proficient in the JavaScript programming language
const readline = require('readline-sync');
function ask() {
let x,y;
do {
x = readline.question('input numero x = ');
} while (isNaN(x));
do {
y = readline.question('input numero y = ');
} while (isNaN(y));
let operation = readline.question('Input operation (*, /, +, -) = ');
let result;
switch (operation) {
case '*':
result = x * y;
break;
case '/':
result = x / y;
break;
case '+':
result = +(x) + +(y);
break;
case '-':
result = x - y;
break;
default:
console.log('error \n \n[END SCRIPT]')
return;
}
console.log(x + operation + y + '=' + result)
};
ask()