;TDLR Values passed to through Angular's @Input become available after the component is initialised, hence, the value of totalCarsNumber is available in ngOnInit. Hence, you have to use ngOnInit to implement it.
An optional input needs to be annotated with question suffix. The number type should be lowercased. Moreover, we set null as a default value for the optional input so that we can check it later if it has been set.
@Input() totalCarsNumber: number;
@Input() availableCarsNumber?: number = null;
Then we can use ngOnInitto check if the value for this.availableCarsNumber has been provided on a component otherwise it will be null and then we set the value to totalCarsNumber.
ngOnInit() {
this.availableCarsNumber = this.availableCarsNumber === null ? this.totalCarsNumber : this.availableCarsNumber;
}
ngOnInitor write the logic for it somewhere but I wanted to know if it's possible using only inputsOnChangeslife cycle hook, not theOnInitone