DEV Community

Julien Dephix
Julien Dephix

Posted on

1 1

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. πŸ”₯

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay