const isDate = (str) => { return (new Date(str) !== "Invalid Date") && !isNaN(new Date(str)); } console.log(isDate('2020-01-01')) console.log(isDate('abc'))