I am faced with the task of examining each property of an object to determine if it is truthy, and then removing any that are not.
var user = {
name: 'my name',
email: null,
pwHash: 'U+Ldlngx2BYQk',
birthday: undefined,
username: 'myname33',
age: 0
}
This is the code I attempted to use
function truth(x) {
if (x) {
console.log("truthy");
} else {
delete;
}
}
for (x in user) {
truth(user[x]);
}
However, the code is not functioning as expected and I'm uncertain if I am accurately checking for truthiness. Can you please assist in identifying my mistake?