0

Please help me to correct this

//getting output "The flight undefined is undefined" 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... number = flightNumber; status = status; };

22nd Aug 2022, 1:27 PM
bijay swarnakar
bijay swarnakar - avatar
2 Answers
+ 1
you need to use 'this' to refer object property.. Use this.number = flightNumber; this.status = status; Share code link if not work, instead copy paste.
22nd Aug 2022, 1:35 PM
Jayakrishna šŸ‡®šŸ‡³
+ 1
The this keyword refers to the current object. Note that this is not a variable. It is a keyword, and its value cannot be changed. this.number = flightNumber; this.status = status;
22nd Aug 2022, 1:35 PM
SoloProg
SoloProg - avatar