repl.it
@MNouri/

Hotel

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//In the exercise, you can book doubleBedRooms and/or singleBedRooms and wil keep count of the booked and unbooked;
var hotel = {
  doubleBedRooms: 10,
  singleBedRooms: 10,
};


function bookHotel (numOfDoubleBedRoom, numOfSingleBedRoom){
  var booked = false;

  if (numOfDoubleBedRoom <= hotel.doubleBedRooms && numOfSingleBedRoom <= hotel.singleBedRooms){
    booked = true;
    hotel.doubleBedRooms -= numOfDoubleBedRoom;
    hotel.singleBedRooms -= numOfSingleBedRoom;
  }
  else {
    booked = false;
  }

  if (booked == true){
    console.log("Booked!: " + numOfDoubleBedRoom + " Double Bed Room(s), " + numOfSingleBedRoom + " Single Bed Room(s)")
  }
  else{
    console.log("Not Booked!: " + "We have " + hotel.doubleBedRooms + " Double Bed Rooms and " + hotel.singleBedRooms + " Single Bed Rooms");
  }
}


bookHotel(1,0)