Learn Functional Programming by Building a Spreadsheet - Step 23

hi together

i am stuck in this lesson currently.

my console shows the message: You should pass a callback function to your sort method to accurately sort the numbers in ascending order. Use an implicit return for clarity.

it should exactly do whats requiered.
Can someone explain?

/* file: script.js */
const isEven = num => num % 2 === 0;
const sum = nums => nums.reduce((acc, el) => acc + el, 0);
const average = nums => sum(nums) / nums.length;


// User Editable Region

const median = (nums)=>{
  const sorted = nums.slice().sort((a, b) => b - a);
}

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

Challenge Information:

Learn Functional Programming by Building a Spreadsheet - Step 23

1 Like

the order is the problem. When I switched your function to a-b it worked.
(if a is < b then it should come first)

1 Like

no way :sweat_smile: thank you so much.

i could swear i tried it that way but it passed now.

happy Coding!

1 Like

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