Total newbie here with JS, I have a basic JS function that I need to just test to see some output from it.
function GetDateWithSeparator(separator) {
var today = new Date();
var dateTime = ''
if (separator === '-') {
today.setDate(today.getDate() - 1)
dateTime = today.getFullYear() + separator + ('0' + (today.getMonth() + 1)).slice(-2) + separator + ('0' + today.getDate()).slice(-2)
}
else {
dateTime = today.getFullYear() + separator + ('0' + (today.getMonth() + 1)).slice(-2) + separator + ('0' + today.getDate()).slice(-2)
}
return dateTime;
}
I am trying to test this in an online Javascript code tester but it’s not displaying any output. I also tried using console.log(dateTime)
at the bottom of the script, however that still does not result in anything.
It seems like I need to supply some input value for the seperator
argument, however I’m not sure what the syntax is to do this within a code tester tool. Any help is appreciated!