So I'm learning JS, regarding functions and the use of return. Is there a functional difference between these 2 functions? They are both supposed to be BMI calculators. I've tested them out, and the first one works once you call the function and set a weight/height.
1.)
function bmiCalculator(weight, height){ return bmi = Math.round(weight / Math.pow(height, 2));}
2.)
function bmiCalculator(weight, height){ var bmi = Math.round(weight / Math.pow(height, 2)); return bmi;}
1.) works once I call function:
bmiCalculator(65, 1.8);
shows 20 on console
2.) works once I code:
var bmi = bmiCalculator(65, 1.8);console.log(bmi);
shows 20 on console