ReferenceError: str is not defined
<p>Im very new to javascript Im working through the <a href="http://www.w3schools.com/js/tryit.asp?filename=tryjs_string_replace" rel="nofollow">w3school tutorial</a>, trying to replace all occurrences within a certain string.</p>

<p>I have the following string <code>08/18/16</code> I would like to replace all occurences of <code>/</code> to <code>,</code></p>

<p>As per W3schools example I try to achieve the above as follow:</p>

<p><code>date1 = str.replace("/",",");</code></p>

<p>However the above results in an error </p>

<blockquote>
  <p>ReferenceError: str is not defined date1 = str.replace("/",",")</p>
</blockquote>

<p>I would really appreciate it if someone could give the following code a scan. </p>

<pre><code>var firstDate = document.getElementById("firstDate").value;
var secondDate = document.getElementById("secondDate").value;
var date1 = firstDate.substring(0,11);
var date2 = secondDate.substring(0,11);
date1 = str.replace("/",",");
date2 = str.replace("/",",");
</code></pre>