ファイル構成:
/lib/math.js
/app.js
コード
/lib/math.js
// 加算関数
exports.add = function(a, b)
{
return a + b;
}
// sayhelo関数
exports.sayhelo = function()
{
switch (arguments.length)
{
case 1:
return 'helo ' + arguments[0] + '.';
default:
return 'helo everyone.';
}
}