Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVASCRIPT TASK; TASK 1 Write a function called 'Hotel' which defines a hotel object. It should have properties of name, number of rooms in

IN JAVASCRIPT TASK;

TASK 1

Write a function called 'Hotel' which defines a hotel object. It should have properties of name, number of rooms in total and the number of rooms currently occupied.

Add a method (implemented as a function) to the object which determines the number of rooms the hotel currently has available.

* NOTE:- There is NO TEST for this task specifically, however the next task will use this function to build a set of objects, and there is a test for that.

Properties available in each hotel are:- name - string, totalRooms - number, bookedRooms - number

name Name of the hotel.

totalRooms Number of rooms in the hotel.

bookedRooms Number of rooms in the hotel which are currently occupied.

return newly created hotel object

function Hotel(name, totalRooms, bookedRooms){

//declare the hotel object using LITERAL notation

//return hotel;

}

TASK 2;

Write a function called createHotels(). It should declare three hotel objects, each one with different numbers of rooms and different numbers of rooms booked.

The largest hotel is called "The Grand Hotel", and it should have 421 rooms of which 398 are currently booked.

The middle sized hotel is called "The Seaview Hotel", and it should have 222 rooms of which 189 are currently booked.

The smallest sized hotel is called "The Quayside Hotel", and it should have 84 rooms of which 36 are currently booked.

Use console.table to view and check the the object contents

Return an array containing all three hotels.

function createHotels() {

//declare the hotel objects by calling the 'Hotel' function

//Use console.table to view and check the the object contents

//return an array containing the three hotels in the chain

//return chainOfHotels;

}

* TASK 3 : Write a function called totalAvailability(). It should take in an array of hotel objects as a parameter.

Loop through the array. Use the method (implemented as a function) inside the hotel object, which determines the hotel room availablilty, to calculate the total numbers of rooms available across all of the hotels in the chain.

Properties available in each hotel are: name - string, totalRooms - number, bookedRooms - number

return The total numbers of rooms available across the chain.

function totalAvailability(chainOfHotels){

//return chainTotalAvailability;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

How do you try to manipulate your unique smell?

Answered: 1 week ago