JSFiddle - React, Tailwind, and code Playground

JavaScript

var excludedDepartmentsList = [1, 2, 3, 4, 5, 6];
var currentDepartmentId = 5;

var position = $.inArray(currentDepartmentId, excludedDepartmentsList);

if (position > -1) {
    alert(position);
    var q = excludedDepartmentsList.splice(position, 1);
    alert(q);
    alert(excludedDepartmentsList);
    return;
}