How can I add a full stop to the end of string, if it's not already there, in JavaScript?
<p>I'm trying to figure out how to check if a string ends in a full stop, if it doesn't one should be added via vanilla JavaScript. Any ideas?</p>

<p>I was thinking something like this might work to actually see if there is a full stop at the end of the variable, but it seems to error out?</p>

<p>Also at the moment I have no idea how i'd add the full stop to the end of the string.</p>

<pre><code>    if todoTitle.str.charAt(str.length-1) != "." {
        alert("doesn't end in .");
    } else {
        alert("does end in .");
    };
</code></pre>

<p>Any ideas about the best way to go about this? Thanks!</p>
