-
Notifications
You must be signed in to change notification settings - Fork 0
/
lecture_07.js
68 lines (55 loc) · 1.56 KB
/
lecture_07.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// ....................................Conditional_Statement..................................................
let a =prompt("Enter ur age")
console.log(a)
console.log(typeof (a)) //output before parseint
a = Number.parseInt(a) //converting the string in to number
console.log(typeof(a)) //output after parseint
// write a programme to find biggest no?
let b = 7;
let c = 6;
let d = 8;
if (b > c && b > d) {
alert(`${b} is the biggest no`);
} else if (c > d) {
alert(`${c} is the biggest no`);
} else {
alert(`${d} is the biggest no`);
}
// Switch for fruit shop
let fruit;
fruit = prompt("Which fruit you want to buy sir");
switch (fruit) {
case "Orange":
document.write("Orange is 60 Rs per kg");
break;
case "Banana":
document.write("Banana is 60 Rs per kg");
break;
case "Mango":
document.write("Mango is 60 Rs per kg");
break;
case "Papaya":
document.write("Papaya is 60 Rs per kg");
break;
default:
document.write(`${fruit} is not Available`);
}
// use switch for making mini calculator
let operator ;
let e ;
let f ;
e = prompt("Enter 1st operand");
operator = prompt("Enter operator");
f = prompt("Enter 2nd operand");
e = Number.parseInt(a);
f = Number.parseInt(b);
// console.log(typeof(a));
// console.log(typeof(b));
switch(operator){
case '+' : document.write(a+b);break;
case '-' : document.write(a-b);break;
case '*' : document.write(a*b);break;
case '/' : document.write(a/b);break;
case '%' : document.write(a%b);break;
default : document.write(` ${operator} Operator is not defined`)
}