Compare a word against words in an array
<p>Write a function <code>offOne(word, book)</code> which takes
a string called <code>word</code> and an array of strings called <code>book</code>.
It returns an array of all the <code>word</code>s in <code>book</code> of the same
length that are one letter different.</p>

<p>Examples:</p>

<pre><code>offOne("cat", ["cat", "fat", "flat", "tar"]) =&gt; ["fat", "tar"]
offOne("will", ["wilt", "willow", "wail"]) =&gt; ["wilt", "wail"]
</code></pre>

<p>My function is currently:</p>

<pre><code>function offOne(word, book) {
    var array = [];
    var count = 0;

    for (var i = 0; i &lt; book.length; i++) {
        if (book.length === word.length) {
            if (word.indexOf(book[i]) !== -1) {
                count += 1;

                if (count === (book[i].length - 1)) {
                    array.push(book[i]);
                }
            }
        }
    }
    return array;
}
</code></pre>

<p>Does anyone know how to solve this? I got stuck for a while here.</p>