Intermediate Algorithm Scripting - Arguments optional

Hi Guys! I am struggling a bit in this exercise.

I have managed to passed almost all demands, but I am falling in one and can’t see where I am doing at wrong. Here is the code:

function addTogether(a, b) {
  if(typeof(a) !== 'number' || (b != undefined && typeof(b) !== 'number')) {
    return undefined;
  }
  if(b == undefined) {
    return c => addTogether(a, c);
  }
  return a + b;
}

addTogether(2,3);

Failed:addTogether(5, undefined); #where it doesn’t pass#

Link to Challenge

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 (').

1 Like

please post a link to the challenge

Thank you very much Randell.

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