The code shown below is intended to output the present working directory to the console. Instead it outputs, "undefined". For purposes of this learning experience, it is important that I obtain the desired result as the returned value of the system function. Any ideas on how I can make this work?
#!/usr/bin/node
var child_process = require('child_process');
function system(cmd) {
child_process.exec(cmd, function (error, stdout, stderr) {
return stdout;
})};
console.log(system('pwd'));