Tell us what’s happening:
I can’t seem to pass tests 5 and 7. I checked the output from my functions and it matches the expected output. Any ideas of whether something is missing?
Your code so far
let currentDate = new Date();
let currentDateFormat = `Current Date and Time: ${currentDate}`;
console.log(currentDateFormat);
function formatDateMMDDYYYY(date) {
return `Formatted Date (MM/DD/YYYY): ${date.getMonth()+1}/${date.getDate()}/${date.getFullYear()}`
}
function formatDateLong(date) {
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
return `Formatted Date (Month Day, Year): ${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`
}
// Testing 5 and 7, both result in true
let testDate = new Date("Fri Sep 27 2024 16:16:11 GMT+0500 (Pakistan Standard Time)");
console.log(formatDateMMDDYYYY(testDate) === "Formatted Date (MM/DD/YYYY): 9/27/2024");
console.log(formatDateLong(testDate) === "Formatted Date (Month Day, Year): September 27, 2024");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Challenge Information:
Build a Date Conversion Program - Build a Date Conversion Program