So I have an array that I created but I would like to execute an action if one or more variables are empty in my array.
jQuery(document).ready( function($) {
var fields = ["", "two", "three", "four", "five"];
if (fields.length === 0) {
alert('One or more variables are empty!');
}
else {
alert('All variables are here!');
}
});
I know this code above is wrong because it will always launch the latter.
So basically
var fields = ["", "two", "three", "four", "five"];
Should return One or more variables are empty!
And this:
var fields = ["one", "two", "three", "four", "five"];
Should return All variables are here!