Uncaught TypeError: Cannot read property 'replace' of undefined using jQuery
<p>I'm making space separator on integer. This is my code </p>

<pre><code>if ( $.fn.appear &amp;&amp; $.fn.countTo ) {
    $('.counter').appear(function() {
        $('.timer').each(count);
        function count(options) {
            var $this = $(this);
            options = $.extend({}, options || {}, $this.data('countToOptions').replace(/ /g,'') || {});
            $this.countTo(options);
        }
    });
}
</code></pre>

<p>When I'm execute an integer can display but show <strong>Uncaught TypeError: Cannot read property 'replace' of undefined</strong>. So how to fix my code?</p>