Skip to content

Commit f84ed0a

Browse files
authored
Update 1603-design-parking-system.js
Added comments above each if stetment.
1 parent 6919818 commit f84ed0a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

javascript/1603-design-parking-system.js

+7
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@ class ParkingSystem {
1818
* @return {boolean}
1919
*/
2020
addCar(carType) {
21+
// If carType is 1 (big) and there are available big parking spaces
2122
if (carType === 1 && this.bigRemaining > 0) {
2223
this.bigRemaining -= 1;
2324
return true;
2425
}
26+
27+
// If carType is 2 (medium) and there are available medium parking spaces
2528
if (carType === 2 && this.mediumRemaining > 0) {
2629
this.mediumRemaining -= 1;
2730
return true;
2831
}
32+
33+
// If carType is 3 (small) and there are available small parking spaces
2934
if (carType === 3 && this.smallRemaining > 0) {
3035
this.smallRemaining -= 1;
3136
return true;
3237
}
38+
39+
// If no suitable parking space is available for the given carType
3340
return false;
3441
}
3542
}

0 commit comments

Comments
 (0)