Date return in string order : <p>my 4th assignment</p>

<p>Write a javascript function that returns the date. The date should be returned as a string in the order (DD-MM-YYYY) and in the following formats:
01-12-2016
01/12/2017
Tip: Make over an input argument that is chosen for the dash (-) or slash (/) as a separator stabbing.</p>

<p>I got this</p>

<pre><code>&lt;script&gt;
function formattedDate(date) {
var vandaag = new Date(date || Date.now()),
    month = '' + (vandaag.getMonth() + 1),
    day = '' + vandaag.getDate(),
    year = vandaag.getFullYear();
if (month.length &lt; 2) month = '0' + month;
if (day.length &lt; 2) day = '0' + day;
return [day, month, year].join('-');}
document.write('&lt;br&gt; Vandaag met (-) :  ' + formattedDate()); 

function formattedDat(date) {
var vandaa = new Date(date || Date.now()), 
    mont = '' + (vandaa.getMonth() + 1),
    da = '' + vandaa.getDate(),
    yea = vandaa.getFullYear();
if (mont.length &lt; 2) mont = '0' + mont;
if (da.length &lt; 2) da = '0' + da;
return [da, mont, yea].join('/');}
document.write('&lt;br&gt; Vandaag met (/):  ' + formattedDat());
&lt;/script
</code></pre>

<p>but i dont want it to write two times, and i need buttons for each order (-) and (/)</p>
