My original task was to create a function that returned a boolean value if my data object contained a truthy value.
I do not care what value or key is truthy, only that the data contains a truthy value.
var fruits = { apples: false, oranges: true, bananas: true }
When iterating over this object the return should be true
because there are true
values within.
The following function did work:
return Object.values(fruits).some(function(k) {
return k;
});
However I cannot use Object.value
nor the array.some
due to IE compatibility
The suggested Polyfill is to use .map
instead to get each value, however but the next step is removing .some()
- I have tried using .filter()
but this takes me back to the original problem that it returns the key
that is truthy not merely an assertion that a truthy value exists in the databaset