-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicCalc.js
More file actions
22 lines (21 loc) · 768 Bytes
/
Copy pathBasicCalc.js
File metadata and controls
22 lines (21 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Basic calc program
let a=Number(prompt("Enter 1-add 2-sub 3-mul 4-div 5-rem:")) // Normally prompt only take a string if you want as a number you have to give it explicitly eg:parseInt
switch(a){
case 1:
console.log(Number(prompt("num1:"))+Number(prompt("num2:")));
break;
case 2:
console.log(Number(prompt("num1:"))-Number(prompt("num2:")));
break;
case 3:
console.log(Number(prompt("num1:"))*Number(prompt("num2:")));
break;
case 4:
console.log(Number(prompt("num1:"))/Number(prompt("num2:")));
break;
case 5:
console.log(Number(prompt("num1:"))%Number(prompt("num2:")));
break;
default:
console.log("Enter available choice")
}