0
Where is the issue in the constructor
Where is the issue in that code and how we fix the. Constructor function Flight(flightNumber, status) { //fix the constructor this.number = flightNumber; this.status = status; };
8 Antworten
+ 2
Please show the completed code.
Look at the given code, it says:
//assign a flight object to flight1 variable
+ 2
Is this the complete code? could it be that you accidentally deleted
function main()
+ 1
Which error do you get?
+ 1
function Flight(flightNumber, status) {
if (typeof flightNumber !== "string") {
throw new TypeError("flightNumber must be a string");
}
if (!["delayed", "on time", "cancelled"].includes(status)) {
throw new TypeError("status must be one of 'delayed', 'on time', or 'cancelled'");
}
this.number = flightNumber;
this.status = status;
};
0
No l will show the code
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)
}
0
It already assigned
0
It fixed
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)
}
class Flight {
constructor(flightNumber,status){
this.number = flightNumber;
this.status = status;
}
};
0
Bro or sis it is very simple just give a look at the given code 😎😎