Javascript Remove Element From Array If Condition In Sql