I am working on some code that takes an array of numbers and will remove any blanks and numbers with commas in them from the array.
for(var x = 0; z<employeeIDs.length; x++){
if(employeeIDs[x] == ""){
employeeIDs.splice(x, 1)
x--
continue
}
if(employeeIDs.includes(",")){
employeeIDs.splice(x, 1)
x--
}
}
it seems to be working for the blanks but not the commas... Anyone see why that may be the case?
UPDATE:
I created another identical for loop and moved the 2nd if statement to that loop and things work as intended. I still don't know why it wouldn't work under the same loop?
employeeIDs[x].includes(","), notemployeeIDs.includes(","). And in for loop you havezinstead ofx