Skip to content

Commit

Permalink
Update 1603-design-parking-system.js
Browse files Browse the repository at this point in the history
Updating if conditions.
  • Loading branch information
aadil42 committed Sep 7, 2023
1 parent e035151 commit 6c75be4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions javascript/1603-design-parking-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ class ParkingSystem {
* @return {boolean}
*/
addCar(carType) {
if(carType === 1 && this.isBigRemaining > 0) {
const isBigCarAvailable = (carType === 1 && this.isBigRemaining > 0);
if(isBigCarAvailable) {
this.isBigRemaining -= 1;
return true;
}
if(carType === 2 && this.isMediumRemaining > 0) {
const isMediumCarAvailable = (carType === 2 && this.isMediumRemaining > 0);
if(isMediumCarAvailable) {
this.isMediumRemaining -= 1;
return true;
}
if(carType === 3 && this.isSmallRemaining > 0) {
const isSmallCarAvailable = (carType === 3 && this.isSmallRemaining > 0);
if(isSmallCarAvailable) {
this.isSmallRemaining -= 1;
return true;
}
return false;
}
}
}


/**
* Your ParkingSystem object will be instantiated and called as such:
* var obj = new ParkingSystem(big, medium, small)
Expand Down

0 comments on commit 6c75be4

Please sign in to comment.