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

220
Views
Error de referencia no capturado: useStudent no está definido

Sé que esta puede ser una pregunta tonta y es posible que no haga esta pregunta de la manera correcta, pero estoy atascado en esta parte. Sigo intentando ejecutar este programa y dice "Error de referencia no detectado: useStudent no está definido" cuando verifico la consola en "Estudiante" Verifico mi script, está perfectamente bien y mi código

 <script src="A2.js"></script> <body> <div class="column1"> <div class="input"> <button onclick="useStudent()"> Student</button> <button onclick="useCar()"> Car</button> </body> </html> here is my script added to this code function useStudent(){ var stu = "Jon Lee"; var ye = 3; console.log("year: " + ye); var maj = "Math" console.log("major: " + maj) var message = stu.displayMe(); console.log(message); console.log('-------------'); // set year to be 4 ye = 4; // set major to be "test" maj = "test"; // output year and major console.log("year: " + ye); console.log("major: " + maj); message = stu.displayMe(); console.log(message); } here is displayme displayMe() { this.id + this.name + this.Year + this.Major }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El tipo "stu" que definió es una cadena y parece que necesita un objeto de estudiante. por lo tanto, necesita una función de conistractore para crear el objeto estudiante y establecer el método displayMe() como su propiedad.

 function Stu (id,name, year,maj){ this.id = id; this.name = name; this.year = year; this.major = maj; this.displayMe = function(){ return this.id + this.name + this.year + this.major} } function useStudent(){ let stu = new Stu(1,"Jon Lee",3,'Math') console.log("year: " + stu.year); console.log("major: " + stu.maj); console.log(stu.displayMe() ); console.log('-------------'); stu.maj = 'EECS'; stu.year = 4; console.log("year: " + stu.year); console.log("major: " + stu.maj); console.log(stu.displayMe() ); console.log('-------------'); }
about 4 years ago · Juan Pablo Isaza Report
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!