Learn Functional Programming by Building a Spreadsheet - Step 6

Tell us what’s happening:

“Hey everyone, I’m looking for some guidance on using the Array() constructor in JavaScript. Specifically, I’m curious about its usage with single numeric arguments versus multiple arguments. Any insights or examples would be greatly appreciated!”

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: 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

const range = (start, end) => {
   return new Array([]);
}

// User Editable Region


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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0

Challenge Information:

Learn Functional Programming by Building a Spreadsheet - Step 6

Welcome to the forum!

You can study Array( ) here:

The thing with this task (I struggled with this too first) is that it wants you to write the function in one specific way:

  • After the new ES6 syntax as an arrow function and without brackets for the function body (one element rule).
  • Also implicit, meaning without a return keyword.
  • Array( ) without anything passed to is as an “empty array”.