Question: I want to break out of `.each()` iterations and it doesn't allow me to. Here is my code. Thanks for the help guys! Appreciate it.

```
$('#btn-submit-add').click(function(){
    var answerField = 1;
    $('.addAnswerChoice').each(function(){
        var answerChoice = $(this).val();
        if (answerChoice == ""){
            $('#answerChoice-'+answerField+'-Error').show();
            $(this).focus();
            return false; // this doesn't work
        }
        answerField++;
    });
    alert('doing stuff after');
});

```

Answer: 
My guess is that you're trying to return `false` from the click handler to cancel the submit. The way you have it your `return false` statement returns from the function you passed to `.each()`, which does break out of the `.each()` loop but it doesn't return from the outer function that is the click handler. So execution then continues with the statement after the `.each()`, i.e., the final alert. And your click is not cancelled. Try this instead:

```
$('#btn-submit-add').click(function(e){
    var answerField = 1;
    $('.addAnswerChoice').each(function(){
        var answerChoice = $(this).val();
        if (answerChoice == ""){
            $('#answerChoice-'+answerField+'-Error').show();
            $(this).focus();
            e.preventDefault();
            return false;
        }
        answerField++;
    });
});

```

jQuery passes the [event object](http://api.jquery.com/category/events/event-object/) to your click handler (notice I've added a parameter called `e`), so you can use [`event.preventDefault()`](http://api.jquery.com/event.preventdefault/) to stop the click from working.
This solution is almost like `each` only but short-circuits when the first `true` value is returned. So, you don't have to explicitly break out of the iterations.

```
Array.prototype.slice.call(document.getElementsByClassName("addAnswerChoice")).some(function(item) {
 var answerChoice = item.value;
 if (answerChoice == ""){     
        $('#answerChoice-'+answerField+'-Error').show();
        item.focus();
        return true;
 }
 return false;
});

```