This question has already been answered:

function calcD(a, b, c) { return b*b - 4*a*c; } calcD(-4, 2, 1); alert(calcD()); 

Why did the function display NaN according to the idea, as I understand it, it should output a number?

 function calcD(a, b, c) { return b*b - 4*a*c; } var test = calcD(-4, 2, 1); alert(test); // 20 

But how did you get the number?

Reported as a duplicate at Grundy. javascript Dec 1 '18 at 6:13 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • You run the function twice: the first time you pass numbers to it and it returns a number, but you don’t use it at all and just throw it away; the second time you don’t send a single number to it, without numbers, it naturally thinks it is horrible and gives out NaN, which is displayed via alert - andreymal

1 answer 1

Window.alert (message) message is an optional (optional) string of text that you want to display in a dialog box, or an object that will be converted to a string and displayed.

But the most important thing is that you do not pass parameters to the function. Those. call calcD (undefined, undefined, undefined)