title: how to add space to the end of a string in javascript?
body: <p>I have the following string.</p>
  
  <pre><code>&lt;span class="add"&gt;foo bar1&lt;/span&gt;
  </code></pre>
  
  <p>Now I have to check the last character in this string.If the last character in this string is 1,add a space to the end of the string and move the cursor out of the span tag, Else if the last character in this string is not 1,just move the cursor out of the span and do not add a space.  </p>
  
  <p>So can anyone help me how it can be done in javascript.This will happen when I click a button 'Done'. I am quite new to stackoverflow.So if I made q mistake in the question,please forgive me.
  Thanks</p>