Im very new to javascript Im working through the w3school tutorial, trying to replace all occurrences within a certain string.
I have the following string 08/18/16
I would like to replace all occurences of /
to ,
As per W3schools example I try to achieve the above as follow:
date1 = str.replace(/,,);
However the above results in an error
ReferenceError: str is not defined date1 = str.replace(/,,)
I would really appreciate it if someone could give the following code a scan.
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(/,,);