Answers for "javascript remove junk element from array"

0

javascript remove junk element from array

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)))
Posted by: Guest on July-29-2021

Code answers related to "javascript remove junk element from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language