I am trying to use an if statement and the or || operator to test if the value of the select box option for type of room is either single King, single Double Queen, or single two twins and then execute some code. I keep getting the message "uncaught syntax error unidentified token ||" right where the || operator is in the if statement.
var hotel = {
name:"Benson hotel",
rooms:500,
jsuites:10,
ssuites:10,
booked:100,
checkAvailability: function(){
return this.rooms - this.booked;
}
};
hotel.name = "Bonton";
var elName = document.getElementById("hotelN");
elName.textContent = hotel.name;
function checkin(){
var nRooms = document.getElementById("numRooms").value * 1;
var tRoom = document.getElementById("typeRoom");
if (tRoom.value = "singleK")||(tRoom.value ="singleQ")||(tRoom.value = "singleT") { //*I am getting the following message about above line of code in the console. "uncaught syntax error unidentified token ||" Obviously the above if statement with || operator is not correct//
hotel.booked = numRooms + hotel.booked;
if hotel.checkAvailability() < 0 {
var rAvail = nRooms + (hotel.checkAvailability());
if rAvail <= 0 {
var noSay = document.getElementById("say");
noSay.textContent = "We have no rooms available";
}
else {
var yesSay = document.getElementById("say");
yesSay.textContent = "We have" + rAvail + "rooms available";
}
}
<body>
<div id="wrapper">
<div id="heading">
<h1 id="hotelN"></h1>
/div>
<div id="main">
<form id="myForm">
<fieldset>
<legend>Book a Room</legend><p>
<label for="rm1">Number of Rooms:</label>
<input type="number" max="10" min="1" value="1"name="rm" id="numRooms">
Type of room: <select type="text" maxlength="14" id="typeRoom">
<option value="singleK">Single King Bed</option>
<option value="singleQ">Single Queen Bed</option>
<option value="singleT">Single Two Twins</option>
<option value="jsuite">Junior One Bedroom Suite</option>
<option value="srsuite">Senior Two Bedroom Suite</option>
</select></p>
Occupancy:<select type="text">
<option>One adult</option>
<option>Two adults</option>
<option>One adult and Child</option>
</select>
Check In Date: <input type="date"name="checkin" id="cInDate">
Check Out Date: <input type="date" name="checkout" id="cOutDate">
<button type="button" onclick="checkin()">Submit</button>
</fieldset>
</form>
<H1 class="al">Hotel Room Availability</H1>
<p class="al" ><span id="say"></span> and check out on July <span id="dateOut"></span></p>
<p id="first">jjjj</p>
<p id="second"></p>
</div>
</div>