Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2-JS-basics/starter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@

<body>
<h1>Section 2: JavaScript Language Basics</h1>

<script src="main.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions 2-JS-basics/starter/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*****************************
* 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's 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").

GOOD LUCK 😀
*/

let markValues = {
mass: 30,
height: 2.5
}

let johnValues = {
mass: 25,
height: 3
}

function whosBmiIsHigher(val1, val2){
let markBmi = markValues.mass / Math.pow(markValues.height, 2);
let johnBmi = johnValues.mass / Math.pow(johnValues.height, 2);

if(markBmi > johnBmi){
console.log("At " + markBmi + "kg, Mark has a higher Bmi than John at " + johnBmi + "kg");
} else {
console.log("At " + johnBmi + "kg, John has a higher Bmi than John at " + markBmi + "kg");
}
}

whosBmiIsHigher(markValues, johnValues);