Learn Functional Programming by Building a Spreadsheet - Step 4

Tell us what’s happening:

I appear to be doing what is requested, but it is not satisfying the test. Though not what is being asked, I also tried with a value of the string ‘name’, but that was also not sufficient. I checked the MDN documentation to make sure my syntax for assignment via textContent was correct.

Your code so far

window.onload = () => {
const container = document.getElementById(“container”);
const createLabel = (name) => {
const label = document.createElement(“div”);
label.className = ‘label’;
label.textContent = ${name}
}
}

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="./styles.css" />
    <title>Functional Programming Spreadsheet</title>
  </head>
  <body>
    <div id="container">
      <div></div>
    </div>
    <script src="./script.js"></script>
  </body>
</html>
/* file: styles.css */
#container {
  display: grid;
  grid-template-columns: 50px repeat(10, 200px);
  grid-template-rows: repeat(11, 30px);
}

.label {
  background-color: lightgray;
  text-align: center;
  vertical-align: middle;
  line-height: 30px;
}
/* file: script.js */

// User Editable Region

window.onload = () => {
  const container = document.getElementById("container");
  const createLabel = (name) => {
    const label = document.createElement("div");
    label.className = 'label';
    label.textContent = `${name}`
  }
}

// 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/121.0.0.0 Safari/537.36

Challenge Information:

Learn Functional Programming by Building a Spreadsheet - Step 4

label.textContent = `${name}`

Remember that name is an argument passed into the createLabel function so it doesn’t need to go in quotes (which would be a string). I don’t think backticks are wrong here but I don’t think they are needed

1 Like

Yes, that did it. I think the result would be the same, but the test required no interpolation.

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