Count Space(s) in a string
<p>I have a string <code>&quot;John Doe's iPhone6&quot;</code></p>
<p>Visually, I know that it contains 2 spaces.</p>
<p>How do I count spaces in a string in javascript ?</p>
<h1>I've tried</h1>
<pre><code>var input = this.value;
// console.log(input.count(' '));
</code></pre>