Tell us what’s happening:
Hi all,
The code below is not passing the tutorial and keeps saying
You should use the return
keyword.
Could anyone please give me more hints?
Your code so far
const median = nums => {
const sorted = nums.slice().sort((a, b) => a - b);
const length = sorted.length;
const middle = Math.ceil(length / 2 - 1);
return isEven(length) ?(sorted[middle] + sorted[middle + 1]) / 2 : sorted[middle];
};
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36
Challenge Information:
Learn Functional Programming by Building a Spreadsheet - Step 24