title: how to count number of japanese and latin characters in a string?
body: <p>I need to write a function that properly follows Japanese counting of characters and therefore returns length of characters in a string given these conditions:</p>
  <ul>
  <li>1 for Full-width char (Japanese kanji, katakana, and hiragana)</li>
  <li>0.5 for Half-width char (0-9, A-Z).</li>
  </ul>
  <p>here is my unit test I wrote:</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>  describe('#getCaptionLength', () =&gt; {
      it('should return correct caption length for japanase', () =&gt; {
        const text = 'を取り外すコネクタと考えてください';
        const result = getCaptionLength(text);
        expect(result).toBe(17)
      });
  
      it('should return correct caption length for japanase mixed with latin', () =&gt; {
        const text = 'を取り外すコネクタと考えてください hello world';
        const result = getCaptionLength(text);
        expect(result).toBe(17 + 6);
      });
    });</code></pre>
  </div>
  </div>
  </p>
  <p>Can you please help me write this function that would pass my unit test?
  Thanks!</p>