0

function bmival(h, w) {
  var b = h * 2;
  var o = w / b
  // var r= Math.trunc(o)
  return (`Your BMI is ${o}`)
  if (o < 18.5) {
    return 'you are underweight'
  } else if (o > 18.5 && o < 25.5) {
    return 'You come under fit category'
  } else {
    return 'you are overweight and obese'
  }
}

console.log(bmival(1.895, 70))

The if statement not returning the string i was making a Bmicalculator and don't know what i am doing wrong

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • 5
    You have an unconditional `return` before the `if`. Nothing after an unconditional `return` will execute, because the `return` ends the function. – T.J. Crowder Aug 28 '22 at 10:16
  • 1
    Side note: Your logic is incorrect. What if the value is **exactly** `18.5`? (Remove the `o > 18.5 &&` part of the second `if`. Remember, you'll only reach that if the first `if`'s condition was false.) – T.J. Crowder Aug 28 '22 at 10:18
  • update on question i was doing it wrong the first return causing the problem thanks for answering – Ayush panwar Aug 28 '22 at 15:17

0 Answers0