I am trying to construct an array looping over another array which more or less looks like this
var x = [1, null, 324, 110, null]
I am trying to loop over this and check if an item at index i is not null then it goes into a new array
var numberCollection = [];
for(var i = 0; i < x.length; i++){
numberCollection[i] = (!!x[i]) ? x[i];
}
console.log(numberCollection)
which definitely does not work. What am I missing? I saw some examples of deleting an invalid item from an array but that is out of scope in this context