-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
43 lines (36 loc) · 1.08 KB
/
script.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
// comparing the BMI of Mark and John
let massMark = 78;
let massJohn = 92;
let heightMark =1.69;
let heightJohn= 1.95;
markBMI= massMark/ heightMark**2
console.log(markBMI)
johnBMI = massJohn/ heightJohn**2
console.log(johnBMI)
markHigherBMI= markBMI > johnBMI;
console.log(markHigherBMI)
if (markHigherBMI) alert ('Marks BMI is higher than Johns BMI')
else alert('Johns BMI is higher')
//comparing again
massMark = 95;
massJohn = 85;
heightMark =1.88;
heightJohn= 1.76;
markBMI= massMark/ heightMark**2
console.log(markBMI)
johnBMI = massJohn/ heightJohn**2
console.log(johnBMI)
markHigherBMI= markBMI > johnBMI;
console.log(markHigherBMI)
if (markHigherBMI) alert ('Marks BMI is higher than Johns BMI')
else alert('Johns BMI is higher')
// using if else statements
// const age = 15;
// const isOldEnough = age >=18;
// if (isOldEnough){
// console.log('Sarah can have driving license 🚗')
// }
// else{
// const yearsLeft = 18-age;
// console.log(`Sarah cannot have a driving license. Wait another ${yearsLeft} years :)`)
// }