How can a return statement after a function call, output string with double quote to console?

Viewed 13

How can a return statement after a function call, output string with double quote to console. I'm getting only single quotes.

 var BMI;
var message;
function bmiCalculator(weight, height)
    {
        BMI = Math.round((weight / (height * height))*100)/100;
       
     if (BMI < 18.5){
             message = "Your BMI is " + BMI + ", so your are underweight.";

        }

        if (BMI > 18.5 && BMI < 24.9){
          message =  "Your BMI is " + BMI + ", so your are normal.";
}
        if  (BMI > 24.9){
             message = "Your BMI is " + BMI + ", so your are overweight.";

        }
        return message;
    }
    

 bmiCalculator(90, 2);
1 Answers

You can use single quotes in javascript to delimit strings, which means your double quotes become regular strings e.g.

console.log('Hello "world"').

Otherwise you are looking for the javascript string escape character which works like this:

console.log("Hello \"world\"").
Related