JavaScript Objects Coding Challenge

Description

This coding challenge focuses on JavaScript objects and methods. The objective was to create two objects, each representing a person, with properties including firstName, lastName, mass, and height. Additionally, a method named calcBMI was to be implemented in each object to calculate the BMI (Body Mass Index) based on the provided formula. Finally, a comparison between the BMIs of the two individuals was to be logged to the console using a specific string format.

Challenge Details

  1. Create two JavaScript objects, each representing a person, with properties:
    • firstName
    • lastName
    • mass (in kilograms)
    • height (in meters)
  2. Implement a method named calcBMI within each object to calculate the BMI using the formula: BMI = mass / (height * height)
  3. Use an if/else statement to compare the BMIs of the two individuals.
  4. Log a message to the console indicating whose BMI is higher, following the format: "{firstName} {lastName}'s BMI ({calculatedBMI}) is higher than {firstName} {lastName}'s BMI ({calculatedBMI})."

Example Output

For example, if the calculated BMIs for two individuals were:

  • John Miller: BMI = 24.5
  • Mark Smith: BMI = 23.4 The output logged to the console should be: "John Miller's BMI (24.5) is higher than Mark Smith's BMI (23.4)."

Usage

  1. Clone the repository to your local machine: git clone https://github.com/Olamiposi-cloud-coder/objectsChallenge.git

  2. Open the index.js file and review the implementation of the objects and methods.

  3. Run the code to see the comparison of BMIs logged to the console.

Author

[Cloud] - [https://github.com/Olamiposi-cloud-coder]

Feel free to contribute to the project by providing feedback, suggestions, or improvements via pull requests.

Happy coding!