We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6919818 commit f84ed0aCopy full SHA for f84ed0a
javascript/1603-design-parking-system.js
@@ -18,18 +18,25 @@ class ParkingSystem {
18
* @return {boolean}
19
*/
20
addCar(carType) {
21
+ // If carType is 1 (big) and there are available big parking spaces
22
if (carType === 1 && this.bigRemaining > 0) {
23
this.bigRemaining -= 1;
24
return true;
25
}
26
+
27
+ // If carType is 2 (medium) and there are available medium parking spaces
28
if (carType === 2 && this.mediumRemaining > 0) {
29
this.mediumRemaining -= 1;
30
31
32
33
+ // If carType is 3 (small) and there are available small parking spaces
34
if (carType === 3 && this.smallRemaining > 0) {
35
this.smallRemaining -= 1;
36
37
38
39
+ // If no suitable parking space is available for the given carType
40
return false;
41
42
0 commit comments