My objective is to determine if a field called name is empty.
My code is returning this error:
"object is not a function'.
This is resolved because I initially used (name) not [name] in the ifstatement
function notEmptyOrNull() {
var name1 = "Sherlock";
var name2 = "Watson";
var name3 = "";
var namesArray= ["Ben", "Lucy", "Watson", "Sherlock"];
if (namesArray[name1] !== null) { // resolved error
console.log(name1);
return true;
}
return false;
}
notEmptyOrNull();
Updated the code:
if (namesArray(name) to if (namesArray[name] which resolved the error.
But when I tested for name3 which I have changed to an 'empty string' = ""
How do I do this ?
In Chrome Dev Tools I would like to see output as true or false for each.
I would also like to output the data of each field.
Again, this is rather simple but I am still sorting this out.
I know that I'm missing sections of the code to accomplish this.
namesArray()(except in old IE), you donamesArray[name1]!if ( namesArray.indexOf(name1) === -1 )anyway