check all values match using prototype

Posted by snaken on Stack Overflow See other posts from Stack Overflow or by snaken
Published on 2010-06-07T21:47:15Z Indexed on 2010/06/07 21:52 UTC
Read the original article Hit count: 157

Filed under:
|
|

Using prototype, is there a simple method of checking that a group of values match, for example - can this code be refined to a single line or something otherwise more elegant?

var val = '';
var fail = false;

$('form').select('.class').each(function(e){
    if(!val){
        val = $F(e);
    }else{
        if(val != $F(e)) fail = true;
    }
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about prototype