Tell us what’s happening:
Man, I got this after some trials but i still dont get why we use the spread operator and why not provide the first and second item of the array in the first place. Would you guys mind weighing in.
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)
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Learn Functional Programming by Building a Spreadsheet - Step 103