-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
  • 6,405
  • 6
  • 28
  • 69
JonDoeBeep
  • 41
  • 6

1 Answers1

1

Just use Array.prototype.includes:

usernames.includes(username)
Aplet123
  • 33,825
  • 1
  • 29
  • 55