I have three objects, a,b and c
function N(z, y){
   this.z = z;
   this.y = y;
}
var a = new N(true,0);
var b = new N(false, 1);
var c = new N(false, 2);
I want to create a function that can determine which object has a true value for its z and return its y value.
This is what I have:
N.prototype.check = function(){
   if(this.z == true){
      return this.y;
   }    
}
function check(){
   var x;
   x = a.check();
   if(x !=undefined){
      return x;
   }
   x = b.check();
   if(x !=undefined){
      return x;
   }
   x = c.check();  
   if(x !=undefined){
      return x;
   }  
}
var x = check();
It works. But I have this feeling that I'm taking a detour. Is there a better way to achieve this?
