After click, a calculated BMI is shown as 0.3; expected answer was 22.8
Code snippet in question:
calculateButton.addEventListener('click', function() {
var feet = feetField.value;
var inches = inchesField.value;
var heightInInches = (feet * 12) + inches;
bmiDisplay.text = ((weightField.value / (heightInInches * heightInInches)) * 703).toFixed(1);
});
heightInInches should equal 68, not 608. Seems like somehow feet (5) is being multiplied by 120 instead of 12 and then tacking on the inches (8) at the end, but I don’t quite understand why that’s happening, and why it’s hiding from me when I step through the code?
Debugger shows the correct values for feet(5) and inches(8) in the formula but an incorrect value assigned to heightInInches after the calculation.
I think I formatted the question correctly; long time listener, first time caller. I’ve just been staring at it too long… I had screenshots of my UI and the debugger but I had to remove those images from the post. Ok, thanks for checking it out.
Try by adding: