Tried
let markWeights = 78
let markHeight = 1.69
let johnWeights = 92
let johnHeight = 1.95
let markBMI = markWeights / markHeight ** 2
let johnBMI = johnWeights / (johnHeight * johnHeight)
let markHigherBMI = markBMI > johnBMI
console.log("Mark's BMI is" + ' ' + markBMI);
// Mark's BMI is 27.309968138370508
console.log("John's BMI is" + ' ' + johnBMI);
// John's BMI is 24.194608809993426
console.log("Does Mark has a higher BMI than John? The answer is" + ' ' + markHigherBMI);
// Does Mark has a higher BMI than John? The answer is true
Answer
const massMark = 78;
const heightMark = 1.69;
const massJohn = 92;
const heightJohn = 1.95;
const BMIMark = massMark / heightMark ** 2;
const BMIJohn = massJohn / (heightJohn * heightJohn);
const markHigherBMI = BMIMark > BMIJohn;
console.log(BMIMark, BMIJohn, markHigherBMI);
// 27.309968138370508 24.194608809993426 true
semi colon을 다 빼먹음 ;;
'Programming > JavaScript' 카테고리의 다른 글
Taking Decisions: if / else Statements (0) | 2022.08.16 |
---|---|
Strings and Template Literals (0) | 2022.08.09 |
Operator Precedence (0) | 2022.07.10 |
Basic Operators (0) | 2022.07.10 |
let, const and var (0) | 2022.07.10 |