-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.js
More file actions
30 lines (18 loc) · 970 Bytes
/
Copy pathstrings.js
File metadata and controls
30 lines (18 loc) · 970 Bytes
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
//Problem
//Use the BMI example from Challenge #1, and the code you already wrote, and improve it:
//1. Print a nice output to the console, telling the user who has the higher BMI. The message can be either:
//"Mark's BMI is higher than John's!" or "John's BMI is higher than Mark's!".
//2. Modify the outputs above to use template literals to include the BMI values in the outputs.
const massMark = 78;
const heightMark = 1.69;
const massJohn = 92;
const heightJohn = 1.95;
const BMIMark = massMark / (heightMark * heightMark);
const BMIJohn = massJohn / (heightJohn * heightJohn);
//console.log(BMIMark, BMIJohn);
(BMIJohn>BMIMark)?console.log("John's BMI is higher than Mark's!"):console.log("Mark's BMI is higher than John's!");
if(BMIJohn>BMIMark){
console.log(`John's BMI (${BMIJohn}) is higher than Mark's (${BMIMark})!`);
}else{
console.log(`Mark's BMI (${BMIMark}) is higher than John's (${BMIJohn})!`);
}