Learn Functional Programming by Building a Spreadsheet - Step 20

Tell us what’s happening:

I understand that I should be calling a function in the .reduce() call, but the instructions do not state what function I am to call, and the console does not give a hint on what function is to be passed in reduce(). Any ideas on this unclear step?

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
    <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>
    <div id="container">
    <script src="./script.js"></script>
/* 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 sum = (nums) => nums.reduce();

// User Editable Region

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;
  const letters = charRange("A", "J");
  range(1, 99).forEach(number => {
    letters.forEach(letter => {
      const input = document.createElement("input");
      input.type = "text";
      input.id = letter + number;
      input.ariaLabel = letter + number;

Your browser information:

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

Challenge Information:

Learn Functional Programming by Building a Spreadsheet - Step 20

Its callback should sum all the numbers. If you look at MDN for reduce, you can see an example of summing an array.

I haven’t gone through the curriculum, but has this not been taught yet anywhere?

1 Like

This youtube video about the reduce method really cleared things up for me. (https://www.youtube.com/watch?v=g1C40tDP0Bk)