N
N
nvdfxx2019-11-14 09:54:34
Vue.js
nvdfxx, 2019-11-14 09:54:34

How to dynamically change the maximum number of array elements?

sandbox
There is a functionality for choosing the type of room. The room type object contains a field for the maximum number of guests that can be in this room.
The problem is that if you select a room type with a large possible number of guests, add guests, and then change the type to a type with a smaller possible number of guests, then this number remains from the previous type, i.e. greater than the maximum possible for the current type

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Bobkov, 2019-11-14
@nvdfxx

Hang up a method to change the type of room.
When changing the type, check the current number of guests.
If more than the maximum number in the new one, change the array of guests as needed (delete unnecessary ones, reset them to zero, or something else).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question