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

207
Vistas
Why does it print "undefined" on the console?

I have the following JavaScript code:

please help

let statement = ['Kim is a good, kind and smart boy'];
    
let kim = {
  message () {
    console.log(statement);
  },
  interest () {
    console.log('sports');
  }
}
console.log(kim.message());
console.log(kim.interest());

I expect that it should print this output:

[ 'Kim is a good, kind and smart boy' ]
sports

But instead, it prints the following:

[ 'Kim is a good, kind and smart boy' ]
undefined
sports
undefined

Why does it print "undefined" after each function within the method?

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

0

I suppose you're calling console.log(kim.message()); and console.log(kim.interest());

console.log prints the return value of the passed function but because both the function don't have a return statement console.log prints undefined that's way you see those additional undefined logs.

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