title: How to detect two spaces in middle of the string?
body: <p>i have a code that is working fine for the double spaces("&nbsp;&nbsp;") at the end of the string, but won't work for spaces in middle of the any string.</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 userInput = prompt("In which city do you live?");
  lengthUserInput = userInput.length;
  correctName = true;
  
  for (i = 0; i &lt; lengthUserInput; i++) {
    if (userInput.slice(i, i + 2) === " ") {
      correctName = false;
    }
  }
  
  if (correctName === false) {
    alert("Double spaces are not allowed");
  } else {
    alert(userInput);
  }</code></pre>
  </div>
  </div>
  </p>