title: Calculate BMI JavaScript switch
body: <p>I am doing  a standard task with codewares: Write function bmi that calculates body mass index (bmi = weight / height2).</p>
  <p>Here is my solution:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function bmi(weight, height) {
    let bmi = weight / (height ** 2)
  
    if (bmi &lt;= 18.5) {
  
      return "Underweight";
    } else if (bmi &lt;= 25.0) {
  
      return "Normal"
    } else if (bmi &lt;= 30.0) {
  
      return "Overweight"
    } else if (bmi &gt; 30) {
      return "Obese"
    }
  }
  
  console.log(bmi(80, 1.80))</code></pre>
  </div>
  </div>
  </p>
  <p>I have a question: is it possible to solve this problem with the help of a switch?  Because I tried it in different ways and in the console I have <code>undefined</code>:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function bmi(weight, height) {
  
    let bmi = weight / (height ** 2)
  
    let c = "Normal"
  
    switch (bmi) {
      case "Underweight":
        bmi &lt;= 18.5;
        break;
  
      case "Normal":
        bmi &lt;= 25.0;
        break;
  
      case "Overweight":
        bmi &lt;= 30.0;
        break;
  
      default:
        return;
    }
  }
  console.log(bmi(80, 1.80))</code></pre>
  </div>
  </div>
  </p>