Build a Todo App using Local Storage - Step 66

Tell us what’s happening:

Typical! Always in my case. Get to the last step and bomb! They don’t let you pass! LOL Step 66
Finally, it is time to call the removeSpecialChars on the id property in your taskObj.

This will help prevent issues caused by special characters in HTML element IDs.

With that you have completed the project.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

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

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0

Challenge Information:

Build a Todo App using Local Storage - Step 66

You’re applying that function to the entire id property value. Think about what piece of that it makes sense to apply that function to.

I do not follow, they came up with the same response I did for the answer. It makes sense to satanize everything .

How does it make sense to remove special characters from a string method, an array method, and a date when the purpose of removeSpecialChars() is to remove special characters from HTML element ids as stated in the instructions?

This will help prevent issues caused by special characters in HTML element IDs.

But thanks for the typo chuckle: :rofl:

Because you wouldn’t want those characters in the date either? Also yea the typo that now that i see it is funny. Sometimes that is accurate for code…….evil code

if just worrying about the ID
I tried
id: `${removeSpecialChars(titleInput.value.toLowerCase().split(" “).join(”-"))}-${Date.now()}`,

Log Date.now(). How will that ever have special characters? :slight_smile:

let’s put it like this, what’s the sense to add the dashes to then remove them with removeSpecialChars?

So what is it asking to sanitize just the titleinput.value?

yes, only the part of code that comes from the user. Otherwise you would be removing the dashes that you have written code to put in there

There might be some confusion since it looks like the regular expression in the given code has been changed to /[^A-Za-z0-9\-\s]/g (sometime since I did this last year).

the line has never been changed since the project was added to the full stack curriculum

what do you think it was before?

I saved it as /[^a-z\s]/ig about a year ago. I can’t think of any reason why I would have changed it, but it sounds like I must have.

the step in which the function is created has freedom of implementation, maybe it’s that that is causing the confusion?

Makes sense. I must have saved my code as I went along rather than copying all of the seed code at the end of the workshop.