title: Having trouble with specific function in javascript
body: <p>I have a question concerning javascript. I have created a function which prompts the user to enter a string, and once the string is entered will perform a for loop to go through the entire length of the string, looking for the character "B" and then return the number of "B"s found in the result variable. As far as my knowledge, I feel that the code I have should work, however not matter how many "B" are present within my code, the function consistently returns 2. Any ideas on why this would be happening   </p>
  
  <pre><code>function countBs(string) {
      var result = 1;
      var string = prompt("Please Enter a String");
      for (count = 0; count &lt; string.length; string++) {
          if (string.charAt(count) == "B") {
              result += 1;
              return result;
          }
      }
  };
  </code></pre>