+ 2

Creating Your Own Objects - Landed

Creating Your Own Objects - landed, function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); var flight1 = new Flight(flightNumber, flightStatus); //assign a flight object to flight1 variable //output console.log('The flight ' + flight1.number + ' is ' + flight1.status) } function Flight(flightNumber, status) { //fix the constructor this.number = flightNumber; this.status = status; }; ============================== in here, before the //fix the constructor, it suggest to convert function Flight (flightNumber, status) {} to class Flight { constructor(flightNumber,status){} } why did this suggest?

2nd Sep 2021, 1:17 AM
Udaya Bandara
1 Odpowiedź
+ 1
Udaya Bandara Probably because in ES6, a relatively "newer" version of JS, they make often use of Classes. Message me if you have more detailed questions. Best of luck!
2nd Sep 2021, 4:08 AM
Tia
Tia - avatar