Learn Functional Programming by Building a Spreadsheet - Step 17

Tell us what’s happening:

hi please i want know why my solution don’t work. thank you

Your code so far

<!-- 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: script.js */
const range = (start, end) => Array(end - start + 1).fill(start).map((element, index) => element + index);
const charRange = (start, end) => range(start.charCodeAt(0), end.charCodeAt(0)).map(code => String.fromCharCode(code));

window.onload = () => {
  const container = document.getElementById("container");
  const createLabel = (name) => {
    const label = document.createElement("div");
    label.className = "label";
    label.textContent = name;
    container.appendChild(label);
  }
  const letters = charRange("A", "J");
  letters.forEach(createLabel);
  range(1, 99).forEach(number => {
    createLabel(number);

// User Editable Region

    letters.forEach(letter => {
      const input = document.createElement('input');
      input.setAttribute("type", "text");
      input.setAttribute("id", letter + number)
    })

// User Editable Region

  })
}
/* 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;
}

Your browser information:

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

Challenge Information:

Learn Functional Programming by Building a Spreadsheet - Step 17

It will be best if you use the actual attribute names instead of setAttribute and then assign each their respective values.

1 Like

thanks you but why ?

Please tell us what’s happening in your own words
Learning to describe problems is hard, but it’s an essential part of programming
Also, the more you tell us, the more we can help

1 Like

i wanted know why my solution where i use “setAttribute” to create the the type and the id don’t work even if it should be .And now stephenmutheu says " It will be best if you use the actual attribute names instead of setAttribute " so i asked why ?

Hi there!
The challenge step is specific about the instructions. The setAttribute() function is not specified in the challenge instructions.

3 Likes

i understand that now. thank you