The problem is that you are not currently writing anything in response to the request.
response.write()
You also use methods like alert(); which are browser methods, but the code you execute is executed on the server side.
Currently, you are only declaring methods, but not calling anything.
This example should work:
var http = require('http'); port = process.argv[2] || 8888; http.createServer(function(request, response) { response.writeHead(200, { 'Content-Type': 'text/html' }); var PI = Math.PI; area = function(r) { var res1 = PI * r * r; response.write('Area = ' + res1);
source share