Build a Date Conversion Program - Build a Date Conversion Program

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

Your solution works from my end. Try to rest the project, and copy the code back in from your forum post or:

Please try one of the following steps to move forward.

Click on the “Reset” step button and force a refresh of your page with CTRL + F5 if you’re on Windows then try to paste the code in again. On other systems, please follow the instructions here.

or - Try the step in incognito or private mode.

or - Disable any/all extensions that interface with the freeCodeCamp website (such as Dark Mode, Ad Blockers, or Spellcheckers), and set your browser zoom level to 100%. Both of these factors can cause tests to fail erroneously.

or - Ensure your browser is up-to-date or try a different browser.

or - Turn off high contrast themes on Windows (from accessibility settings menu)

I hope one of these will work for you.

I tried all of those things and it still doesn’t pass. Oh well at least the code works :slight_smile:

What browser are you using? Which other browser did you try?

Do you use a VPN?