Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
¿Cómo imprimir atributos de objetos numéricos usando la consola?

Soy un principiante en medio de un curso básico de js. Tengo un ejercicio simple relacionado con objetos y todo parece estar funcionando, excepto los valores numéricos donde la consola imprime la función en lugar del resultado deseado.

 // My code --> const pete = { firstname1: "Pete", fullname1: "Pete Programmer", age: 20, firstname: function() {return this.firstname1}, fullname: function() {return this.fullname1}, age1: function() {return this.age1} } const cara = { firstname1: "Cara", fullname1: "Cara Code", age1: 32, firstname: function() {return this.firstname1}, fullname: function() {return this.fullname1}, age: function() {return this.age1} } // teachers uneditable code --> console.log("Name: " + pete.fullname() + "\tAge: " + pete.age); console.log("Name: " + cara.fullname() + "\tAge: " + cara.age); console.log(cara.firstname + "is " + (cara.age - pete.age) + " years older than " + pete.firstname);

Salida de la consola:

 "Name: Pete Programmer Age: 20" "Name: Cara Code Age: function() {return this.age1}" "function() {return this.firstname1}is NaN years older than function() {return this.firstname1}"

No he podido encontrar la respuesta a pesar de que parece un problema simple.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!