korhantokgoz / BMICompareProject

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mass Compare Project With our knowledge of JavaScript, let’s calculate and compare of the Mark’s and John’s BMI (Body Mass Index), which is calculated using the formula: BMI = mass / height2 = mass / (height * height). (mass in kg and height in meter). 1. To start, Store Mark's and John's mass and height in variables. Create variables named massMark , massJohn , heightMark and heightJohn set them equal to some value. 2. Calculate both their BMIs using the given formula. Set the results to variables named BMIJohn and BMIMark. 3. Write a comment above that explains this line of code. Print this BMIs to the console.

Use Math operators to shorten BMI results. (Math.Floor, Math.Round or toFixed) 5. According to the console, create a boolean variable higherBMI containing information about whether if Mark has a higher BMI than John or reverse. Use compare statement (< or >). Hint let A = 8; let B = 5; const bigger = A > B; // this gives “true” const bigger = A < B; // this gives “false” 6. Use console.log and string interpolation (containing the variables from all steps) to log the result something like this: Is Mark's BMI is higher than John's? Answer is “true". Because Mark's BMI is BMIMARK and John's BMI is BMIJOHN

Challange! Enrich your work. You can add values by using prompt and use string interpolation to see your result in alert screen. 8. Prepare a Readme file and send your work to the github account.

Additional Step! If you wish, you can make this compare with an if else stattement instead of boolean variable that you created in step 5. Usage of if else statement example: if (someValue > otherValue) { console.log('someValue is higher than otherValue'); } else { console.log('someValue is lower than otherValue'); }

About


Languages

Language:JavaScript 53.7%Language:CSS 27.6%Language:HTML 18.6%