Hi there.
I think I have a better advanced solution for this code challenge.
Just wanted to ask if there’s any way I can submit it for possible consideration.
It’s very succinct and uses the latest ES6 syntax as can be seen below:.
/* jshint esversion: 6 */
function addTogether( a, b ) {
if( typeof(a) != "number" ) // validate first argument
return undefined;
if(arguments.length > 1) {
if( typeof(b) != "number" ) // validate second argument
return undefined;
else
return a + b;
} else // callback was invoked
return (b) => typeof b == "number"? a + b : undefined ; // validate second argument
}
console.log( addTogether(2)(3) );