Skip to content

Instantly share code, notes, and snippets.

@clive-bunting
Created December 4, 2015 21:13
Show Gist options
  • Select an option

  • Save clive-bunting/ef83b1cf2373b934bfb6 to your computer and use it in GitHub Desktop.

Select an option

Save clive-bunting/ef83b1cf2373b934bfb6 to your computer and use it in GitHub Desktop.
Bonfire: Arguments Optional
// Bonfire: Arguments Optional
// Author: @clive-bunting
// Challenge: http://www.freecodecamp.com/challenges/bonfire-arguments-optional
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function add() {
if (typeof arguments[0] !== "number") {
return undefined;
}
var first = arguments[0];
if (arguments[1] === undefined) {
return function() {
if (typeof arguments[0] !== "number") {
return undefined;
}
return first + arguments[0];
};
}
if (typeof arguments[1] !== "number") {
return undefined;
}
return first + arguments[1];
}
add(2,3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment