title: .Trim Is Not A Function Error When Trying To Remove The Space From Returned Data
body: <p>I have a <code>DataTable</code> which is being populated by <code>JSON</code>. The days of the week (for example) are returning as a <code>string</code> which i am applying <code>.split(',')</code> to and is working in my <code>forEach</code> function, but i need to apply a class to my days returned buttons but due to the space in the string it only falls into my 'Mon' button and not the rest due to the space.</p>
  
  <p><strong>Working code</strong></p>
  
  <pre><code>var selectedDays = modifyRecordData.selectedDays;
  var splitSelectedDays = selectedDays.split(',');
  console.log(splitSelectedDays);
  
  splitSelectedDays.forEach(day =&gt; {
    if(day == 'Mon') {
      alert('in Mon')
      $('#mon').removeClass('btn-default');
      $('#mon').addClass('btn-primary');
    }
  
    if (day == 'Tue') {
      alert('in Tue')
      $('#tue').removeClass('btn-default');
      $('#tue').addClass('btn-primary');
    }
  
    // AND SO ON
  })
  </code></pre>
  
  <p>This also returns</p>
  
  <p><a href="https://i.stack.imgur.com/WO4Gk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WO4Gk.png" alt="enter image description here"></a></p>
  
  <p>I have tried the following but none are working</p>
  
  <pre><code>var selectedDays = modifyRecordData.selectedDays;
  var splitSelectedDays = selectedDays.split(',').trim();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>var selectedDays = modifyRecordData.selectedDays;
  var splitSelectedDays = selectedDays.split(',').trim();
  var test = splitSelectedDays.trim();
  </code></pre>
  
  <p>also thruught about trying in the actual <code>loop</code> as each one returned as a <code>string</code> using the below</p>
  
  <pre><code>splitSelectedDays.forEach(day =&gt; {
        splitSelectedDays.trim();
  </code></pre>
  
  <p>But always get the function error.</p>
  
  <p>I am wanting to remove the space, then lowercase the value then i can use the <code>var</code> in on <code>addClass</code> function rather than an <code>IF</code> for each day of the week</p>