Need help with Learn Functional Programming by Building a Spreadsheet Step 103

My code so far:

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 => [...new Set(nums).values()]
}
1 Like

this is missing a colon, a value, and a comma after

My code so far:

const spreadsheetFunctions = {
  "": {value: "", text: ""},
  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 => [...new Set(nums).values()]
}

What exactly do I have to do to this code that still does not pass?

1 Like

I am having the exact same problem. I have tried numerous functions on MDN including this snippet “”: () => (‘’),
that returns " " when I console.log(“”);
Used arrays, Object.key(), and read from countless sites. They seem to think the Object Property should be a word and then the condition. My brain broke. :slightly_smiling_face:

I am piggy backing this post because their are multiple posts seeking the same help “or a solution at this point”. Appreciate any assistance that can be provided.

I have read the previous forum post’s and this “last step” has had me stuck for a couple of days.

@ILM has just about given the solution away.

Use that advice in conjunction with how the other lines of code are structured.

Happy coding

Hi Teller,

Thanks for your reply but the advice of “this is missing a colon, a value, and a comma after” is not helping because the value is the issue we seem to be struggling with.

When you say value, I think maybe that is where I am lost. What could it possibly be when referring to an empty string? I have tried :
“”: (“”,() => {(“”)}),
“”: (array) => [“”], ---- console.log(Object(“”));Returns > String { "" }
“”: “”, — console.log((‘’)); RETURNS “”
“”: (“”), — console.log(Object(‘’)); Returns > String { "" }
I am all out of ideas. Thanks

What value appears after each colon in the function?

This whole variable is simply an Object of spreadsheetFunctions made up of property names referencing functions, while some have keys (nums) acting as functions. To your point, anything inside of the () is a parameter or function, the latter requiring a definition and call back. This is probably more simple than I am making it. I feel like I am going to be kicking myself when I figure it out. Thanks again Teller for your guidance. I will try again tomorrow.

1 Like

The object property you are asked to add consists of an empty string as the key and a function as the value.

The function should accept an argument using a parameter and simpely return that parameter.

the value is an object here, when the request is a function that takes one parameter and returns that parameter. Please try to write such function

Thank you Teller, lasJorg, and ilenia…It took me a bit and as I suspected, I am kicking myself. Thanks for your guidance.

1 Like

the problem is the exercise dont tell you what argument to use in the function but i got it and discovered by myself. use the same arguments you used in the other functions of the whole code.

That is because it doesn’t matter. You can name the parameter whatever you’d like.

"": (whatever) => whatever

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