0

I am trying to create a very simple multiplier function.

Although I've used Number() function, I still get NaN upon calling the function.

let x = prompt("1. sayı");
let y = prompt("2. sayı");
let num1 = Number(x);
let num2 = Number(y);


function multiply(num1, num2) {
  let result = num1 * num2;
  alert(result);
}

multiply();
CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
Deniz Göçer
  • 25
  • 1
  • 4
  • 2
    Inside the function, the `num1` and `num2` are arguments, not the outer variables - but you're not passing any arguments, so they're both `undefined`. Remove the arguments, and it'll work (could also remove the function entirely) – CertainPerformance Feb 29 '20 at 11:47

1 Answers1

-1

That’s because you’re not passing any arguments to multilply() and you’re expecting and undefined num1 and num2 in the function.

Do —-> multiply(num1, num2)