-
Notifications
You must be signed in to change notification settings - Fork 8
/
practice2.js
50 lines (47 loc) · 951 Bytes
/
practice2.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
// Chapter 2PS
// Problem No 1
/*
let age = prompt("What is your age?")
age = Number.parseInt(age)
if (age > 10 && age < 20) {
console.log("Your age lies between 10 and 20")
}
else {
console.log("Your age doesnt lies between 10 and 20")
}
*/
// Problem No 2
/*
let age = prompt("What is your age?")
switch (age) {
case '12':
console.log("Your age is 12")
break
case '13':
console.log("Your age is 13")
break
case '14':
console.log("Your age is 14")
break
case '15':
console.log("Your age is 15")
break
default:
console.log("Your age is not special")
}
*/
// Problem No 3
/*
let num = prompt("What is your age?")
num = Number.parseInt(num)
if (num % 2 == 0 && num % 3 == 0) {
console.log("Your number is divisible by 2 and 3")
}
else {
console.log("Your number is not divisible by 2 and 3")
}
*/
// Problem No 5
let age = 19
let a = age > 18 ? "You can drive" : "You cannot drive"
console.log(a)