I want to compile javascript like I would java in the terminal (on a mac) where I can input a file and get the output returned to me. I have managed to create an alias of the javascript compiler located deep in the Systems folder, and have created an alias for rhino to execute files as well.
I can now type js file_name.js (for the native js program) or rjs (for rhino) and it will compile in either alias (program), returning errors where they exist. However if there are no errors no output is returned.
My question is, how do I return an output using js in terminal. Here is the simple code I am using to test this functionality:
function add()
{
var sum = 0;
for(var i = 0, j = arguments.length; i < j; i++)
{
sum += arguments[i];
}
return sum;
}
add(1,2,3,4);