Skip to content

Commit

Permalink
Update 1603-design-parking-system.js
Browse files Browse the repository at this point in the history
Added comments above each if stetment.
  • Loading branch information
aadil42 authored Jul 2, 2023
1 parent 6919818 commit f84ed0a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions javascript/1603-design-parking-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@ class ParkingSystem {
* @return {boolean}
*/
addCar(carType) {
// If carType is 1 (big) and there are available big parking spaces
if (carType === 1 && this.bigRemaining > 0) {
this.bigRemaining -= 1;
return true;
}

// If carType is 2 (medium) and there are available medium parking spaces
if (carType === 2 && this.mediumRemaining > 0) {
this.mediumRemaining -= 1;
return true;
}

// If carType is 3 (small) and there are available small parking spaces
if (carType === 3 && this.smallRemaining > 0) {
this.smallRemaining -= 1;
return true;
}

// If no suitable parking space is available for the given carType
return false;
}
}
Expand Down

0 comments on commit f84ed0a

Please sign in to comment.