The function ‘formatDate’ does this by creating a new Date object from the input date and then extracting the month, day, and year components to build the final formatted date string.
function formatDate(date) {
let formattedDate = new Date(date);
let month = formattedDate.getMonth() + 1;
let day = formattedDate.getDate();
let year = formattedDate.getFullYear();
return month + '/' + day + '/' + year;
}