DEV Community

Julien Dephix
Julien Dephix

Posted on

JavaScript mini challenge: selectpicker and max options

Hello coders!

I had to work on a simple problem this week and thought it could be a good idea for a mini challenge.

Here's the gist of it:

users should be able to select as many cities as they like from a drop down as long as they're not located in more than 2 countries.

In the image below I've selected 5 cities and only 2 countries so it's all good.
Image description

I should not be able to select any city in Spain as it would result in 3 countries.

Image description

Give it a go!

Feel free to change anything that could make your life and code easier.

Our project uses bootstrap-select so you need to implement your solution with that plugin.

Here's a Codepen template for you to play with (I used the same to implement my solution):

Solution

I'll post a follow-up later to explain my solution and get feedback too.

Have fun! 💻

I'm looking forward to your entries. 🔥

Top comments (0)