-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIfElse.js
29 lines (24 loc) · 805 Bytes
/
IfElse.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
var firstName = 'John';
var civilStatus = 'single';
if (civilStatus === 'married') {
console.log(firstName + ' is married!');
} else {
console.log(firstName + ' will hopefully marry soon :)'); // will execute
}
var isMarried = true;
if (isMarried) {
console.log(firstName + ' is married!'); // execute
} else {
console.log(firstName + ' will hopefully marry soon :)');
}
var massMark = 78; // kg
var heightMark = 1.69; // meters
var massJohn = 92;
var heightJohn = 1.95;
var BMIMark = massMark / (heightMark * heightMark); // 27.309968138370508
var BMIJohn = massJohn / (heightJohn * heightJohn); // 24.194608809993426
if (BMIMark > BMIJohn) {
console.log('Mark\'s BMI is higher than John\'s.'); // true
} else {
console.log('John\'s BMI is higher than Marks\'s.'); // false
}