JSFiddle - React, Tailwind, and code Playground

by Shabeer Sheffa

HTML

<select>
  <option value=""></option>
  <option value=""></option>
  <option value=""> False</option>
  <option value=""> True</option>
  <option value="">False False</option>
  <option value="">False True</option>
  <option value="">True</option>
  <option value="">True True</option>
</select>

JavaScript

var values = [];

$("select").children().each(function() {
  if (values.length > 0) {
    var notExists = false;
    for (var x = 0; x < values.length; x++) {
      var _text = this.text.replace(/\s/g, "");
      var value = values[x].replace(/\s/g, "");
      
      if (values[x].length > _text.length) {
        //console.log('>>+', value, ' || ', _text, value.indexOf(_text))
        notExists = value.indexOf(_text) > -1 ? true : false;
      } else {
        //console.log('>>*', value, ' || ', _text, _text.indexOf(value))
        notExists = _text.indexOf(value) > -1 ? true : false;
      }
    }
    if (notExists) {
      //this.remove();
      values.push(this.text);
    }
  } else {
    values.push(this.text);
  }
});


console.log(values)