Learn localStorage by Building a Todo App - Step 13

Tell us what’s happening:

I am trying to add an id to taskOBJ with the value of the value of titleInput.

id: ${titleInput.value},

not sure why this doesn’t work. This question was recently shortened from previously having to include more formatting. Is this bugged?

Your code so far

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

/* file: styles.css */

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

  const taskObj = {
    id: `${titleInput.value}`,
  };
  console.log(taskObj);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 13

Hello!

You don’t need a literal. Just tell JavaScript that it should read the value stored by the user into the variable titleInput.

1 Like

got it. Thanks! Why does a value of a value not go into ${} in this instance. Im a little shaky on that part still. Does the ${} become redundant when you use .value

One reason is that the user input might not be a string, but a number, and you might get a errors. Template literals help you to output dynamic expressions into a string.

1 Like

I gotcha. I see now that, after going through step 22 that we were building toward a larger concept, as always. I think I wasn’t focused on what was being asked directly in step 13 and too focused on the bigger concept. Thanks!