Learn Functional Programming by Building a Spreadsheet - Step 85

Tell us what’s happening:

i don’t know how to solve this challenge
Your apply function should call the spreadsheetFunctions[fn.toLowerCase()] function.

Your code so far

// User Editable Region

const applyFunction = str => {
  const noHigh = highPrecedence(str);
  const infix = /([\d.]+)([+-])([\d.]+)/;
  const str2 = infixEval(noHigh, infix);
  const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i;
  const toNumberList = args => args.split(",").map(parseFloat);
  const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()].toNumberList(args);

// 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/ Safari/537.36

Challenge Information:

Learn Functional Programming by Building a Spreadsheet - Step 85

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

A question for you. Do you understand what the value of spreadsheetFunctions[fn.toLowerCase()] is?

1 Like

Hi @mahdaouiilyas

Pass in the result of calling toNumberList with args as an argument.

You code has it as a method rather than a call.

Happy coding

1 Like

fn represent the key inside spreadsheetFunctions object, and it will access a function based on the fn value . right!!!

If you are saying that spreadsheetFunctions[fn.toLowerCase()] resolves to the name of a function then you are correct. And then of course you call a function using parentheses, passing in any arguments to the function inside of the parentheses.

1 Like