title: Trying to make dictionary in JavaScript using array and objects
body: <p>Today I was trying to make Trying to make dictionary in JavaScript using array and objects</p>
  
  <p>I am trying to make search here using prompt</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;body style="font-size: 40px"&gt;
    &lt;input type="text" id="myin"&gt;
    &lt;button id="btn"&gt;Search&lt;/button&gt;
    &lt;div id="outputArea"&gt;&lt;/div&gt;
  
    &lt;script&gt;
      var outputAreaRef = document.getElementById("outputArea");
      var output = "";
      var word = prompt("Enter something: ");
  
      var acronyms = [{
          acronym: "omg",
          meaning: "Oh MY God"
        },
        {
          acronym: "lol",
          meaning: "Laugh Out Loud"
        },
        {
          acronym: "lmao",
          meaning: "Laughing My Age Off"
        },
        {
          acronym: "wtf",
          meaning: "What This Function"
        }
      ];
      for (var i = 0; i &lt; acronyms.length; i++) {
        if (acronyms[i].acronym === word) {
          word = acronyms[i].meaning;
  
          outputAreaRef.innerHTML = word;
        }
      }
    &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But when trying to use an input element with onclick button function rather than the prompt it does not work at all </p>
  
  <p>here is the code with input and button</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;body style="font-size: 40px"&gt;
    &lt;input type="text" id="myin"&gt;
    &lt;button id="btn"&gt;Search&lt;/button&gt;
    &lt;div id="outputArea"&gt;&lt;/div&gt;
  
    &lt;script&gt;
      var outputAreaRef = document.getElementById("outputArea");
      var output = "";
      var word = document.getElementById("myin");
  
      var acronyms = [{
          acronym: "omg",
          meaning: "Oh MY God"
        },
        {
          acronym: "lol",
          meaning: "Laugh Out Loud"
        },
        {
          acronym: "lmao",
          meaning: "Laughing My Age Off"
        },
        {
          acronym: "wtf",
          meaning: "What This Function"
        }
      ];
      for (var i = 0; i &lt; acronyms.length; i++) {
        if (acronyms[i].acronym === word) {
          word = acronyms[i].meaning;
  
          document.getElementById('btn').onclick = function() {
            outputAreaRef.innerHTML = word;
          }
        }
  
  
      }
    &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please help where is the wrong </p>
  
  <p>Sorry for my bad ENGLISH,</p>