-1

I have a list called usernames, that stores usernames. I want to see if the specific username is on the list and deny the person if it is. Code:

var usernames = ["someuser",""];

io.on('connection', function(socket){

  socket.on("join", function(room, username == usernames){
    if (username != "" || username == usernames){
   // do something
    }
  })
Nimantha
  • 5,793
  • 5
  • 23
  • 56
JonDoeBeep
  • 41
  • 6

1 Answers1

1

Just use Array.prototype.includes:

usernames.includes(username)
Aplet123
  • 30,962
  • 1
  • 21
  • 47