0

What's wrong in this code correct me please

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 //Mycode function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); var flight1 new flight(flightNumber,flightStatus se); //assign a flight object to flight1 variable //output console.log('The flight ' + flight1.number + ' is ' + flight1.status) } function Flight(flightNumber, status) { //fix the constructor flight1.number = flightNumber; flight1.Status = status; };

17th Feb 2021, 7:08 PM
NIKHIL SONAWANE
NIKHIL SONAWANE - avatar
15 odpowiedzi
+ 11
Try this new. Its work for me. function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); function Flight(flightNumber, flightStatus) { //fix the constructor this.flightNumber = flightNumber; this.flightStatus = flightStatus; }; var flight1 = new Flight(flightNumber ,flightStatus); //assign a flight object to flight1 variable //output console.log('The flight ' + flight1.flightNumber + ' is ' + flight1.flightStatus) }
27th Jun 2021, 1:23 PM
Sowmiyashree S
Sowmiyashree S - avatar
+ 4
var flight1 = new Flight(flightNumber,flightStatus); you've forgot the equal sign, don't use capitalized class name and have ' se' at end of arguments ^^
17th Feb 2021, 7:53 PM
visph
visph - avatar
+ 3
function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); function Flight(flightNumber, flightStatus) { //fix the constructor this.flightNumber = flightNumber; this.flightStatus = flightStatus; }; var flight1 = new Flight(flightNumber ,flightStatus); //assign a flight object to flight1 variable //output console.log('The flight ' + flight1.flightNumber + ' is ' + flight1.flightStatus) } Good Luck
25th Jan 2022, 8:30 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
+ 2
you should also lowercase 'Status' attribute in consttuctor and replace 'flight1' by 'this'
17th Feb 2021, 7:55 PM
visph
visph - avatar
+ 1
#Code is : function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); function Flight(flightNumber, flightStatus) { //fix the constructor this.flightNumber = flightNumber; this.flightStatus = flightStatus; }; var flight1 = new Flight(flightNumber ,flightStatus); //assign a flight object to flight1 variable //output console.log('The flight ' + flight1.flightNumber + ' is ' + flight1.flightStatus) }
13th Mar 2023, 9:35 AM
Md Hasan Sikder
Md Hasan Sikder - avatar
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.flightNumber + ' is ' + flight1.flightStatus) } function Flight(flightNumber,flightStatus) { //fix the constructor this.flightNumber = flightNumber; this.flightStatus = flightStatus; } This one works. Flight1 is the object and flightNumber/flightStatus are the properties and check if you write them the same way everywhere
20th Jun 2021, 3:42 PM
Razvan Roşu
Razvan Roşu - avatar
0
Hello all, I am new to this and lost. Am I suppose to plug the numbers in and run? Is there more information on this topic. After I finished one lesson it dropped me into this with not a lot of information on Input output. Thanks Thanks
23rd Nov 2021, 1:13 PM
DiAngelo Conley
DiAngelo Conley - avatar
0
function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); //assign a flight object to flight1 variable var flight1= new Flight(flightNumber, flightStatus) //output console.log('The flight '+ flightNumber +' is ' + flightStatus) } function Flight(flightNumber, flightStatus) { //fix the constructor this.flightNumber = flightNumber; this.flightStatus = flightStatus; };
30th Jul 2022, 12:36 PM
Santhosh R
Santhosh R - avatar
0
Can't we only assign values to new object as seen in example below function person(name, age, color) { this.name = name; this.age = age; this.favColor = color; } var p1 = new person("John", 42, "green"); var p2 = new person("Amy", 21, "red"); document.write(p1.age); document.write(p2.name); But they have assigned the predefined variable in the solution below function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); function Flight(flightNumber, flightStatus) { //fix the constructor this.flightNumber = flightNumber; this.flightStatus = flightStatus; }; var flight1 = new Flight(flightNumber ,flightStatus); //assign a flight object to flight1 variable //output console.log('The flight ' + flight1.flightNumber + ' is ' + flight1.flightStatus) } I have a confusion with this part var flight1 = new Flight(flightNumber ,flightStatus); //assign a flight object to flight1 variable Please help me to understand it.
3rd Aug 2022, 1:02 AM
Fahad Nawaz
Fahad Nawaz - avatar
0
function main() { var flightNumber = readLine(); var flightStatus = readLine(); function Flight(number, status) { this.number = flightNumber; this.status = flightStatus; }; var flight1 = new Flight(); console.log('The flight ' + flight1.number + ' is ' + flight1.status) }
9th Dec 2022, 2:01 PM
mohammad gholami
mohammad gholami - avatar
0
function main() { function Flight(number, status) { this.number = readLine(); this.status = readLine(); }; var flight1 = new Flight(); console.log('The flight ' + flight1.number + ' is ' + flight1.status) }
9th Dec 2022, 2:19 PM
mohammad gholami
mohammad gholami - avatar
0
there is 2 answers for me but the solution may be more than 2 referring to the coder, but this is my 2 answers: number 1:- function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); var flight1; //assign a flight object to flight1 variable flight1 ={ number :flightNumber, status :flightStatus, } //output console.log('The flight ' + flight1.number + ' is ' + flight1.status) } function Flight(flightNumber, status) { //fix the constructor number = flightNumber; status = status; }; ------------------------------------------------------------------------------------------------- or this code: number 2:- function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); var flight1; //assign a flight object to flight1 variable flight1 ={ number :flightNumber, status :flightStatus, } //output console.log('The flight ' + flight1.number + ' is ' + flight1.status) }
8th Jan 2023, 11:01 AM
Shevar Sansiro
Shevar Sansiro - avatar
0
function main() { //take flight number and its status var flightNumber = readLine(); var flightStatus = readLine(); var flight1; //assign a flight object to flight1 variable var flight1 = new Flight(flightNumber,flightStatus); //output console.log('The flight ' + flight1.number + ' is ' + flight1.status) } function Flight(flightNumber, status) { //fix the constructor this.number = flightNumber; this.status = status; };
18th Mar 2023, 3:46 AM
Imashi Dharmawardana
Imashi Dharmawardana - avatar
0
here is mine 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; };
8th Sep 2023, 4:17 PM
LEMUEL BALLARES
LEMUEL BALLARES - avatar
- 1
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) { this.number = flightNumber; this.status = status; };
23rd May 2022, 9:26 PM
Erhan TEZER