-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge1.js
More file actions
33 lines (25 loc) · 999 Bytes
/
challenge1.js
File metadata and controls
33 lines (25 loc) · 999 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
31
32
33
/************************************
* Coding Challenge 1
*/
/*
Mark and John are trying to compare their BMI (Body Mass Index),
which is calculated using the formula:
BMI = mass/height^2 = mass/(height*height).
(mass in kg and height in meter).
1. Store Mark's and John'm mass and height in variables.
2. Calculate both their BMIs.
3. Create a boolean variable containing information about
whether Mark has a higher BMI than John.
4. Print a string to the console containing the variable from
step 3. (something like "Is Mark's BMI higher than John's? true"
*/
var massMark = prompt("What is Mark's body mass?");
var massJohn = prompt("What is John's body mass?");
var heightMark = prompt("What is Mark's height?");
var heightJohn = prompt("What is John's height");
var markBMI = massMark/(heightMark^2);
var johnBMI = massJohn/(heightJohn^2);
console.log(markBMI);
console.log(johnBMI);
var markGreater = markBMI > johnBMI;
console.log("Is Mark's BMI higher than John's? " + markGreater);