Skip to content
Advertisement

can someone help me with the code for this function? [closed]

Hello so i have to do a function that when i call it has to show me the Student information and i have to call it getInfo so i tried something like this but i don’t know what code i have to put for the function: Can someone help me:

class Student {
    Name
    Adress
    Phone
    Course 
    Constructor(Name,Phone,Adress) {
       
    }
}
var Name= "Stefan"
var Adress= "Strada Campia Islaz numarul 50"
var Phone="+40766334455"
var Course="Curs Javascript"
function getinfo(Name, Adress, Phone,Course) {
    
}

Advertisement

Answer

class Student {
  constructor(name, adress, phone, course) {
    this.name = name;
    this.adress = adress;
    this.phone = phone;
    this.course = course;
  }

  getInfo() {
    console.log(this.name);
    console.log(this.adress);
    console.log(this.phone);
    console.log(this.course);
  }
}

var newStudent = new Student('Stefan', 'Strada Campia Islaz numarul 50', '+40766334455', 'Curs Javascript');
newStudent.getInfo();
Advertisement