I have looked at previous Q/A and I did not find much help there. Mainly as I did not understand what was coded.
I am just looking to remove any empty values in my array.
My simple approach - that is not working!
My code is -
var colors = [a, b, c, d, e, f];
var newArray = [];
for (var i = 0; i < colors.length; i++) {
if (colors[i] !== 'undefined' || colors[i] !== null || colors[i] !== "") {
newArray.push(colors[i]);
}
}
console.log(newArray.length); // == 6
console.log(newArray) //== yellow,blue,red,,,
I would have thought that my if statement would filter all elements with value and push on to my new array.
I really need newArray length to equal 3 and just hold vales, no empty string "" should be in the newArray.
Thank you in advance.
nulland""at the same time.