Hola estoy haciendo tu curso de JavaScript y me quedé atoraado en el ejercicio del capítulo 41 Definición de varias clases. Si no es mucha molestia me podrías decir qué está mal en este código? function Persona(){ this.nombre=prompt('Ingrese nombre'); this.edad=parseInt(prompt('Ingrese edad')); } function Empresa(eda){ this.eda=eda; this.ingresar=function(){ if (this.eda>=60){ document.write(' no puede ingresar a esta empresa' + ''); } else { document.write(' si puede ingresar a esta empresa' + ''); } } } let persona1; persona1= new Persona(); let empresa1; empresa1 = new Empresa(); empresa1.ingresar(persona1.edad); No me reconoce el atributo persona1.edad. Desde ya muchas gracias
function Persona(){ this.nombre=prompt('Ingrese nombre'); this.edad=parseInt(prompt('Ingrese edad')); } function Empresa(eda){ // recibe la edad el constructor this.eda=eda; this.ingresar=function(){ alert(this.eda) if (this.eda>=60){ document.write(' no puede ingresar a esta empresa' + ''); } else { document.write(' si puede ingresar a esta empresa' + ''); } } } let persona1; persona1= new Persona(); let empresa1; empresa1 = new Empresa(persona1.edad); // le pasamos en el constructor la edad empresa1.ingresar();