Step 51 build a to do list not passing

hi, doing the to do list project and up to step 51. it is not liking when i then edit the form and not passing, have done a reset of the lesson, done a hard refresh, and also rewrote the function, but is is not still passing. so pasting my javascript, the errors and a link to the step.

can any one help. no help button on this step. happens with some steps on some lessons, dont know why this is happening. and also pity the editor is not more accessible with a screen reader. rant over.

ps: pasting below.

javascript:

           // Step 1–51 JS

// Get DOM elements
const taskForm = document.getElementById("task-form");
const confirmCloseDialog = document.getElementById("confirm-close-dialog");
const openTaskFormBtn = document.getElementById("open-task-form-btn");
const closeTaskFormBtn = document.getElementById("close-task-form-btn");
const addOrUpdateTaskBtn = document.getElementById("add-or-update-task-btn");
const cancelBtn = document.getElementById("cancel-btn");
const discardBtn = document.getElementById("discard-btn");
const tasksContainer = document.getElementById("tasks-container");
const titleInput = document.getElementById("title-input");
const dateInput = document.getElementById("date-input");
const descriptionInput = document.getElementById("description-input");

// Data
const taskData = [];
let currentTask = {};

// Add or update task
const addOrUpdateTask = () => {
  const dataArrIndex = taskData.findIndex(item => item.id === currentTask.id);

  const taskObj = {
    id: `${titleInput.value.toLowerCase().split(" ").join("-")}-${Date.now()}`,
    title: titleInput.value,
    date: dateInput.value,
    description: descriptionInput.value
  };

  if (dataArrIndex === -1) {
    // Add new task
    taskData.unshift(taskObj);
  } else {
    // Update existing task
    taskData[dataArrIndex] = taskObj;
  }

  updateTaskContainer();
  reset();
};

// Update tasks container
const updateTaskContainer = () => {
  tasksContainer.innerHTML = "";
  taskData.forEach(({ id, title, date, description }) => {
    tasksContainer.innerHTML += `
      <div class="task" id="${id}">
        <p><strong>Title:</strong> ${title}</p>
        <p><strong>Date:</strong> ${date}</p>
        <p><strong>Description:</strong> ${description}</p>
        <button onclick="editTask(this)" type="button" class="btn">Edit</button>
        <button onclick="deleteTask(this)" type="button" class="btn">Delete</button>
      </div>
    `;
  });
};

// Delete task
const deleteTask = (buttonEl) => {
  const dataArrIndex = taskData.findIndex(item => item.id === buttonEl.parentElement.id);
  buttonEl.parentElement.remove();
  taskData.splice(dataArrIndex, 1);
};

// Edit task
const editTask = (buttonEl) => {
  const dataArrIndex = taskData.findIndex(item => item.id === buttonEl.parentElement.id);
  currentTask = taskData[dataArrIndex];

  titleInput.value = currentTask.title;
  dateInput.value = currentTask.date;
  descriptionInput.value = currentTask.description;

  addOrUpdateTaskBtn.innerText = "Update Task";
  taskForm.classList.remove("hidden");
};

// Reset form
const reset = () => {
  titleInput.value = "";
  dateInput.value = "";
  descriptionInput.value = "";
  taskForm.classList.add("hidden");
  currentTask = {};
};

// Open task form
openTaskFormBtn.addEventListener("click", () => {
  taskForm.classList.toggle("hidden");
});

closeTaskFormBtn.addEventListener("click", () => {
  const formInputValuesUpdated =
    titleInput.value !== currentTask.title ||
    dateInput.value !== currentTask.date ||
    descriptionInput.value !== currentTask.description;

  if (formInputValuesUpdated) {
    confirmCloseDialog.showModal();
  } else {
    reset();
  }
});


// Dialog buttons
cancelBtn.addEventListener("click", () => confirmCloseDialog.close());

discardBtn.addEventListener("click", () => {
  confirmCloseDialog.close();
  reset();
});

// Form submit
taskForm.addEventListener("submit", (e) => {
  e.preventDefault();
  addOrUpdateTask();
});

erorrs:
Sorry, your code does not pass. You’re getting there.

Your formInputValuesUpdated variable should check if titleInput.value is not equal to currentTask.title.
link to the step:

Hi @BlindVisionMan

Your solution works from my end. Please try one of the following steps to move forward.

Click on the “Restart Step” button and force a refresh of your page with CTRL + F5 then try to paste the code in again.

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.

I hope one of these will work for you.

Make sure you copy the current code and save it somewhere safe first.

Happy coding

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

hi, using the jaws for windows 2026 screen reader, and the step is not passing, did go and research the code and what it does. have tried multiple variations and then went back to the step insturctions, but it is not passing and also done multiple resets of the lesson, multiple hard refreshes of the step. have rewritten the function several times with different variations. and also tried google chrome, firefox and edge in incofnito or private browsing, but you have a serious bug, fcc is very strict, so what is it looking for and how to get it to pass. have tried this step to fix for 5 or 6 hours and having to then have accessibility barrier on top of this. is frustrating. so, how to get this to pass, this may be easy for you sighted people, but close your eyes, use a screen reader like jaws, nvda, or windows narrator and the keyboard, then try walking in my shoes for a few hours or a day. sorry, frustration and rant over. probably too hard to rewrite the fcc editor to loosen up the way it tests, but this is driving me insane. and no wonder sighted people get frustrated and still not working, so test it on your end, you said it did pass on your end. so why is it my code, or is it a bug with fcc? totally frustrated and need your help, and then a lot of time wasting as i am 15.5 hours ahead of new york in adelaide, australia and 18.5 hours ahead of los angelos and i know i am the only blind person and trying to be patient, but still feels like banging my head against a brick wall some times. so can any one help me out. or is it just me who is having nightmares, i did do some research and some forums a lot of people sturggling with this step in the to do list project. so pasting the javas script code, the error and the link to the step.
help!
thank you.
marvin.
ps: pasting now.

java script:

.e// Step 1–51 JS



// Get DOM elements

const taskForm = document.getElementById("task-form");

const confirmCloseDialog = document.getElementById("confirm-close-dialog");

const openTaskFormBtn = document.getElementById("open-task-form-btn");

const closeTaskFormBtn = document.getElementById("close-task-form-btn");

const addOrUpdateTaskBtn = document.getElementById("add-or-update-task-btn");

const cancelBtn = document.getElementById("cancel-btn");

const discardBtn = document.getElementById("discard-btn");

const tasksContainer = document.getElementById("tasks-container");

const titleInput = document.getElementById("title-input");

const dateInput = document.getElementById("date-input");

const descriptionInput = document.getElementById("description-input");



// Data

const taskData = \[\];

let currentTask = {};



// Add or update task

const addOrUpdateTask = () => {

  const dataArrIndex = taskData.findIndex(item => item.id === currentTask.id);



  const taskObj = {

    id: \`${titleInput.value.toLowerCase().split(" ").join("-")}-${Date.now()}\`,

    title: titleInput.value,

    date: dateInput.value,

    description: descriptionInput.value

  };



  if (dataArrIndex === -1) {

    taskData.unshift(taskObj); // Add new task

  } else {

    taskData\[dataArrIndex\] = taskObj; // Update existing task

  }



  updateTaskContainer();

  reset();

};



// Update tasks container

const updateTaskContainer = () => {

  tasksContainer.innerHTML = "";

  taskData.forEach(({ id, title, date, description }) => {

    tasksContainer.innerHTML += \`

      <div class="task" id="${id}">

        <p><strong>Title:</strong> ${title}</p>

        <p><strong>Date:</strong> ${date}</p>

        <p><strong>Description:</strong> ${description}</p>

        <button onclick="editTask(this)" type="button" class="btn">Edit</button>

        <button onclick="deleteTask(this)" type="button" class="btn">Delete</button>

      </div>

    \`;

  });

};



// Delete task

const deleteTask = (buttonEl) => {

  const dataArrIndex = taskData.findIndex(item => item.id === buttonEl.parentElement.id);

  buttonEl.parentElement.remove();

  taskData.splice(dataArrIndex, 1);

};



// Edit task

const editTask = (buttonEl) => {

  const dataArrIndex = taskData.findIndex(item => item.id === buttonEl.parentElement.id);

  currentTask = taskData\[dataArrIndex\];



  titleInput.value = currentTask.title;

  dateInput.value = currentTask.date;

  descriptionInput.value = currentTask.description;



  addOrUpdateTaskBtn.innerText = "Update Task";

  taskForm.classList.remove("hidden");

};



// Reset form

const reset = () => {

  titleInput.value = "";

  dateInput.value = "";

  descriptionInput.value = "";

  taskForm.classList.add("hidden");

  currentTask = {};

};



// Open task form

openTaskFormBtn.addEventListener("click", () => {

  taskForm.classList.toggle("hidden");

});



// Close task form

closeTaskFormBtn.addEventListener("click", () => {

  const formInputValuesUpdated = titleInput.value !== currentTask.title;



  if (formInputValuesUpdated) {

    confirmCloseDialog.showModal();

  } else {

    reset();

  }

});



// Dialog buttons

cancelBtn.addEventListener("click", () => confirmCloseDialog.close());



discardBtn.addEventListener("click", () => {

  confirmCloseDialog.close();

  reset();

});



// Form submit

taskForm.addEventListener("submit", (e) => {

  e.preventDefault();

  addOrUpdateTask();

});

errors:

Your formInputValuesUpdated variable should check if titleInput.value is not equal to currentTask.title or dateInput.value is not equal to currentTask.date.

link to the step:

This button only appears if you have tried to submit an answer at least three times.

Hey, I found the issue with your code, extra spaces in your solution caused an error

So your initial code is correct, but please use this edited line of code without extra spaces to pass the task:

const formInputValuesUpdated = titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description;

hi ray, i would like to thank you very much for helping me out, did not notice the extra spaces and using a screen reader. so did try reading line by line and word by word, but missed that extra spaces, screen readers do not always pick up hidden characters, or stray characters. so got it to pass. so i thank you for helping me.

have a great day.

marvin.

1 Like

Nice to hear, Marvin, I’m always glad to help.
You’re welcome and happy coding!