HELP with Landed problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

HELP with Landed problem

The result says flightStatus 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(number, status) { //fix the constructor this.number= flightNumber; this.status= flightStatus; }

9th Apr 2021, 3:01 PM
Lee 4 Code
Lee 4 Code - avatar
5 Answers
+ 2
Inside the Flight constructor the variable names dont match with the arguments
11th Apr 2021, 8:44 AM
Giorgos
+ 1
The below code should work, 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; };
29th Jun 2022, 12:43 PM
Nikita S Mallya
0
Thank you, this has been resolved this.number = number this.status = status
11th Apr 2021, 11:55 AM
Lee 4 Code
Lee 4 Code - avatar
0
can you please explain why my code is not working properly? I've tried to rebuild the proposal from practice, so that is more like from the course. I wanted to define "object constructor", and build (via "var...") new object with certain properties... Bob was hired as an airport information officer and needs to generate status messages for each flight․ Let’s help him! Complete the given program by fixing the constructor, making a flight object, and assign it to given variable to correctly execute the corresponding message. Flight ID and the flight status(landed, on time, delayed, etc.) are taken as input. Sample Input NGT 929 landed Sample Output Flight NGT 929 has landed Use new keyword to create a new object using constructor. -------------- Code to use from course: function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); var flight1; //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; }; --------------------- My attempt: function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); } function Flight(flightNumber, flightStatus) { //fix the constructor this.number = flightNumber; this.status = flightStatus; } var flight1 = new Flight(flightNumber,flightStatus); console.log('The flight ' + flight1.number + ' is ' + flight1.status);
31st Aug 2021, 10:26 PM
Pawel
0
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(number, status) { //fix the constructor this.number= number; this.status= status; }
23rd Jul 2023, 9:14 AM
Amir Mohammednur Jemal
Amir Mohammednur Jemal - avatar