Intermediate Algorithm Scripting - Arguments Optional

Why is this doesn’t satisfy
addTogether(2)([3]) should return undefined .
it dose return undefined
and it already satisfied all the other conditions

function addTogether() {
if(typeof(arguments[0])=== "number"){
    if(arguments.length !== 2){
        return ((y) => {return arguments[0] + y});
      if(arguments[1] !== undefined && typeof(arguments[1]) === "number"){
    return arguments[0] + arguments[1];
  return undefined;


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: Intermediate Algorithm Scripting - Arguments Optional

Link to the challenge:

This function will never return ‘undefined’

it already satisfied all the other conditions, including returning undefined

Not quite. This function that you are returning won’t return undefined at any point.

return ((y) => {return addTogether(arguments[0] , y)});

But This function DID return undefined, did you even test it?

The outer function did return undefined sometimes, but the function you were returning did not have a way to return undefined!

Your update two posts above fixes that issue.

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