forked from phongpheu12101991/btvn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bt2.js
61 lines (50 loc) · 2.05 KB
/
bt2.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
//1.What is Boolean? Write down 3 different expression that results a Boolean type (i.e. 5 == 6)
//Boolean is a datatype that returns either of two values i.e. true or false. In JavaScript, boolean is used as a function to get the value of a variable, object, conditions, expressions etc. in terms of true or false.
//2.What is nested conditionals? Write a piece of code that uses nested conditionals
//-A nested if is an if statement that is the target of another if or else. Nested if statements means an if statement inside an if statement.
// let age = Number(prompt('Age ?'));
// if (age>=18) {
// if (age<=22) {
// console.log('La sinh vien');
// }
// else {
// console.log('Da tot nghiep');
// }
// }
// else {
// console.log('Chua hoc dai hoc');
// }
//=============BTVN============
//1.'Write a program that asks user their height (cm) and weight (kg), and then calculate their BMI (Body Mass Index):
// 'BMI = mass (kg) / (height(m) x height(m)
// Note: you must do the conversion from cm to m before calculation
// Then based on the BMI, tell them that they are:
// Severely underweight if BMI < 16
// Underweight if BMI is between 16 and 18.5
// Normal if BMI is between 18.5 and 25
// Overweight if BMI is between 25 and 30
// Obese if BMI is more than 30'
// let m = Number(prompt('Can nang? (kg)'));
// let h = Number(prompt('Cheu cao? (cm)'))/100;
// let BMI = m/(h*h);
// console.log(BMI.toFixed(1));
// if (BMI<16) {
// console.log('Severely underweight');
// }
// else if (BMI>=16 && BMI<18.5) {
// console.log('Underweight');
// }
// else if (BMI>=18.5 && BMI<25) {c
// onsole.log('Normal');
// }
// else if (BMI>=25 && BMI<30) {
// console.log('Overweight');
// }
// else {
// console.log('Obese')
// };
//2.Write a program that asks users enter a number and then calculates factorial of n: (1 * 2 * 3 *... *n)
// let i = 1;
// let n = Number(prompt('enter a number'));
// for (let y = 1;y <= n;y++) {i=i*y};
// console.log(`factorial of ${n} = ${i}`);