documentation/test/fixture/throws.input.js
2015-06-08 11:12:10 -04:00

16 lines
327 B
JavaScript

/**
* This function returns the number plus two.
*
* @param {Number} a the number
* @returns {Number} numbertwo
* @throws {Error} if number is 3
* @example
* var result = returnTwo(4);
* // result is 6
*/
function returnTwo(a) {
if (a === 3) throw new Error('cannot be 3');
// this returns a + 2
return a + 2;
}