Matching strings to arrays
<p>I have a problem with this code:</p>

<pre><code>var buyerChoice = prompt("Enter a either apple, orange, or banana:", "");        

var fruits = new Array ("apple", "orange", "banana");

for(i=0; i &lt; fruits.length; i++) {
    if(buyerChoice === fruits[i]) {
        document.write(buyerChoice);
    } else if (buyerChoice !== fruits[i]){
        document.write("Sorry, " +buyerChoice+ " is out of season.");
        break;
    }
}
</code></pre>

<p>I believe the problems lies in the <code>else-if</code> statement because every time I type in an item that exists in my variable, it will return <code>//appleSorry, apple is out of season</code>, thus meeting both conditions.</p>

<p>I'm stumped. I guess the bottom line is how to effectively match a string from a prompt to an array, testing each item and how to parse an array if a prompted string doesn't exist.</p>
