Retrieve individual values

Report a typo

Fill in the blanks to complete the function that retrieves the year, month and day values and returns the current date in the format "YYYY-MM-DD":

Fill in the gaps with the relevant elements
function getCurrentDate() {
    let date = new Date();
    let year = ;
    let month =  + 1; // increase month by 1
    let day = ;

    return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;
}

Create a free account to access the full topic