-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex_28.js
40 lines (40 loc) · 1.69 KB
/
ex_28.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
// Stages of Life: Write an if-else chain that determines a person’s stage of life. Set a value for the variable age, and then:
// • If the person is less than 2 years old, print a message that the person is a baby.
// • If the person is at least 2 years old but less than 4, print a message that the person is a toddler.
// • If the person is at least 4 years old but less than 13, print a message that the person is a kid.
// • If the person is at least 13 years old but less than 20, print a message that the person is a teenager.
// • If the person is at least 20 years old but less than 65, print a message that the person is an adult.
// • If the person is age 65 or older, print a message that the person is an elder.
// let personAge = 10;
// if(personAge < 2){
// console.log(`The person is a baby`);
// }else if(personAge >= 2 && personAge < 4){
// console.log(`The person is a toddler`);
// }else if(personAge >= 4 && personAge < 13){
// console.log(`The person is a kid`);
// }else if(personAge >= 13 && personAge < 20){
// console.log(`The person is a teenager`);
// }else if(personAge >= 20 && personAge < 65){
// console.log(`The person is a Adult`);
// }else if(personAge >= 65){
// console.log(`The person is an elder`);
// }
var age = 25;
if (age < 2) {
console.log("The person is a baby.");
}
else if (age >= 2 && age < 4) {
console.log("The person is a toddler.");
}
else if (age >= 4 && age < 13) {
console.log("The person is a kid.");
}
else if (age >= 13 && age < 20) {
console.log("The person is a teenager.");
}
else if (age >= 20 && age < 65) {
console.log("The person is an adult.");
}
else if (age >= 65) {
console.log("The person is an elder.");
}