• What's wrong with my code?

Question related to mission Convert Date

 

Hi, this is my code, what is wrong? when I run code pass without a problem, but when I check solution is the problem

function convertDate(date: string): string {
    let arr = date.split('/').reverse().join('-')
    if( new Date(arr) == 'Invalid Date'  ){return "Error: Invalid date."}

    return arr
}

this is the console out: 5,9: This comparison appears to be unintentional because the types 'Date' and 'string' have no overlap.

assert.strictEqual(convertDate("25/12/2021"), "2021-12-25");

Thanks!