How to compare a word to any elements in an array
===

I am trying to find a word (that a player will make out of random letters) from a text file(dictionary) 

    var words = [];

    $(document).ready(function()
                  {
                  $.get("dictionary.txt", function(txt)
                        {                           
                            words = txt.split("\n"); //get array of all words                      
                        });
                  });


    $(function()
    {
    $("#playButton").on("click",function()
                      {
                         for(var k = 0; k < words.length; k++)
                         {
                           if(completedWord == words[k])
                           {
                              alert("hi");
                           }
                      
                         }
                      
                         if($.inArray(completedWord,words) > -1)
                         {
                            alert(completedWord + " is in array");
                         }
                      
                      });
  
    });


The part where I am having trouble is that the alerts are only displayed when I enter in the last word in the array/text file.

The text file contains "one", "two" and "three" (for example purposes), when I enter "three" the alerts are displayed but not for "one" and "two".

Is there any way that I can enter any one of the options and display the alerts.

Thank you.