title: TypeError: string.split is not a function
body: <p>I'm solving an exercise problem. Solved it in Visual Studio (it worked), copied the solution to the browser (Codewars challenge) and it returned this error: </p>
  
  <pre><code>TypeError: string.split is not a function
     at bulk
      at _
      at begin
      at it
          at /runner/frameworks/javascript/cw-2.js:159:11
      at Promise._execute
      at Promise._resolveFromExecutor
      at new Promise
      at Object.describe
              at Object.handleError
          at ContextifyScript.Script.runInThisContext
      at Object.exports.runInThisContext
  </code></pre>
  
  <p>Here's my code: </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>function bulk(string) {
      var arr = string.split(", ");
      var whatYouAte = [];
      for (var i = 0; i &lt; arr.length; i++) {
          arr[i] = arr[i].replace(/g /g, ' ');
          whatYouAte.push(arr[i].split(" "));
      }
  
      var proteins = 0; 
      var calories = 0; 
  
      console.log(whatYouAte);
  
      for (var j = 0; j &lt; whatYouAte.length; j++) {
          var foodAmount = whatYouAte[j][0];
          var foodName = whatYouAte[j][1];
          var foodProteinKcal = food[foodName][0];
          var foodCarbKcal = food[foodName][1];
          var foodFatKcal = food[foodName][2];
          proteins += foodAmount / 100 * foodProteinKcal;
          calories += foodAmount / 100 * (foodProteinKcal + foodCarbKcal + foodFatKcal); 
  
      }
  
      return "Total proteins: " + proteins + " grams, Total calories: " + calories + ".";
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I think I once had a similar problem and solved it by making this.split(), but now this doesn't work (Codewars doesn't accept, returns "TypeError: this.split is not a function"). 
  Thanks!</p>