I need to loop through object
and change exactly one of its non-true
properties to true
.
var object = {a: true, b: false, c: false, d: false}
function changeOne(object) {
for(var i in object) {
if(object[i] !== true) {
object[i] = true;
break;
}
}
}
This seems like a really bad way to go about this. Is there a better way?