If I have a JavaScript object:
var object = {
propertyOne: undefined,
propertyTwo: 'defined',
propertyThree: 'defined',
propertyFour: undefined
}
How can I create a method that will list the properties with undefined values (in the example's case, propertyOne and propertyFour).
I'm quite new to JavaScript, and this is what I had so far:
function getEmptyProperties(object) {
var emptyProps = [];
for (var property in object) {
if (object.property === undefined) {
emptyProps += property
}
}
return emptyProps
}
But this returns ALL of the properties, regardless if they are undefined or not.
I know I'm missing some things that are principal in JS, but can't figure it out. Kindly help please?