argumentsoptional.js

function addTogether(a,b) {
    if (a && typeof(a) === "number") {
      if (b) {
        if (typeof(b) === "number") {
          return a + b;
        }
        else {
          return undefined;
        }
      }
      else {
        return function(b){
          if (b && typeof(b) === "number") {
            return a + b;
          }
          else {
            return undefined;
          }
        }
      }
    }
  }

  console.log(addTogether(2)(2));
The code is running in this page - open your console to see the results. This code is maintained in a Github repo at https://github.com/r1chard5mith/fcc_exercises Made with love by Richard Smith as part of Freecodecamp.