title: How to check existence and amount of certain characters within a string (e.g. 'x'/'X' and 'o'/'O')?
body: <p>I was on code wars (fundamentals) and there was a kata that asked me to make a program that allows you to see if amount of <code>'x'</code> and <code>'o'</code> are the same (for example <code>'xXXooO'</code> should return <code>true</code> and <code>'xXxxO'</code> should return <code>false</code>).</p>
  <p>Using my best knowledge about coding (which is a little) I built this code but it wouldn't work.</p>
  <pre><code>function XO(str) {
    let string = str;
    const o = string.match(/O/g) + string.match(/o/g);
    const x = string.match(/X/g) + string.match(/x/g);
    if (o.length != x.length) {
      return true;
    } else {
      return false;
    }
  }
  </code></pre>
  <p>Please tell me what is wrong with my code.</p>
  <p>This part is after I updated.</p>
  <p>I updated my code but it says that null is not an object. I updated the variables too, and I don't think that is the reason why.</p>
  <pre><code>function XO(str) {
    let string = str;
    const largeO = string.match(/O/g);
    const smallO = string.match(/o/g);
    const largeX = string.match(/X/g);
    const smallX = string.match(/x/g);
    const oCombined = largeO.length + smallO.length;
    const xCombined = largeX.length + smallX.length;
    if (oCombined = xCombined) {
      return true;
    } else {
      return false;
    }
  }
  console.log(XO(&quot;OxX&quot;));
  </code></pre>