let myArray = ["user1","user2", "", ""] console.log(myArray) function cleanArray(_array) { for (i in _array){ if(_array[i] == ''){ _array.splice(i, 1) } } return _array } console.log(cleanArray(cleanArray(myArray)))