Additional test case for Arguments Optional

Hello CodeCampers!

Tell us what’s happening:
In the challenge linked below, it is asked “If either argument isn’t a valid number, return undefined.”
Please, consider adding a test where the first argument isn’t a valid number, but the second is.

I passed the challenge with this code:

//buggy function
function addTogether(...args) {

  if (arguments.length == 1 && typeof(args[0]) == 'number')
  return ( val => (typeof(val) === 'number') ? args[0] + val : undefined );

  if (arguments.length >= 2 && typeof(args[1]) == 'number'){
    return args[0] + args[1];
  } else
  return undefined; 

}

//test code
addTogether("2", 3); // gives 23, not 5 as expected

Challenge:
Arguments Optional

Link to the challenge:

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

Like this one?

addTogether("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

Oh, I think you mean where the first argument isn’t a valid number but the second is.

Oh, I think you mean where the first argument isn’t a valid number but the second is .

Exactly! I edited the sentence. I think the test case in the code was clear.
Thank you for your reply!

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