Skip to content
Advertisement

How to detect if the script is trying to add the two same IDs?

I’m trying to make a logger for IDs and names, but I can’t seem to detect if the script is trying to add the two same IDs.

I’ve tried id.includes(user._id), but it always passed the if test. Here’s the code:

JavaScript

Advertisement

Answer

You can search your id array with find this will give you the current object which you can match your user._id against.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement