WEB222-Assignment 1
WEB222-Assignment 1
Assignment 1
Instructions:
● Your assessment will be tested using Visual Studio Code. It is your responsibility to ensure
the app runs properly in the same environment.
● In addition to implementing the required functionality, learners are required to use the
coding conventions demonstrated in class (let & const, arrow functions, etc), clear
organization of code, clarity of variable naming, etc. These factors are included as part of
the assessment’s grading criteria. Comments for code snippets are recommended but not
required.
● You are not permitted to use Javascript’s higher order array functions, such as map(),
filter(), forEach(), find(), closest(), etc.
Submission Checklist:
❏ Create a Javascript file containing your assessment solution. Your file must be named:
a1_studentname_studentid.js. Replace studentname and studentid with your name and id.
At the top of your js file, add the following declaration. FIll in the blanks with your student
name, id, and date.
/*********************************************************************************
* WEB222 – Assignment 1
* I declare that this assignment is my own work in accordance with college Academic Policy.
* No part of this assignment has been copied manually or electronically from any other source
* (including web sites) or distributed to other students.
*
* Name: ______________________ Student ID: ______________ Date: ________________
*
********************************************************************************/
Academic Integrity
● You are to adhere to the college’s Academic Integrity Policy.
https://www.senecacollege.ca/about/policies/academic-integrity-policy.html
● Learners are reminded that using full or partial solutions found on the Internet / other
people is not permitted
Page 1 of 4
2
Problem Description:
You were hired by a local travel agency to build an application that manages flight reservations.
Using Javascript, you are to create a console based application per the specifications below.
1. Create an array of flights. Each flight in the array must be represented as an object literal.
Every flight has a carrier, flight number, departure city, arrival city, flight distance, and total number
of available seats. You must include the following flights in your array.
Carrier Flight Number Departure City Arrival City Distance Available Seats
Note that the function must work for any array of flight objects, of any size.
Page 2 of 4
3
Specifically, if the function is able to find a matching flight, the function should attempt to
to reserve the number of available seats on the flight by the specified amount. If there is an
insufficient number of seats available, then the operation should fail and the function
should return false. If there is a sufficient number of seats, the function should reduce the
amount of available seats by the requested amount. The function should then return true.
If the function cannot find a flight matching the specified flightNumber, the function should
return false.
3. After creating these functions, write the code to perform the following operations.
Wherepossible, you must use the calculateFlightPrice, searchFlights, showAllFlights, and
reserveSeats functions.
2. Search for flights departing DFW. If yes, display the number of flights found. If no, output
“No flights found”.
3. Search for flights departing PHX. If flights found, display the number of flights found. If no,
output “No flights found”.
4. Retrieve flight #AC306 from the list of flights. Using the AC306 object:
iii. The percentage difference in prices, to 2 decimal points (HINT: Use the
toFixed() function)
7. Output a list of available flights. NOTE: If you have created / implemented everything
correctly, the list of available flights will contain:
Page 3 of 4
4
Sample output
When writing your code, please make it obvious what your program is doing. For example, if your
program will be searching for a flight, then your output should indicate that the program is
searching for something.
See below for an example of what a clear and obvious program output is. Your specific program
output may be slightly different depending on the specific requirements listed above.
Note, the coloured & highlighted text is for your reference only. Your output should not have coloured
text.
Available Flights:
No flights found.
Available Flights:
Page 4 of 4