I have an object which gets passed to a function as such:
function(config['options'])
There are certain values in here such as config['options']['property1']
which are set as 1, which I want to change to true
(like wise 0 to false
) before they get passed to this function.
How do I go about doing this, I can't seem to figure it using .each()
options
is an object, so use a for-in loop to iterate the properties:
for (var key in config.options) {
var current = config.options[key];
if (current === 1) {
config.options[key] = true;
}
if (current === 0) {
config.options[key] = false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With