Double quotes and temporal literals

  1. Give your label element a for attribute with the value X-#-name , where X is the value of the entryDropdown element and # is the value of entryNumber . Remember that HTML attributes should be wrapped in double quotes.

CURRENT CODE:

function addEntry() {
  const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
  const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]').length;
  const HTMLString = `
  <label for="`#${entryDropdown.value}`-${entryNumber}-name">`Entry ${entryNumber} Name`</label>
}

Hello:(

You have to close your label element ( : The Label element - HTML: HyperText Markup Language | MDN (mozilla.org))
:

<label for="username">Enter your username:</label>

And you are missing the first back tick from your template literal.
JavaScript Template Strings (w3schools.com)

let text = `Hello World!`;
  <label for = `${entryDropdown.value} - ${entryNumber} - name entry ${entryNumber} name`></label>

This doesn’t work either. It’s not even giving me the help option.

A self closing tags in HTML are the type of HTML tags that need not to be closed manually by its closing tag, which means there is no saperate closing tag for it as .

<label for="html">HTML</label>
const HTMLString  = `<label></label>`

thank you, I didn’t realize this was an option.

function addEntry() {
  const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
  const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]').length;
  const HTMLString = `<label for=${entryDropdown.value}-${entryNumber}-name></label>`
}

this still doesn’t work. I copied and pasted " Your label element should have a for attribute set to ${entryDropdown.value}-${entryNumber}-name "

Can you tell me which step is this?

const HTMLString = `
  <label for="${entryDropdown.value}-${entryNumber}-name">Entry ${entryNumber} Name</label>`;

my goodness. Thank you so much!

If you put your code between backticks, ``` (three each) before and after your code, then it is more readable:)

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

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

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

don’t use the backticks here, remove them, you are already in a template literal, adding more backticks means you are ending the string early

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.