LLD - Design — Parking Lot System
In the following code, what is the main issue that prevents the
ParkingLot from using different parking strategies correctly?
class ParkingLot {
constructor() {
this.strategy = null;
}
setStrategy(strategy) {
this.strategy = strategy;
}
park(vehicle) {
return this.strategy.findSpot(vehicle);
}
}
const lot = new ParkingLot();
lot.park('car');