Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
Chrome devtools there is no console output from running snippet code

I have some troubles with the console's output when I try to run some snippet js code from the "source" tab. Instead of getting a valid output, I get "undefined" (I've checked the code in JSFiddle and it's correct the output is:20 )

Why does it happen and how can I resolve it?

JS:

    //Create your function below this line.
//The first parameter should be the weight and the second should be the height.

function bmiCalculator(weight, height){
  return Math.round(weight/Math.pow(height,2));
}


/* If my weight is 65Kg and my height is 1.8m, I should be able to call your function like this:

var bmi = bmiCalculator(65, 1.8); 

bmi should equal 20 when it's rounded to the nearest whole number.

*/


var bmi = bmiCalculator(65, 1.8); 
console.log(bmi);

enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Snippets are code run directly in the console, it output the returned value of last statement, in your case it's console.log(), which doesn't return anything, hens it shows undefined. (it's like typing in console: console.log(console.log("ok")) )

If your remove console.log() all together, it will print out the value of the variable instead:

    //Create your function below this line.
//The first parameter should be the weight and the second should be the height.

function bmiCalculator(weight, height){
  return Math.round(weight/Math.pow(height,2));
}


/* If my weight is 65Kg and my height is 1.8m, I should be able to call your function like this:

var bmi = bmiCalculator(65, 1.8); 

bmi should equal 20 when it's rounded to the nearest whole number.

*/


var bmi = bmiCalculator(65, 1.8); 
bmi;

You can get rid of bmi variable too, just execute the function.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda