top of page

Using Java Script to work out BMI // body mass index.

const masstMark = 78; // declaration, variable, operator, value
const heightMark = 1.69; // declaration, variable, operator, value 

const massJohn = 92;

const heightJohn = 1.95;

// new variable added to indecate BMI value

const BMIMark = massMark / heightMark ** 2; // 78kg divided by 1.69m 2 squared       

  BMIMark         27.309968etc

const BMIJohn = massJohn / (heightJohn * heightJohn);   92kg dived by 3.84 (1.92 x 1.92)

  BMIJohn           24.194608etc

    

const markHigherBMI = BMIMark > BMIJohn; // Boolean              

console should read

const massMark = 78;

const heightMark = 1.69;

const massJohn = 92;

const heightJohn = 1.95;

const BMIMark = massMark / heightMark ** 2;// (heightMark * heightMark);

const BMIJohn = massJohn / (heightJohn * heightJohn);

const markHigherBMI = BMIMark > BMIJohn;

console.log(BMIMark, BMIJohn, markHigherBMI);

bottom of page