Arguments Optional - NaN function

A little confused on this code why it is not working for the last two cases. As far as I understand it JavaScript doesn’t have tight ‘type casting’ like other langs, so why does ‘NaN’ not work here ?

  • A

Your code so far

function addTogether(a, b) {
  if (isNaN(a)) {
    return undefined;
  if (b != null) {
  return a + b;
  return function Sum(x) { 
    if (isNaN(x)) {
     return undefined;
    } else { 
     return a + x; 


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:

isNan() doesn’t return true if the argument is a type other than a number. It returns true if the argument is specifically NaN. Look at using typeof instead.

Thanks Ariel, I will look into that def.


  • A