Tell us what’s happening:
I have tried several different approaches to solve this problem, including a for loop, .map() method, .filter() method, but nothing seems to work, and I’m seeing the message : “Your nodupes function should remove all duplicate values from the array.” What am I doing wrong?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const spreadsheetFunctions = {
sum,
average,
median,
even: nums => nums.filter(isEven),
someeven: nums => nums.some(isEven),
everyeven: nums => nums.every(isEven),
firsttwo: nums => nums.slice(0, 2),
lasttwo: nums => nums.slice(-2),
has2: nums => nums.includes(2),
increment: nums => nums.map(num => num + 1),
random: ([x, y]) => Math.floor(Math.random() * y + x),
range: nums => range(...nums),
nodupes: nums => nums.forEach(i => nums[i] === nums[i + 1] ? nums.splice(i, 1) : nums),
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Challenge Information:
Learn Functional Programming by Building a Spreadsheet - Step 104