Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Issue with getting a single item in list

Hi I’m having an issue getting a single item in a list. The list compromises of menu ids and I would like to get the specific id as opposed to the whole list.

Here is what I’m working with:

// list of menus ids
const select_menu_ids = ["menu1", "menu2" ];

// filter through the list seems to return the whole list instead of item in list
const ids = select_menu_ids.filter((menu_id) => menu_id); 

// the statement that checks the id in the list
if (customId === `${ids}`) {...

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If what to want is to check is a customId is inside the select_menu_ids, your if check should be something like this :

// list of menus ids
const select_menu_ids = [ "menu1", "menu2" ];

if (select_menu_ids.includes(customId)) { ... }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading