title: javascript searching for an integer in array
body: <p>This is my code searching for an integer in a user-generated array. I can't figure out how to get the code to actually search the array for the code instead of simply stating the integer searched. Any help would be appreciated!   </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-js lang-js prettyprint-override"><code>var count = "";
  var arr;
  
  function myFunction() {
    var count = prompt("Input array size:");
    document.getElementById("demo_a").innerHTML = "Total Count= " + count;
    arr = [count];
    for (i = 0; i &lt; count; i++) {
      arr[i] = prompt("Enter an integer:");
    }
    document.getElementById("demo_b").innerHTML = arr.toString();
    bubbleSort(arr);
    document.getElementById("demo_b").innerHTML = arr.toString();
  }
  
  function myPrompt() {
    var search = prompt("Please enter an integer to search for:");
    document.getElementById("demo_c").innerHTML = "Search For: " + search;
    binarySearch(arr, search);
  }
  
  function bubbleSort(arr) {
    var i, j, temp = 0;
    for (i = 0; i &lt; arr.length - 1; i++) {
      for (j = 0; j &lt; arr.length - 1; j++) {
        if (arr[j] &gt; arr[j + 1]) {
          temp = arr[j];
          arr[j] = arr[j + 1];
          arr[j + 1] = temp;
        }
      }
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button type="button" onclick="myFunction()"&gt;Input data&lt;/button&gt;
  &lt;button type="button" onclick="myPrompt()"&gt;Find Integer&lt;/button&gt;
  &lt;p id="demo_a"&gt;&lt;/p&gt;
  &lt;p id="demo_b"&gt;&lt;/p&gt;
  &lt;p id="demo_c"&gt;&lt;/p&gt;
  &lt;p id="demo_d"&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>