class Students {
name;
address;
schoolName = "Morning Sun School";
constructor(name,address,fatherName){
this.name = name;
this.address = address;
this.fatherName = fatherName;
}
raceCompetition(){
console.log(this.name, "start to run")
}
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");
console.log(olivia);
olivia.raceCompetition()
console.log(emma);
emma.raceCompetition()
// output of olivia
Students {
name: 'Olivia',
address: 'USA',
schoolName: 'Morning Sun School',
fatherName: 'James'
}
Olivia start to run
// output of Emma
Students {
name: 'Emma',
address: 'UK',
schoolName: 'Morning Sun School',
fatherName: 'alex'
}
Emma start to run