title: How to replace the last character in JavaScript with a word?
body: <p>I checked out all the answers related to this matter and none of these apply. I'd like to build a simple script asking about the name and the gender. If a person identifies herself as a woman, the script will delete the last character from the string and replace it with the word 'woman', e.g. Agnes => Agnewoman, Maya => Maywoman etc. I know that strings are immutable in JavaScript. I used a colloquial language to express my idea.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Let's get started&lt;/title&gt;
  &lt;link href="../_css/site.css" rel="stylesheet"&gt;
  
  &lt;script&gt;
  var name = prompt("What's your name", " ");
  var answer = prompt("Are you a woman?", " ");
  &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div class="wrapper"&gt;
    &lt;header&gt;
      JAVASCRIPT &lt;span class="amp"&gt;and&lt;/span&gt; jQUERY
    &lt;/header&gt;
    &lt;div class="content"&gt;
      &lt;div class="main"&gt;
        &lt;h1&gt;Variables&lt;/h1&gt;
  
        &lt;script&gt;
          if (answer == "yes" || answer == "Yes" || answer == "YES" || answer == "y" || answer == "Y"){
            document.write(...);
          } else {
  
          };
        &lt;/script&gt;
  
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>