Is this a bug in challenge?

Got error in console:
vendor-main-84ab4d5263.js:58Uncaught TypeError: Cannot read property 'split' of undefined

And testing doesn’t want to complete self.
I don’t have split in code.
Here is code:

function addTogether(a, b) {
  
  console.log("Enter in addTogehter(a,b ) with " + a + ", " + b);
  if ( isNaN(a) || isNaN(b) )
    return undefined;
  console.log("Pass inNan in addTogehter(a,b) with " + a + ", " + b);
  
  return a+b;
}

function addTogether(a){
  
  console.log("Enter in addTogehter(a ) with " + a);
  if ( isNaN(a) )
    return undefined;
  
  console.log("Pass inNan in addTogehter(a) with " + a);
  return function(b){
    
  console.log("Enter in addTogehter(b ) with " + b);
  if ( isNaN(a) || isNaN(b) )
    return undefined;
    
  console.log("Pass inNan in addTogehter(b) with " + b);
    
    return a+b;
  };
  
}

addTogether(2, 3);
  1. You can’t overload functions in javascript.
  2. You should use arguments object
1 Like

@jenovs is correct that overloading like you’re doing does not work in JS (only the last function declaration with that name will be used), but there is an open bug related to this. It seems that calling a function that returns a function on the final line of a solution crashes the challenge code execution

Relevant Link: https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8796

1 Like