So, I have this:
setup.getPreset = function () {
var svpreset = State.variables.preset;
var result;
Object.keys(svpreset).forEach(function (gender) {
if (svpreset[gender] === true) {
result = gender;
}
});
return result;
};
And this works. It does exactly what I want. But it sure wasn't my first attempt at getting this result. Is there some nice function that will break out of an iteration and return a value other than a truth value?
I've tried .some and .every, but they won't return the value. Just the success. So, if I do this:
setup.getPreset = function () {
var svpreset = State.variables.preset;
return Object.keys(svpreset).every(function (gender) {
if (svpreset[gender] === true) {
return = gender;
}
});
};
All it does is return true or false, if it can find it or not.
So... nifty function that plays nice? Or is the method I do have a good enough solution? It's clunky. Super super clunky, but it works. So, that's good?