I'm currently taking a course on Coursera, and doing an exercise using node.js code to calculate a quadratic expression. All the code is given and this exercise is merely to get us to know node.js, but still I'm encountering a problem entering a prompt.
the code is here:
var quad = require('./quadratic');
var prompt = require('prompt');
prompt.get(['a', 'b', 'c'], function (err, result) {
if (err) { return onErr(err); }
console.log('Command-line input received:');
console.log('a: ' + result.a);
console.log('b: ' + result.b);
console.log('c: ' + result.c);
quad(result.a,result.b,result.c, function(err,quadsolve) {
if (err) {
console.log('Error: ', err);
}
else {
console.log("Roots are "+quadsolve.root1() + " " + quadsolve.root2());
}
});
});
As you see, I'm using the prompt module, but when I enter the input for a, the cmd is skipping the input for b and requesting me to enter `c, which in turn of couse, resulting in an error.
How to fix this issue, and why does it happen?
