I’m currently creating a seating plan. User’s should be able to select up to 3 available tables. After 3 tables are selected, the user should not be able to select anymore.
At the moment, the user is able to select 4 tables, which I do not want. Also, when 4 tables are selected, the user cannot unselect these tables any longer. Whereas, when the condition hasn’t been met, users can unselect tables.
Things I’ve tried:
- Playing around with the logical operators.
- Putting the if statement in a function and using return
Here is a JSFiddle with the problem: https://jsfiddle.net/manoj1234/euamdpb3/2/